feat:登录的功能完成

This commit is contained in:
李伊帆
2026-09-21 09:36:38 +08:00
parent ce93816fd5
commit 24d001e0f5
20 changed files with 299 additions and 40 deletions

19
src/utils/auth-guard.ts Normal file
View File

@@ -0,0 +1,19 @@
import { getAccessToken } from '@/utils/auth-storage'
export const LOGIN_PAGE = '/pages/Login/user-login/index'
export function isLoggedIn() {
return Boolean(getAccessToken())
}
/** 未登录时跳转登录页,返回是否已登录 */
export function ensureLoggedIn(showToast = true) {
if (isLoggedIn())
return true
if (showToast)
uni.showToast({ title: '请先登录', icon: 'none' })
uni.reLaunch({ url: LOGIN_PAGE })
return false
}