feat: 系统设置国际化切换

This commit is contained in:
TsMask
2023-12-04 18:18:26 +08:00
parent 205e07af45
commit 12643cac12
5 changed files with 164 additions and 3 deletions

View File

@@ -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;
},