Authored by wangtao

集成平台

... ... @@ -82,7 +82,7 @@
# password: 123456
spring:
application:
name: aj-report
name: mj-aj-report
cloud:
bootstrap:
enabled: true
... ... @@ -90,9 +90,9 @@ spring:
config:
server-addr: http://192.168.0.40:8848
file-extension: yaml
namespace: monitor-dev-mj
namespace: monitor-dev-ww
discovery:
namespace: monitor-dev-mj
namespace: monitor-dev-ww
server-addr: http://192.168.0.40:8848
main:
allow-bean-definition-overriding: true
... ...
... ... @@ -4,6 +4,6 @@ const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
BASE_API: '"http://192.168.0.75:8089"',
MONITOR_GATEWAY: '"http://192.168.0.75:8080"'
BASE_API: '"/aj-web"',
MONITOR_GATEWAY: '"/mj"'
})
... ...
... ... @@ -57,7 +57,7 @@ module.exports = {
* then assetsPublicPath should be set to "/bar/".
* In most cases please use '/' !!!
*/
assetsPublicPath: '/',
assetsPublicPath: '/aj-web/',
/**
* Source Maps
... ...
'use strict'
module.exports = {
NODE_ENV: '"production"',
BASE_API: '""',
MONITOR_GATEWAY: '""'
BASE_API: '"/aj-web"',
MONITOR_GATEWAY: '"/mj"'
}
... ...
import axios from 'axios'
import { Message, MessageBox } from 'element-ui'
import store from '../store'
import { getToken } from '@/utils/auth'
import {Message, MessageBox} from 'element-ui'
import {getToken} from '@/utils/auth'
const getParams = () => {
let map = {};
let query = window.location.search.substring(1);
if (query == '') {
query = document.location.href
let args = query.split('?');
let arr = [];
if (args && args.length > 1) {
arr = args[1].split('&')
}
for (let i = 0; i < arr.length; i++) {
let pair = arr[i].split("=");
map[pair[0]] = pair[1];
}
return map;
}
let vars = query.split("&");
for (let i = 0; i < vars.length; i++) {
let pair = vars[i].split("=");
map[pair[0]] = pair[1];
}
return map;
}
// 创建axios实例
const service = axios.create({
baseURL: process.env.NODE_ENV == 'development' ? process.env.BASE_API : '/',// api 的 base_url
baseURL: process.env.BASE_API,// api 的 base_url
timeout: 120000 // 请求超时时间
})
... ... @@ -12,6 +37,34 @@ const service = axios.create({
service.interceptors.request.use(
config => {
config.headers['Authorization'] = (getToken() == null || getToken() == undefined) ? '' : getToken()
// 平台token
let mjToken = getParams()['AuthVal'];
if (mjToken) {
let hash = btoa(window.location.hash);
let url = config.url;
let userId = getParams()['userId'];
let userName = getParams()['nickName'];
switch (config.method) {
case 'post':
config.headers.AuthorizationMj = "BearerMj " + mjToken + ""
config.headers.MjUserId = userId;
config.headers.MjUserName = userName;
config.headers.MjHash = hash;
break;
default:
var access_token = `accessToken=${mjToken}&MjUserId=${userId}&MjUserName=${userName}&MjHash=${hash}`;
if (url.indexOf('?') === -1) {
url += '?' + access_token;
} else {
url += '&' + access_token;
}
config.url = url;
}
}
return config
},
error => {
... ... @@ -42,8 +95,7 @@ service.interceptors.response.use(
localStorage.clear()
window.location.href = "/";
})
}
else if (res.code !== '200') {
} else if (res.code !== '200') {
Message({
message: res.message,
type: 'error',
... ... @@ -56,9 +108,9 @@ service.interceptors.response.use(
},
error => {
//start lsq 超时用console输出信息 2022-03-14
if(error.code == 'ECONNABORTED' && error.message.indexOf('timeout')!=-1){
console.log(error.message)
}else{
if (error.code == 'ECONNABORTED' && error.message.indexOf('timeout') != -1) {
console.log(error.message)
} else {
Message({
message: error.message,
type: 'error',
... ...