From 0cb4823b5b0ad5668a801da0def2b7d9296f9cbd Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 4 Dec 2021 23:27:39 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=89=8D=E7=AB=AF=E7=99=BB=E9=99=86?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=EF=BC=8C=E6=8E=A5=E5=85=A5=E7=A7=9F=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- yudao-admin-ui/src/utils/request.js | 6 ++++++ yudao-admin-ui/src/views/login.vue | 19 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/yudao-admin-ui/src/utils/request.js b/yudao-admin-ui/src/utils/request.js index c063ec300..4daa6e464 100644 --- a/yudao-admin-ui/src/utils/request.js +++ b/yudao-admin-ui/src/utils/request.js @@ -3,6 +3,7 @@ import { Notification, MessageBox, Message } from 'element-ui' import store from '@/store' import { getToken } from '@/utils/auth' import errorCode from '@/utils/errorCode' +import Cookies from "js-cookie"; axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' // 创建axios实例 @@ -19,6 +20,11 @@ service.interceptors.request.use(config => { if (getToken() && !isToken) { config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 } + // 设置租户 + const tenantId = Cookies.get('tenantId'); + if (tenantId) { + config.headers['tenant-id'] = tenantId; + } // get请求映射params参数 if (config.method === 'get' && config.params) { let url = config.url + '?'; diff --git a/yudao-admin-ui/src/views/login.vue b/yudao-admin-ui/src/views/login.vue index d963e24c3..b098e13ad 100644 --- a/yudao-admin-ui/src/views/login.vue +++ b/yudao-admin-ui/src/views/login.vue @@ -2,6 +2,11 @@