feat(web): 添加 usePermission hook + AuthButton/AuthGuard 声明式权限组件
This commit is contained in:
13
apps/web/src/components/AuthButton.tsx
Normal file
13
apps/web/src/components/AuthButton.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { usePermission } from '../hooks/usePermission';
|
||||
|
||||
interface AuthButtonProps {
|
||||
code: string;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export function AuthButton({ code, children }: AuthButtonProps) {
|
||||
const { hasPermission } = usePermission(code);
|
||||
if (!hasPermission) return null;
|
||||
return <>{children}</>;
|
||||
}
|
||||
Reference in New Issue
Block a user