@@ -31,7 +31,8 @@ export class DeleteCommandHandler extends TreeViewCommandHandler<DownloadedExpor
31
31
32
32
private confirm (
33
33
itemName : string ,
34
- hasLocalFile = true
34
+ hasLocalFile = true ,
35
+ detail : string | undefined | null = '数据可能无法恢复, 请谨慎操作!'
35
36
) : Thenable < null | { shouldDeleteLocal : boolean } | undefined > {
36
37
const options : ( MessageItem & {
37
38
result : ReturnType < DeleteCommandHandler [ 'confirm' ] > extends Thenable < infer R > ? R : never ;
@@ -42,7 +43,7 @@ export class DeleteCommandHandler extends TreeViewCommandHandler<DownloadedExpor
42
43
return window
43
44
. showInformationMessage (
44
45
`确定要删除 ${ itemName } 吗?` ,
45
- { modal : true , detail : '数据可能无法恢复, 请谨慎操作!' } ,
46
+ { modal : true , detail : detail ? detail : undefined } ,
46
47
...options
47
48
)
48
49
. then (
@@ -55,26 +56,30 @@ export class DeleteCommandHandler extends TreeViewCommandHandler<DownloadedExpor
55
56
item : DownloadedExportTreeItem ,
56
57
{ hasConfirmed = false } = { }
57
58
) : Promise < void > {
58
- const parent = item . parent ;
59
- const isChildOfRecord = parent instanceof BlogExportRecordTreeItem ;
60
59
const result = hasConfirmed
61
60
? { shouldDeleteLocal : true }
62
- : await this . confirm ( `博客备份-${ path . basename ( item . downloadedExport . filePath ) } ` , ! isChildOfRecord ) ;
61
+ : await this . confirm (
62
+ `博客备份-${ path . basename ( item . downloadedExport . filePath ) } ` ,
63
+ false ,
64
+ '删除后备份文件无法恢复'
65
+ ) ;
63
66
if ( result == null ) return ;
64
67
65
- let { shouldDeleteLocal } = result ;
66
- shouldDeleteLocal = shouldDeleteLocal || isChildOfRecord ;
67
- await this . removeDownloadedBlogExport ( item . downloadedExport , { shouldDeleteLocal } ) ;
68
+ await this . removeDownloadedBlogExport ( item . downloadedExport , { shouldDeleteLocal : true } ) ;
68
69
69
- if ( shouldDeleteLocal ) await BlogExportProvider . optionalInstance ?. refreshRecords ( { force : false } ) ;
70
- else await BlogExportProvider . optionalInstance ?. refreshDownloadedExports ( ) ;
70
+ await BlogExportProvider . optionalInstance ?. refreshRecords ( { force : false } ) ;
71
+ await BlogExportProvider . optionalInstance ?. refreshDownloadedExports ( ) ;
71
72
}
72
73
73
74
private async deleteExportRecordItem ( item : BlogExportRecordTreeItem ) {
74
75
const { record } = item ;
75
76
const downloaded = await DownloadedExportStore . instance . findById ( record . id ) ;
76
77
77
- const confirmResult = await this . confirm ( `云端博客备份-${ record . fileName } ` , downloaded != null ) ;
78
+ const confirmResult = await this . confirm (
79
+ `云端博客备份-${ record . fileName } ` ,
80
+ downloaded != null ,
81
+ '删除后备份无法恢复'
82
+ ) ;
78
83
if ( confirmResult == null ) return ;
79
84
80
85
const { shouldDeleteLocal } = confirmResult ;
0 commit comments