| | |
| | | <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="reset" onclick="switchTab('reset')">密码重置</button> |
| | | </div> |
| | | <button id="logoutBtn" onclick="logout()">退出登录</button> |
| | | </div> |
| | |
| | | <div id="tab-keys" class="panel"> |
| | | <h2>会员密钥</h2> |
| | | <div class="toolbar"> |
| | | <select id="genType"><option value="day">日卡</option><option value="month">月卡</option><option value="year">年卡</option></select> |
| | | <select id="genType"><option value="day">日卡</option><option value="month">月卡</option><option value="year">年卡</option><option value="forever">永久卡</option></select> |
| | | <input id="genCount" type="number" value="10" min="1" max="100" style="width:80px"> |
| | | <button class="btn" onclick="generateKeys()">生成密钥</button> |
| | | <span style="flex:1"></span> |
| | | <input id="keyKeyword" placeholder="搜索激活码"> |
| | | <input id="keyKeyword" placeholder="搜索激活码/手机号"> |
| | | <select id="keyStatus"> |
| | | <option value="">全部状态</option> |
| | | <option value="0">未使用</option> |
| | |
| | | <tbody id="catTable"></tbody> |
| | | </table> |
| | | </div> |
| | | |
| | | <!-- 公告设置 --> |
| | | <div id="tab-ann" class="panel hidden"> |
| | | <h2>首页公告</h2> |
| | | <p style="color:#888;font-size:12px;margin-bottom:14px">客户端打开首页时自动弹出的系统公告;内容留空则不弹出。</p> |
| | | <div class="form-row"> |
| | | <textarea id="annContent" style="min-height:180px" placeholder="请输入公告内容..."></textarea> |
| | | </div> |
| | | <button class="btn" onclick="saveAnnouncement()">保存公告</button> |
| | | </div> |
| | | |
| | | <!-- 工具管理 --> |
| | | <div id="tab-tools" class="panel hidden"> |
| | | <h2>工具管理</h2> |
| | | <div class="toolbar"> |
| | | <button class="btn" onclick="showToolModal()">+ 添加工具</button> |
| | | </div> |
| | | <table> |
| | | <thead><tr><th>ID</th><th>封面</th><th>名称</th><th>大小</th><th>描述</th><th>下载文件</th><th>操作</th></tr></thead> |
| | | <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> |
| | |
| | | |
| | | <div id="toast" class="toast"></div> |
| | | |
| | | <!-- 工具编辑弹窗 --> |
| | | <div id="toolModal" class="modal-mask hidden"> |
| | | <div class="modal"> |
| | | <h3 id="toolModalTitle">添加工具</h3> |
| | | <input type="hidden" id="t_id"> |
| | | <div class="form-row"><label>工具名称 *</label><input id="t_name" placeholder="如:百度网盘"></div> |
| | | <div class="form-row"><label>大小(如 85.2MB)</label><input id="t_size"></div> |
| | | <div class="form-row"><label>封面图</label> |
| | | <input id="t_cover" placeholder="封面图URL,或点击上传" onchange="renderToolCover()"> |
| | | <input type="file" accept="image/*" onchange="uploadSingle(this, 'image', 't_cover'); setTimeout(renderToolCover, 500)"> |
| | | <div id="t_cover_list"></div> |
| | | </div> |
| | | <div class="form-row"><label>下载文件</label> |
| | | <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> |
| | | <button class="btn" onclick="saveTool()">保存</button> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | <script> |
| | | let token = localStorage.getItem('admin_token') || ''; |
| | | let editingScreenshots = [], editingFiles = []; |
| | |
| | | function enterPanel() { |
| | | document.getElementById('loginPage').style.display = 'none'; |
| | | document.getElementById('mainPage').style.display = 'flex'; |
| | | loadStats(); loadKeys(1); loadGames(); loadCategories(); |
| | | 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'].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() { |
| | |
| | | if (k.status === 0) { st = '未使用'; cls = 'tag-blue'; } |
| | | else if (k.expired) { st = '已过期'; cls = 'tag-red'; } |
| | | else { st = '使用中'; cls = 'tag-green'; } |
| | | if (k.frozen) st += ' · 已冻结'; |
| | | return `<tr> |
| | | <td>${k.id}</td><td style="font-family:Consolas">${k.code}</td> |
| | | <td><span class="tag tag-gray">${k.card_name}</span></td> |
| | | <td><span class="tag ${cls}">${st}</span></td> |
| | | <td><span class="tag ${k.frozen ? 'tag-red' : cls}">${st}</span></td> |
| | | <td>${k.phone || '-'}</td> |
| | | <td style="max-width:160px;overflow:hidden;text-overflow:ellipsis">${k.machine_code || '-'}</td> |
| | | <td>${k.expired_at_str || '-'}</td> |
| | | <td>${k.reset_count}</td> |
| | | <td> |
| | | <button class="btn btn-sm" onclick="freezeKey(${k.id})">${k.frozen ? '解冻' : '冻结'}</button> |
| | | ${k.status === 1 ? `<button class="btn btn-sm" onclick="resetKey(${k.id})">重置(可再用)</button> ` : ''} |
| | | <button class="btn btn-sm btn-danger" onclick="deleteKey(${k.id})">删除</button> |
| | | </td></tr>`; |
| | |
| | | toast(res.msg, res.code !== 0); |
| | | loadKeys(keyPage); |
| | | } |
| | | async function freezeKey(id) { |
| | | if (!confirm('确定冻结/解冻该密钥?冻结后该激活码无法使用。')) return; |
| | | const res = await api(`/admin/api/keys/${id}/freeze`, {method: 'POST'}); |
| | | toast(res.msg, res.code !== 0); |
| | | loadKeys(keyPage); |
| | | } |
| | | async function deleteKey(id) { |
| | | if (!confirm('确定删除该密钥?')) return; |
| | | const res = await api(`/admin/api/keys/${id}`, {method: 'DELETE'}); |
| | |
| | | <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, |
| | |
| | | loadCategories(); |
| | | } |
| | | |
| | | /* ---------- 公告 ---------- */ |
| | | async function loadAnnouncement() { |
| | | const res = await api('/admin/api/announcement'); |
| | | if (res.code !== 0) return; |
| | | document.getElementById('annContent').value = (res.data && res.data.content) || ''; |
| | | } |
| | | async function saveAnnouncement() { |
| | | const content = document.getElementById('annContent').value; |
| | | const res = await api('/admin/api/announcement', {method: 'POST', body: {content}}); |
| | | toast(res.msg, res.code !== 0); |
| | | } |
| | | |
| | | /* ---------- 工具管理 ---------- */ |
| | | async function loadTools() { |
| | | const res = await api('/admin/api/tools'); |
| | | if (res.code !== 0) return; |
| | | const rows = res.data.map(t => `<tr> |
| | | <td>${t.id}</td> |
| | | <td><img src="${t.cover}" style="width:56px;height:36px;object-fit:cover;border-radius:4px" onerror="this.style.visibility='hidden'"></td> |
| | | <td>${t.name}</td> |
| | | <td>${t.size || '-'}</td> |
| | | <td style="max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap" title="${t.description || ''}">${t.description || '-'}</td> |
| | | <td style="max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap" title="${t.file_url || ''}">${t.file_url || '-'}</td> |
| | | <td> |
| | | <button class="btn btn-sm" onclick='showToolModal(${JSON.stringify(t).replace(/'/g,"'")})'>修改</button> |
| | | <button class="btn btn-sm btn-danger" onclick="deleteTool(${t.id})">删除</button> |
| | | </td></tr>`).join(''); |
| | | document.getElementById('toolTable').innerHTML = rows || '<tr><td colspan="7" style="text-align:center;color:#666">暂无数据</td></tr>'; |
| | | } |
| | | function renderToolCover() { |
| | | const url = document.getElementById('t_cover').value; |
| | | document.getElementById('t_cover_list').innerHTML = url ? `<div class="file-item"><img src="${url}"><span>${url}</span></div>` : ''; |
| | | } |
| | | function showToolModal(t) { |
| | | document.getElementById('toolModalTitle').innerText = t ? '修改工具' : '添加工具'; |
| | | document.getElementById('t_id').value = t ? t.id : ''; |
| | | document.getElementById('t_name').value = t ? t.name : ''; |
| | | 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'); |
| | | } |
| | | function hideToolModal() { document.getElementById('toolModal').classList.add('hidden'); } |
| | | async function saveTool() { |
| | | const body = { |
| | | id: parseInt(document.getElementById('t_id').value) || 0, |
| | | name: document.getElementById('t_name').value.trim(), |
| | | 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); |
| | | const res = await api('/admin/api/tools', {method: 'POST', body}); |
| | | toast(res.msg, res.code !== 0); |
| | | if (res.code === 0) { hideToolModal(); loadTools(); } |
| | | } |
| | | async function deleteTool(id) { |
| | | if (!confirm('确定删除该工具?')) return; |
| | | const res = await api(`/admin/api/tools/${id}`, {method: 'DELETE'}); |
| | | toast(res.msg, res.code !== 0); |
| | | 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> |