mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-01 03:56:38 +08:00
chore(repo): add lint config and normalize scripts
This commit is contained in:
@@ -32,9 +32,17 @@ export function usePermission(
|
||||
const tier = useAuthStore((state) => state.tier)
|
||||
const role = useAuthStore((state) => state.user?.role)
|
||||
const isAuthenticated = useAuthStore((state) => state.token !== null)
|
||||
const hasSuperAccess = isSuper || tier === 'plus' || role === 'admin'
|
||||
|
||||
// 权限未加载时自动获取
|
||||
useEffect(() => {
|
||||
if (!hasSuperAccess && isAuthenticated && autoFetch && Object.keys(permissions).length === 0 && !isLoading) {
|
||||
fetchPermissions()
|
||||
}
|
||||
}, [autoFetch, fetchPermissions, hasSuperAccess, isAuthenticated, isLoading, permissions])
|
||||
|
||||
// 超级用户有所有权限
|
||||
if (isSuper || tier === 'plus' || role === 'admin') {
|
||||
if (hasSuperAccess) {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -43,13 +51,6 @@ export function usePermission(
|
||||
return false
|
||||
}
|
||||
|
||||
// 权限未加载时自动获取
|
||||
useEffect(() => {
|
||||
if (autoFetch && Object.keys(permissions).length === 0 && !isLoading) {
|
||||
fetchPermissions()
|
||||
}
|
||||
}, [autoFetch, permissions, isLoading, fetchPermissions])
|
||||
|
||||
return hasPermission(key)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user