diff --git a/src/i18n/index.ts b/src/i18n/index.ts index 0bef6117..1d0a4659 100644 --- a/src/i18n/index.ts +++ b/src/i18n/index.ts @@ -46,15 +46,6 @@ function mergeArrObj(list: T, key: string) { return obj; } -// 远程获取i18n -try { - const infoI18n = await info(); - itemize['zh-cn'].push(...infoI18n.data['zh-cn']); - itemize.en.push(...infoI18n.data.en); -} catch (e) { - // 考虑请求不过去没有后台的情况下导致的i18n失效 -} - for (const key in itemize) { messages[key] = { name: key, @@ -79,3 +70,27 @@ export const i18n = createI18n({ fallbackLocale: zhcnLocale.name, messages, }); + +const messageLocal = {}; + +const itemizeLocal = { en: [] as any[], 'zh-cn': [] as any[] }; + +// 远程获取i18n +try { + setTimeout(async () => { + const infoI18n = await info(); + itemizeLocal['zh-cn'].push(...infoI18n.data['zh-cn']); + itemizeLocal.en.push(...infoI18n.data.en); + for (const key in itemizeLocal) { + messageLocal[key] = { + name: key, + ...mergeArrObj(itemizeLocal, key), + }; + } + i18n.global.mergeLocaleMessage('zh-cn', messageLocal['zh-cn']); + i18n.global.mergeLocaleMessage('en', messageLocal['en']); + i18n.global.locale.value = themeConfig.value.globalI18n; + }, 50); +} catch (e) { + // 考虑请求不过去没有后台的情况下导致的i18n失效 +} diff --git a/src/utils/request.ts b/src/utils/request.ts index ebeed8de..ca6a6b71 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -1,5 +1,4 @@ import axios, { AxiosInstance, InternalAxiosRequestConfig } from 'axios'; -import { ElMessageBox } from 'element-plus'; import { Session, Local } from '/@/utils/storage'; import qs from 'qs'; import { useMessageBox } from '../hooks/message'; diff --git a/src/views/admin/user/personal.vue b/src/views/admin/user/personal.vue index 91390348..3479feb4 100644 --- a/src/views/admin/user/personal.vue +++ b/src/views/admin/user/personal.vue @@ -61,12 +61,7 @@ - + @@ -213,7 +208,7 @@ const handleSaveUser = () => { if (!valid) { return false; } - editInfo(formData) + editInfo(formData.value) .then(() => { useMessage().success('修改成功'); // 更新上下文的 user信息 @@ -260,6 +255,9 @@ const initUserInfo = (userId: any) => { console.log(formData.value, 'formData'); initSocialList(); }) + .catch((err) => { + useMessage().error(err.msg); + }) .finally(() => { loading.value = false; }); @@ -296,6 +294,9 @@ const Unbinding = (type) => { .then((res) => { useMessage().success('解绑成功'); }) + .catch((err) => { + useMessage().error(err.msg); + }) .finally(() => { initUserInfo(formData.value.userId); }); diff --git a/src/views/login/component/mobile.vue b/src/views/login/component/mobile.vue index 5ef83fbe..0cd39e6a 100644 --- a/src/views/login/component/mobile.vue +++ b/src/views/login/component/mobile.vue @@ -1,5 +1,5 @@