fix(qdreader): tidy query and delete menu text

This commit is contained in:
2026-05-23 02:10:06 +08:00
parent 50824baae4
commit a8dc7233a7
3 changed files with 62 additions and 46 deletions
+26 -18
View File
@@ -4,7 +4,7 @@
//[author: Hermes] //[author: Hermes]
//[service: BOSS] //[service: BOSS]
//[class: 工具类] //[class: 工具类]
// [version: 2.14.0] // [version: 2.15.0]
// [platform: web,qq,wx,tg,tb,fs,we] // [platform: web,qq,wx,tg,tb,fs,we]
// [public: false] // [public: false]
// [price: 0] // [price: 0]
@@ -279,7 +279,7 @@ function contentText() {
} }
function usage() { function usage() {
return [ return [
"启点读书签到插件 v2.14.0", "启点读书签到插件 v2.15.0",
"【一级菜单】", "【一级菜单】",
"账号管理:启点账号", "账号管理:启点账号",
"执行查询:启点查询", "执行查询:启点查询",
@@ -917,19 +917,28 @@ function displayMsg(msg) {
return msg return msg
} }
function accountName(uid, remarks) { function accountName(uid, remarks) {
return maskUid(uid) + (remarks && remarks[uid] ? "" + remarks[uid] + "" : "") return maskUid(uid) + (remarks && remarks[uid] ? "[" + remarks[uid] + "]" : "")
}
function compactTaskMsg(msg) {
msg = displayMsg(msg)
msg = msg.replace(/^完全体任务完成:/, "")
msg = msg.replace(/^部分任务失败:/, "")
return msg
} }
function formatResultLine(uid, r, remarks, emptyText) { function formatResultLine(uid, r, remarks, emptyText) {
var name = accountName(uid, remarks) var name = accountName(uid, remarks)
if (!r) return " " + name + ":⚪ " + (emptyText || "暂无执行记录") if (!r) return "- " + name + ":⚪ " + (emptyText || "暂无执行记录")
return "• " + name + "" + (r.ok ? "✅ " : "❌ ") + displayMsg(r.msg) + (r.time ? "\n 时间:" + shortTime(r.time) : "") var status = r.ok ? "✅" : "❌"
var line = "- " + name + "" + status + " " + compactTaskMsg(r.msg)
if (r.time) line += "\n 时间:" + shortTime(r.time)
return line
} }
function formatRunSummary(log, label, key) { function formatRunSummary(log, label, key) {
log = log || {} log = log || {}
var lines = [] var lines = []
lines.push((label || "最近批次") + (key ? "" + key : "")) lines.push("批次:" + (key || log.runId || "最近") + "" + (label || "最近记录") + "")
lines.push("来源" + sourceName(log.source) + " 时间" + shortTime(log.finishedAt)) lines.push("时间" + shortTime(log.finishedAt) + " 来源" + sourceName(log.source))
lines.push("汇总:✅ " + (log.okCount || 0) + " " + (log.failCount || 0) + " 总计 " + (log.total || 0)) lines.push("统计:成功 " + (log.okCount || 0) + " / 失败 " + (log.failCount || 0) + " / 总计 " + (log.total || 0))
return lines return lines
} }
function queryStatus(targetUid) { function queryStatus(targetUid) {
@@ -946,21 +955,20 @@ function queryStatus(targetUid) {
if (!uids.length) return "当前用户还没有保存启点读书CK" if (!uids.length) return "当前用户还没有保存启点读书CK"
var archiveInfo = latestArchiveForVisible(uids) var archiveInfo = latestArchiveForVisible(uids)
var useArchive = archiveInfo && (!run || !run.finishedAt) var useArchive = archiveInfo && (!run || !run.finishedAt)
var lines = [] var lines = [targetUid ? "启点查询|单账号" : "启点查询|最近签到"]
if (useArchive) { if (useArchive) {
var arun = archiveInfo.log || {} var arun = archiveInfo.log || {}
lines.push(targetUid ? "启点单账号最近签到记录" : "启点最近签到记录") lines = lines.concat(formatRunSummary(arun, "归档", archiveInfo.key))
lines = lines.concat(formatRunSummary(arun, "归档批次", archiveInfo.key)) lines.push("明细:")
lines.push("结果明细:")
for (var ai = 0; ai < uids.length; ai++) lines.push(formatResultLine(uids[ai], archiveInfo.itemMap[String(uids[ai])], remarks, "归档中暂无该账号记录")) for (var ai = 0; ai < uids.length; ai++) lines.push(formatResultLine(uids[ai], archiveInfo.itemMap[String(uids[ai])], remarks, "归档中暂无该账号记录"))
return lines.join("\n") return lines.join("\n")
} }
lines.push(targetUid ? "启点单账号最近签到记录" : "启点最近签到记录") if (!targetUid && run && run.finishedAt) lines = lines.concat(formatRunSummary(run, "最近", ""))
if (!targetUid && run && run.finishedAt) lines = lines.concat(formatRunSummary(run, "最近批次", ""))
else if (run && run.finishedAt) lines.push("时间:" + shortTime(run.finishedAt) + " 来源:" + sourceName(run.source)) else if (run && run.finishedAt) lines.push("时间:" + shortTime(run.finishedAt) + " 来源:" + sourceName(run.source))
lines.push("结果明细:") else lines.push("批次:暂无")
lines.push("明细:")
for (var i = 0; i < uids.length; i++) lines.push(formatResultLine(uids[i], last[uids[i]], remarks, "暂无执行记录")) for (var i = 0; i < uids.length; i++) lines.push(formatResultLine(uids[i], last[uids[i]], remarks, "暂无执行记录"))
if (archiveInfo) lines.push("历史归档:" + archiveInfo.key + "(可用于判断最近一次签到)") if (archiveInfo) lines.push("归档:" + archiveInfo.key)
return lines.join("\n") return lines.join("\n")
} }
@@ -980,7 +988,7 @@ function accountMenuText(store, bind) {
} }
} }
lines.push("0、添加/更新账号") lines.push("0、添加/更新账号")
lines.push("负编号删除账号,例如 -1") lines.push("-删除账号,例如 -1")
lines.push("q、退出") lines.push("q、退出")
return lines.join("\n") return lines.join("\n")
} }
@@ -1060,7 +1068,7 @@ function accountDetailText(uid, store, bind) {
function accountConfigText(uid, store, bind) { function accountConfigText(uid, store, bind) {
var detail = accountDetailText(uid, store, bind) var detail = accountDetailText(uid, store, bind)
if (/^(无权|未找到)/.test(detail)) return detail if (/^(无权|未找到)/.test(detail)) return detail
return detail + "\n\n账号操作:\n1、修改备注\n2、任务配置\n3、立即签到该账号\n-1、删除该账号\nq、返回/退出" return detail + "\n\n账号操作:\n1、修改备注\n2、任务配置\n3、立即签到该账号\n-删除该账号\nq、返回/退出"
} }
function accountConfigMenu(uid, store, bind) { function accountConfigMenu(uid, store, bind) {
if (!uid) return reply("未选择账号,已退出") if (!uid) return reply("未选择账号,已退出")
+26 -18
View File
@@ -4,7 +4,7 @@
//[author: Hermes] //[author: Hermes]
//[service: BOSS] //[service: BOSS]
//[class: 工具类] //[class: 工具类]
// [version: 2.14.0] // [version: 2.15.0]
// [platform: web,qq,wx,tg,tb,fs,we] // [platform: web,qq,wx,tg,tb,fs,we]
// [public: false] // [public: false]
// [price: 0] // [price: 0]
@@ -279,7 +279,7 @@ function contentText() {
} }
function usage() { function usage() {
return [ return [
"启点读书签到插件 v2.14.0", "启点读书签到插件 v2.15.0",
"【一级菜单】", "【一级菜单】",
"账号管理:启点账号", "账号管理:启点账号",
"执行查询:启点查询", "执行查询:启点查询",
@@ -917,19 +917,28 @@ function displayMsg(msg) {
return msg return msg
} }
function accountName(uid, remarks) { function accountName(uid, remarks) {
return maskUid(uid) + (remarks && remarks[uid] ? "" + remarks[uid] + "" : "") return maskUid(uid) + (remarks && remarks[uid] ? "[" + remarks[uid] + "]" : "")
}
function compactTaskMsg(msg) {
msg = displayMsg(msg)
msg = msg.replace(/^完全体任务完成:/, "")
msg = msg.replace(/^部分任务失败:/, "")
return msg
} }
function formatResultLine(uid, r, remarks, emptyText) { function formatResultLine(uid, r, remarks, emptyText) {
var name = accountName(uid, remarks) var name = accountName(uid, remarks)
if (!r) return " " + name + ":⚪ " + (emptyText || "暂无执行记录") if (!r) return "- " + name + ":⚪ " + (emptyText || "暂无执行记录")
return "• " + name + "" + (r.ok ? "✅ " : "❌ ") + displayMsg(r.msg) + (r.time ? "\n 时间:" + shortTime(r.time) : "") var status = r.ok ? "✅" : "❌"
var line = "- " + name + "" + status + " " + compactTaskMsg(r.msg)
if (r.time) line += "\n 时间:" + shortTime(r.time)
return line
} }
function formatRunSummary(log, label, key) { function formatRunSummary(log, label, key) {
log = log || {} log = log || {}
var lines = [] var lines = []
lines.push((label || "最近批次") + (key ? "" + key : "")) lines.push("批次:" + (key || log.runId || "最近") + "" + (label || "最近记录") + "")
lines.push("来源" + sourceName(log.source) + " 时间" + shortTime(log.finishedAt)) lines.push("时间" + shortTime(log.finishedAt) + " 来源" + sourceName(log.source))
lines.push("汇总:✅ " + (log.okCount || 0) + " " + (log.failCount || 0) + " 总计 " + (log.total || 0)) lines.push("统计:成功 " + (log.okCount || 0) + " / 失败 " + (log.failCount || 0) + " / 总计 " + (log.total || 0))
return lines return lines
} }
function queryStatus(targetUid) { function queryStatus(targetUid) {
@@ -946,21 +955,20 @@ function queryStatus(targetUid) {
if (!uids.length) return "当前用户还没有保存启点读书CK" if (!uids.length) return "当前用户还没有保存启点读书CK"
var archiveInfo = latestArchiveForVisible(uids) var archiveInfo = latestArchiveForVisible(uids)
var useArchive = archiveInfo && (!run || !run.finishedAt) var useArchive = archiveInfo && (!run || !run.finishedAt)
var lines = [] var lines = [targetUid ? "启点查询|单账号" : "启点查询|最近签到"]
if (useArchive) { if (useArchive) {
var arun = archiveInfo.log || {} var arun = archiveInfo.log || {}
lines.push(targetUid ? "启点单账号最近签到记录" : "启点最近签到记录") lines = lines.concat(formatRunSummary(arun, "归档", archiveInfo.key))
lines = lines.concat(formatRunSummary(arun, "归档批次", archiveInfo.key)) lines.push("明细:")
lines.push("结果明细:")
for (var ai = 0; ai < uids.length; ai++) lines.push(formatResultLine(uids[ai], archiveInfo.itemMap[String(uids[ai])], remarks, "归档中暂无该账号记录")) for (var ai = 0; ai < uids.length; ai++) lines.push(formatResultLine(uids[ai], archiveInfo.itemMap[String(uids[ai])], remarks, "归档中暂无该账号记录"))
return lines.join("\n") return lines.join("\n")
} }
lines.push(targetUid ? "启点单账号最近签到记录" : "启点最近签到记录") if (!targetUid && run && run.finishedAt) lines = lines.concat(formatRunSummary(run, "最近", ""))
if (!targetUid && run && run.finishedAt) lines = lines.concat(formatRunSummary(run, "最近批次", ""))
else if (run && run.finishedAt) lines.push("时间:" + shortTime(run.finishedAt) + " 来源:" + sourceName(run.source)) else if (run && run.finishedAt) lines.push("时间:" + shortTime(run.finishedAt) + " 来源:" + sourceName(run.source))
lines.push("结果明细:") else lines.push("批次:暂无")
lines.push("明细:")
for (var i = 0; i < uids.length; i++) lines.push(formatResultLine(uids[i], last[uids[i]], remarks, "暂无执行记录")) for (var i = 0; i < uids.length; i++) lines.push(formatResultLine(uids[i], last[uids[i]], remarks, "暂无执行记录"))
if (archiveInfo) lines.push("历史归档:" + archiveInfo.key + "(可用于判断最近一次签到)") if (archiveInfo) lines.push("归档:" + archiveInfo.key)
return lines.join("\n") return lines.join("\n")
} }
@@ -980,7 +988,7 @@ function accountMenuText(store, bind) {
} }
} }
lines.push("0、添加/更新账号") lines.push("0、添加/更新账号")
lines.push("负编号删除账号,例如 -1") lines.push("-删除账号,例如 -1")
lines.push("q、退出") lines.push("q、退出")
return lines.join("\n") return lines.join("\n")
} }
@@ -1060,7 +1068,7 @@ function accountDetailText(uid, store, bind) {
function accountConfigText(uid, store, bind) { function accountConfigText(uid, store, bind) {
var detail = accountDetailText(uid, store, bind) var detail = accountDetailText(uid, store, bind)
if (/^(无权|未找到)/.test(detail)) return detail if (/^(无权|未找到)/.test(detail)) return detail
return detail + "\n\n账号操作:\n1、修改备注\n2、任务配置\n3、立即签到该账号\n-1、删除该账号\nq、返回/退出" return detail + "\n\n账号操作:\n1、修改备注\n2、任务配置\n3、立即签到该账号\n-删除该账号\nq、返回/退出"
} }
function accountConfigMenu(uid, store, bind) { function accountConfigMenu(uid, store, bind) {
if (!uid) return reply("未选择账号,已退出") if (!uid) return reply("未选择账号,已退出")
+10 -10
View File
@@ -333,11 +333,11 @@ test('query falls back to archived sign results after daily log was cleared', ()
qdreader_archive_json: JSON.stringify({ '2026-05-18': archiveRun }), qdreader_archive_json: JSON.stringify({ '2026-05-18': archiveRun }),
}; };
const r = runPlugin({ content: '启点查询', store, userId: 'user-a', listens: ['1'] }); const r = runPlugin({ content: '启点查询', store, userId: 'user-a', listens: ['1'] });
assert.match(r.replies[1], /启点最近签到记录/); assert.match(r.replies[1], /启点查询|最近签到/);
assert.match(r.replies[1], /归档批次:2026-05-18/); assert.match(r.replies[1], /批次:2026-05-18(归档)/);
assert.match(r.replies[1], /汇总:✅ 1 1 总计 2/); assert.match(r.replies[1], /统计:成功 1 \/ 失败 1 \/ 总计 2/);
assert.match(r.replies[1], / 12\*\*\*45(主号):✅ 签到成功/); assert.match(r.replies[1], /- 12\*\*\*45\[主号\]:✅ 签到成功/);
assert.match(r.replies[1], / 67\*\*\*90(副号):❌ Cookie失效/); assert.match(r.replies[1], /- 67\*\*\*90\[副号\]:❌ Cookie失效/);
}); });
test('query output shortens timestamps and long raw messages for readability', () => { test('query output shortens timestamps and long raw messages for readability', () => {
@@ -602,10 +602,10 @@ test('query command shows last sign log not account management', () => {
}; };
const r = runPlugin({ content: '启点查询', store, userId: 'user-a', listens: ['1'] }); const r = runPlugin({ content: '启点查询', store, userId: 'user-a', listens: ['1'] });
assert.match(r.replies[0], /启点查询/); assert.match(r.replies[0], /启点查询/);
assert.match(r.replies[1], /启点最近签到记录/); assert.match(r.replies[1], /启点查询|最近签到/);
assert.match(r.replies[1], /最近批次/); assert.match(r.replies[1], /批次:最近(最近)/);
assert.match(r.replies[1], /来源:定时任务/); assert.match(r.replies[1], /来源:定时任务/);
assert.match(r.replies[1], /汇总:✅ 1 1 总计 2/); assert.match(r.replies[1], /统计:成功 1 \/ 失败 1 \/ 总计 2/);
assert.match(r.replies[1], /12\*\*\*45/); assert.match(r.replies[1], /12\*\*\*45/);
assert.match(r.replies[1], /主号/); assert.match(r.replies[1], /主号/);
assert.match(r.replies[1], /签到成功/); assert.match(r.replies[1], /签到成功/);
@@ -629,7 +629,7 @@ test('query menu can inspect a single bound account', () => {
assert.match(r.replies[1], /请选择要查询的账号/); assert.match(r.replies[1], /请选择要查询的账号/);
assert.match(r.replies[1], /1\. 12\*\*\*45/); assert.match(r.replies[1], /1\. 12\*\*\*45/);
assert.match(r.replies[1], /2\. 67\*\*\*90/); assert.match(r.replies[1], /2\. 67\*\*\*90/);
assert.match(r.replies[2], /启点单账号最近签到记录/); assert.match(r.replies[2], /启点查询|单账号/);
assert.match(r.replies[2], /67\*\*\*90/); assert.match(r.replies[2], /67\*\*\*90/);
assert.match(r.replies[2], /副号/); assert.match(r.replies[2], /副号/);
assert.doesNotMatch(r.replies[2], /12\*\*\*45/); assert.doesNotMatch(r.replies[2], /12\*\*\*45/);
@@ -683,7 +683,7 @@ test('account menu first screen lists accounts and positive number opens config'
assert.match(r.replies[0], /账号列表如下/); assert.match(r.replies[0], /账号列表如下/);
assert.match(r.replies[0], /1、12\*\*\*45\[主号\]/); assert.match(r.replies[0], /1、12\*\*\*45\[主号\]/);
assert.match(r.replies[0], /2、67\*\*\*90\[副号\]/); assert.match(r.replies[0], /2、67\*\*\*90\[副号\]/);
assert.match(r.replies[0], /负编号删除账号/); assert.match(r.replies[0], /-删除账号,例如 -1/);
assert.match(r.replies[1], /启点账号详情/); assert.match(r.replies[1], /启点账号详情/);
assert.match(r.replies[1], /67\*\*\*90/); assert.match(r.replies[1], /67\*\*\*90/);
assert.match(r.replies[1], /账号操作/); assert.match(r.replies[1], /账号操作/);