From c985a7ff834e4a4175ea779612bfa964563e6511 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com> Date: Tue, 23 May 2023 12:16:24 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E6=96=B0=E5=A2=9E=E7=BF=BB?= =?UTF-8?q?=E8=AF=91=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/i18n/index.js | 17 +++++++++-------- src/i18n/lang/en.json | 3 ++- src/i18n/lang/zh-cn.json | 3 ++- src/i18n/lang/zh-tw.json | 3 ++- src/layout/components/Settings/index.vue | 2 +- src/store/modules/app.js | 4 ++-- src/views/system/user/index.vue | 4 +++- 7 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/i18n/index.js b/src/i18n/index.js index f03b3fe..587a2af 100644 --- a/src/i18n/index.js +++ b/src/i18n/index.js @@ -1,10 +1,11 @@ import { createI18n } from 'vue-i18n' // import useAppStore from '@/store/modules/app' -import { listLangByLocale } from '@/api/system/commonLang' -import jsCookie from 'js-cookie' +import { listLangByLocale } from '@/api/system/commonlang.js' +import defaultSettings from '@/settings' +import cache from '@/plugins/cache' const language = computed(() => { // return useAppStore().lang - return jsCookie.get('lang') || 'zh-cn' + return cache.local.get('lang') || defaultSettings.defaultLang }) import zhCn from './lang/zh-cn.json' @@ -24,7 +25,7 @@ const i18n = createI18n({ // 全局注入 $t 函数 globalInjection: true, fallbackLocale: 'zh-cn', - locale: language.value, //默认选择的语言 + locale: language.value, //默认选择的语言 legacy: false, // 使用 Composition API 模式,则需要将其设置为false messages: { 'zh-cn': { @@ -37,17 +38,17 @@ const i18n = createI18n({ ...pageLoginTw, ...pagemenuTw }, - 'en': { + en: { ...en, ...pageLoginEn, ...pagemenuEn - }, + } //... 在这里添加其他语言支持 } }) const loadLocale = () => { - listLangByLocale(language.value).then(res => { + listLangByLocale(language.value).then((res) => { const { code, data } = res if (code == 200) { i18n.global.mergeLocaleMessage(language.value, data) @@ -55,4 +56,4 @@ const loadLocale = () => { }) } loadLocale() -export default i18n; \ No newline at end of file +export default i18n diff --git a/src/i18n/lang/en.json b/src/i18n/lang/en.json index 293c25f..758bc85 100644 --- a/src/i18n/lang/en.json +++ b/src/i18n/lang/en.json @@ -88,7 +88,8 @@ "identity": "Identity", "content1": "The code is completely free and open source, easy to read and understand, and the interface is simple and beautiful, giving you one more choice and reference for your project.", "topNav": "Top nav", - "commonFuncs": "Common Functions" + "commonFuncs": "Common Functions", + "openWatermark": "Open Watermark" }, "common": { "ok": "Ok", diff --git a/src/i18n/lang/zh-cn.json b/src/i18n/lang/zh-cn.json index 557a62e..e048402 100644 --- a/src/i18n/lang/zh-cn.json +++ b/src/i18n/lang/zh-cn.json @@ -88,7 +88,8 @@ "identity": "身份", "content1": "代码完全免费开源,易读易懂、界面简洁美观,给你的项目多一种选择与参考。", "topNav": "顶部导航", - "commonFuncs": "常用功能" + "commonFuncs": "常用功能", + "openWatermark": "开启水印" }, "common": { "ok": "确定", diff --git a/src/i18n/lang/zh-tw.json b/src/i18n/lang/zh-tw.json index b6396d5..13f9f33 100644 --- a/src/i18n/lang/zh-tw.json +++ b/src/i18n/lang/zh-tw.json @@ -88,7 +88,8 @@ "rewardUser": "打賞作者喝杯咖啡表示鼓勵", "content1": "代碼完全免費開源,易讀易懂、界面簡潔美觀,給你的項目多一種選擇與參考。", "topNav": "頂部導航", - "commonFuncs": "常用功能" + "commonFuncs": "常用功能", + "openWatermark": "開啟水印" }, "common": { "ok": "確定", diff --git a/src/layout/components/Settings/index.vue b/src/layout/components/Settings/index.vue index 98630eb..ef6264c 100644 --- a/src/layout/components/Settings/index.vue +++ b/src/layout/components/Settings/index.vue @@ -64,7 +64,7 @@