1. 前端登陆界面,接入租户

This commit is contained in:
YunaiV
2021-12-04 23:27:39 +08:00
parent 7c8fe2fc50
commit 0cb4823b5b
2 changed files with 23 additions and 2 deletions

View File

@ -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 + '?';