@@ -104,7 +104,7 @@ import { useDevelopingApps } from '../stores/app';
104
104
import { ApplicationInfo } from ' @devbox/core' ;
105
105
import { OPERATE_ACTION } from ' ../types/constants' ;
106
106
import { FilesSelectType } from ' ../types/types' ;
107
- import { BtDialog } from ' @bytetrade/ui' ;
107
+ import { BtDialog , BtNotify , NotifyDefinedType } from ' @bytetrade/ui' ;
108
108
import { useI18n } from ' vue-i18n' ;
109
109
110
110
import PopupMenu from ' ./common/PopupMenu.vue' ;
@@ -120,7 +120,6 @@ const props = defineProps({
120
120
121
121
const { t } = useI18n ();
122
122
const $q = useQuasar ();
123
- const appName = ref (props .app .appName );
124
123
const chartNodes = ref <any >([]);
125
124
const selectedKey = ref (null );
126
125
const tempFile = ref ();
@@ -182,16 +181,24 @@ watch(
182
181
183
182
async function onSaveFile() {
184
183
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
+ });
192
201
}
193
- fileStatus .value = false ;
194
- $q .notify (' success to save file' );
195
202
}
196
203
}
197
204
@@ -246,9 +253,9 @@ async function loadChart() {
246
253
}
247
254
];
248
255
} 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
252
259
});
253
260
}
254
261
}
@@ -271,9 +278,9 @@ const onSelected = async (value) => {
271
278
fileInfo .lang = res .extension ;
272
279
fileInfo .name = res .name ;
273
280
} 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
277
284
});
278
285
}
279
286
};
@@ -301,9 +308,9 @@ const loadChildren = async (node: any) => {
301
308
302
309
chartNodes .value = nodes ;
303
310
} 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
307
314
});
308
315
}
309
316
};
@@ -362,25 +369,37 @@ const createDialg = (path: string, action: OPERATE_ACTION) => {
362
369
};
363
370
364
371
const 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
+ }
374
385
};
375
386
376
387
const 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
+ }
384
403
};
385
404
386
405
const renameDialg = (path : string , label : string , action : OPERATE_ACTION ) => {
@@ -412,23 +431,67 @@ const renameDialg = (path: string, label: string, action: OPERATE_ACTION) => {
412
431
413
432
const renamefile = async (path : string , label : string , newname : any ) => {
414
433
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
+ }
424
458
};
425
459
426
460
const 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
+ }
432
495
};
433
496
</script >
434
497
<style lang="scss">
0 commit comments