网络请求如果登录失效则不跳转页面

This commit is contained in:
wangxiaowei
2025-12-26 14:44:23 +08:00
parent dc635de2e9
commit 5c95b26665

View File

@ -69,7 +69,9 @@ const alovaInstance = createAlova({
const token = uni.getStorageSync('token')
if (!token) {
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('[请求错误]:未登录')
}
@ -113,7 +115,7 @@ const alovaInstance = createAlova({
if (config.meta?.toast !== false) {
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}`)
}