feat: 更新 showToast 显示逻辑,添加错误代码上下文;更新语言存储键以包含应用版本
This commit is contained in:
1
auto-imports.d.ts
vendored
1
auto-imports.d.ts
vendored
@@ -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']>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
6
src/vite-env.d.ts
vendored
@@ -32,3 +32,9 @@ declare module "vue-router" {
|
||||
requiresAuth: ? boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__APP_VERSION__: string;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user