chore(repo): add lint config and normalize scripts

This commit is contained in:
ShukeBta
2026-06-07 11:54:45 +08:00
parent d94330b30f
commit cf2f77f35d
6 changed files with 1253 additions and 20 deletions
+9 -8
View File
@@ -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)
}