feat(qdreader): streamline account menu

This commit is contained in:
2026-05-22 22:41:05 +08:00
parent a7792012a1
commit 56808b9f18
3 changed files with 188 additions and 82 deletions
+65 -30
View File
@@ -4,7 +4,7 @@
//[author: Hermes]
//[service: BOSS]
//[class: 工具类]
// [version: 2.12.0]
// [version: 2.13.0]
// [platform: web,qq,wx,tg,tb,fs,we]
// [public: false]
// [price: 0]
@@ -279,7 +279,7 @@ function contentText() {
}
function usage() {
return [
"启点读书签到插件 v2.12.0",
"启点读书签到插件 v2.13.0",
"【一级菜单】",
"账号管理:启点账号",
"执行查询:启点查询",
@@ -968,18 +968,22 @@ function listenInput(timeoutMs) {
try { if (typeof sender !== "undefined" && sender && sender.listen) return trim(sender.listen(timeoutMs || 60000)) } catch (e) {}
return ""
}
function accountMenuText() {
return [
"启点账号管理",
"1. 查看账号",
"2. 添加/更新账号",
"3. 账号详情/修改备注",
"4. 账号任务配置",
"5. 删除账号",
"6. 清空账号",
"q. 退出",
"请回复序号"
].join("\n")
function accountMenuText(store, bind) {
var uids = visibleUids(store || getStore(), bind || getBindStore(), false)
var remarks = remarksForStore(store || {})
var lines = ["启点账号管理"]
if (!uids.length) lines.push("当前用户还没有保存启点读书CK")
else {
lines.push("现有账号:")
for (var i = 0; i < uids.length; i++) {
var uid = uids[i]
lines.push((i + 1) + ". " + maskUid(uid) + (remarks[uid] ? "" + remarks[uid] + "" : ""))
}
}
lines.push("回复编号进入账号配置,例如 1")
lines.push("回复负编号删除账号,例如 -1")
lines.push("回复 a 添加/更新账号;all 清空账号;q 退出")
return lines.join("\n")
}
function queryMenuText() {
return [
@@ -1054,25 +1058,43 @@ function accountDetailText(uid, store, bind) {
"修改备注请回复新备注名,发送 清空 可删除备注,发送 q 退出"
].join("\n")
}
function accountConfigText(uid, store, bind) {
var detail = accountDetailText(uid, store, bind)
if (/^(无权|未找到)/.test(detail)) return detail
return detail + "\n\n账号配置:\n1. 修改备注\n2. 任务配置\n3. 立即签到该账号\n-1. 删除该账号\nq. 返回/退出\n请回复选项"
}
function accountConfigMenu(uid, store, bind) {
if (!uid) return reply("未选择账号,已退出")
var cfg = accountConfigText(uid, store, bind)
reply(cfg)
if (/^(无权|未找到)/.test(cfg)) return
var op = listenInput(60000)
if (!op || /^(q|退出|取消|返回)$/i.test(op)) return reply("已退出")
if (/^(1|备注|改名|名称)$/i.test(op)) {
reply("请回复新备注名;发送 清空 可删除备注;q 退出")
var remark = listenInput(60000)
if (!remark || /^(q|退出|取消)$/i.test(remark)) return reply("已退出")
var remarks = remarksForStore(store)
if (/^(清空|删除|none)$/i.test(remark)) delete remarks[uid]; else remarks[uid] = remark.slice(0, 30)
setRemarkStore(remarks)
return reply("已更新备注:" + maskUid(uid) + (remarks[uid] ? "" + remarks[uid] + "" : ""))
}
if (/^(2|任务|配置|开关)$/i.test(op)) return taskMenuForUid(uid)
if (/^(3|签到|执行|立即)$/i.test(op)) return reply(signAll(uid, false, "menu"))
if (/^-1$/.test(op) || /^(删除|delete|del|rm)$/i.test(op)) return reply(handleDelete("删除 " + uid, store, bind))
return reply("未识别选项,已退出")
}
function accountDetailMenu(store, bind) {
var uid = chooseUid(store, bind, "请选择要查看/修改备注的账号:")
if (!uid) return reply("已退出")
var detail = accountDetailText(uid, store, bind)
reply(detail)
if (/^(无权|未找到)/.test(detail)) return
var remark = listenInput(60000)
if (!remark || /^(q|退出|取消)$/i.test(remark)) return reply("已退出")
var remarks = remarksForStore(store)
if (/^(清空|删除|none)$/i.test(remark)) delete remarks[uid]; else remarks[uid] = remark.slice(0, 30)
setRemarkStore(remarks)
return reply("已更新备注:" + maskUid(uid) + (remarks[uid] ? "" + remarks[uid] + "" : ""))
return accountConfigMenu(uid, store, bind)
}
function accountMenu(store, bind) {
reply(accountMenuText())
var uids = visibleUids(store, bind, false)
reply(accountMenuText(store, bind))
var op = listenInput(60000)
if (!op || /^(q|退出|取消)$/i.test(op)) return reply("已退出")
if (/^(1|查看|查询|列表|账号)$/i.test(op)) return reply(accountListText(store, bind))
if (/^(2|添加|新增|更新)$/i.test(op)) {
if (/^(a|add|添加|新增|更新)$/i.test(op)) {
reply("请在60秒内发送 QX 抓到的完整 Cookieq:退出)")
var ck = listenInput(60000)
if (!ck || /^(q|退出|取消)$/i.test(ck)) return reply("已退出")
@@ -1080,18 +1102,31 @@ function accountMenu(store, bind) {
var remarkMsg = (save.ok && save.uids.length === 1) ? maybePromptRemark(save.uids[0], store) : ""
return reply(save.text + remarkMsg)
}
if (/^(3|详情|备注|改名|名称)$/i.test(op)) return accountDetailMenu(store, bind)
if (/^(4|任务|配置|开关)$/i.test(op)) {
if (/^(all|清空|全部)$/i.test(op)) return reply(handleDelete("删除 all", store, bind))
var n = parseInt(op, 10)
if (!isNaN(n) && String(n) === op.replace(/^\+/, "")) {
if (n > 0) {
if (n > uids.length) return reply("编号无效,已退出")
return accountConfigMenu(uids[n - 1], store, bind)
}
if (n < 0) {
var idx = Math.abs(n)
if (idx > uids.length) return reply("编号无效,已退出")
return reply(handleDelete("删除 " + uids[idx - 1], store, bind))
}
}
if (/^(查看|查询|列表|账号)$/i.test(op)) return reply(accountListText(store, bind))
if (/^(详情|备注|改名|名称)$/i.test(op)) return accountDetailMenu(store, bind)
if (/^(任务|配置|开关)$/i.test(op)) {
var taskUid = chooseUid(store, bind, "请选择要配置任务的账号:")
if (!taskUid) return reply("已退出")
return taskMenuForUid(taskUid)
}
if (/^(5|删除)$/i.test(op)) {
if (/^(删除)$/i.test(op)) {
var uid = chooseUid(store, bind, "请选择要删除的账号:")
if (!uid) return reply("已退出")
return reply(handleDelete("删除 " + uid, store, bind))
}
if (/^(6|清空|全部)$/i.test(op)) return reply(handleDelete("删除 all", store, bind))
return reply("未识别选项,已退出")
}
function queryMenu() {