Skip to content

Commit b581af0

Browse files
committed
feat: 支持从 Gist 恢复时保留当前 GitHub Token
1 parent cc10e11 commit b581af0

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
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.45",
3+
"version": "2.15.47",
44
"private": true,
55
"scripts": {
66
"dev": "vite --host",

src/api/settings/index.ts

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

src/views/My.vue

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
size="small"
103103
:disabled="syncIsDisabled"
104104
:loading="downloadIsLoading"
105-
@click="sync('download')"
105+
@click="downloadBtn"
106106
>
107107
<font-awesome-icon
108108
v-if="!downloadIsLoading"
@@ -473,7 +473,7 @@ const upload = async() => {
473473
}
474474
}
475475
476-
const sync = async (query: "download" | "upload") => {
476+
const sync = async (query: "download" | "upload", options?: { keep?: string[] }) => {
477477
switch (query) {
478478
case "download":
479479
downloadIsLoading.value = true;
@@ -483,7 +483,7 @@ const sync = async (query: "download" | "upload") => {
483483
break;
484484
}
485485
486-
const res = await useSettingsApi().syncSettings(query);
486+
const res = await useSettingsApi().syncSettings(query, options);
487487
488488
if (res?.data?.status === "success") {
489489
switch (query) {
@@ -506,6 +506,27 @@ const sync = async (query: "download" | "upload") => {
506506
downloadIsLoading.value = false;
507507
uploadIsLoading.value = false;
508508
};
509+
510+
const downloadBtn = () => {
511+
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+
});
529+
}
509530
const proxyTips = () => {
510531
Dialog({
511532
title: '通过代理/节点/策略进行下载',

0 commit comments

Comments
 (0)