基于角色的权限控制

1、用户角色枚举、权限枚举、结果记录和密码存储模型
IPermissionService 接口及包含认证、权限检查、密码管理和登出功能的 PermissionService 单例
2、支持层级化角色-权限映射的权限矩阵(SuperAdmin ⊇ Admin ⊇ User)
密码持久化至 passwords.json 文件,并提供工厂默认值回退机制
3、UI 层
LoginDialog — 启动时弹出模态登录对话框,支持密码掩码输入、错误提示以及取消退出功能
RibbonStatusAreaView — 在Ribbon右侧区域始终显示角色标签和“切换用户”按钮
权限感知的CncEditorViewModel — 用户角色无法使用CNC编辑控件
权限感知的CncInspectionModulePipelineViewModel — 用户角色无法进行流程编辑
设置导航可见性 — Admin/User角色隐藏Factory_Settings,User角色隐藏Report_Settings
PasswordManagementView — 仅SuperAdmin可访问的修改角色密码对话框
PermissionTooltipHelper — 附加属性,在禁用控件上显示“当前角色无权访问此功能”提示
This commit is contained in:
zhengxuan.zhang
2026-06-01 17:15:59 +08:00
parent acbed526f6
commit 741874e85d
41 changed files with 1953 additions and 43 deletions
@@ -0,0 +1,22 @@
using System;
namespace XplorePlane.Models
{
/// <summary>
/// 角色变更事件参数(供不使用 EventAggregator 的组件直接订阅)。
/// </summary>
public class RoleChangedEventArgs : EventArgs
{
/// <summary>变更前角色(首次登录时为 null)。</summary>
public UserRole? OldRole { get; }
/// <summary>变更后角色。</summary>
public UserRole NewRole { get; }
public RoleChangedEventArgs(UserRole? oldRole, UserRole newRole)
{
OldRole = oldRole;
NewRole = newRole;
}
}
}