From fb865e40a670ff26f8f2098bf4f1b0bf076d3e17 Mon Sep 17 00:00:00 2001 From: mzl92 Date: Mon, 31 Aug 2026 14:50:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8A=B6=E6=80=81=E7=81=AF=E4=BF=AE=E5=A4=8D:?= =?UTF-8?q?=20waiting=5Frelogin/qr=5Fexpired=E6=96=B0=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=E5=88=B6'=E7=AD=89=E5=BE=85=E6=89=AB=E7=A0=81'=E9=BB=84?= =?UTF-8?q?=E7=81=AF(=E4=BC=98=E5=85=88=E4=BA=8E=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E5=88=A4=E5=AE=9A,runner=E7=AD=89=E6=89=AB=E7=A0=81=E6=97=B6?= =?UTF-8?q?=E8=BF=9B=E7=A8=8B=E6=B4=BB=E7=9D=80=E4=BD=86=E9=9D=9E=E8=BF=90?= =?UTF-8?q?=E8=A1=8C);=20=E6=9C=AA=E7=9F=A5=E7=8A=B6=E6=80=81=E5=A6=82?= =?UTF-8?q?=E5=AE=9E=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=86=8D=E8=AF=AF=E6=A0=87?= =?UTF-8?q?=E5=B7=B2=E6=94=B6=E5=B7=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 2 ++ server.js | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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); });