diff --git a/src/http/alova.ts b/src/http/alova.ts index 52aaf61..696c795 100644 --- a/src/http/alova.ts +++ b/src/http/alova.ts @@ -4,6 +4,7 @@ import AdapterUniapp from '@alova/adapter-uniapp' import { createAlova } from 'alova' import { createServerTokenAuthentication } from 'alova/client' import VueHook from 'alova/vue' +import { LOGIN_PAGE } from '@/router/config' import { ContentTypeEnum, ResultEnum, ShowMessage } from './tools/enum' // 配置动态Tag @@ -29,7 +30,7 @@ const { onAuthRequired, onResponseRefreshToken } = createServerTokenAuthenticati } catch (error) { // 切换到登录页 - await uni.reLaunch({ url: '/pages/login/login' }) + await uni.reLaunch({ url: LOGIN_PAGE }) throw error } }, diff --git a/src/http/http.ts b/src/http/http.ts index e8b47ae..1d3ce2e 100644 --- a/src/http/http.ts +++ b/src/http/http.ts @@ -1,6 +1,7 @@ import type { IDoubleTokenRes } from '@/api/types/login' import type { CustomRequestOptions } from '@/http/types' import { nextTick } from 'vue' +import { LOGIN_PAGE } from '@/router/config' import { useTokenStore } from '@/store/token' import { isDoubleTokenMode } from '@/utils' @@ -30,7 +31,7 @@ export function http(options: CustomRequestOptions) { if (!isDoubleTokenMode) { // 未启用双token策略,清理用户信息,跳转到登录页 tokenStore.logout() - uni.navigateTo({ url: '/pages/login/login' }) + uni.navigateTo({ url: LOGIN_PAGE }) return reject(res) } /* -------- 无感刷新 token ----------- */ @@ -76,7 +77,7 @@ export function http(options: CustomRequestOptions) { await tokenStore.logout() // 跳转到登录页 setTimeout(() => { - uni.navigateTo({ url: '/pages/login/login' }) + uni.navigateTo({ url: LOGIN_PAGE }) }, 2000) } finally { diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 1be810f..c69423c 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -11,6 +11,7 @@ diff --git a/src/pages/me/me.vue b/src/pages/me/me.vue index d926110..8dbb5b6 100644 --- a/src/pages/me/me.vue +++ b/src/pages/me/me.vue @@ -12,6 +12,7 @@