Files
nl-blogs/blog-wot-uniapp/src/subPackages/admin/composables/useAdminGuard.ts
李琦 4e245f789b 1. 小程序端
2. 视频优化2
2026-07-30 14:14:28 +08:00

21 lines
542 B
TypeScript

/**
* 后台页鉴权守卫:未登录或无员工角色则回我的页。
*/
import { useAuth } from '@/composables/useAuth'
import { useAppMode } from '@/composables/useAppMode'
export function useAdminGuard() {
const { isAuthenticated } = useAuth()
const { canEnterAdmin } = useAppMode()
function guardAdmin(): boolean {
if (!isAuthenticated() || !canEnterAdmin.value) {
uni.reLaunch({ url: '/pages/mine/index' })
return false
}
return true
}
return { guardAdmin, isAuthenticated, canEnterAdmin }
}