@@ -104,7 +104,7 @@ import { useDevelopingApps } from '../stores/app';
104104import { ApplicationInfo } from ' @devbox/core' ;
105105import { OPERATE_ACTION } from ' ../types/constants' ;
106106import { FilesSelectType } from ' ../types/types' ;
107- import { BtDialog } from ' @bytetrade/ui' ;
107+ import { BtDialog , BtNotify , NotifyDefinedType } from ' @bytetrade/ui' ;
108108import { useI18n } from ' vue-i18n' ;
109109
110110import PopupMenu from ' ./common/PopupMenu.vue' ;
@@ -120,7 +120,6 @@ const props = defineProps({
120120
121121const { t } = useI18n ();
122122const $q = useQuasar ();
123- const appName = ref (props .app .appName );
124123const chartNodes = ref <any >([]);
125124const selectedKey = ref (null );
126125const tempFile = ref ();
@@ -182,16 +181,24 @@ watch(
182181
183182async function onSaveFile() {
184183 if (selectedKey .value != null ) {
185- const res: any = await axios .put (
186- store .url + ' /api/files/' + selectedKey .value ,
187- fileInfo .code ,
188- { headers: { ' content-type' : ' text/plain' } }
189- );
190- if (res .code != 200 ) {
191- return ;
184+ try {
185+ const res: any = await axios .put (
186+ store .url + ' /api/files/' + selectedKey .value ,
187+ fileInfo .code ,
188+ { headers: { ' content-type' : ' text/plain' } }
189+ );
190+
191+ fileStatus .value = false ;
192+ BtNotify .show ({
193+ type: NotifyDefinedType .SUCCESS ,
194+ message: t (' message.save_file_success' )
195+ });
196+ } catch (e ) {
197+ BtNotify .show ({
198+ type: NotifyDefinedType .FAILED ,
199+ message: t (' message.save_file_failed' ) + e .message
200+ });
192201 }
193- fileStatus .value = false ;
194- $q .notify (' success to save file' );
195202 }
196203}
197204
@@ -246,9 +253,9 @@ async function loadChart() {
246253 }
247254 ];
248255 } catch (e : any ) {
249- $q . notify ({
250- type: ' negative ' ,
251- message: ' failed to loadChart; ' + e .message
256+ BtNotify . show ({
257+ type: NotifyDefinedType . FAILED ,
258+ message: t ( ' message.save_loadChart_failed ' ) + e .message
252259 });
253260 }
254261}
@@ -271,9 +278,9 @@ const onSelected = async (value) => {
271278 fileInfo .lang = res .extension ;
272279 fileInfo .name = res .name ;
273280 } catch (e : any ) {
274- $q . notify ({
275- type: ' negative ' ,
276- message: ' onSelect failed; ' + e .message
281+ BtNotify . show ({
282+ type: NotifyDefinedType . FAILED ,
283+ message: t ( ' message.save_loadChart_failed ' ) + e .message
277284 });
278285 }
279286};
@@ -301,9 +308,9 @@ const loadChildren = async (node: any) => {
301308
302309 chartNodes .value = nodes ;
303310 } catch (e : any ) {
304- $q . notify ({
305- type: ' negative ' ,
306- message: ' loadChildren failed; ' + e .message
311+ BtNotify . show ({
312+ type: NotifyDefinedType . FAILED ,
313+ message: t ( ' message.save_loadChildren_failed ' ) + e .message
307314 });
308315 }
309316};
@@ -362,25 +369,37 @@ const createDialg = (path: string, action: OPERATE_ACTION) => {
362369};
363370
364371const createFile = async (path : string ) => {
365- const res = await axios .put (
366- store .url + ' /api/files/' + path ,
367- {},
368- {
369- headers: { ' content-type' : ' text/plain' }
370- }
371- );
372- $q .notify (' success to create file' );
373- await loadChart ();
372+ try {
373+ await axios .put (store .url + ' /api/files/' + path );
374+ BtNotify .show ({
375+ type: NotifyDefinedType .SUCCESS ,
376+ message: t (' message.create_file_success' )
377+ });
378+ await loadChart ();
379+ } catch (e ) {
380+ BtNotify .show ({
381+ type: NotifyDefinedType .FAILED ,
382+ message: t (' message.create_file_failed' ) + e .message
383+ });
384+ }
374385};
375386
376387const createFolder = async (path : string ) => {
377- const res = await axios .post (
378- store .url + ' /api/files/' + path + ' ?file_type=dir' ,
379- {},
380- { headers: { ' content-type' : ' text/plain' } }
381- );
382- $q .notify (' success to create folder' );
383- await loadChart ();
388+ try {
389+ const res = await axios .post (
390+ store .url + ' /api/files/' + path + ' ?file_type=dir'
391+ );
392+ BtNotify .show ({
393+ type: NotifyDefinedType .SUCCESS ,
394+ message: t (' message.create_folder_success' )
395+ });
396+ await loadChart ();
397+ } catch (e ) {
398+ BtNotify .show ({
399+ type: NotifyDefinedType .FAILED ,
400+ message: t (' message.create_folder_failed' ) + e .message
401+ });
402+ }
384403};
385404
386405const renameDialg = (path : string , label : string , action : OPERATE_ACTION ) => {
@@ -412,23 +431,67 @@ const renameDialg = (path: string, label: string, action: OPERATE_ACTION) => {
412431
413432const renamefile = async (path : string , label : string , newname : any ) => {
414433 const newpath = path .replace (label , newname );
415- const res = await axios .patch (
416- store .url + ' /api/files/' + path + ' ?action=rename&destination=' + newpath ,
417- {},
418- {
419- headers: { ' content-type' : ' text/plain' }
420- }
421- );
422- $q .notify (' success to rename' );
423- await loadChart ();
434+
435+ try {
436+ await axios .patch (
437+ store .url +
438+ ' /api/files/' +
439+ path +
440+ ' ?action=rename&destination=' +
441+ newpath ,
442+ {},
443+ {
444+ headers: { ' content-type' : ' text/plain' }
445+ }
446+ );
447+ BtNotify .show ({
448+ type: NotifyDefinedType .SUCCESS ,
449+ message: t (' message.rename_folder_success' )
450+ });
451+ await loadChart ();
452+ } catch (e ) {
453+ BtNotify .show ({
454+ type: NotifyDefinedType .SUCCESS ,
455+ message: t (' message.rename_folder_failed' )
456+ });
457+ }
424458};
425459
426460const deletefile = async (path : string ) => {
427- const res = await axios .delete (store .url + ' /api/files/' + path , {
428- headers: { ' content-type' : ' text/plain' }
429- });
430- $q .notify (' success to create file' );
431- await loadChart ();
461+ BtDialog .show ({
462+ platform: ' web' ,
463+ cancel: true ,
464+ message: t (' message.deleteTip' ),
465+ okStyle: {
466+ background: ' #00BE9E' ,
467+ color: ' #ffffff'
468+ },
469+ title: ' Delete'
470+ })
471+ .then ((val ) => {
472+ if (val ) {
473+ _deletefile (path );
474+ }
475+ })
476+ .catch ((err ) => {
477+ console .log (err );
478+ });
479+ };
480+
481+ const _deletefile = async (path : string ) => {
482+ try {
483+ await axios .delete (store .url + ' /api/files/' + path );
484+ BtNotify .show ({
485+ type: NotifyDefinedType .SUCCESS ,
486+ message: t (' message.delete_file_success' )
487+ });
488+ await loadChart ();
489+ } catch (e ) {
490+ BtNotify .show ({
491+ type: NotifyDefinedType .FAILED ,
492+ message: t (' message.delete_file_failed' ) + e .message
493+ });
494+ }
432495};
433496 </script >
434497<style lang="scss">
0 commit comments