Skip to content

Commit 77942a3

Browse files
committed
feat: Gist 备份恢复增加 Base64 编码方式
1 parent b10628b commit 77942a3

File tree

3 files changed

+48
-23
lines changed

3 files changed

+48
-23
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store-front-end",
3-
"version": "2.15.48",
3+
"version": "2.15.50",
44
"private": true,
55
"scripts": {
66
"dev": "vite --host",

src/api/settings/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@ export function useSettingsApi() {
1616
data,
1717
});
1818
},
19-
syncSettings: (query: 'download' | 'upload', options?: { keep?: string[] }): AxiosPromise<MyAxiosRes> => {
19+
syncSettings: (query: 'download' | 'upload', options?: { keep?: string[], encode?: 'base64' | 'plain' }): AxiosPromise<MyAxiosRes> => {
2020
return request({
21-
url: `/api/utils/backup?action=${encodeURIComponent(query)}${options?.keep ? `&keep=${encodeURIComponent(options.keep.join(','))}` : ''}`,
22-
method: 'get'
21+
url: `/api/utils/backup`,
22+
method: 'get',
23+
params: {
24+
action: query,
25+
keep: options?.keep?.join(','),
26+
encode: options?.encode
27+
}
2328
});
2429
},
2530
restoreSettings: (data: StoragePostData): AxiosPromise<MyAxiosRes> => {

src/views/My.vue

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
:disabled="syncIsDisabled"
8989
size="small"
9090
:loading="uploadIsLoading"
91-
@click="sync('upload')"
91+
@click="uploadBtn"
9292
>
9393
<font-awesome-icon
9494
icon="fa-solid fa-cloud-arrow-up"
@@ -473,7 +473,7 @@ const upload = async() => {
473473
}
474474
}
475475
476-
const sync = async (query: "download" | "upload", options?: { keep?: string[] }) => {
476+
const sync = async (query: "download" | "upload", options?: { keep?: string[], encode?: 'base64' | 'plain' }) => {
477477
switch (query) {
478478
case "download":
479479
downloadIsLoading.value = true;
@@ -507,25 +507,45 @@ const sync = async (query: "download" | "upload", options?: { keep?: string[] })
507507
uploadIsLoading.value = false;
508508
};
509509
510+
const uploadBtn = () => {
511+
Dialog({
512+
title: '请选择',
513+
content: '若选择明文, 将不会保留 GitHub Token. 若选择 Base64 编码, 将完整保留数据(后端版本必须 >= 2.19.85)',
514+
footerDirection: 'vertical',
515+
onCancel: () => {
516+
sync('upload');
517+
},
518+
cancelText: '明文(将不会保留 GitHub Token)',
519+
okText: 'Base64 编码上传',
520+
onOk: () => {
521+
sync('upload', {
522+
encode: 'base64'
523+
});
524+
},
525+
popClass: "auto-dialog",
526+
closeOnPopstate: true,
527+
lockScroll: false,
528+
});
529+
}
510530
const downloadBtn = () => {
511531
Dialog({
512-
title: '请选择',
513-
content: '若想保留本地当前已设置的 GitHub Token, 请选择保留(后端版本必须 >= 2.19.83)',
514-
footerDirection: 'vertical',
515-
onCancel: () => {
516-
sync('download');
517-
},
518-
okText: '保留当前 Token, 覆盖其他数据',
519-
cancelText: '覆盖(需重新设置 Token)',
520-
onOk: () => {
521-
sync('download', {
522-
keep: ['settings.gistToken']
523-
});
524-
},
525-
popClass: "auto-dialog",
526-
closeOnPopstate: true,
527-
lockScroll: false,
528-
});
532+
title: '请选择',
533+
content: '若想保留本地当前已设置的 GitHub Token, 请选择保留(后端版本必须 >= 2.19.83)',
534+
footerDirection: 'vertical',
535+
onCancel: () => {
536+
sync('download');
537+
},
538+
okText: '保留当前 Token, 覆盖其他数据',
539+
cancelText: '覆盖(可能需重新设置 Token)',
540+
onOk: () => {
541+
sync('download', {
542+
keep: ['settings.gistToken']
543+
});
544+
},
545+
popClass: "auto-dialog",
546+
closeOnPopstate: true,
547+
lockScroll: false,
548+
});
529549
}
530550
const proxyTips = () => {
531551
Dialog({

0 commit comments

Comments
 (0)