feat: 消息通知中心 + 账号安全体系 + Bug修复
## 新增功能 ### 消息通知中心 (全新模块) - 新增 MessageController / NotificationService / NotificationRepo - SSR 消息页面 (/messages):左侧边栏 + 右侧卡片列表,noindex 元标签 - 通知能力:列表分页、单条标为已读、一键全部标为已读 - 未读数角标 (1/66/99+):侧边栏 + 导航栏铃铛图标 - 导航栏轮询 /api/messages/unread 每 60 秒刷新未读数 - 审核通过/驳回时自动 fire-and-forget 推送通知 ### 密码修改 - ChangePassword:验证当前密码 → 新密码强度校验(8位+字母+数字) → 哈希更新 - 修改后递增 token_version 强制所有设备退登 ### 账号自助注销 - DeleteAccount:验证密码 → 设置 deleted 状态 → 记录原因 → 吊销 JWT - 注销后登录二次确认:Login 检测 deleted → 返回 confirm_restore - ConfirmRestore 恢复账号,重新签发 token - 注销页文案:"账号将在 7 天后正式注销,期间可随时重新登录恢复" ### IP 审计记录 - 注册时记录 RegIP,登录时记录 LastLoginIP + LastLoginAt - clientIP() 支持 X-Forwarded-For / X-Real-IP 反向代理 ### 安全加固 - Login 防时序攻击:用户不存在时仍执行完整 bcrypt 比对 - FindByEmail 改用 Unscoped() 覆盖软删除用户 - 站长 (owner) 不允许自主注销,避免权限体系死锁 ## Bug 修复 1. 注销按钮不触发:JS IIFE 中 profile 代码 return 阻塞了 account 标签页处理器注册 → 拆分为两层 IIFE,profile 放在内层 2. label 缺少 for 属性导致控制台警告 → 全部补充 for 属性 3. 注销后未自动退登:DeleteAccount 只设状态未吊销 JWT → 末尾加 InvalidateSessions 4. 退登后重定向 500 panic:authenticateToken 中 err||versionMismatch 合并判断 在 err=nil 但版本不匹配时返回 (nil,nil) → 拆为两个独立判断 injectUserContext 增加 claims==nil / 类型断言空安全守卫 5. 注销后登录直接提示"登录成功":FindByEmail 默认 scope 排除软删除记录 → 改用 Unscoped() ## 文件变更 - 新建 17 个文件 (消息/审核/站点设置完整模块) - 修改 25 个文件 (认证/设置/中间件/前端) - 统计:+3229 / -161,42 files changed
This commit is contained in:
@ -130,6 +130,45 @@ header {
|
||||
color: var(--color-secondary) !important;
|
||||
}
|
||||
|
||||
/* ---------- Nav Messages Bell ---------- */
|
||||
.nav-messages {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 6px;
|
||||
border-radius: 50%;
|
||||
transition: background .15s ease;
|
||||
}
|
||||
|
||||
.nav-messages:hover {
|
||||
background: rgba(52, 152, 219, .08);
|
||||
}
|
||||
|
||||
.nav-bell-icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.nav-bell-badge {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: -2px;
|
||||
min-width: 16px;
|
||||
height: 16px;
|
||||
padding: 0 4px;
|
||||
font-size: .65rem;
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
background: var(--color-danger);
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.mobile-menu-btn {
|
||||
display: none;
|
||||
background: none;
|
||||
|
||||
294
templates/MetaLab-2026/static/css/messages.css
Normal file
294
templates/MetaLab-2026/static/css/messages.css
Normal file
@ -0,0 +1,294 @@
|
||||
/* ============================================================
|
||||
MetaLab Messages Styles — 消息中心页样式
|
||||
左侧导航 + 右侧消息卡片列表
|
||||
============================================================ */
|
||||
|
||||
/* ---------- Page Body ---------- */
|
||||
body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* ---------- Layout ---------- */
|
||||
.msg-layout {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
max-width: 1200px;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
padding: 2rem 20px;
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
/* ---------- Left Sidebar ---------- */
|
||||
.msg-sidebar {
|
||||
width: 220px;
|
||||
flex-shrink: 0;
|
||||
background: var(--color-surface);
|
||||
border-radius: var(--radius);
|
||||
box-shadow: var(--shadow);
|
||||
border: 1px solid var(--color-border);
|
||||
padding: 1.25rem 1rem;
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.msg-sidebar-header {
|
||||
margin-bottom: .75rem;
|
||||
}
|
||||
|
||||
.msg-sidebar-header h2 {
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.msg-sidebar-nav {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.msg-sidebar-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: .6rem;
|
||||
padding: .65rem 1rem;
|
||||
border-radius: var(--radius);
|
||||
font-size: .92rem;
|
||||
color: var(--color-secondary);
|
||||
font-weight: 500;
|
||||
transition: all .15s ease;
|
||||
}
|
||||
|
||||
.msg-sidebar-item:hover {
|
||||
background: rgba(52, 152, 219, .06);
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
.msg-sidebar-item.active {
|
||||
background: rgba(52, 152, 219, .1);
|
||||
color: var(--color-accent);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.msg-sidebar-icon {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.msg-sidebar-count {
|
||||
margin-left: auto;
|
||||
min-width: 20px;
|
||||
height: 20px;
|
||||
padding: 0 5px;
|
||||
font-size: .7rem;
|
||||
font-weight: 700;
|
||||
color: #fff;
|
||||
background: var(--color-accent);
|
||||
border-radius: 10px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
/* ---------- Right Content Area ---------- */
|
||||
.msg-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* ---------- Toolbar ---------- */
|
||||
.msg-toolbar {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-bottom: .75rem;
|
||||
}
|
||||
|
||||
.msg-mark-all-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: .35rem .9rem;
|
||||
font-size: .82rem;
|
||||
font-weight: 500;
|
||||
font-family: inherit;
|
||||
color: var(--color-accent);
|
||||
background: transparent;
|
||||
border: 1px solid var(--color-accent);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: all .15s ease;
|
||||
}
|
||||
|
||||
.msg-mark-all-btn:hover {
|
||||
background: var(--color-accent);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.msg-mark-all-btn:disabled {
|
||||
opacity: .5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
/* ---------- Right Content Area ---------- */
|
||||
.msg-main {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
/* ---------- Message Card ---------- */
|
||||
.msg-card {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: .9rem;
|
||||
padding: 1rem 1.25rem;
|
||||
background: var(--color-surface);
|
||||
border-radius: var(--radius);
|
||||
border: 1px solid var(--color-border);
|
||||
margin-bottom: .6rem;
|
||||
transition: background .15s ease, border-color .15s ease;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.msg-card:hover {
|
||||
border-color: var(--color-accent);
|
||||
background: #f8fafe;
|
||||
}
|
||||
|
||||
.msg-card.unread {
|
||||
background: #f0f6fe;
|
||||
border-left: 3px solid var(--color-accent);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.msg-icon {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(52, 152, 219, .1);
|
||||
border-radius: 8px;
|
||||
color: var(--color-accent);
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.msg-body {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.msg-title {
|
||||
font-size: .92rem;
|
||||
font-weight: 600;
|
||||
color: var(--color-primary);
|
||||
margin-bottom: .25rem;
|
||||
}
|
||||
|
||||
.msg-content {
|
||||
font-size: .85rem;
|
||||
color: var(--color-secondary);
|
||||
line-height: 1.55;
|
||||
margin-bottom: .4rem;
|
||||
}
|
||||
|
||||
.msg-meta {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
font-size: .78rem;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.msg-type {
|
||||
color: rgba(52, 152, 219, .7);
|
||||
}
|
||||
|
||||
.msg-badge {
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 50%;
|
||||
background: var(--color-accent);
|
||||
flex-shrink: 0;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
/* ---------- Pagination ---------- */
|
||||
.msg-pagination {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: .75rem;
|
||||
padding: 1.5rem 0;
|
||||
}
|
||||
|
||||
.msg-page-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: .4rem 1rem;
|
||||
font-size: .85rem;
|
||||
color: var(--color-accent);
|
||||
border: 1px solid var(--color-accent);
|
||||
border-radius: 6px;
|
||||
font-weight: 500;
|
||||
transition: all .15s ease;
|
||||
}
|
||||
|
||||
.msg-page-btn:hover {
|
||||
background: var(--color-accent);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.msg-page-btn.disabled {
|
||||
color: #ccc;
|
||||
border-color: #ddd;
|
||||
cursor: not-allowed;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.msg-page-info {
|
||||
font-size: .85rem;
|
||||
color: var(--color-text-light);
|
||||
}
|
||||
|
||||
/* ---------- Empty State ---------- */
|
||||
.msg-empty {
|
||||
text-align: center;
|
||||
padding: 4rem 2rem;
|
||||
color: #bbb;
|
||||
}
|
||||
|
||||
.msg-empty-icon {
|
||||
margin-bottom: 1rem;
|
||||
color: #ddd;
|
||||
}
|
||||
|
||||
.msg-empty p {
|
||||
font-size: .92rem;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
/* ---------- Responsive ---------- */
|
||||
@media (max-width: 768px) {
|
||||
.msg-layout {
|
||||
flex-direction: column;
|
||||
padding: 1rem 16px;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.msg-sidebar {
|
||||
width: 100%;
|
||||
align-self: auto;
|
||||
}
|
||||
|
||||
.msg-sidebar-nav {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.msg-card {
|
||||
padding: .85rem 1rem;
|
||||
}
|
||||
}
|
||||
@ -131,6 +131,18 @@ body {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
/* 审核状态提示 */
|
||||
.settings-audit-notice {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 0.75rem 2rem;
|
||||
background: #fff8e1;
|
||||
border-bottom: 1px solid #ffe082;
|
||||
color: #e65100;
|
||||
font-size: .85rem;
|
||||
}
|
||||
|
||||
.settings-card-body {
|
||||
padding: 1.25rem 2rem 1.5rem;
|
||||
}
|
||||
@ -495,3 +507,64 @@ body {
|
||||
padding: 1rem 1.25rem 1.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- Form Group (Password / Delete) ---------- */
|
||||
.settings-card + .settings-card {
|
||||
margin-top: 1.5rem;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.form-group:last-of-type {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
display: block;
|
||||
font-size: .85rem;
|
||||
color: var(--color-text-light);
|
||||
font-weight: 500;
|
||||
margin-bottom: .35rem;
|
||||
}
|
||||
|
||||
.form-hint {
|
||||
font-size: .8rem;
|
||||
color: #bbb;
|
||||
margin-left: .75rem;
|
||||
}
|
||||
|
||||
/* ---------- Danger Card (Delete Account) ---------- */
|
||||
.settings-card-danger {
|
||||
border: 1px solid #ffcdd2;
|
||||
}
|
||||
|
||||
.settings-card-danger .settings-card-header h2 {
|
||||
color: var(--color-danger);
|
||||
}
|
||||
|
||||
.settings-danger-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: .55rem 1.5rem;
|
||||
font-size: .88rem;
|
||||
font-weight: 600;
|
||||
font-family: inherit;
|
||||
color: #fff;
|
||||
background: var(--color-danger);
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: background .15s ease, opacity .15s ease;
|
||||
}
|
||||
|
||||
.settings-danger-btn:hover {
|
||||
background: #c0392b;
|
||||
}
|
||||
|
||||
.settings-danger-btn:disabled {
|
||||
opacity: .6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user