Delete 'admin.html'

main
p7u42olxg 2 months ago
parent 55fda2f0bd
commit 61e102afdc

@ -1,110 +0,0 @@
<!-- admin.html -->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<title>管理员后台 - 失物招领平台</title>
<style>
* { margin:0; padding:0; font-family:"Microsoft YaHei"; }
body { background:#f5f7fa; padding:20px; }
.container { max-width:1200px; margin:auto; }
.tabs { display:flex; margin-bottom:20px; }
.tab { padding:10px 20px; background:#e0e0e0; cursor:pointer; }
.tab.active { background:#1890ff; color:white; }
.content { background:white; padding:20px; border-radius:8px; }
.item { padding:15px; border-bottom:1px solid #eee; }
.stats { display:flex; flex-wrap:wrap; gap:20px; margin-top:20px; }
.stat-card { background:#f9f9f9; padding:15px; border-radius:6px; flex:1; min-width:200px; }
</style>
</head>
<body>
<div class="container">
<h2>管理员后台</h2>
<div class="tabs">
<div class="tab active" onclick="showTab('review')">内容审核</div>
<div class="tab" onclick="showTab('stats')">数据统计</div>
</div>
<div id="reviewContent" class="content">
<h3>待审核信息</h3>
<div id="pendingList"></div>
</div>
<div id="statsContent" class="content" style="display:none;">
<h3>平台数据看板</h3>
<div class="stats">
<div class="stat-card">
<h4>总物品数</h4>
<p id="totalItems">0</p>
</div>
<div class="stat-card">
<h4>高频地点</h4>
<p id="topLocation">-</p>
</div>
<div class="stat-card">
<h4>热门类别</h4>
<p id="topCategory">-</p>
</div>
</div>
</div>
</div>
<script>
let user = JSON.parse(localStorage.getItem('user'));
if (!user || user.role !== 'admin') {
alert('无权限访问!');
location.href = 'login.html';
}
let items = JSON.parse(localStorage.getItem('items')) || [];
function showTab(tab) {
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
event.target.classList.add('active');
document.getElementById('reviewContent').style.display = tab === 'review' ? 'block' : 'none';
document.getElementById('statsContent').style.display = tab === 'stats' ? 'block' : 'none';
if (tab === 'stats') renderStats();
}
function renderPending() {
const pending = items.filter(i => i.status === 'pending');
document.getElementById('pendingList').innerHTML = pending.length > 0 ?
pending.map(item => `
<div class="item">
<strong>[${item.type === 'lost' ? '寻物' : '招领'}]</strong> ${item.name}
<div>${item.desc}</div>
<div>📍 ${item.location} · 用户: ${item.userId}</div>
<button onclick="approve('${item.id}', true)" style="background:green;color:white;padding:5px 10px;border:none;margin-right:10px;">通过</button>
<button onclick="approve('${item.id}', false)" style="background:red;color:white;padding:5px 10px;border:none;">拒绝</button>
</div>
`).join('') : '<p>暂无待审核信息</p>';
}
function approve(id, isApprove) {
const item = items.find(i => i.id === id);
if (item) {
item.status = isApprove ? 'approved' : 'rejected';
localStorage.setItem('items', JSON.stringify(items));
renderPending();
}
}
function renderStats() {
const approved = items.filter(i => i.status === 'approved');
document.getElementById('totalItems').innerText = approved.length;
// 高频地点
const locCount = {};
approved.forEach(i => locCount[i.location] = (locCount[i.location] || 0) + 1);
const topLoc = Object.entries(locCount).sort((a,b)=>b[1]-a[1])[0];
document.getElementById('topLocation').innerText = topLoc ? `${topLoc[0]} (${topLoc[1]}次)` : '-';
// 热门类别(这里简化为按名称关键词)
document.getElementById('topCategory').innerText = '证件类、电子设备(模拟)';
}
renderPending();
</script>
</body>
</html>
Loading…
Cancel
Save