Skip to content

Commit 2def5d7

Browse files
authored
feat: add confirmation dialog for pull all (#197)
1 parent 514d9c3 commit 2def5d7

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/cmd/post-list/post-pull-all.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ async function overwriteFile(path: string, text: string) {
2121
}
2222

2323
// 单次累计随笔请求上限
24-
const MAX_POST_LIMIT = 1000
24+
const MAX_POST_LIMIT = 1024
2525
// 单次累计随笔字节上限
26-
const MAX_BYTE_LIMIT = MAX_POST_LIMIT * 10000
26+
const MAX_BYTE_LIMIT = MAX_POST_LIMIT * 1024 * 20
27+
const MAX_MB_LIMIT = Math.round(MAX_BYTE_LIMIT / 1024 / 1024)
2728

2829
export async function postPullAll() {
2930
const isVip = (await UserService.getInfo())?.is_vip ?? false
@@ -32,6 +33,16 @@ export async function postPullAll() {
3233
return
3334
}
3435

36+
const answer = await Alert.info(
37+
'确认下载所有随笔吗?',
38+
{
39+
modal: true,
40+
detail: `单次下载最多${MAX_POST_LIMIT}篇,累计字符数不超过${MAX_MB_LIMIT}MB`,
41+
},
42+
'确认'
43+
)
44+
if (answer !== '确认') return
45+
3546
let strategy = ConflictStrategy.ask
3647

3748
const opt = {

src/cmd/post-list/upload-post.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,11 @@ export async function uploadPost(input?: Post | PostTreeItem | PostEditDto, conf
155155
path.extname(localFilePath).endsWith('md') || path.extname(localFilePath).endsWith('mkd') || post.isMarkdown
156156

157157
if (MarkdownCfg.isShowConfirmMsgWhenUploadPost() && confirm) {
158-
const answer = await Alert.warn(
159-
'确认上传博文吗?',
158+
const answer = await Alert.info(
159+
'确认上传这篇博文吗?',
160160
{
161161
modal: true,
162-
detail: '本地博文将保存至服务端(可通过设置关闭对话框)',
162+
detail: '本地博文将保存至服务端(可通过设置关闭此对话框)',
163163
},
164164
'确认'
165165
)

0 commit comments

Comments
 (0)