调试接口
This commit is contained in:
@ -49,7 +49,7 @@ const alovaInstance = createAlova({
|
||||
statesHook: VueHook,
|
||||
|
||||
beforeRequest: onAuthRequired((method) => {
|
||||
console.log("🚀 ~ method:", method)
|
||||
// console.log("🚀 ~ method:", method)
|
||||
// 设置默认 Content-Type
|
||||
method.config.headers = {
|
||||
ContentType: ContentTypeEnum.JSON,
|
||||
@ -69,9 +69,10 @@ const alovaInstance = createAlova({
|
||||
// method.config.headers.token = token;
|
||||
|
||||
const token = uni.getStorageSync('token')
|
||||
console.log("🚀 ~ token=auth:", token)
|
||||
if (!token) {
|
||||
toast.info('请先登录')
|
||||
router.switchTab('/pages/my/my', 500)
|
||||
router.navigateTo(import.meta.env.VITE_LOGIN_URL, 500)
|
||||
throw new Error('[请求错误]:未登录')
|
||||
}
|
||||
|
||||
@ -115,7 +116,7 @@ const alovaInstance = createAlova({
|
||||
|
||||
if (config.meta?.toast !== false) {
|
||||
toast.info(msg)
|
||||
router.switchTab('/pages/my/my', 1000)
|
||||
router.navigateTo(import.meta.env.VITE_LOGIN_URL, 1000)
|
||||
}
|
||||
throw new Error(`登录超时[${code}]:${msg}`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user