|
|
@@ -7,6 +7,7 @@ import { tansParams, blobValidate } from "@/utils/common";
|
|
|
import cache from '@/plugins/cache'
|
|
|
import { saveAs } from 'file-saver'
|
|
|
import { message } from '@/utils/resetMessage'
|
|
|
+import {hashWithSalt} from '@/utils/SHA256'
|
|
|
let downloadLoadingInstance;
|
|
|
// 是否显示重新登录
|
|
|
export let isRelogin = { show: false };
|
|
|
@@ -32,6 +33,10 @@ service.interceptors.request.use(config => {
|
|
|
if (getToken() && !isToken) {
|
|
|
config.headers['userToken'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
|
|
|
}
|
|
|
+ // 防重时间戳
|
|
|
+ const timestamp = Date.now();
|
|
|
+ config.headers['timestamp'] = timestamp;
|
|
|
+ config.headers['sign'] = hashWithSalt(timestamp+getToken())
|
|
|
// get请求映射params参数
|
|
|
if (config.method === 'get' && config.params) {
|
|
|
let url = config.url + '?' + tansParams(config.params);
|
|
|
@@ -101,7 +106,10 @@ service.interceptors.response.use(res => {
|
|
|
});
|
|
|
}
|
|
|
return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
|
|
|
- }else if(code === 406) {
|
|
|
+ } else if (code ===415) {
|
|
|
+
|
|
|
+
|
|
|
+ } else if(code === 406) {
|
|
|
MessageBox.confirm('你的账户已在别的设备登录,请重新登录', '系统提示', { confirmButtonText: '重新登录', type: 'warning', showCancelButton: false, }).then(() => {
|
|
|
store.dispatch('LogOut').then(() => {
|
|
|
if (process.env.NODE_ENV == 'production') {
|
|
|
@@ -113,7 +121,6 @@ service.interceptors.response.use(res => {
|
|
|
}).catch(() => {
|
|
|
|
|
|
});
|
|
|
- return Promise.reject('error')
|
|
|
} else if (code === 500) {
|
|
|
Message({ message: msg, type: 'error' })
|
|
|
return Promise.reject(new Error(msg))
|