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, url,
method, method,
headers: { headers: {
'X-Token': localStorage.getItem('token'), 'token': getCookie('token'),
...method !== 'get' ? {'Content-Type': 'application/json'} : {} ...method !== 'get' ? {'Content-Type': 'application/json'} : {}
}, },
baseURL: import.meta.env.VITE_BASE_API, baseURL: import.meta.env.VITE_BASE_API,
...method !== 'get' ? {data: JSON.stringify(body)} : {} ...method !== 'get' ? {data: JSON.stringify(body)} : {}
}).then(resp => resp.data).then(response => { }).then(resp => resp.data).then(response => {
if (response.code !== 200 && response.code !== 0) { if (response.code !== 200 && response.code !== 0) {
console.log(1111111111) if (response.code === 1000) {
console.log(response.code) 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'}) // if (import.meta.env.DEV && response.code === 1000) {
} else { // router.push({path: '/login'})
// } else {
// window.open()
// response.showMsg && notification.open({ // response.showMsg && notification.open({
// message: response.showMsg, // message: response.showMsg,
// duration: 2, // duration: 2,
// }); // });
} // }
throw new Error('接口异常') throw new Error('接口异常')
} }
return response return response