refactor: permission

This commit is contained in:
tao.chen
2026-08-25 21:21:28 +08:00
parent e186e5e541
commit 38e763d08e
11 changed files with 171 additions and 1037 deletions
+6
View File
@@ -20,6 +20,7 @@ export type AuthUser = {
status: string;
role_code: string | null;
is_system_admin: boolean;
permissions: string[];
};
export type AuthWorkspace = {
@@ -312,3 +313,8 @@ export function useApi(): WorkspaceBoundApi {
deleteWorkspaceMember: (workspaceId, userId) => rawApi.deleteWorkspaceMember(workspaceId, userId),
}), [workspaceId]);
}
export function usePermission(code: string): boolean {
const { user } = useAuth();
return user?.permissions.includes(code) ?? false;
}