feat: 从客户端获取首选语言

This commit is contained in:
TsMask
2023-11-08 16:47:07 +08:00
parent d9940c7c0d
commit de48ffa10c
2 changed files with 7 additions and 2 deletions

View File

@@ -6,7 +6,7 @@ import enUS from './locales/en-US';
const i18n = createI18n({
legacy: false, // 使用 Composition API 的方式创建 i18n 实例
locale: localGet(CACHE_LOCAL_I18N) || 'zh_CN', // 默认显示语言
locale: localGet(CACHE_LOCAL_I18N) || 'en-US', // 默认显示语言
messages: {
zh_CN: zhCN,
en_US: enUS,

View File

@@ -4,8 +4,12 @@ import {
sessionGetJSON,
sessionSetJSON,
} from '@/utils/cache-session-utils';
import { localGet } from '@/utils/cache-local-utils';
import { TOKEN_KEY, TOKEN_KEY_PREFIX } from '@/constants/token-constants';
import { CACHE_SESSION_FATCH } from '@/constants/cache-keys-constants';
import {
CACHE_LOCAL_I18N,
CACHE_SESSION_FATCH,
} from '@/constants/cache-keys-constants';
import {
APP_REQUEST_HEADER_CODE,
APP_REQUEST_HEADER_VERSION,
@@ -92,6 +96,7 @@ const FATCH_OPTIONS: OptionsType = {
headers: {
[APP_REQUEST_HEADER_CODE]: import.meta.env.VITE_APP_CODE,
[APP_REQUEST_HEADER_VERSION]: import.meta.env.VITE_APP_VERSION,
'Accept-Language': `${localGet(CACHE_LOCAL_I18N)};q=0.9`,
},
dataType: 'json',
responseType: 'json',