1. 前端用户下拉菜单优化 - 改用CSS动画,解决鼠标移动问题 2. 帖子管理增加显示/隐藏开关 3. 帖子详情页可直接删除回复 4. 新增回复管理页面(列表、删除) 5. 用户管理增加编辑功能(用户名、邮箱、手机、简介) 6. 用户管理增加查看帖子按钮 7. 所有页面侧边栏添加回复管理入口 8. 数据库增加 is_hidden 字段
140 lines
6.4 KiB
HTML
140 lines
6.4 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
|
|
<title>回复管理 - 论坛后台</title>
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
<link href="https://cdn.jsdelivr.net/npm/remixicon@3.5.0/fonts/remixicon.css" rel="stylesheet">
|
|
</head>
|
|
<body class="bg-gray-50 min-h-screen">
|
|
<div class="flex">
|
|
<aside class="w-64 bg-slate-800 min-h-screen fixed left-0 top-0">
|
|
<div class="p-6">
|
|
<h1 class="text-white text-xl font-bold flex items-center gap-2">
|
|
<i class="ri-code-s-slash-line text-2xl text-blue-400"></i>
|
|
论坛后台
|
|
</h1>
|
|
</div>
|
|
<nav class="mt-6">
|
|
<a href="/admin" class="flex items-center gap-3 px-6 py-3 text-slate-300 hover:bg-slate-700 hover:text-white">
|
|
<i class="ri-dashboard-line"></i><span>仪表盘</span>
|
|
</a>
|
|
<a href="/admin/users" class="flex items-center gap-3 px-6 py-3 text-slate-300 hover:bg-slate-700 hover:text-white">
|
|
<i class="ri-user-line"></i><span>用户管理</span>
|
|
</a>
|
|
<a href="/admin/posts" class="flex items-center gap-3 px-6 py-3 text-slate-300 hover:bg-slate-700 hover:text-white">
|
|
<i class="ri-file-text-line"></i><span>帖子管理</span>
|
|
</a>
|
|
<a href="/admin/replies" class="flex items-center gap-3 px-6 py-3 bg-slate-700 text-white">
|
|
<i class="ri-chat-3-line"></i><span>回复管理</span>
|
|
</a>
|
|
<a href="/admin/topics" class="flex items-center gap-3 px-6 py-3 text-slate-300 hover:bg-slate-700 hover:text-white">
|
|
<i class="ri-tools-line"></i><span>主题管理</span>
|
|
</a>
|
|
</nav>
|
|
<div class="absolute bottom-0 left-0 right-0 p-4 border-t border-slate-700">
|
|
<a href="/" target="_blank" class="text-slate-400 hover:text-white text-sm flex items-center gap-2">
|
|
<i class="ri-external-link-line"></i> 访问前台
|
|
</a>
|
|
<button onclick="logout()" class="mt-2 text-slate-400 hover:text-red-400 text-sm flex items-center gap-2">
|
|
<i class="ri-logout-box-line"></i> 退出登录
|
|
</button>
|
|
</div>
|
|
</aside>
|
|
|
|
<main class="ml-64 flex-1 p-8">
|
|
<h1 class="text-2xl font-bold text-gray-800 mb-6">回复管理</h1>
|
|
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-100 overflow-hidden">
|
|
<table class="w-full">
|
|
<thead class="bg-gray-50 border-b border-gray-100">
|
|
<tr>
|
|
<th class="px-4 py-3 text-left text-sm font-medium text-gray-500">回复内容</th>
|
|
<th class="px-4 py-3 text-left text-sm font-medium text-gray-500">作者</th>
|
|
<th class="px-4 py-3 text-left text-sm font-medium text-gray-500">帖子</th>
|
|
<th class="px-4 py-3 text-left text-sm font-medium text-gray-500">赞</th>
|
|
<th class="px-4 py-3 text-left text-sm font-medium text-gray-500">回复时间</th>
|
|
<th class="px-4 py-3 text-left text-sm font-medium text-gray-500">操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="replyTable">
|
|
<tr><td colspan="6" class="px-6 py-8 text-center text-gray-500">加载中...</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
|
|
<script>
|
|
// 检查登录状态
|
|
async function checkAuth() {
|
|
const res = await fetch('/admin/api/check-auth');
|
|
const data = await res.json();
|
|
if (!data.logged_in) {
|
|
window.location.href = '/admin/login';
|
|
}
|
|
}
|
|
checkAuth();
|
|
|
|
// 退出登录
|
|
async function logout() {
|
|
await fetch('/admin/api/logout', { method: 'POST' });
|
|
window.location.href = '/admin/login';
|
|
}
|
|
|
|
async function loadReplies() {
|
|
const res = await fetch('/admin/api/replies');
|
|
const replies = await res.json();
|
|
|
|
const tbody = document.getElementById('replyTable');
|
|
|
|
if (replies.length === 0) {
|
|
tbody.innerHTML = '<tr><td colspan="6" class="px-6 py-8 text-center text-gray-500">暂无回复</td></tr>';
|
|
return;
|
|
}
|
|
|
|
tbody.innerHTML = replies.map(r => `
|
|
<tr class="border-b border-gray-50 hover:bg-gray-50">
|
|
<td class="px-4 py-3">
|
|
<p class="text-gray-800 max-w-md">${r.content}</p>
|
|
</td>
|
|
<td class="px-4 py-3 text-gray-600">${r.author}</td>
|
|
<td class="px-4 py-3">
|
|
<a href="/post/${r.post_id}" target="_blank" class="text-blue-600 hover:text-blue-800">
|
|
${r.post_title}
|
|
</a>
|
|
</td>
|
|
<td class="px-4 py-3">
|
|
<span class="px-2 py-1 bg-pink-100 text-pink-700 rounded text-xs">${r.likes}</span>
|
|
</td>
|
|
<td class="px-4 py-3 text-sm text-gray-500">
|
|
${new Date(r.created_at).toLocaleString()}
|
|
</td>
|
|
<td class="px-4 py-3">
|
|
<button onclick="deleteReply('${r.id}')" class="text-red-500 hover:text-red-700">
|
|
<i class="ri-delete-bin-line"></i> 删除
|
|
</button>
|
|
</td>
|
|
</tr>
|
|
`).join('');
|
|
}
|
|
|
|
async function deleteReply(replyId) {
|
|
if (!confirm('确定要删除这条回复吗?')) return;
|
|
|
|
const res = await fetch(`/admin/api/replies/${replyId}`, { method: 'DELETE' });
|
|
const data = await res.json();
|
|
|
|
if (data.success) {
|
|
loadReplies();
|
|
} else {
|
|
alert('删除失败: ' + (data.error || '未知错误'));
|
|
}
|
|
}
|
|
|
|
loadReplies();
|
|
</script>
|
|
</body>
|
|
</html> |