Explorar el Código

feat: 新增国际化请求头配置

叶静 hace 1 mes
padre
commit
32fa0b3c66
Se han modificado 1 ficheros con 6 adiciones y 0 borrados
  1. 6 0
      src/sheep/request/index.js

+ 6 - 0
src/sheep/request/index.js

@@ -6,6 +6,7 @@ import { ElMessage } from 'element-plus';
 import { isNil } from 'lodash';
 import { baseURL } from '@/sheep/config';
 import { apiRouting } from '@/sheep/config/api-routing';
+import { getCurrentLanguage } from '@/locales';
 
 const options = {
   // 显示操作成功消息 默认不显示
@@ -80,6 +81,11 @@ request.interceptors.request.use(
     const token = $storage.get('token');
     if (token) config.headers['Accesstoken'] = token;
 
+    // 添加语言请求头
+    const currentLanguage = getCurrentLanguage();
+    const languageCode = currentLanguage === 'en-US' ? 'en' : 'zh';
+    config.headers['language'] = languageCode;
+
     // 🔑 API路由处理
     const processedConfig = apiRouting.processRequest(config);