diff --git a/public/index.html b/public/index.html index 9e94bb5..61ce421 100644 --- a/public/index.html +++ b/public/index.html @@ -14,6 +14,8 @@ body{font:14px/1.6 -apple-system,"Segoe UI","Microsoft YaHei",sans-serif;backgro .tchip{display:inline-flex;align-items:center;gap:5px;padding:3px 10px;border-radius:12px;font-size:12px;background:rgba(255,255,255,.08);color:#cbd5e1} .tchip .dot{width:8px;height:8px;border-radius:50%;background:#94a3b8} .tchip.running .dot{background:#22c55e;animation:pulse 1.5s infinite} +.tchip.waiting .dot{background:#f59e0b;animation:pulse 1.5s infinite} +.tchip.waiting{color:#fcd34d} .tchip.done .dot{background:#10b981} .tchip.error .dot{background:#ef4444;animation:pulse 1s infinite} .tchip.error{color:#fca5a5} diff --git a/server.js b/server.js index 4943f80..4c27b5f 100644 --- a/server.js +++ b/server.js @@ -339,13 +339,21 @@ app.get('/api/task-status', requireAuth, async (req, res) => { let s = null; try { s = JSON.parse(fs.readFileSync(path.join(stateDir, `state-${acct}.json`), 'utf8')); } catch (_) {} const isAlive = alive(acct); + // 等待扫码优先于"进程活着=运行中": 登录过期时runner进程活着但只是在等扫码 + if (s && s.date === bjToday && (s.status === 'waiting_relogin' || s.status === 'qr_expired')) { + out[acct] = { + state: 'waiting', text: '等待扫码', + detail: s.status === 'qr_expired' ? '二维码已过期,需重启任务' : (isAlive ? '登录过期,群里扫码后自动复工' : '扫码监听进程已退出,需人工处理'), + }; + continue; + } if (isAlive) { out[acct] = { state: 'running', text: '运行中', chatLeft: s && s.chatLeft }; continue; } if (!s || s.date !== bjToday) { out[acct] = { state: 'idle', text: '今日未运行' }; continue; } if (s.status === 'running') out[acct] = { state: 'stopped', text: '已停止', detail: '状态未更新(进程已退出)' }; else if (s.status === 'stopped_by_user') out[acct] = { state: 'stopped', text: '手动停止' }; else if (doneSet.has(s.status)) out[acct] = { state: 'done', text: '已收工', chatLeft: s.chatLeft }; else if (errSet.has(s.status)) out[acct] = { state: 'error', text: '异常停止', detail: s.status }; - else out[acct] = { state: 'done', text: '已收工', chatLeft: s.chatLeft }; + else out[acct] = { state: 'stopped', text: `已停止(${s.status})` }; // 未知状态如实显示,不再误标"已收工" } res.json(out); });