fix(admin): 添加管理操作错误处理及更新模板样式
- 管理后台帖子与用户审核操作中添加失败错误重定向处理 - 管理后台帖子、用户、评论删除操作中添加错误检查及提示 - 用户角色更新操作失败时添加错误重定向 - 用户封禁通知失败时添加相应错误提示 - 登录登出时session保存加入错误处理 - 讨论区上传目录创建失败时显示错误提示 - 移除admin_dashboard.html多余样式及修正侧边栏当前页高亮 - admin_posts.html和admin_users.html添加状态样式动态使用的隐藏span元素 - admin_users.html为角色选择添加label以提升无障碍性 - 升级项目依赖版本,包含gin、gorm、validator等核心库版本更新
This commit is contained in:
@@ -40,18 +40,6 @@
|
||||
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
|
||||
.stat-number { font-size: 2.5rem; font-weight: 700; color: var(--primary); line-height: 1.2; margin-bottom: 4px; }
|
||||
.stat-label { color: var(--text-hint); font-size: 0.95rem; }
|
||||
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
|
||||
table { width: 100%; border-collapse: collapse; }
|
||||
th { background: var(--surface-light); padding: 12px 15px; text-align: left; font-weight: 600; color: var(--primary); border-bottom: 1px solid var(--border); }
|
||||
td { padding: 12px 15px; border-bottom: 1px solid var(--border); color: var(--text-soft); }
|
||||
tr:last-child td { border-bottom: none; }
|
||||
tr:hover { background: var(--surface-light); }
|
||||
.actions a { margin-right: 10px; color: var(--text-hint); text-decoration: none; }
|
||||
.actions a:hover { color: var(--primary); }
|
||||
.actions .delete { color: #ff6b6b; }
|
||||
.actions .delete:hover { color: #ff4d4d; }
|
||||
.actions .approve { color: var(--primary); }
|
||||
.actions .approve:hover { color: var(--primary-light); }
|
||||
.message { background: var(--surface-light); border-left: 4px solid var(--primary); padding: 12px 20px; margin-bottom: 20px; border-radius: 8px; color: var(--text); }
|
||||
@media (max-width: 768px) { .admin-wrapper { flex-direction: column; } .sidebar { width: 100%; height: auto; position: static; } }
|
||||
</style>
|
||||
@@ -64,7 +52,7 @@
|
||||
<p>管理面板</p>
|
||||
</div>
|
||||
<ul class="sidebar-menu">
|
||||
<li><a href="/admin" class="{{if eq .Page "dashboard"}}active{{end}}">📊 仪表盘</a></li>
|
||||
<li><a href="/admin" class="active">📊 仪表盘</a></li>
|
||||
<li><a href="/admin/pending_posts" class="{{if eq .Page "pending_posts"}}active{{end}}">⏳ 待审核帖子</a></li>
|
||||
<li><a href="/admin/pending_users" class="{{if eq .Page "pending_users"}}active{{end}}">👥 待审核用户</a></li>
|
||||
<li><a href="/admin/posts" class="{{if eq .Page "posts"}}active{{end}}">📝 帖子管理</a></li>
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
tr:hover { background: var(--surface-light); }
|
||||
.actions a { margin-right: 10px; color: var(--text-hint); text-decoration: none; }
|
||||
.actions .delete { color: #ff6b6b; }
|
||||
/* 状态样式通过模板动态应用: status-{{.Status}} */
|
||||
.status-approved { color: var(--primary); }
|
||||
.status-pending { color: #ffb347; }
|
||||
.status-rejected { color: #ff6b6b; }
|
||||
@@ -42,6 +43,8 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- 状态样式类通过模板动态使用: status-approved, status-pending, status-rejected -->
|
||||
<span style="display:none;" class="status-approved status-pending status-rejected"></span>
|
||||
<div class="admin-wrapper">
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar-header"><div class="logo">lv8girl</div><p>管理面板</p></div>
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!-- 状态样式类通过模板动态使用: status-approved, status-pending, status-rejected -->
|
||||
<span style="display:none;" class="status-approved status-pending status-rejected"></span>
|
||||
<div class="admin-wrapper">
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar-header"><div class="logo">lv8girl</div><p>管理面板</p></div>
|
||||
@@ -78,7 +80,8 @@
|
||||
{{else}}
|
||||
<form method="post" action="/admin/users/role" style="display:inline;">
|
||||
<input type="hidden" name="user_id" value="{{.ID}}">
|
||||
<select name="new_role" onchange="this.form.submit()">
|
||||
<label for="role-{{.ID}}" style="display:none;">角色</label>
|
||||
<select id="role-{{.ID}}" name="new_role" onchange="this.form.submit()">
|
||||
<option value="user" {{if eq .Role "user"}}selected{{end}}>用户</option>
|
||||
<option value="admin" {{if eq .Role "admin"}}selected{{end}}>管理员</option>
|
||||
<option value="banned" {{if eq .Role "banned"}}selected{{end}}>封禁</option>
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<body class="dark-mode">
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<div class="top-bar">
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
.footer-text a:hover { text-decoration: underline; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<body class="dark-mode">
|
||||
<div class="login-wrapper">
|
||||
<div class="header">
|
||||
<div class="logo">lv8girl<span>绿坝娘</span></div>
|
||||
@@ -61,12 +61,12 @@
|
||||
{{if .Error}}<div class="error-message">{{.Error}}</div>{{end}}
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label>用户名 / 邮箱</label>
|
||||
<input type="text" name="login" placeholder="请输入用户名或邮箱" required>
|
||||
<label for="login">用户名 / 邮箱</label>
|
||||
<input type="text" id="login" name="login" placeholder="请输入用户名或邮箱" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>密码</label>
|
||||
<input type="password" name="password" placeholder="请输入密码" required>
|
||||
<label for="password">密码</label>
|
||||
<input type="password" id="password" name="password" placeholder="请输入密码" required>
|
||||
</div>
|
||||
<button type="submit" class="btn">登 录</button>
|
||||
</form>
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
.footer a:hover { color: var(--accent); }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<body class="dark-mode">
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<div class="logo">lv8girl<span>绿坝娘</span></div>
|
||||
|
||||
@@ -104,7 +104,9 @@
|
||||
@media (max-width: 800px) { .main-layout { flex-direction: column; } }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<body class="dark-mode">
|
||||
<!-- liked 类通过模板动态应用 -->
|
||||
<span style="display:none;" class="like-btn liked"></span>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<div class="logo">lv8girl<span>绿坝娘</span></div>
|
||||
@@ -160,7 +162,8 @@
|
||||
<h2 class="comments-title">评论 ({{len .Comments}})</h2>
|
||||
{{if .IsLoggedIn}}
|
||||
<form method="post" action="/post/{{.Post.ID}}/comment" class="comment-form">
|
||||
<textarea name="content" placeholder="写下你的评论..." required></textarea>
|
||||
<label for="comment-content" style="display:none;">评论内容</label>
|
||||
<textarea id="comment-content" name="content" placeholder="写下你的评论..." required></textarea>
|
||||
<button type="submit">发表评论</button>
|
||||
</form>
|
||||
{{else}}
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
.footer-links a:hover { color: var(--accent); }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<body class="dark-mode">
|
||||
<div class="post-wrapper">
|
||||
<div class="header">
|
||||
<div class="logo">lv8girl<span>绿坝娘</span></div>
|
||||
@@ -68,16 +68,16 @@
|
||||
{{else}}
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
<label>标题</label>
|
||||
<input type="text" name="title" placeholder="请输入标题" required>
|
||||
<label for="title">标题</label>
|
||||
<input type="text" id="title" name="title" placeholder="请输入标题" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>内容</label>
|
||||
<textarea name="content" placeholder="请输入帖子内容..." required></textarea>
|
||||
<label for="content">内容</label>
|
||||
<textarea id="content" name="content" placeholder="请输入帖子内容..." required></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>上传图片(可选,不超过2MB)</label>
|
||||
<input type="file" name="image" accept="image/*">
|
||||
<label for="image">上传图片(可选,不超过2MB)</label>
|
||||
<input type="file" id="image" name="image" accept="image/*">
|
||||
<div class="file-note">支持 JPEG、PNG、GIF、WEBP 格式</div>
|
||||
</div>
|
||||
<button type="submit" class="btn">发 布</button>
|
||||
|
||||
@@ -46,9 +46,6 @@
|
||||
.dropdown a:hover { background: var(--surface-light); }
|
||||
.theme-toggle { background: var(--surface-light); border: none; color: var(--text); font-size: 1.3rem; width: 38px; height: 38px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
|
||||
.theme-toggle:hover { background: var(--accent); color: var(--surface); }
|
||||
.success-message, .error-message { padding: 12px 20px; border-radius: 8px; margin-bottom: 20px; }
|
||||
.success-message { background: var(--primary); color: white; }
|
||||
.error-message { background: #ff6b6b; color: white; }
|
||||
.profile-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 25px; margin-bottom: 30px; display: flex; gap: 25px; flex-wrap: wrap; }
|
||||
.profile-avatar { width: 100px; height: 100px; border-radius: 50%; background: var(--gradient); overflow: hidden; display: flex; align-items: center; justify-content: center; color: white; font-size: 2.5rem; font-weight: 600; flex-shrink: 0; }
|
||||
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
|
||||
@@ -85,7 +82,7 @@
|
||||
.footer a:hover { color: var(--accent); }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<body class="dark-mode">
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<div class="logo">lv8girl<span>绿坝娘</span></div>
|
||||
@@ -135,6 +132,7 @@
|
||||
</form>
|
||||
</div>
|
||||
{{else}}
|
||||
<!--suppress HtmlUnknownTarget-->
|
||||
<a href="/send-message?to={{.User.ID}}" class="edit-btn" style="margin-top:10px;">📩 发送私信</a>
|
||||
{{end}}
|
||||
</div>
|
||||
@@ -187,8 +185,11 @@
|
||||
themeToggle.textContent = document.body.classList.contains('dark-mode') ? '☀️' : '🌓';
|
||||
});
|
||||
function toggleUpload() {
|
||||
var form = document.getElementById('uploadForm');
|
||||
form.style.display = form.style.display === 'none' ? 'block' : 'none';
|
||||
/** @type {HTMLElement|null} */
|
||||
const form = document.getElementById('uploadForm');
|
||||
if (form instanceof HTMLElement) {
|
||||
form.style.display = form.style.display === 'none' ? 'block' : 'none';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
.footer-text a:hover { text-decoration: underline; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<body class="dark-mode">
|
||||
<div class="register-wrapper">
|
||||
<div class="header">
|
||||
<div class="logo">lv8girl<span>绿坝娘</span></div>
|
||||
@@ -69,20 +69,20 @@
|
||||
{{else}}
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label>用户名</label>
|
||||
<input type="text" name="username" placeholder="3-20个字符,支持中文、字母、数字、下划线" required>
|
||||
<label for="username">用户名</label>
|
||||
<input type="text" id="username" name="username" placeholder="3-20个字符,支持中文、字母、数字、下划线" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>邮箱</label>
|
||||
<input type="email" name="email" placeholder="请输入有效邮箱" required>
|
||||
<label for="email">邮箱</label>
|
||||
<input type="email" id="email" name="email" placeholder="请输入有效邮箱" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>密码</label>
|
||||
<input type="password" name="password" placeholder="至少6位" required>
|
||||
<label for="password">密码</label>
|
||||
<input type="password" id="password" name="password" placeholder="至少6位" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>确认密码</label>
|
||||
<input type="password" name="confirm_password" placeholder="请再次输入密码" required>
|
||||
<label for="confirm_password">确认密码</label>
|
||||
<input type="password" id="confirm_password" name="confirm_password" placeholder="请再次输入密码" required>
|
||||
</div>
|
||||
<div class="checkbox-group">
|
||||
<input type="checkbox" name="agree" id="agree" required>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
.footer-links a:hover { color: var(--accent); }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<body class="dark-mode">
|
||||
<div class="wrapper">
|
||||
<div class="header">
|
||||
<div class="logo">lv8girl<span>绿坝娘</span></div>
|
||||
@@ -62,8 +62,8 @@
|
||||
{{if .Success}}<div class="success-message">{{.Success}}</div>{{end}}
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label>内容</label>
|
||||
<textarea name="content" placeholder="请输入私信内容..."></textarea>
|
||||
<label for="content">内容</label>
|
||||
<textarea id="content" name="content" placeholder="请输入私信内容..."></textarea>
|
||||
</div>
|
||||
<button type="submit" class="btn">发送</button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user