fix(qqmusic): 金币单独成组渲染,不混进成长值里

renderAccount 原来把所有 done 的 step 平铺,金币签到会显示成
「✓ 金币签到 已签 + 30 金币」夹在成长值中间,容易被读成成长值 +30。

改成按 name 前缀 /^金币/ 分组:
- 成长值那几行走原来的 done/warn/skip 三态
- 金币单独一行 💰 金币:签到 已签 + 30 金币 / 抽奖签到 已签 + 已领
- 金币全 skip 时收成一行「· 金币:今日已签」
- 金币失败仍按 warn/fail 单独列出(带 ActID 过期的提示)

顺带导出 renderAccount 供测试直接渲染。
This commit is contained in:
2026-11-07 18:52:02 +08:00
parent 57a49ab7f5
commit a9acafa3ba

View File

@@ -984,15 +984,29 @@ function pushCardResult(results) {
* 全部 skip 的项折叠成一行,避免通知被十几行「今日已完成」淹没。 */ * 全部 skip 的项折叠成一行,避免通知被十几行「今日已完成」淹没。 */
function renderAccount(uin, r) { function renderAccount(uin, r) {
const icon = { done: '✓', warn: '△', fail: '✗', skip: '·' } const icon = { done: '✓', warn: '△', fail: '✗', skip: '·' }
const did = r.steps.filter(s => s.status === 'done') // 金币体系的 step 名字都以「金币」开头 —— 单独成组,别混进成长值里让人误读
const warn = r.steps.filter(s => s.status === 'warn' || s.status === 'fail') const isCoin = s => /^金币/.test(s.name)
const skip = r.steps.filter(s => s.status === 'skip') const coin = r.steps.filter(isCoin)
const rest = r.steps.filter(s => !isCoin(s))
const did = rest.filter(s => s.status === 'done')
const warn = rest.filter(s => s.status === 'warn' || s.status === 'fail')
const skip = rest.filter(s => s.status === 'skip')
const lines = [`${r.verdict === 'done' ? '🟢' : '🟡'} ${uin}:成长值 +${r.total}`] const lines = [`${r.verdict === 'done' ? '🟢' : '🟡'} ${uin}:成长值 +${r.total}`]
for (const s of did) lines.push(` ${icon.done} ${s.name}${s.detail ? ` ${s.detail}` : ''}`) for (const s of did) lines.push(` ${icon.done} ${s.name}${s.detail ? ` ${s.detail}` : ''}`)
for (const s of warn) lines.push(` ${icon[s.status]} ${s.name}${s.detail ? ` ${s.detail}` : ''}`) for (const s of warn) lines.push(` ${icon[s.status]} ${s.name}${s.detail ? ` ${s.detail}` : ''}`)
if (skip.length) { if (skip.length) {
lines.push(` ${icon.skip} 无需处理 ${skip.length} 项:${skip.map(s => s.name).join('、')}`) lines.push(` ${icon.skip} 无需处理 ${skip.length} 项:${skip.map(s => s.name).join('、')}`)
} }
// 金币单独一行:它不加成长值,混在上面会被当成成长值的一部分
if (coin.length) {
const doneCoin = coin.filter(s => s.status === 'done')
const badCoin = coin.filter(s => s.status === 'warn' || s.status === 'fail')
if (doneCoin.length) {
lines.push(` 💰 金币:${doneCoin.map(s => `${s.name.replace(/^金币/, '') || '签到'}${s.detail ? ` ${s.detail}` : ''}`).join(' / ')}`)
}
for (const s of badCoin) lines.push(` ${icon[s.status]} ${s.name}${s.detail ? ` ${s.detail}` : ''}`)
if (!doneCoin.length && !badCoin.length) lines.push(` · 金币:今日已签`)
}
if (r.cardUrl) lines.push(` 🎁 分享卡 ${r.cardUrl}`) if (r.cardUrl) lines.push(` 🎁 分享卡 ${r.cardUrl}`)
return lines.join('\n') return lines.join('\n')
} }
@@ -1077,4 +1091,4 @@ async function main() {
if (require.main === module) { if (require.main === module) {
main().catch(e => { console.error('[QQ音乐] 未捕获异常:', e); process.exitCode = 1 }) main().catch(e => { console.error('[QQ音乐] 未捕获异常:', e); process.exitCode = 1 })
} }
module.exports = { time33, zzc, QMClient, parseAccounts, pushCardResult } module.exports = { time33, zzc, QMClient, parseAccounts, pushCardResult, renderAccount }