tangning преди 1 година
родител
ревизия
748c3bedb2
променени са 1 файла, в които са добавени 5 реда и са изтрити 0 реда
  1. 5 0
      src/utils/http/axios/index.ts

+ 5 - 0
src/utils/http/axios/index.ts

@@ -174,7 +174,9 @@ const transform: AxiosTransform = {
    */
    */
   requestInterceptors: (config, options) => {
   requestInterceptors: (config, options) => {
     // 请求之前处理config
     // 请求之前处理config
+    const { locale } = useI18n();
     const token = getToken();
     const token = getToken();
+    const lang = locale.value;
     if (token && (config as Recordable)?.requestOptions?.withToken !== false) {
     if (token && (config as Recordable)?.requestOptions?.withToken !== false) {
       // jwt token
       // jwt token
       // (config as Recordable).headers.Authorization = options.authenticationScheme
       // (config as Recordable).headers.Authorization = options.authenticationScheme
@@ -184,6 +186,9 @@ const transform: AxiosTransform = {
         ? `${options.authenticationScheme} ${token}`
         ? `${options.authenticationScheme} ${token}`
         : token;
         : token;
     }
     }
+    if (lang && (config as Recordable)) {
+      (config as Recordable).headers.lang = lang == 'zh_CN' ? 'zh' : 'ja';
+    }
     return config;
     return config;
   },
   },