Commit 6fd59784 authored by lihaihan's avatar lihaihan

request增加用户token信息

parent 2f2f4a7e
This diff is collapsed.
{
"name": "huamu_party_building_3d",
"version": "1.0.0",
"description": "花木街道数字孪生城市",
"homepage": "/statics/huamu_party_building_3d",
"author": "GuoMingyao",
"private": true,
"scripts": {
"dev": "vite",
"start": "npm run dev",
"build": "vue-tsc --noEmit && vite build --mode production",
"build:sit": "vue-tsc --noEmit && vite build --mode sit",
"serve": "vite preview"
},
"dependencies": {
"@vicons/ionicons5": "^0.11.0",
"@yzfe/svgicon": "^1.1.0",
"@yzfe/vue3-svgicon": "^1.0.1",
"ali-oss": "^6.16.0",
"animate.css": "^4.1.1",
"axios": "^0.21.1",
"countup.js": "^2.0.8",
"dayjs": "^1.10.6",
"docx": "^6.0.3",
"echarts": "^5.1.2",
"esri-loader": "^3.2.0",
"exceljs": "^4.3.0",
"file-saver": "^2.0.5",
"lz-string": "^1.4.4",
"md5": "^2.3.0",
"normalize.css": "^8.0.1",
"parse-domain": "^4.1.0",
"qs": "^6.10.1",
"vite-plugin-svgicon": "^1.0.0",
"vue": "^3.2.6",
"vuex": "^4.0.0",
"xlsx": "^0.17.2"
},
"devDependencies": {
"@rollup/plugin-alias": "^3.1.5",
"@types/exceljs": "^1.3.0",
"@types/file-saver": "^2.0.3",
"@types/md5": "^2.3.1",
"@types/node": "^16.3.2",
"@types/qs": "^6.9.7",
"@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.28.5",
"@vitejs/plugin-vue": "^1.6.0",
"@vitejs/plugin-vue-jsx": "^1.1.7",
"@vue/compiler-sfc": "^3.2.6",
"eslint": "^7.30.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-vue": "^7.14.0",
"naive-ui": "^2.18.2",
"prettier": "^2.3.2",
"stylus": "^0.54.8",
"typescript": "^4.3.5",
"vite": "^2.5.2",
"vue-eslint-parser": "^7.10.0",
"vue-tsc": "^0.2.3"
}
"name": "huamu_party_building_3d",
"version": "1.0.0",
"description": "花木街道数字孪生城市",
"homepage": "/statics/huamu_party_building_3d",
"author": "GuoMingyao",
"private": true,
"scripts": {
"dev": "vite",
"start": "npm run dev",
"build": "vue-tsc --noEmit && vite build --mode production",
"build:sit": "vue-tsc --noEmit && vite build --mode sit",
"serve": "vite preview"
},
"dependencies": {
"@vicons/ionicons5": "^0.11.0",
"@yzfe/svgicon": "^1.1.0",
"@yzfe/vue3-svgicon": "^1.0.1",
"ali-oss": "^6.16.0",
"animate.css": "^4.1.1",
"axios": "^0.21.1",
"countup.js": "^2.0.8",
"dayjs": "^1.10.6",
"docx": "^6.0.3",
"echarts": "^5.1.2",
"esri-loader": "^3.2.0",
"exceljs": "^4.3.0",
"file-saver": "^2.0.5",
"lz-string": "^1.4.4",
"md5": "^2.3.0",
"normalize.css": "^8.0.1",
"parse-domain": "^4.1.0",
"qs": "^6.10.1",
"vite-plugin-svgicon": "^1.0.0",
"vue": "^3.2.6",
"vuex": "^4.0.0",
"xlsx": "^0.17.2"
},
"devDependencies": {
"@rollup/plugin-alias": "^3.1.5",
"@types/exceljs": "^1.3.0",
"@types/file-saver": "^2.0.3",
"@types/md5": "^2.3.1",
"@types/node": "^16.3.2",
"@types/qs": "^6.9.7",
"@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.28.5",
"@vitejs/plugin-vue": "^1.6.0",
"@vitejs/plugin-vue-jsx": "^1.1.7",
"@vue/compiler-sfc": "^3.2.6",
"eslint": "^7.30.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-vue": "^7.14.0",
"naive-ui": "^2.18.2",
"prettier": "^2.3.2",
"stylus": "^0.54.8",
"typescript": "^4.3.5",
"vite": "^2.5.2",
"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) => {
......@@ -96,7 +99,7 @@ const ajax = ({
'Content-Type': contentType,
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers':
'Authorization,Origin, X-Requested-With, Content-Type, Accept',
'Authorization,Origin, X-Requested-With, Content-Type, Accept',
'Access-Control-Allow-Methods': '*',
__show_loading: showLoading,
...headers,
......
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