From 20f937a4edc49e63ebfafff538caad647bbde414 Mon Sep 17 00:00:00 2001 From: downeyin <853384781@qq.com> Date: Fri, 26 Jul 2024 00:11:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=A7=9F=E6=88=B7ID?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E9=85=8D=E7=BD=AE=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 3 +++ sheep/api/infra/file.js | 6 +++--- sheep/config/index.js | 5 ++++- sheep/request/index.js | 8 ++++---- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.env b/.env index 4860a552..adcc17dd 100644 --- a/.env +++ b/.env @@ -22,3 +22,6 @@ SHOPRO_STATIC_URL = https://file.sheepjs.com # 是否开启直播 1 开启直播 | 0 关闭直播 (小程序官方后台未审核开通直播权限时请勿开启) SHOPRO_MPLIVE_ON = 0 + +# 租户ID 默认 1 +SHOPRO_TENANT_ID = 1 diff --git a/sheep/api/infra/file.js b/sheep/api/infra/file.js index a4bac46f..f7f2a964 100644 --- a/sheep/api/infra/file.js +++ b/sheep/api/infra/file.js @@ -1,4 +1,4 @@ -import { baseUrl, apiPath } from '@/sheep/config'; +import { baseUrl, apiPath, tenantId } from '@/sheep/config'; const FileApi = { // 上传文件 @@ -15,8 +15,8 @@ const FileApi = { name: 'file', header: { // Accept: 'text/json', - Accept : '*/*', - 'tenant-id' :'1', + Accept: '*/*', + 'tenant-id': tenantId, // Authorization: 'Bearer test247', }, success: (uploadFileRes) => { diff --git a/sheep/config/index.js b/sheep/config/index.js index 48f46ef9..9aa4f523 100644 --- a/sheep/config/index.js +++ b/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 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 default { baseUrl, apiPath, staticUrl, - websocketPath + tenantId, + websocketPath, }; diff --git a/sheep/request/index.js b/sheep/request/index.js index 99c38a4f..700c7dda 100644 --- a/sheep/request/index.js +++ b/sheep/request/index.js @@ -4,7 +4,7 @@ */ import Request from 'luch-request'; -import { baseUrl, apiPath } from '@/sheep/config'; +import { baseUrl, apiPath, tenantId } from '@/sheep/config'; import $store from '@/sheep/store'; import $platform from '@/sheep/platform'; import { @@ -96,8 +96,8 @@ http.interceptors.request.use( config.header['Authorization'] = token; } // TODO 芋艿:特殊处理 - config.header['Accept'] = '*/*' - config.header['tenant-id'] = '1'; + config.header['Accept'] = '*/*'; + config.header['tenant-id'] = tenantId; config.header['terminal'] = '20'; // config.header['Authorization'] = 'Bearer test247'; return config; @@ -299,4 +299,4 @@ const request = (config) => { return http.middleware(config); }; -export default request; \ No newline at end of file +export default request;