feat: 审核规则模版+设置页面整合+去掉角色切换demo
后端:
- AuditRule 新增 value 字段, rule_type 扩展 DDL/DML
- MySQL/PG/Redis 预设规则种子接口 POST /audit-rules/seed/{db_type}
- 公告管理 CRUD (announcements)
- 消息推送 CRUD+测试 (notifications: 钉钉/飞书/邮件)
- LDAP 配置 CRUD+测试连接 (ldap-config)
- 164 tests passing (+31 新增)
前端:
- AuditRulesPage 重写: DB类型Tab+DDL/DML分组+参数编辑
- SettingsPage: 系统设置主页(审核规则/公告/推送/LDAP)
- NotificationPage: 钉钉/飞书/SMTP配置
- LdapConfigPage: LDAP设置+测试连接
- AnnouncementPage: 公告Markdown编辑
- 去掉左下角角色切换demo
- 侧边栏合并为: 系统设置(含审核规则+公告+推送+LDAP)
This commit is contained in:
1 parent
d5d19d6be4
commit
bab55d3927
27 files changed
+2881
-591
No files matched your search
@@ -6,7 +6,6 @@ import {
|
||||
} from 'lucide-react';
|
||||
import { menuSections } from '@/lib/mock';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import type { UserRole } from '@/hooks/useAuth';
|
||||
import { useTheme } from '@/hooks/useTheme';
|
||||
|
||||
const iconMap: Record<string, React.ElementType> = {
|
||||
@@ -15,15 +14,8 @@ const iconMap: Record<string, React.ElementType> = {
|
||||
Settings, Clock, Megaphone,
|
||||
};
|
||||
|
||||
const roleBadgeStyle: Record<UserRole, string> = {
|
||||
admin: 'bg-purple-500/15 text-purple-400',
|
||||
dba: 'bg-blue-500/15 text-blue-400',
|
||||
developer: 'bg-green-500/15 text-green-400',
|
||||
guest: 'bg-gray-500/15 text-gray-400',
|
||||
};
|
||||
|
||||
export default function Layout() {
|
||||
const { user, logout, switchRole, visibleMenuItems } = useAuth();
|
||||
const { user, logout, visibleMenuItems } = useAuth();
|
||||
const { theme, toggleTheme } = useTheme();
|
||||
const location = useLocation();
|
||||
const navigate = useNavigate();
|
||||
@@ -34,18 +26,6 @@ export default function Layout() {
|
||||
return item?.label || '仪表盘';
|
||||
};
|
||||
|
||||
const toggleRole = () => {
|
||||
const roles: UserRole[] = ['admin', 'dba', 'developer', 'guest'];
|
||||
const idx = roles.indexOf(user.role);
|
||||
const nextRole = roles[(idx + 1) % roles.length];
|
||||
switchRole(nextRole);
|
||||
// 切换角色后如果当前页面无权限,自动跳仪表盘
|
||||
const allowed = visibleMenuItems.find(m => m.id === currentPath);
|
||||
if (!allowed && currentPath !== 'dashboard') {
|
||||
navigate('/dashboard', { replace: true });
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex h-screen bg-[var(--dg-bg-primary)] text-[var(--dg-text-primary)] overflow-hidden">
|
||||
{/* 侧边栏 */}
|
||||
@@ -102,21 +82,6 @@ export default function Layout() {
|
||||
|
||||
{/* 底部 */}
|
||||
<div className="p-4 border-t border-[var(--dg-border)]">
|
||||
{/* 角色切换演示 */}
|
||||
<div className="mb-3 px-3 py-2 rounded-lg bg-[var(--dg-bg-tertiary)] border border-[var(--dg-border)]">
|
||||
<div className="flex items-center justify-between">
|
||||
<span className="text-xs text-[var(--dg-text-muted)]">当前角色</span>
|
||||
<span className={`text-xs font-medium px-2 py-0.5 rounded ${roleBadgeStyle[user.role]}`}>
|
||||
{user.roleName}
|
||||
</span>
|
||||
</div>
|
||||
<button
|
||||
onClick={toggleRole}
|
||||
className="mt-2 w-full text-center text-[11px] text-[var(--dg-text-muted)] hover:text-blue-400 transition-colors py-1 rounded hover:bg-[var(--dg-bg-hover)]"
|
||||
>
|
||||
[演示] 切换角色
|
||||
</button>
|
||||
</div>
|
||||
<div className="flex items-center gap-3 p-2 rounded-lg hover:bg-[var(--dg-bg-hover)] cursor-pointer transition-colors">
|
||||
<div className="w-9 h-9 rounded-full dg-gradient-br flex items-center justify-center text-white font-semibold text-sm flex-shrink-0">
|
||||
{user.avatar}
|
||||
@@ -145,8 +110,7 @@ export default function Layout() {
|
||||
<span className="text-[var(--dg-text-primary)] font-medium">{getPageTitle()}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
{/* 角色标签 */}
|
||||
<span className={`px-2.5 py-1 rounded-md text-xs font-medium ${roleBadgeStyle[user.role]}`}>
|
||||
<span className="px-2.5 py-1 rounded-md text-xs font-medium bg-blue-500/15 text-blue-400">
|
||||
{user.roleName}
|
||||
</span>
|
||||
<button
|
||||
|
||||
Reference in new issue
Block a user