Skip to content

Commit

Permalink
feat: 增加下载缓存阈值
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Mar 4, 2024
1 parent ce767f6 commit 8083a0a
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store-front-end",
"version": "2.14.150",
"version": "2.14.151",
"private": true,
"scripts": {
"dev": "vite --host",
Expand Down
1 change: 1 addition & 0 deletions src/assets/icons/max.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 3 additions & 1 deletion src/locales/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
3 changes: 3 additions & 0 deletions src/store/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const useSettingsStore = defineStore("settingsStore", {
githubUser: "",
defaultUserAgent: "",
defaultTimeout: "",
cacheThreshold: "",
syncTime: 0,
theme: {
auto: true,
Expand All @@ -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 || "";
Expand All @@ -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 || "";
Expand Down
1 change: 1 addition & 0 deletions src/types/store/settings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface SettingsPostData {
githubUser?: string;
defaultUserAgent?: string;
defaultTimeout?: string;
cacheThreshold?: string;
theme?: {
auto: boolean;
name?: CustomTheme;
Expand Down
33 changes: 30 additions & 3 deletions src/views/My.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,17 @@
right-icon="tips"
@click-right-icon="timeoutTips"
/>
<nut-input
class="input"
v-model="cacheThresholdInput"
:disabled="!isEditing"
:placeholder="$t(`myPage.placeholder.cacheThreshold`)"
type="number"
input-align="left"
:left-icon="iconMax"
right-icon="tips"
@click-right-icon="cacheThresholdTips"
/>
</div>
</div>

Expand Down Expand Up @@ -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";
Expand All @@ -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(() => {
Expand All @@ -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);
Expand All @@ -306,6 +319,7 @@ const toggleEditMode = async () => {
gistToken: tokenInput.value,
defaultUserAgent: uaInput.value,
defaultTimeout: timeoutInput.value,
cacheThreshold: cacheThresholdInput.value,
});
setDisplayInfo();
} else {
Expand All @@ -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;
Expand Down Expand Up @@ -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`);
};
// 同步 上传
Expand Down Expand Up @@ -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(() => {
Expand Down

0 comments on commit 8083a0a

Please sign in to comment.