Commit 6fd59784 authored by lihaihan's avatar lihaihan

request增加用户token信息

parent 2f2f4a7e
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -61,5 +61,4 @@
"vue-eslint-parser": "^7.10.0",
"vue-tsc": "^0.2.3"
}
}
\ No newline at end of file
}
......@@ -2,10 +2,13 @@ import { tokenIns } from '@/util/tokenUtil'
let BASE_URL: string = ''
let TOKEN: string = ''
let mdtUser: string = ''
let imperToken: string = ''
let imperMdtUser: string = ''
let MAP_CONFIG: { jsApiUrl: string; cssUrl: string } = {
jsApiUrl: '',
cssUrl: '',
}
};
function getToken() {
const header = window.__DM_GLOBE_UTIL
......@@ -14,10 +17,26 @@ function getToken() {
return header ? header.authorization : tokenIns.get()
}
switch (process.env.NODE_ENV) {
case 'production':
BASE_URL = 'https://www.maicedata.com/collector/data/' // 生产环境
TOKEN = getToken()
let header = window.__DM_GLOBE_UTIL ? window.__DM_GLOBE_UTIL.getHeader() : null
if (header) {
//新版的取值方式
TOKEN = header['authorization']
mdtUser = header['mdt-user']
imperToken = header['x-impersonate-token']
imperMdtUser = header['x-impersonate-user']
} else {
//旧版的取值方式
TOKEN = tokenIns.get()
mdtUser = tokenIns.getMdtUser()
imperToken = tokenIns.getImperToken()
imperMdtUser = tokenIns.getImperMdtUser()
}
// TOKEN = getToken()
MAP_CONFIG = {
jsApiUrl: 'http://10.108.3.48/api418/arcgis_js_api/library/4.18/init.js',
cssUrl:
......@@ -43,6 +62,9 @@ switch (process.env.NODE_ENV) {
export default {
TOKEN,
mdtUser,
imperToken,
imperMdtUser,
BASE_URL,
MAP_CONFIG,
ORGANIZATION: '733d0ac0-f67e-4bde-8872-3ca00983f18c',
......
......@@ -10,7 +10,10 @@ const Axios = axios.create({
Axios.interceptors.request.use(
(config) => {
// 添加token
config.headers.authorization = api.TOKEN
config.headers.Authorization = (window as any)._TMP_TOKEN_ || api.TOKEN;
config.headers['mdt-user'] = api.mdtUser;
config.headers['x-impersonate-token'] = api.imperToken;
// config.headers.authorization = api.TOKEN
return config
},
(error) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment