Skip to content

Commit

Permalink
feat: 支持设置全局请求超时(后端 > 2.14.140)
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Jan 7, 2024
1 parent 1bd01e1 commit 65a4381
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 4 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.29",
"version": "2.14.30",
"private": true,
"scripts": {
"dev": "vite --host",
Expand Down
1 change: 1 addition & 0 deletions src/assets/icons/timeout.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 @@ -367,9 +367,11 @@ export default {
githubUser: 'Please input GitHub username',
gistToken: 'Please input Gist Token',
defaultUserAgent: 'Please input Default User-Agent',
defaultTimeout: 'Please input Default Timeout (in milliseconds)',
noGithubUser: 'Not set GitHub username',
noGistToken: 'Not set Gist Token',
noDefaultUserAgent: 'Not set default user-agent'
noDefaultUserAgent: 'Not set default user-agent',
noDefaultTimeout: 'Not set default timeout'
},
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 @@ -369,9 +369,11 @@ export default {
githubUser: '请输入 GitHub 用户名',
gistToken: '请输入 GitHub 令牌',
defaultUserAgent: '请输入默认 User-Agent',
defaultTimeout: '请输入默认超时(单位: 毫秒)',
noGithubUser: '未配置 GitHub 用户名',
noGistToken: '未配置 GitHub 令牌',
noDefaultUserAgent: '未配置默认 User-Agent'
noDefaultUserAgent: '未配置默认 User-Agent',
noDefaultTimeout: '未配置默认超时'
},
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 @@ -15,6 +15,7 @@ export const useSettingsStore = defineStore('settingsStore', {
gistToken: '',
githubUser: '',
defaultUserAgent: '',
defaultTimeout: '',
syncTime: 0,
theme: {
auto: true,
Expand All @@ -36,6 +37,7 @@ export const useSettingsStore = defineStore('settingsStore', {
this.gistToken = res.data.gistToken || '';
this.githubUser = res.data.githubUser || '';
this.defaultUserAgent = res.data.defaultUserAgent || '';
this.defaultTimeout = res.data.defaultTimeout || '';
this.syncTime = res.data.syncTime || 0;
this.avatarUrl = res.data.avatarUrl || '';
this.artifactStore = res.data.artifactStore || '';
Expand Down Expand Up @@ -64,6 +66,7 @@ export const useSettingsStore = defineStore('settingsStore', {
this.gistToken = res.data.gistToken || '';
this.githubUser = res.data.githubUser || '';
this.defaultUserAgent = res.data.defaultUserAgent || '';
this.defaultTimeout = res.data.defaultTimeout || '';
this.avatarUrl = res.data.avatarUrl || '';
this.artifactStore = res.data.artifactStore || '';
showNotify({ type: 'success', title: t(`myPage.notify.save.succeed`) });
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 @@ -11,6 +11,7 @@ interface SettingsPostData {
gistToken?: string;
githubUser?: string;
defaultUserAgent?: string;
defaultTimeout?: string;
theme?: {
auto: boolean;
name?: CustomTheme;
Expand Down
16 changes: 15 additions & 1 deletion src/views/My.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@
input-align="left"
:left-icon="iconUA"
/>
<nut-input
class="input"
v-model="timeoutInput"
:disabled="!isEditing"
:placeholder="$t(`myPage.placeholder.defaultTimeout`)"
type="number"
input-align="left"
:left-icon="iconTimeout"
/>
</div>
</div>

Expand Down Expand Up @@ -226,6 +235,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 iconTimeout from "@/assets/icons/timeout.svg";
import { useAppNotifyStore } from "@/store/appNotify";
import { useGlobalStore } from "@/store/global";
import { useSettingsStore } from "@/store/settings";
Expand All @@ -245,7 +255,7 @@ const router = useRouter();
const { showNotify } = useAppNotifyStore();
const { currentUrl: host } = useHostAPI();
const settingsStore = useSettingsStore();
const { githubUser, gistToken, syncTime, avatarUrl, defaultUserAgent } =
const { githubUser, gistToken, syncTime, avatarUrl, defaultUserAgent, defaultTimeout } =
storeToRefs(settingsStore);
const displayAvatar = computed(() => {
Expand All @@ -269,6 +279,7 @@ const onClickAbout = () => {
const userInput = ref("");
const tokenInput = ref("");
const uaInput = ref("");
const timeoutInput = ref("");
const isEditing = ref(false);
const isEditLoading = ref(false);
const isInit = ref(false);
Expand All @@ -282,12 +293,14 @@ const toggleEditMode = async () => {
githubUser: userInput.value,
gistToken: tokenInput.value,
defaultUserAgent: uaInput.value,
defaultTimeout: timeoutInput.value,
});
setDisplayInfo();
} else {
userInput.value = githubUser.value;
tokenInput.value = gistToken.value;
uaInput.value = defaultUserAgent.value;
timeoutInput.value = defaultTimeout.value;
}
isEditLoading.value = false;
isEditing.value = !isEditing.value;
Expand All @@ -305,6 +318,7 @@ const setDisplayInfo = () => {
? 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`);
};
// 同步 上传
Expand Down

0 comments on commit 65a4381

Please sign in to comment.