This commit is contained in:
yuping
2022-12-15 18:08:38 +08:00
parent 92ee6c42c2
commit 7f62593c0b

View File

@@ -85,23 +85,25 @@ export async function request(_url, params) {
url,
method,
headers: {
'X-Token': localStorage.getItem('token'),
'token': getCookie('token'),
...method !== 'get' ? {'Content-Type': 'application/json'} : {}
},
baseURL: import.meta.env.VITE_BASE_API,
...method !== 'get' ? {data: JSON.stringify(body)} : {}
}).then(resp => resp.data).then(response => {
if (response.code !== 200 && response.code !== 0) {
console.log(1111111111)
console.log(response.code)
if (import.meta.env.DEV && response.code === 1000) {
router.push({path: '/login'})
} else {
// response.showMsg && notification.open({
// message: response.showMsg,
// duration: 2,
// });
if (response.code === 1000) {
import.meta.env.DEV ? router.push({path: '/login'}) : window.open(import.meta.env.VITE_BASE_LOGIN_URL)
}
// if (import.meta.env.DEV && response.code === 1000) {
// router.push({path: '/login'})
// } else {
// window.open()
// response.showMsg && notification.open({
// message: response.showMsg,
// duration: 2,
// });
// }
throw new Error('接口异常')
}
return response