Эх сурвалжийг харах

feat: 增加租户ID自定义配置支持

downeyin 1 жил өмнө
parent
commit
20f937a4ed

+ 3 - 0
.env

@@ -22,3 +22,6 @@ SHOPRO_STATIC_URL = https://file.sheepjs.com
 
 
 # 是否开启直播  1 开启直播 | 0 关闭直播 (小程序官方后台未审核开通直播权限时请勿开启)
 # 是否开启直播  1 开启直播 | 0 关闭直播 (小程序官方后台未审核开通直播权限时请勿开启)
 SHOPRO_MPLIVE_ON = 0
 SHOPRO_MPLIVE_ON = 0
+
+# 租户ID 默认 1
+SHOPRO_TENANT_ID = 1

+ 3 - 3
sheep/api/infra/file.js

@@ -1,4 +1,4 @@
-import { baseUrl, apiPath } from '@/sheep/config';
+import { baseUrl, apiPath, tenantId } from '@/sheep/config';
 
 
 const FileApi = {
 const FileApi = {
   // 上传文件
   // 上传文件
@@ -15,8 +15,8 @@ const FileApi = {
         name: 'file',
         name: 'file',
         header: {
         header: {
           // Accept: 'text/json',
           // Accept: 'text/json',
-          Accept : '*/*',
-          'tenant-id' :'1',
+          Accept: '*/*',
+          'tenant-id': tenantId,
           // Authorization:  'Bearer test247',
           // Authorization:  'Bearer test247',
         },
         },
         success: (uploadFileRes) => {
         success: (uploadFileRes) => {

+ 4 - 1
sheep/config/index.js

@@ -11,10 +11,13 @@ console.log(`[芋道商城 ${version}]  http://doc.iocoder.cn`);
 
 
 export const apiPath = import.meta.env.SHOPRO_API_PATH;
 export const apiPath = import.meta.env.SHOPRO_API_PATH;
 export const staticUrl = import.meta.env.SHOPRO_STATIC_URL;
 export const staticUrl = import.meta.env.SHOPRO_STATIC_URL;
+export const tenantId = import.meta.env.SHOPRO_TENANT_ID;
 export const websocketPath = import.meta.env.SHOPRO_WEBSOCKET_PATH;
 export const websocketPath = import.meta.env.SHOPRO_WEBSOCKET_PATH;
+
 export default {
 export default {
   baseUrl,
   baseUrl,
   apiPath,
   apiPath,
   staticUrl,
   staticUrl,
-  websocketPath
+  tenantId,
+  websocketPath,
 };
 };

+ 4 - 4
sheep/request/index.js

@@ -4,7 +4,7 @@
  */
  */
 
 
 import Request from 'luch-request';
 import Request from 'luch-request';
-import { baseUrl, apiPath } from '@/sheep/config';
+import { baseUrl, apiPath, tenantId } from '@/sheep/config';
 import $store from '@/sheep/store';
 import $store from '@/sheep/store';
 import $platform from '@/sheep/platform';
 import $platform from '@/sheep/platform';
 import {
 import {
@@ -96,8 +96,8 @@ http.interceptors.request.use(
       config.header['Authorization'] = token;
       config.header['Authorization'] = token;
     }
     }
 		// TODO 芋艿:特殊处理
 		// TODO 芋艿:特殊处理
-    config.header['Accept'] = '*/*'
-    config.header['tenant-id'] = '1';
+    config.header['Accept'] = '*/*';
+    config.header['tenant-id'] = tenantId;
     config.header['terminal'] = '20';
     config.header['terminal'] = '20';
     // config.header['Authorization'] = 'Bearer test247';
     // config.header['Authorization'] = 'Bearer test247';
 		return config;
 		return config;
@@ -299,4 +299,4 @@ const request = (config) => {
 	return http.middleware(config);
 	return http.middleware(config);
 };
 };
 
 
-export default request;
+export default request;