Skip to content

Commit 21f274e

Browse files
committed
feat: Gist 备份选项
1 parent 077b274 commit 21f274e

File tree

9 files changed

+89
-27
lines changed

9 files changed

+89
-27
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.69",
3+
"version": "2.15.70",
44
"private": true,
55
"scripts": {
66
"dev": "vite --host",

src/locales/en.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,11 @@ export default {
906906
},
907907
},
908908
moreSettingPage: {
909+
gistUpload: {
910+
title: 'Gist Upload',
911+
base64: 'Base64 Encoded',
912+
plaintext: 'Plaintext(w/o GitHub Token)',
913+
},
909914
subProgress: {
910915
title: "Subscription Progress Style",
911916
hidden: "Hidden",

src/locales/zh.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,11 @@ export default {
895895
},
896896
},
897897
moreSettingPage: {
898+
gistUpload: {
899+
title: 'Gist 上传',
900+
base64: 'Base64 编码',
901+
plaintext: '明文(不带 GitHub Token)',
902+
},
898903
subProgress: {
899904
title: '订阅进度样式',
900905
hidden: '不显示',

src/store/global.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const useGlobalStore = defineStore('globalStore', {
1010
state: (): GlobalStoreState => {
1111
return {
1212
subProgressStyle: localStorage.getItem('subProgressStyle') || 'hidden',
13+
gistUpload: localStorage.getItem('gistUpload') || 'base64',
1314
isLoading: true,
1415
isFlowFetching: true,
1516
fetchResult: false,
@@ -86,6 +87,14 @@ export const useGlobalStore = defineStore('globalStore', {
8687
}
8788
this.subProgressStyle = style;
8889
},
90+
setGistUpload(style: string) {
91+
if (style && style !== 'base64') {
92+
localStorage.setItem('gistUpload', style);
93+
} else {
94+
localStorage.removeItem('gistUpload');
95+
}
96+
this.gistUpload = style;
97+
},
8998
setBottomSafeArea(height: number) {
9099
this.bottomSafeArea = height;
91100
},

src/store/settings.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ export const useSettingsStore = defineStore("settingsStore", {
4444
istabBar: false,
4545
istabBar2: false,
4646
subProgressStyle: "hidden",
47+
gistUpload: "base64",
4748
},
49+
gistUpload: "base64",
4850
avatarUrl: "",
4951
artifactStore: "",
5052
artifactStoreStatus: "",
@@ -89,14 +91,15 @@ export const useSettingsStore = defineStore("settingsStore", {
8991
this.appearanceSetting.istabBar = res.data.data.appearanceSetting?.istabBar ?? "";
9092
this.appearanceSetting.istabBar2 = res.data.data.appearanceSetting?.istabBar2 ?? "";
9193
this.appearanceSetting.subProgressStyle = res.data.data.appearanceSetting?.subProgressStyle ?? "hidden";
94+
this.gistUpload = res.data.data?.gistUpload ?? "base64";
9295
} else {
9396
showNotify({
9497
title: `获取配置失败`,
9598
type: "danger",
9699
});
97100
}
98101
},
99-
async editGistSettings(data: SettingsPostData) {
102+
async changeSettings(data: SettingsPostData) {
100103
const { showNotify } = useAppNotifyStore();
101104
const res = await settingsApi.setSettings(data);
102105
if (res?.data?.status === "success" && res?.data?.data) {
@@ -111,6 +114,7 @@ export const useSettingsStore = defineStore("settingsStore", {
111114
this.avatarUrl = res.data.data.avatarUrl || "";
112115
this.artifactStore = res.data.data.artifactStore || "";
113116
this.artifactStoreStatus = res.data.data.artifactStoreStatus || "";
117+
this.gistUpload = res.data.data.gistUpload || "";
114118
showNotify({ type: "success", title: t(`myPage.notify.save.succeed`) });
115119
} else {
116120
showNotify({
@@ -133,6 +137,7 @@ export const useSettingsStore = defineStore("settingsStore", {
133137
istabBar,
134138
istabBar2,
135139
subProgressStyle,
140+
gistUpload,
136141
} = globalStore;
137142
const data = {
138143
isSimpleMode: isSimpleMode ?? false,
@@ -145,6 +150,7 @@ export const useSettingsStore = defineStore("settingsStore", {
145150
istabBar: istabBar ?? false,
146151
istabBar2: istabBar2 ?? false,
147152
subProgressStyle: subProgressStyle ?? "hidden",
153+
gistUpload: gistUpload ?? "base64",
148154
};
149155
const list = Object.keys(data) as (keyof SettingsPostData)[];
150156
// 判断是否有本地持久化的外观设置

src/types/store/globalStore.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ interface GlobalStoreState {
1818
ishostApi: string;
1919
savedPositions: any;
2020
subProgressStyle: any;
21+
gistUpload: any;
2122
defaultIconCollection: string;
2223
defaultIconCollections?: any;
2324
customIconCollections?: any[];

src/types/store/settings.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface SettingsPostData {
2323
dark: CustomTheme;
2424
light: CustomTheme;
2525
};
26+
gistUpload?: base64 | plaintext;
2627
appearanceSetting?: {
2728
isSimpleMode?: boolean; // 简洁模式
2829
isLeftRight?: boolean; // 卡片右滑呼出
@@ -39,7 +40,7 @@ interface SettingsPostData {
3940
istabBar?: boolean; // 隐藏 "Gist 同步" 页
4041
istabBar2?: boolean; // 隐藏 "文件" 页
4142
subProgressStyle?: string; // 订阅进度样式
42-
}
43+
},
4344
}
4445

4546
interface StoragePostData {

src/views/My.vue

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ const router = useRouter();
311311
const { showNotify } = useAppNotifyStore();
312312
const { currentUrl: host } = useHostAPI();
313313
const settingsStore = useSettingsStore();
314-
const { githubUser, gistToken, syncTime, avatarUrl, defaultUserAgent, defaultProxy, defaultTimeout, cacheThreshold, syncPlatform, githubProxy } =
314+
const { githubUser, gistToken, syncTime, avatarUrl, defaultUserAgent, defaultProxy, defaultTimeout, cacheThreshold, syncPlatform, githubProxy, gistUpload } =
315315
storeToRefs(settingsStore);
316316
317317
const displayAvatar = computed(() => {
@@ -357,7 +357,7 @@ const fileInput = ref(null);
357357
const toggleEditMode = async () => {
358358
isEditLoading.value = true;
359359
if (isEditing.value) {
360-
await settingsStore.editGistSettings({
360+
await settingsStore.changeSettings({
361361
syncPlatform: syncPlatformInput.value,
362362
githubUser: userInput.value,
363363
gistToken: tokenInput.value,
@@ -526,26 +526,28 @@ const sync = async (query: "download" | "upload", options?: { keep?: string[], e
526526
};
527527
528528
const uploadBtn = () => {
529-
Dialog({
530-
title: '请选择',
531-
content: '若选择明文, 将不会保留 GitHub Token. 若选择 Base64 编码, 将完整保留数据(后端版本必须 >= 2.19.85)',
532-
footerDirection: 'vertical',
533-
onCancel: () => {
534-
sync('upload', {
535-
encode: 'plaintext'
536-
});
537-
},
538-
cancelText: '明文(将不会保留 GitHub Token)',
539-
okText: 'Base64 编码上传',
540-
onOk: () => {
541-
sync('upload', {
542-
encode: 'base64'
543-
});
544-
},
545-
popClass: "auto-dialog",
546-
closeOnPopstate: true,
547-
lockScroll: false,
548-
});
529+
const encode = gistUpload.value || 'base64';
530+
sync('upload', { encode });
531+
// Dialog({
532+
// title: '请选择',
533+
// content: '若选择明文, 将不会保留 GitHub Token. 若选择 Base64 编码, 将完整保留数据(后端版本必须 >= 2.19.85)',
534+
// footerDirection: 'vertical',
535+
// onCancel: () => {
536+
// sync('upload', {
537+
// encode: 'plaintext'
538+
// });
539+
// },
540+
// cancelText: '明文(将不会保留 GitHub Token)',
541+
// okText: 'Base64 编码上传',
542+
// onOk: () => {
543+
// sync('upload', {
544+
// encode: 'base64'
545+
// });
546+
// },
547+
// popClass: "auto-dialog",
548+
// closeOnPopstate: true,
549+
// lockScroll: false,
550+
// });
549551
}
550552
const downloadBtn = () => {
551553
Dialog({

src/views/settings/moreSetting.vue

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,27 @@
164164
>
165165
</nut-picker>
166166
</nut-cell-group>
167+
<nut-cell-group>
168+
<nut-cell
169+
class="cell-item"
170+
:title="$t(`moreSettingPage.gistUpload.title`)"
171+
:desc="gistUploadName"
172+
@click="()=>{showGistUploadPicker=true}"
173+
is-link
174+
>
175+
</nut-cell>
176+
<nut-picker
177+
v-model="gistUploadValue"
178+
v-model:visible="showGistUploadPicker"
179+
:columns="[
180+
{ text: $t(`moreSettingPage.gistUpload.base64`), value: 'base64' },
181+
{ text: $t(`moreSettingPage.gistUpload.plaintext`), value: 'plaintext' }
182+
]"
183+
:title="$t(`moreSettingPage.gistUpload.title`)"
184+
@confirm="gistUploadConfirm"
185+
>
186+
</nut-picker>
187+
</nut-cell-group>
167188

168189
<nut-cell-group>
169190
<nut-cell :title="$t(`themeSettingPage.auto`)" class="cell-item">
@@ -265,8 +286,8 @@
265286
// subProgressStyle,
266287
} = storeToRefs(globalStore);
267288
// 外观设置
268-
const { changeAppearanceSetting } = settingsStore;
269-
const { appearanceSetting } = storeToRefs(settingsStore);
289+
const { changeAppearanceSetting, changeSettings } = settingsStore;
290+
const { appearanceSetting, gistUpload } = storeToRefs(settingsStore);
270291
const { showNotify } = useAppNotifyStore();
271292
272293
const InputHostApi = ref('');
@@ -287,6 +308,7 @@
287308
// const isEditing = ref(false);
288309
const isInit = ref(false);
289310
const subProgressStyleValue = ref(['hidden']);
311+
const gistUploadValue = ref(['base64']);
290312
291313
const pickerType = ref('');
292314
const autoSwitch = ref(false);
@@ -305,6 +327,16 @@
305327
}
306328
changeAppearanceSetting({ appearanceSetting: data });
307329
};
330+
const showGistUploadPicker = ref(false);
331+
332+
const gistUploadName = computed(() => {
333+
return t(`moreSettingPage.gistUpload.${gistUploadValue.value}`)
334+
})
335+
const gistUploadConfirm = ({ selectedValue }) => {
336+
changeSettings({
337+
gistUpload: selectedValue[0]
338+
});
339+
};
308340
const setSimpleMode = (isSimpleMode: boolean) => {
309341
// globalStore.setSimpleMode(isSimpleMode);
310342
const data = {
@@ -610,6 +642,7 @@
610642
awtabBar.value = appearanceSetting.value.istabBar;
611643
awtabBar2.value = appearanceSetting.value.istabBar2;
612644
subProgressStyleValue.value = [appearanceSetting.value.subProgressStyle];
645+
gistUploadValue.value = [gistUpload.value];
613646
// SimpleSwitch.value = isSimpleMode.value;
614647
// LeftRight.value = isLeftRight.value;
615648
// awIconColor.value = isIconColor.value;

0 commit comments

Comments
 (0)