diff --git a/package.json b/package.json index 7f59ddbbe..1f2146e67 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sub-store-front-end", - "version": "2.14.150", + "version": "2.14.151", "private": true, "scripts": { "dev": "vite --host", diff --git a/src/assets/icons/max.svg b/src/assets/icons/max.svg new file mode 100644 index 000000000..5df3fc60f --- /dev/null +++ b/src/assets/icons/max.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/locales/en.ts b/src/locales/en.ts index e8b598018..5ceff1e11 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -422,10 +422,12 @@ export default { gistToken: 'Please input Gist Token', defaultUserAgent: 'Please input Default User-Agent', defaultTimeout: 'Please input Default Timeout (in milliseconds)', + cacheThreshold: 'Please input Cache Threshold (in KB)', noGithubUser: 'Not set GitHub username', noGistToken: 'Not set Gist Token', noDefaultUserAgent: 'Not set default user-agent', - noDefaultTimeout: 'Not set default timeout' + noDefaultTimeout: 'Not set default timeout', + noCacheThreshold: 'Not set cache threshold', }, btn: { download: 'Download', diff --git a/src/locales/zh.ts b/src/locales/zh.ts index 5642e945a..03b2770d4 100644 --- a/src/locales/zh.ts +++ b/src/locales/zh.ts @@ -424,10 +424,12 @@ export default { gistToken: '请输入 GitHub 令牌', defaultUserAgent: '请输入默认 User-Agent', defaultTimeout: '请输入默认超时(单位: 毫秒)', + cacheThreshold: '请输入缓存阈值(单位: KB)', noGithubUser: '未配置 GitHub 用户名', noGistToken: '未配置 GitHub 令牌', noDefaultUserAgent: '未配置默认 User-Agent', - noDefaultTimeout: '未配置默认超时' + noDefaultTimeout: '未配置默认超时', + noCacheThreshold: '未配置缓存阈值', }, notify: { save: { diff --git a/src/store/settings.ts b/src/store/settings.ts index 25b8848d4..467ca4fd8 100644 --- a/src/store/settings.ts +++ b/src/store/settings.ts @@ -17,6 +17,7 @@ export const useSettingsStore = defineStore("settingsStore", { githubUser: "", defaultUserAgent: "", defaultTimeout: "", + cacheThreshold: "", syncTime: 0, theme: { auto: true, @@ -41,6 +42,7 @@ export const useSettingsStore = defineStore("settingsStore", { this.githubUser = res.data.data.githubUser || ""; this.defaultUserAgent = res.data.data.defaultUserAgent || ""; this.defaultTimeout = res.data.data.defaultTimeout || ""; + this.cacheThreshold = res.data.data.cacheThreshold || ""; this.syncTime = res.data.data.syncTime || 0; this.avatarUrl = res.data.data.avatarUrl || ""; this.artifactStore = res.data.data.artifactStore || ""; @@ -66,6 +68,7 @@ export const useSettingsStore = defineStore("settingsStore", { this.githubUser = res.data.data.githubUser || ""; this.defaultUserAgent = res.data.data.defaultUserAgent || ""; this.defaultTimeout = res.data.data.defaultTimeout || ""; + this.cacheThreshold = res.data.data.cacheThreshold || ""; this.avatarUrl = res.data.data.avatarUrl || ""; this.artifactStore = res.data.data.artifactStore || ""; this.artifactStoreStatus = res.data.data.artifactStoreStatus || ""; diff --git a/src/types/store/settings.d.ts b/src/types/store/settings.d.ts index 6514704b3..34211dff8 100644 --- a/src/types/store/settings.d.ts +++ b/src/types/store/settings.d.ts @@ -14,6 +14,7 @@ interface SettingsPostData { githubUser?: string; defaultUserAgent?: string; defaultTimeout?: string; + cacheThreshold?: string; theme?: { auto: boolean; name?: CustomTheme; diff --git a/src/views/My.vue b/src/views/My.vue index 1ab38d43e..066f3ce32 100644 --- a/src/views/My.vue +++ b/src/views/My.vue @@ -190,6 +190,17 @@ right-icon="tips" @click-right-icon="timeoutTips" /> + @@ -243,6 +254,7 @@ import avatar from "@/assets/icons/avatar.svg?url"; import iconKey from "@/assets/icons/key-solid.png"; import iconUser from "@/assets/icons/user-solid.png"; import iconUA from "@/assets/icons/user-agent.svg"; +import iconMax from "@/assets/icons/max.svg"; import iconTimeout from "@/assets/icons/timeout.svg"; import { useAppNotifyStore } from "@/store/appNotify"; import { useGlobalStore } from "@/store/global"; @@ -264,7 +276,7 @@ const router = useRouter(); const { showNotify } = useAppNotifyStore(); const { currentUrl: host } = useHostAPI(); const settingsStore = useSettingsStore(); -const { githubUser, gistToken, syncTime, avatarUrl, defaultUserAgent, defaultTimeout, syncPlatform } = +const { githubUser, gistToken, syncTime, avatarUrl, defaultUserAgent, defaultTimeout, cacheThreshold, syncPlatform } = storeToRefs(settingsStore); const displayAvatar = computed(() => { @@ -291,6 +303,7 @@ const userInput = ref(""); const tokenInput = ref(""); const uaInput = ref(""); const timeoutInput = ref(""); +const cacheThresholdInput = ref(""); const isEditing = ref(false); const isEditLoading = ref(false); const isInit = ref(false); @@ -306,6 +319,7 @@ const toggleEditMode = async () => { gistToken: tokenInput.value, defaultUserAgent: uaInput.value, defaultTimeout: timeoutInput.value, + cacheThreshold: cacheThresholdInput.value, }); setDisplayInfo(); } else { @@ -314,6 +328,7 @@ const toggleEditMode = async () => { tokenInput.value = gistToken.value; uaInput.value = defaultUserAgent.value; timeoutInput.value = defaultTimeout.value; + cacheThresholdInput.value = cacheThreshold.value; } isEditLoading.value = false; isEditing.value = !isEditing.value; @@ -356,8 +371,9 @@ const setDisplayInfo = () => { tokenInput.value = gistToken.value ? gistToken.value.slice(0, 6) + "************" : t(`myPage.placeholder.noGistToken`); - uaInput.value = defaultUserAgent.value || t(`myPage.placeholder.noDefaultUserAgent`); - timeoutInput.value = defaultTimeout.value || t(`myPage.placeholder.noDefaultTimeout`); + uaInput.value = defaultUserAgent.value || t(`myPage.placeholder.noDefaultUserAgent`); + timeoutInput.value = defaultTimeout.value || t(`myPage.placeholder.noDefaultTimeout`); + cacheThresholdInput.value = cacheThreshold.value || t(`myPage.placeholder.noCacheThreshold`); }; // 同步 上传 @@ -480,6 +496,17 @@ const timeoutTips = () => { lockScroll: false, }); }; +const cacheThresholdTips = () => { + Dialog({ + title: '可尝试设置为 1024', + content: '下载资源过大时\n若要写入缓存\n代理 app 可能会崩溃重启\n可尝试设置此值', + popClass: 'auto-dialog', + okText: 'OK', + noCancelBtn: true, + closeOnPopstate: true, + lockScroll: false, + }); +}; // store 刷新数据完成后 复制内容给 input 绑定 const { isLoading: storeIsLoading, env: backendEnv } = storeToRefs(useGlobalStore()); watchEffect(() => {