From b1e9aef9d2698cf27eccde2f131eae3c4e6a65d0 Mon Sep 17 00:00:00 2001
From: 905086 <k2049@qq.com>
Date: Sun, 08 Nov 2026 16:10:17 +0800
Subject: [PATCH] docs: 添加项目信息和游戏功能需求文档
---
server/admin/index.html | 71 ++++++++++++++++++++++++++++++++---
1 files changed, 65 insertions(+), 6 deletions(-)
diff --git a/server/admin/index.html b/server/admin/index.html
index 3777f69..5ad70f9 100644
--- a/server/admin/index.html
+++ b/server/admin/index.html
@@ -99,6 +99,7 @@
<button data-tab="tools" onclick="switchTab('tools')">工具管理</button>
<button data-tab="cats" onclick="switchTab('cats')">类别管理</button>
<button data-tab="ann" onclick="switchTab('ann')">公告设置</button>
+ <button data-tab="reset" onclick="switchTab('reset')">密码重置</button>
</div>
<button id="logoutBtn" onclick="logout()">退出登录</button>
</div>
@@ -175,6 +176,16 @@
<tbody id="toolTable"></tbody>
</table>
</div>
+
+ <!-- 密码重置申请 -->
+ <div id="tab-reset" class="panel hidden">
+ <h2>找回密码申请</h2>
+ <p style="color:#888;font-size:12px;margin-bottom:14px">用户在客户端"找回密码"中提交的申请。点击"同意并重置"为该用户设置新密码(可自定义,至少6位),重置后请将新密码告知用户。</p>
+ <table>
+ <thead><tr><th>ID</th><th>手机号</th><th>期望新密码</th><th>申请时间</th><th>状态</th><th>新密码</th><th>处理时间</th><th>操作</th></tr></thead>
+ <tbody id="resetTable"></tbody>
+ </table>
+ </div>
</div>
</div>
@@ -188,8 +199,8 @@
<div class="form-row"><label>类别</label><select id="g_category"></select></div>
<div class="form-row"><label>平台</label><select id="g_platform"><option value="pc">PC资源(单机)</option><option value="switch">Switch资源</option></select></div>
<div class="form-row"><label>标签(逗号分隔,如: 即时战略,经典怀旧)</label><input id="g_tags"></div>
- <div class="form-row"><label>游戏大小(如 232.6 GB)</label><input id="g_size"></div>
- <div class="form-row"><label>安装磁盘占用(如 411.6 GB)</label><input id="g_install_size"></div>
+ <div class="form-row"><label>游戏大小(GB,纯数字,如 232.6)*</label><input id="g_size" type="number" step="any" min="0" placeholder="232.6"></div>
+ <div class="form-row"><label>磁盘占用(GB,纯数字,如 411.6)*</label><input id="g_install_size" type="number" step="any" min="0" placeholder="411.6"></div>
<div class="form-row"><label>系统要求</label><input id="g_os" placeholder="Windows 10 64bit"></div>
<div class="form-row"><label>CPU要求</label><input id="g_cpu" placeholder="Intel i5-4460"></div>
<div class="form-row"><label>显卡要求</label><input id="g_gpu" placeholder="GTX 1060 6GB"></div>
@@ -298,11 +309,11 @@
function enterPanel() {
document.getElementById('loginPage').style.display = 'none';
document.getElementById('mainPage').style.display = 'flex';
- loadStats(); loadKeys(1); loadGames(); loadCategories(); loadAnnouncement(); loadTools();
+ loadStats(); loadKeys(1); loadGames(); loadCategories(); loadAnnouncement(); loadTools(); loadResetRequests();
}
function switchTab(tab) {
document.querySelectorAll('.nav-tabs button').forEach(b => b.classList.toggle('active', b.dataset.tab === tab));
- ['keys','games','cats','ann','tools'].forEach(t => document.getElementById('tab-' + t).classList.toggle('hidden', t !== tab));
+ ['keys','games','cats','ann','tools','reset'].forEach(t => document.getElementById('tab-' + t).classList.toggle('hidden', t !== tab));
}
async function loadStats() {
@@ -394,7 +405,7 @@
<td>${g.title}</td>
<td>${g.category_name || '-'}</td>
<td><span class="tag ${g.platform==='pc'?'tag-blue':'tag-green'}">${g.platform==='pc'?'PC':'Switch'}</span></td>
- <td>${g.size}</td>
+ <td>${/^[0-9.]+$/.test(g.size) ? g.size + ' GB' : (g.size || '-')}</td>
<td>${g.download_count}</td>
<td>
<button class="btn btn-sm" onclick='showGameModal(${JSON.stringify(g).replace(/'/g,"'")})'>修改</button>
@@ -407,7 +418,9 @@
if (g) {
document.getElementById('gameModalTitle').innerText = '修改游戏';
g_id.value = g.id; g_title.value = g.title; g_tags.value = g.tags || '';
- g_size.value = g.size || ''; g_install_size.value = g.install_size || '';
+ // 大小统一为 GB 纯数字,历史数据如 "232.6 GB" 去掉单位后填入
+ g_size.value = (g.size || '').replace(/\s*GB$/i, '').trim();
+ g_install_size.value = (g.install_size || '').replace(/\s*GB$/i, '').trim();
g_os.value = g.os_req || ''; g_cpu.value = g.cpu_req || ''; g_gpu.value = g.gpu_req || ''; g_ram.value = g.ram_req || '';
g_version_note.value = g.version_note || ''; g_description.value = g.description || '';
g_launch_exe.value = g.launch_exe || '';
@@ -502,6 +515,11 @@
`<div class="file-item"><span>${f.name}(${f.size})</span><button class="btn btn-sm btn-danger" onclick="editingFiles.splice(${i},1);renderFiles()">移除</button></div>`).join('');
}
async function saveGame() {
+ // 大小/磁盘占用统一为 GB 纯数字,必须校验
+ const sizeVal = g_size.value.trim();
+ const installVal = g_install_size.value.trim();
+ if (!/^\d+(\.\d+)?$/.test(sizeVal)) return toast('游戏大小请填写纯数字(单位GB),如 232.6', true);
+ if (!/^\d+(\.\d+)?$/.test(installVal)) return toast('磁盘占用请填写纯数字(单位GB),如 411.6', true);
const body = {
id: parseInt(g_id.value) || 0,
title: g_title.value.trim(), category_id: parseInt(g_category.value) || 0,
@@ -626,6 +644,47 @@
loadTools();
}
+/* ---------- 密码重置申请 ---------- */
+async function loadResetRequests() {
+ const res = await api('/admin/api/reset_requests');
+ if (res.code !== 0) return;
+ const rows = res.data.map(r => `<tr>
+ <td>${r.id}</td>
+ <td>${r.phone}</td>
+ <td>${r.proposed_password ? `<code style="color:#4a92ff">${r.proposed_password}</code>` : '-'}</td>
+ <td>${(r.created_at || '').replace('T', ' ').slice(0, 19)}</td>
+ <td>${r.status === 1 ? '<span class="tag tag-green">已同意</span>' : '<span class="tag" style="background:#8a6d1a;color:#ffd700">待处理</span>'}</td>
+ <td>${r.status === 1 ? `<code style="color:#ffd700">${r.new_password || '-'}</code>` : '-'}</td>
+ <td>${r.handled_at ? (r.handled_at + '').replace('T', ' ').slice(0, 19) : '-'}</td>
+ <td>
+ ${r.status === 0 ? `<button class="btn btn-sm" onclick="approveReset(${r.id}, '${r.phone}', '${r.proposed_password || ''}')">同意并重置</button>` : ''}
+ <button class="btn btn-sm btn-danger" onclick="deleteReset(${r.id})">删除</button>
+ </td></tr>`).join('');
+ document.getElementById('resetTable').innerHTML = rows || '<tr><td colspan="8" style="text-align:center;color:#666">暂无申请</td></tr>';
+}
+async function approveReset(id, phone, proposed) {
+ const input = prompt(`同意 ${phone} 的找回密码申请。\n请输入要设置的新密码(至少6位,留空则使用用户填写的密码):`, proposed || '');
+ if (input === null) return; // 取消
+ const body = input.trim() ? {new_password: input.trim()} : {};
+ const res = await api(`/admin/api/reset_requests/${id}/approve`, {method: 'POST', body});
+ if (res.code !== 0) return toast(res.msg, true);
+ const newPwd = res.data.new_password;
+ const w = document.createElement('div');
+ w.className = 'modal-mask';
+ w.innerHTML = `<div class="modal" style="width:420px"><h3>重置成功</h3>
+ <p style="margin:10px 0">手机号 <b style="color:#4a92ff">${phone}</b> 的密码已重置为:</p>
+ <p style="font-size:20px;color:#ffd700;text-align:center;margin:14px 0">${newPwd}</p>
+ <p style="color:#888;font-size:12px">请将新密码告知该用户。</p>
+ <div style="text-align:right;margin-top:14px"><button class="btn" onclick="copyText('${newPwd}');this.closest('.modal-mask').remove();loadResetRequests()">复制并关闭</button></div></div>`;
+ document.body.appendChild(w);
+}
+async function deleteReset(id) {
+ if (!confirm('确定删除该申请?')) return;
+ const res = await api(`/admin/api/reset_requests/${id}`, {method: 'DELETE'});
+ toast(res.msg, res.code !== 0);
+ loadResetRequests();
+}
+
document.getElementById('adminPwd').addEventListener('keydown', e => { if (e.key === 'Enter') adminLogin(); });
if (token) enterPanel();
</script>
--
Gitblit v1.10.0