feat(权限): 实现用户权限管理功能

- 更新 UserResource 添加角色和权限管理
  - 添加角色选择字段(多选)
  - 添加直接权限配置(按模块分组的复选框列表)
  - 在用户列表中显示角色和权限数量
  - 添加角色筛选器
  - 防止删除超级管理员
- 创建 ViewUser 页面显示用户详细权限信息
  - 显示所有权限(角色权限 + 直接权限)
  - 按模块分组展示权限
  - 区分显示直接权限
- 创建 UserPolicy 控制用户管理权限
  - 基于 user.* 权限控制访问
  - 保护超级管理员不被编辑和删除
  - 防止用户删除自己
- 在 AppServiceProvider 中注册 UserPolicy
This commit is contained in:
2026-03-11 10:03:21 +08:00
parent a17fe167b0
commit dfe0ff42bc
4 changed files with 388 additions and 29 deletions

View File

@@ -36,5 +36,6 @@ class AppServiceProvider extends ServiceProvider
Gate::policy(\App\Models\Terminal::class, \App\Policies\TerminalPolicy::class);
Gate::policy(SopTemplate::class, SopTemplatePolicy::class);
Gate::policy(\Spatie\Permission\Models\Role::class, \App\Policies\RolePolicy::class);
Gate::policy(\App\Models\User::class, \App\Policies\UserPolicy::class);
}
}