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.
{ {
"name": "huamu_party_building_3d", "name": "huamu_party_building_3d",
"version": "1.0.0", "version": "1.0.0",
"description": "花木街道数字孪生城市", "description": "花木街道数字孪生城市",
"homepage": "/statics/huamu_party_building_3d", "homepage": "/statics/huamu_party_building_3d",
"author": "GuoMingyao", "author": "GuoMingyao",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"start": "npm run dev", "start": "npm run dev",
"build": "vue-tsc --noEmit && vite build --mode production", "build": "vue-tsc --noEmit && vite build --mode production",
"build:sit": "vue-tsc --noEmit && vite build --mode sit", "build:sit": "vue-tsc --noEmit && vite build --mode sit",
"serve": "vite preview" "serve": "vite preview"
}, },
"dependencies": { "dependencies": {
"@vicons/ionicons5": "^0.11.0", "@vicons/ionicons5": "^0.11.0",
"@yzfe/svgicon": "^1.1.0", "@yzfe/svgicon": "^1.1.0",
"@yzfe/vue3-svgicon": "^1.0.1", "@yzfe/vue3-svgicon": "^1.0.1",
"ali-oss": "^6.16.0", "ali-oss": "^6.16.0",
"animate.css": "^4.1.1", "animate.css": "^4.1.1",
"axios": "^0.21.1", "axios": "^0.21.1",
"countup.js": "^2.0.8", "countup.js": "^2.0.8",
"dayjs": "^1.10.6", "dayjs": "^1.10.6",
"docx": "^6.0.3", "docx": "^6.0.3",
"echarts": "^5.1.2", "echarts": "^5.1.2",
"esri-loader": "^3.2.0", "esri-loader": "^3.2.0",
"exceljs": "^4.3.0", "exceljs": "^4.3.0",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
"lz-string": "^1.4.4", "lz-string": "^1.4.4",
"md5": "^2.3.0", "md5": "^2.3.0",
"normalize.css": "^8.0.1", "normalize.css": "^8.0.1",
"parse-domain": "^4.1.0", "parse-domain": "^4.1.0",
"qs": "^6.10.1", "qs": "^6.10.1",
"vite-plugin-svgicon": "^1.0.0", "vite-plugin-svgicon": "^1.0.0",
"vue": "^3.2.6", "vue": "^3.2.6",
"vuex": "^4.0.0", "vuex": "^4.0.0",
"xlsx": "^0.17.2" "xlsx": "^0.17.2"
}, },
"devDependencies": { "devDependencies": {
"@rollup/plugin-alias": "^3.1.5", "@rollup/plugin-alias": "^3.1.5",
"@types/exceljs": "^1.3.0", "@types/exceljs": "^1.3.0",
"@types/file-saver": "^2.0.3", "@types/file-saver": "^2.0.3",
"@types/md5": "^2.3.1", "@types/md5": "^2.3.1",
"@types/node": "^16.3.2", "@types/node": "^16.3.2",
"@types/qs": "^6.9.7", "@types/qs": "^6.9.7",
"@typescript-eslint/eslint-plugin": "^4.28.1", "@typescript-eslint/eslint-plugin": "^4.28.1",
"@typescript-eslint/parser": "^4.28.5", "@typescript-eslint/parser": "^4.28.5",
"@vitejs/plugin-vue": "^1.6.0", "@vitejs/plugin-vue": "^1.6.0",
"@vitejs/plugin-vue-jsx": "^1.1.7", "@vitejs/plugin-vue-jsx": "^1.1.7",
"@vue/compiler-sfc": "^3.2.6", "@vue/compiler-sfc": "^3.2.6",
"eslint": "^7.30.0", "eslint": "^7.30.0",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.4", "eslint-plugin-import": "^2.23.4",
"eslint-plugin-prettier": "^3.4.0", "eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-vue": "^7.14.0", "eslint-plugin-vue": "^7.14.0",
"naive-ui": "^2.18.2", "naive-ui": "^2.18.2",
"prettier": "^2.3.2", "prettier": "^2.3.2",
"stylus": "^0.54.8", "stylus": "^0.54.8",
"typescript": "^4.3.5", "typescript": "^4.3.5",
"vite": "^2.5.2", "vite": "^2.5.2",
"vue-eslint-parser": "^7.10.0", "vue-eslint-parser": "^7.10.0",
"vue-tsc": "^0.2.3" "vue-tsc": "^0.2.3"
}
} }
}
\ No newline at end of file
...@@ -2,10 +2,13 @@ import { tokenIns } from '@/util/tokenUtil' ...@@ -2,10 +2,13 @@ import { tokenIns } from '@/util/tokenUtil'
let BASE_URL: string = '' let BASE_URL: string = ''
let TOKEN: string = '' let TOKEN: string = ''
let mdtUser: string = ''
let imperToken: string = ''
let imperMdtUser: string = ''
let MAP_CONFIG: { jsApiUrl: string; cssUrl: string } = { let MAP_CONFIG: { jsApiUrl: string; cssUrl: string } = {
jsApiUrl: '', jsApiUrl: '',
cssUrl: '', cssUrl: '',
} };
function getToken() { function getToken() {
const header = window.__DM_GLOBE_UTIL const header = window.__DM_GLOBE_UTIL
...@@ -14,10 +17,26 @@ function getToken() { ...@@ -14,10 +17,26 @@ function getToken() {
return header ? header.authorization : tokenIns.get() return header ? header.authorization : tokenIns.get()
} }
switch (process.env.NODE_ENV) { switch (process.env.NODE_ENV) {
case 'production': case 'production':
BASE_URL = 'https://www.maicedata.com/collector/data/' // 生产环境 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 = { MAP_CONFIG = {
jsApiUrl: 'http://10.108.3.48/api418/arcgis_js_api/library/4.18/init.js', jsApiUrl: 'http://10.108.3.48/api418/arcgis_js_api/library/4.18/init.js',
cssUrl: cssUrl:
...@@ -43,6 +62,9 @@ switch (process.env.NODE_ENV) { ...@@ -43,6 +62,9 @@ switch (process.env.NODE_ENV) {
export default { export default {
TOKEN, TOKEN,
mdtUser,
imperToken,
imperMdtUser,
BASE_URL, BASE_URL,
MAP_CONFIG, MAP_CONFIG,
ORGANIZATION: '733d0ac0-f67e-4bde-8872-3ca00983f18c', ORGANIZATION: '733d0ac0-f67e-4bde-8872-3ca00983f18c',
......
...@@ -10,7 +10,10 @@ const Axios = axios.create({ ...@@ -10,7 +10,10 @@ const Axios = axios.create({
Axios.interceptors.request.use( Axios.interceptors.request.use(
(config) => { (config) => {
// 添加token // 添加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 return config
}, },
(error) => { (error) => {
...@@ -96,7 +99,7 @@ const ajax = ({ ...@@ -96,7 +99,7 @@ const ajax = ({
'Content-Type': contentType, 'Content-Type': contentType,
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Headers': 'Access-Control-Allow-Headers':
'Authorization,Origin, X-Requested-With, Content-Type, Accept', 'Authorization,Origin, X-Requested-With, Content-Type, Accept',
'Access-Control-Allow-Methods': '*', 'Access-Control-Allow-Methods': '*',
__show_loading: showLoading, __show_loading: showLoading,
...headers, ...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