diff --git a/src/components/dialogs/LanguageSwitch.vue b/src/components/dialogs/LanguageSwitch.vue index 702bc89..264ab5e 100644 --- a/src/components/dialogs/LanguageSwitch.vue +++ b/src/components/dialogs/LanguageSwitch.vue @@ -5,7 +5,7 @@ width="300px" :close-on-click-modal="false" append-to-body - class="language-switch-dialog" + class="lang-switch-dialog" > @@ -83,9 +83,14 @@ const open = () => { // 确认修改 const handleConfirm = () => { locale.value = tempLang.value - localStorage.setItem('language', tempLang.value) + localStorage.setItem('lang', tempLang.value) ElMessage.success(`语言已切换为:${getLangLabel(tempLang.value)}`) dialogVisible.value = false + + // 触发页面刷新以重新加载数据 + setTimeout(() => { + window.location.reload() + }, 500) } defineExpose({ diff --git a/src/components/locales/index.js b/src/components/locales/index.js index 0422819..3a2aa27 100644 --- a/src/components/locales/index.js +++ b/src/components/locales/index.js @@ -15,7 +15,7 @@ const messages = { // 获取浏览器默认语言或缓存语言 const getLocale = () => { // 优先读取缓存,没有则读取浏览器语言,默认 zh-CN - return localStorage.getItem('language') || 'zh-CN' + return localStorage.getItem('lang') || 'zh-CN' } const i18n = createI18n({ diff --git a/src/components/locales/lang/en.js b/src/components/locales/lang/en.js index 3236083..71945a3 100644 --- a/src/components/locales/lang/en.js +++ b/src/components/locales/lang/en.js @@ -32,6 +32,8 @@ export default { // Currency Types SGD: 'SGD', goldCoin: '', // Gold Coin label intentionally empty + // 对话框标题 + will: 'Will', }, // Audit Group diff --git a/src/main.ts b/src/main.ts index 9079501..23beb46 100644 --- a/src/main.ts +++ b/src/main.ts @@ -49,4 +49,15 @@ app.use(ElementPlus, { const adminStore = useAdminStore() const messageStore = useMessageStore() adminStore.initFromLocalStorage() -messageStore.initFromLocalStorage() \ No newline at end of file +messageStore.initFromLocalStorage() + +// 初始化语言设置 +const initLanguage = () => { + const lang = localStorage.getItem('lang') + if (!lang) { + // 如果没有设置语言,默认使用中文 + localStorage.setItem('lang', 'zh-CN') + } +} + +initLanguage() \ No newline at end of file diff --git a/src/util/request.js b/src/util/request.js index 2b312ca..5871979 100644 --- a/src/util/request.js +++ b/src/util/request.js @@ -26,15 +26,13 @@ export const uploadFile = (file) => { service.interceptors.request.use(config => { const token = localStorage.getItem('token') if (token) { - // 请求体里面为什么放token? - // if (config.data) { - // config.data.token = token; - // } else { - // config.data = { token }; - // } config.headers.token = `${token}` } + // 统一使用 'lang' 作为键名 + const lang = localStorage.getItem('lang') || 'zh-CN' + config.headers.lang = lang return config + }, error => { return Promise.reject(error) }) @@ -56,4 +54,4 @@ service.interceptors.response.use( } ) -export default service +export default service \ No newline at end of file diff --git a/src/views/audit/gold/rechargeAudit.vue b/src/views/audit/gold/rechargeAudit.vue index 3a316b8..6d42dce 100644 --- a/src/views/audit/gold/rechargeAudit.vue +++ b/src/views/audit/gold/rechargeAudit.vue @@ -94,7 +94,7 @@ - +