feat: 更新 showToast 显示逻辑,添加错误代码上下文;更新语言存储键以包含应用版本

This commit is contained in:
2026-01-22 18:07:42 +07:00
parent 9398d4036b
commit 7c5e33cd7f
4 changed files with 11 additions and 3 deletions

1
auto-imports.d.ts vendored
View File

@@ -450,7 +450,6 @@ declare module 'vue' {
readonly shallowReactive: UnwrapRef<typeof import('vue')['shallowReactive']>
readonly shallowReadonly: UnwrapRef<typeof import('vue')['shallowReadonly']>
readonly shallowRef: UnwrapRef<typeof import('vue')['shallowRef']>
readonly showToast: UnwrapRef<typeof import('vant/es')['showToast']>
readonly storeToRefs: UnwrapRef<typeof import('pinia')['storeToRefs']>
readonly syncRef: UnwrapRef<typeof import('@vueuse/core')['syncRef']>
readonly syncRefs: UnwrapRef<typeof import('@vueuse/core')['syncRefs']>

View File

@@ -74,7 +74,9 @@ export function safeClient<T, E>(
}, 2000);
}
else if (!options.silent) {
showToast((res.error as any).message || i18n.global.t("network_error"));
showToast(i18n.global.t((res.error as any).code, {
...(res.error as any).context,
}) || (res.error as any).message || i18n.global.t("network_error"));
}
throw res.error;

View File

@@ -38,7 +38,8 @@ export function useLanguage() {
}
function loadRemoteLanguage() {
const storageKey = `remote-lang-${language.value}`;
const appVersion = window.__APP_VERSION__;
const storageKey = `remote-lang-${language.value}-${appVersion}`;
const remoteLangJson = useStorageCache<string>(storageKey, "", { ttl: 24 * 60 * 60 }); // 缓存 1 天
if (remoteLangJson.value) {
try {

6
src/vite-env.d.ts vendored
View File

@@ -32,3 +32,9 @@ declare module "vue-router" {
requiresAuth: ? boolean;
}
}
declare global {
interface Window {
__APP_VERSION__: string;
}
}