Skip to content

Commit acf28ab

Browse files
committed
ui(create-blog-export): acquire confirm before create (#125)
1 parent df93eef commit acf28ab

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/commands/blog-export/create.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { CommandHandler } from '@/commands/command-handler';
22
import { AlertService } from '@/services/alert.service';
33
import { BlogExportApi } from '@/services/blog-export.api';
44
import { BlogExportProvider } from '@/tree-view-providers/blog-export-provider';
5+
import { MessageItem, window } from 'vscode';
56

67
export class CreateBlogExportCommandHandler extends CommandHandler {
78
static readonly commandName = 'vscode-cnb.blog-export.create';
@@ -13,6 +14,8 @@ export class CreateBlogExportCommandHandler extends CommandHandler {
1314
}
1415

1516
async handle(): Promise<void> {
17+
if (!(await this.confirm())) return;
18+
1619
if (
1720
(await this.blogExportApi.create().catch((e: unknown) => {
1821
AlertService.httpError(typeof e === 'object' && e ? e : {}, { message: '创建博客备份失败' });
@@ -21,4 +24,14 @@ export class CreateBlogExportCommandHandler extends CommandHandler {
2124
)
2225
await BlogExportProvider.optionalInstance?.refreshRecords();
2326
}
27+
28+
private async confirm(): Promise<boolean> {
29+
const items: MessageItem[] = [{ title: '确定', isCloseAffordance: false }];
30+
const result = await window.showInformationMessage(
31+
'确定要创建备份吗?',
32+
{ modal: true, detail: '一天可以创建一次备份' },
33+
...items
34+
);
35+
return result != null;
36+
}
2437
}

0 commit comments

Comments
 (0)