fix(health): 修复 5 角色深度测试发现的 8 个问题
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled

P0 修复:
- 告警状态机新增 active 合法状态 + 转换规则 (active→acknowledged/dismissed)
- 前端路由守卫改为默认拒绝,未注册路由返回 403

P1 修复:
- 侧边栏菜单根据用户权限码过滤,非 admin 隐藏无权限菜单项
- Critical-alerts handler 增加详细错误日志 + div_ceil 安全防护
- 仪表盘统计 API 调用使用 silent 模式避免 500 触发全局 toast

P2 修复:
- 随访类型映射新增 visit → 上门 (前后端同步)
- 随访 fallback 选项新增 visit 类型

排除的假 BUG (代码已正确):
- 患者性别/血型: MCP fill() 不兼容 Select 组件,正常交互正确
- 随访筛选/对话框关闭: 代码逻辑验证正确

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
iven
2026-05-07 08:24:12 +08:00
parent 0acf901893
commit 85a7dacd16
8 changed files with 292 additions and 32 deletions

View File

@@ -394,7 +394,27 @@ export default function MainLayout({ children }: { children: React.ReactNode })
(async () => {
try {
const menus = await getMenusForUser();
if (!cancelled) setDynamicMenus(menus);
if (!cancelled) {
// 根据用户权限过滤菜单:菜单项声明 permission 时,用户必须有对应权限
const perms = useAuthStore.getState().permissions;
const isAdmin = useAuthStore.getState().user?.roles?.some((r: string) => r === 'admin') ?? false;
if (isAdmin) {
setDynamicMenus(menus);
} else {
const filterByPerm = (items: MenuInfo[]): MenuInfo[] =>
items
.map((m) => ({
...m,
children: m.children ? filterByPerm(m.children) : undefined,
}))
.filter((m) => {
if (!m.permission) return true;
return perms.includes(m.permission);
})
.filter((m) => m.menu_type === 'directory' || !m.children || m.children.length > 0 || !m.permission || perms.includes(m.permission));
setDynamicMenus(filterByPerm(menus));
}
}
} catch {
// fallback: 使用空数组,保留插件菜单
}