|
|
@ -3,7 +3,6 @@ import Util from "@/libs/util"; |
|
|
|
import router from "@/router/index"; |
|
|
|
import router from "@/router/index"; |
|
|
|
import Setting from "@/setting"; |
|
|
|
import Setting from "@/setting"; |
|
|
|
import store from '@/store' |
|
|
|
import store from '@/store' |
|
|
|
|
|
|
|
|
|
|
|
const { inIframe } = Setting |
|
|
|
const { inIframe } = Setting |
|
|
|
const service = axios.create({ |
|
|
|
const service = axios.create({ |
|
|
|
baseURL: Setting.apiBaseURL, |
|
|
|
baseURL: Setting.apiBaseURL, |
|
|
@ -14,7 +13,7 @@ service.defaults.headers.post["Content-Type"] = "application/json;charset=UTF-8" |
|
|
|
|
|
|
|
|
|
|
|
// 请求拦截器
|
|
|
|
// 请求拦截器
|
|
|
|
service.interceptors.request.use(config => { |
|
|
|
service.interceptors.request.use(config => { |
|
|
|
let token = localStorage.getItem(inIframe ? 'review_token' : 'expert_token') |
|
|
|
let token = localStorage.getItem(inIframe || router.app._route.path === '/theoryReview' ? 'review_token' : 'expert_token') |
|
|
|
if (token) config.headers.token = token |
|
|
|
if (token) config.headers.token = token |
|
|
|
return config |
|
|
|
return config |
|
|
|
}, err => { |
|
|
|
}, err => { |
|
|
@ -38,12 +37,12 @@ service.interceptors.response.use( |
|
|
|
// 账号互踢
|
|
|
|
// 账号互踢
|
|
|
|
if (!logouted) { |
|
|
|
if (!logouted) { |
|
|
|
Util.local.remove(Setting.storeKey) |
|
|
|
Util.local.remove(Setting.storeKey) |
|
|
|
localStorage.removeItem(inIframe ? 'review_token' : 'expert_token') |
|
|
|
localStorage.removeItem(inIframe || router.app._route.path === '/theoryReview' ? 'review_token' : 'expert_token') |
|
|
|
window.top.exitSystem && window.top.exitSystem() |
|
|
|
window.top.exitSystem && window.top.exitSystem() |
|
|
|
Util.errorMsg(res.msg.includes('顶') ? '您的账号已在其他设备登录,您已被迫下线!' : '登录过期,请重新登录!') |
|
|
|
Util.errorMsg(res.msg.includes('顶') ? '您的账号已在其他设备登录,您已被迫下线!' : '登录过期,请重新登录!') |
|
|
|
localStorage.removeItem('reviewPath') |
|
|
|
localStorage.removeItem('reviewPath') |
|
|
|
setTimeout(() => { |
|
|
|
setTimeout(() => { |
|
|
|
inIframe || store.dispatch('user/logout') |
|
|
|
if (!inIframe && !router.app._route.path === '/theoryReview') store.dispatch('user/logout') |
|
|
|
logouted = 0 |
|
|
|
logouted = 0 |
|
|
|
}, 1500) |
|
|
|
}, 1500) |
|
|
|
logouted = 1 |
|
|
|
logouted = 1 |
|
|
|