| | |
| | | <div class="nav-tabs"> |
| | | <button class="active" data-tab="keys" onclick="switchTab('keys')">密钥管理</button> |
| | | <button data-tab="games" onclick="switchTab('games')">游戏管理</button> |
| | | <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="tools" onclick="switchTab('tools')">工具管理</button> |
| | | <button data-tab="reset" onclick="switchTab('reset')">密码重置</button> |
| | | </div> |
| | | <button id="logoutBtn" onclick="logout()">退出登录</button> |
| | | </div> |
| | |
| | | <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> |
| | | |
| | |
| | | <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> |
| | |
| | | <input id="t_file_url" placeholder="安装包URL,或点击上传"> |
| | | <input type="file" onchange="uploadSingle(this, 'file', 't_file_url')"> |
| | | </div> |
| | | <div class="form-row"><label>启动程序路径</label> |
| | | <input id="t_launch_exe" placeholder="解压后目录内的相对路径,如 A1524\\setup.exe"> |
| | | </div> |
| | | <div class="form-row"><label>描述</label><textarea id="t_description"></textarea></div> |
| | | <div style="display:flex;gap:10px;justify-content:flex-end;margin-top:16px"> |
| | | <button class="btn btn-gray" onclick="hideToolModal()">取消</button> |
| | |
| | | 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() { |
| | |
| | | <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> |
| | |
| | | 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 || ''; |
| | |
| | | `<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, |
| | |
| | | document.getElementById('t_size').value = t ? (t.size || '') : ''; |
| | | document.getElementById('t_cover').value = t ? (t.cover || '') : ''; |
| | | document.getElementById('t_file_url').value = t ? (t.file_url || '') : ''; |
| | | document.getElementById('t_launch_exe').value = t ? (t.launch_exe || '') : ''; |
| | | document.getElementById('t_description').value = t ? (t.description || '') : ''; |
| | | renderToolCover(); |
| | | document.getElementById('toolModal').classList.remove('hidden'); |
| | |
| | | size: document.getElementById('t_size').value.trim(), |
| | | cover: document.getElementById('t_cover').value.trim(), |
| | | file_url: document.getElementById('t_file_url').value.trim(), |
| | | launch_exe: document.getElementById('t_launch_exe').value.trim(), |
| | | description: document.getElementById('t_description').value.trim(), |
| | | }; |
| | | if (!body.name) return toast('请填写工具名称', true); |
| | |
| | | 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> |