feat(router): 完善登录拦截逻辑和路由处理
增加登录状态检查和重定向逻辑 添加 HOME_PAGE 常量导出 优化 tabbar 路径匹配逻辑 导出 setTokenInfo 方法供外部使用 启用路由拦截器日志
This commit is contained in:
@@ -24,7 +24,7 @@ console.log({ isApp, isAppAndroid, isAppHarmony, isAppIOS, isAppPlus, isH5, isMp
|
||||
|
||||
function toLogin() {
|
||||
uni.navigateTo({
|
||||
url: `${LOGIN_PAGE}?redirect=${encodeURIComponent('/pages/about/about')}`,
|
||||
url: `${LOGIN_PAGE}?redirect=${encodeURIComponent('/pages/about/about?a=1&b=2')}`,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import { useTokenStore } from '@/store/token'
|
||||
import { useUserStore } from '@/store/user'
|
||||
import { tabbarList } from '@/tabbar/config'
|
||||
import { isPageTabbar } from '@/tabbar/store'
|
||||
@@ -24,6 +25,7 @@ onLoad((options) => {
|
||||
})
|
||||
|
||||
const userStore = useUserStore()
|
||||
const tokenStore = useTokenStore()
|
||||
function doLogin() {
|
||||
userStore.setUserInfo({
|
||||
userId: 123456,
|
||||
@@ -31,6 +33,11 @@ function doLogin() {
|
||||
nickname: '菲鸽',
|
||||
avatar: 'https://oss.laf.run/ukw0y1-site/avatar.jpg',
|
||||
})
|
||||
// 这里用单token来模拟
|
||||
tokenStore.setTokenInfo({
|
||||
token: '123456',
|
||||
expiresIn: 60 * 60 * 24 * 7,
|
||||
})
|
||||
console.log(redirectUrl.value)
|
||||
let path = redirectUrl.value
|
||||
if (!path.startsWith('/')) {
|
||||
|
||||
Reference in New Issue
Block a user