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

This commit is contained in:
TsMask
2023-11-08 18:17:30 +08:00
parent d27577b799
commit 7eccfd6877

View File

@@ -96,7 +96,6 @@ const FATCH_OPTIONS: OptionsType = {
headers: { headers: {
[APP_REQUEST_HEADER_CODE]: import.meta.env.VITE_APP_CODE, [APP_REQUEST_HEADER_CODE]: import.meta.env.VITE_APP_CODE,
[APP_REQUEST_HEADER_VERSION]: import.meta.env.VITE_APP_VERSION, [APP_REQUEST_HEADER_VERSION]: import.meta.env.VITE_APP_VERSION,
'Accept-Language': `${localGet(CACHE_LOCAL_I18N)};q=0.9`,
}, },
dataType: 'json', dataType: 'json',
responseType: 'json', responseType: 'json',
@@ -121,11 +120,19 @@ function beforeRequest(options: OptionsType): OptionsType | Promise<any> {
); );
} }
// 客户端接受语言
Reflect.set(
options.headers,
'Accept-Language',
`${localGet(CACHE_LOCAL_I18N) || 'en_US'};q=0.9`
);
// 是否需要设置 token // 是否需要设置 token
const token = getToken(); const token = getToken();
if (options.whithToken && token) { if (options.whithToken && token) {
Reflect.set(options.headers, TOKEN_KEY, TOKEN_KEY_PREFIX + token); Reflect.set(options.headers, TOKEN_KEY, TOKEN_KEY_PREFIX + token);
} }
// 是否需要防止数据重复提交 // 是否需要防止数据重复提交
if ( if (
options.repeatSubmit && options.repeatSubmit &&