feat(web): 添加 usePermission hook + AuthButton/AuthGuard 声明式权限组件
This commit is contained in:
6
apps/web/src/hooks/usePermission.ts
Normal file
6
apps/web/src/hooks/usePermission.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { useAuthStore } from '../stores/auth';
|
||||
|
||||
export function usePermission(code: string): { hasPermission: boolean } {
|
||||
const permissions = useAuthStore((s) => s.permissions);
|
||||
return { hasPermission: permissions.includes(code) };
|
||||
}
|
||||
Reference in New Issue
Block a user