From 12643cac12f19c376f9958db9fe4dab2f42fd7aa Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Mon, 4 Dec 2023 18:18:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=9B=BD=E9=99=85=E5=8C=96=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/i18n/locales/en-US.ts | 4 + src/i18n/locales/zh-CN.ts | 4 + src/store/modules/app.ts | 7 +- .../system/setting/components/change-i18n.vue | 143 ++++++++++++++++++ src/views/system/setting/index.vue | 9 +- 5 files changed, 164 insertions(+), 3 deletions(-) create mode 100644 src/views/system/setting/components/change-i18n.vue diff --git a/src/i18n/locales/en-US.ts b/src/i18n/locales/en-US.ts index e18a28f1..151e976d 100644 --- a/src/i18n/locales/en-US.ts +++ b/src/i18n/locales/en-US.ts @@ -1107,6 +1107,10 @@ export default { sysOfficialUrlOpen: 'Open the official website.', sysOfficialUrlInstruction: 'Official website link address', sysOfficialUrlInstruction1: 'start, if you need to hide do not jump to fill in the', + i18n: "Internationalization Switch", + i18nOpen: "Display Switch", + i18nDefault: "Default Languages", + i18nInstruction: 'Whether to display the internationalization switch and set the system default language', }, role:{ allScopeOptions:'All data permissions', diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index acff204e..5d168c85 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -1107,6 +1107,10 @@ export default { sysOfficialUrlOpen: '打开官网', sysOfficialUrlInstruction: '官网链接地址', sysOfficialUrlInstruction1: '开头,如需隐藏不跳转填写', + i18n: "国际化切换", + i18nOpen: "显示切换", + i18nDefault: "默认语言", + i18nInstruction: '是否显示国际化切换,设置系统默认语言', }, role:{ allScopeOptions:'全部数据权限', diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts index 6257246c..71c7bcd3 100644 --- a/src/store/modules/app.ts +++ b/src/store/modules/app.ts @@ -2,7 +2,7 @@ import { getSysConf } from '@/api'; import { CACHE_LOCAL_I18N } from '@/constants/cache-keys-constants'; import { RESULT_CODE_SUCCESS } from '@/constants/result-constants'; import { parseUrlPath } from '@/plugins/file-static-url'; -import { localGet } from '@/utils/cache-local-utils'; +import { localGet, localSet } from '@/utils/cache-local-utils'; import { defineStore } from 'pinia'; /**应用参数类型 */ @@ -95,6 +95,11 @@ const useAppStore = defineStore('app', { this.officialUrl = res.data.officialUrl; this.i18nOpen = res.data.i18nOpen === 'true'; this.i18nDefault = res.data.i18nDefault; + // 切换禁用时,设置默认语言 + const localI18n = localGet(CACHE_LOCAL_I18N); + if (localI18n == null || (!this.i18nOpen && this.i18nDefault)) { + localSet(CACHE_LOCAL_I18N, this.i18nDefault); + } } return res; }, diff --git a/src/views/system/setting/components/change-i18n.vue b/src/views/system/setting/components/change-i18n.vue new file mode 100644 index 00000000..3589e903 --- /dev/null +++ b/src/views/system/setting/components/change-i18n.vue @@ -0,0 +1,143 @@ + + + + + diff --git a/src/views/system/setting/index.vue b/src/views/system/setting/index.vue index 2b021def..cfac504c 100644 --- a/src/views/system/setting/index.vue +++ b/src/views/system/setting/index.vue @@ -6,6 +6,7 @@ import ChangeTitle from './components/change-title.vue'; import ChangeCopyright from './components/change-copyright.vue'; import ChangeHelpDoc from './components/change-help-doc.vue'; import ChangeOfficialUrl from './components/change-official-url.vue'; +import ChangeI18n from './components/change-i18n.vue'; import useI18n from '@/hooks/useI18n'; const { t } = useI18n(); @@ -29,14 +30,18 @@ const { t } = useI18n(); {{ t('views.system.setting.sysLoginBg') }} - + {{ t('views.system.setting.sysHelpDoc') }} - + {{ t('views.system.setting.sysOfficialUrl') }} + + {{ t('views.system.setting.i18n') }} + +