网络请求如果登录失效则不跳转页面
This commit is contained in:
@ -69,7 +69,9 @@ const alovaInstance = createAlova({
|
|||||||
const token = uni.getStorageSync('token')
|
const token = uni.getStorageSync('token')
|
||||||
if (!token) {
|
if (!token) {
|
||||||
toast.info('请先登录')
|
toast.info('请先登录')
|
||||||
router.navigateTo(import.meta.env.VITE_LOGIN_URL, 500)
|
useUserStore().removeUserInfo()
|
||||||
|
uni.$emit('clearUser')
|
||||||
|
// router.navigateTo(import.meta.env.VITE_LOGIN_URL, 500)
|
||||||
throw new Error('[请求错误]:未登录')
|
throw new Error('[请求错误]:未登录')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +115,7 @@ const alovaInstance = createAlova({
|
|||||||
|
|
||||||
if (config.meta?.toast !== false) {
|
if (config.meta?.toast !== false) {
|
||||||
toast.info(msg)
|
toast.info(msg)
|
||||||
router.navigateTo(import.meta.env.VITE_LOGIN_URL, 1000)
|
// router.navigateTo(import.meta.env.VITE_LOGIN_URL, 1000)
|
||||||
}
|
}
|
||||||
throw new Error(`登录超时[${code}]:${msg}`)
|
throw new Error(`登录超时[${code}]:${msg}`)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user