tangning 1 年間 前
コミット
902a264552
1 ファイル変更6 行追加0 行削除
  1. 6 0
      src/utils/http/axios/index.ts

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

@@ -139,6 +139,9 @@ const transform: AxiosTransform = {
   requestInterceptors: (config, options) => {
     // 请求之前处理config
     const token = getToken();
+    const { locale } = useI18n();
+    const lang = locale == 'zh-CN' ? 'zh' : 'en';
+    console.log('locale', locale);
     if (token && (config as Recordable)?.requestOptions?.withToken !== false) {
       // jwt token
       (config as Recordable).headers.Authorization = options.authenticationScheme
@@ -148,6 +151,9 @@ const transform: AxiosTransform = {
         ? `${options.authenticationScheme} ${token}`
         : token;
     }
+    if (lang) {
+      (config as Recordable).headers.lang = lang;
+    }
     return config;
   },