mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-student.git
synced 2025-12-12 12:26:49 +08:00
init
This commit is contained in:
@@ -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 {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user