|
@ -2,6 +2,8 @@ import axios from 'axios'; // 引入axios |
|
|
import { Message } from 'element-ui'; |
|
|
import { Message } from 'element-ui'; |
|
|
import { store } from '@/store/index' |
|
|
import { store } from '@/store/index' |
|
|
import context from '@/main.js' |
|
|
import context from '@/main.js' |
|
|
|
|
|
import router from '@/router/index' |
|
|
|
|
|
|
|
|
const service = axios.create({ |
|
|
const service = axios.create({ |
|
|
baseURL: process.env.VUE_APP_BASE_API, |
|
|
baseURL: process.env.VUE_APP_BASE_API, |
|
|
timeout: 99999 |
|
|
timeout: 99999 |
|
@ -59,10 +61,19 @@ service.interceptors.request.use( |
|
|
service.interceptors.response.use( |
|
|
service.interceptors.response.use( |
|
|
response => { |
|
|
response => { |
|
|
closeLoading() |
|
|
closeLoading() |
|
|
|
|
|
|
|
|
if (response.headers["new-token"]) { |
|
|
if (response.headers["new-token"]) { |
|
|
store.commit('user/setToken', response.headers["new-token"]) |
|
|
store.commit('user/setToken', response.headers["new-token"]) |
|
|
} |
|
|
} |
|
|
if (response.data.code == 0 || response.headers.success === "true") { |
|
|
if (response.data.code == 0 || response.headers.success === "true") { |
|
|
|
|
|
if(response.data.data.needInit){ |
|
|
|
|
|
Message({ |
|
|
|
|
|
type:"info", |
|
|
|
|
|
message:"您是第一次使用,请初始化" |
|
|
|
|
|
}) |
|
|
|
|
|
store.commit("user/NeedInit") |
|
|
|
|
|
router.push({name:"init"}) |
|
|
|
|
|
} |
|
|
return response.data |
|
|
return response.data |
|
|
} else { |
|
|
} else { |
|
|
Message({ |
|
|
Message({ |
|
|