feat(qdreader): add one-click task toggles
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
//[author: Hermes]
|
||||
//[service: BOSS]
|
||||
//[class: 工具类]
|
||||
//[version: 2.7.0]
|
||||
//[version: 2.8.0]
|
||||
//[platform: web,qq,wx,tg,tb,fs,we]
|
||||
//[public: false]
|
||||
//[price: 0]
|
||||
@@ -276,7 +276,7 @@ function contentText() {
|
||||
}
|
||||
function usage() {
|
||||
return [
|
||||
"启点读书签到插件 v2.7.0",
|
||||
"启点读书签到插件 v2.8.0",
|
||||
"【一级菜单】",
|
||||
"账号管理:启点账号",
|
||||
"执行查询:启点查询",
|
||||
@@ -522,7 +522,7 @@ function taskStatusLines(uid) {
|
||||
if (t.sundayOnly) suffix += "(仅周日执行)"
|
||||
lines.push((i + 1) + ". " + t.label + ":" + (enabled ? "开启" : "关闭") + suffix)
|
||||
}
|
||||
lines.push("回复:序号 on/off 切换,例如 2 on;q 退出")
|
||||
lines.push("回复:序号 on/off 切换,例如 2 on;all on 一键开启;all off 一键关闭;q 退出")
|
||||
return lines.join("\n")
|
||||
}
|
||||
function taskMenuForUid(uid) {
|
||||
@@ -530,14 +530,28 @@ function taskMenuForUid(uid) {
|
||||
reply(taskStatusLines(uid))
|
||||
var op = listenInput(60000)
|
||||
if (!op || /^(q|退出|取消)$/i.test(op)) return reply("已退出")
|
||||
var all = getTaskPrefs()
|
||||
var prefs = isObject(all[String(uid)]) ? all[String(uid)] : {}
|
||||
var allMatch = op.match(/^(all|全部|所有|一键|全开|全关)\s*(on|off|开启|关闭|启用|禁用|1|0)?$/i)
|
||||
if (allMatch) {
|
||||
var enableAll = /^(全开)$/i.test(allMatch[1]) || /^(on|开启|启用|1)$/i.test(allMatch[2] || "")
|
||||
if (/^(全关)$/i.test(allMatch[1])) enableAll = false
|
||||
if (!allMatch[2] && /^(all|全部|所有|一键)$/i.test(allMatch[1])) return reply("请指定 all on 或 all off")
|
||||
for (var ai = 0; ai < QD_TASKS.length; ai++) {
|
||||
var at = QD_TASKS[ai]
|
||||
if (at.builtin || !at.settingKey) continue
|
||||
prefs[at.key] = !!enableAll
|
||||
}
|
||||
all[String(uid)] = prefs
|
||||
setTaskPrefs(all)
|
||||
return reply("已" + (enableAll ? "一键开启" : "一键关闭") + "账号 " + maskUid(uid) + " 的全部可选任务\n" + taskStatusLines(uid))
|
||||
}
|
||||
var m = op.match(/^(\d+)\s*(on|off|开启|关闭|启用|禁用|1|0)?$/i)
|
||||
if (!m) return reply("未识别选项,已退出")
|
||||
var idx = parseInt(m[1], 10) - 1
|
||||
if (idx < 0 || idx >= QD_TASKS.length) return reply("编号无效,已退出")
|
||||
var task = QD_TASKS[idx]
|
||||
if (task.builtin || !task.settingKey) return reply(task.label + " 为固定任务,不能关闭")
|
||||
var all = getTaskPrefs()
|
||||
var prefs = isObject(all[String(uid)]) ? all[String(uid)] : {}
|
||||
var currently = prefs[task.key] === true || prefs[task.key] === "true" || prefs[task.key] === 1 || prefs[task.key] === "1"
|
||||
var enable = m[2] ? /^(on|开启|启用|1)$/i.test(m[2]) : !currently
|
||||
prefs[task.key] = !!enable
|
||||
|
||||
Reference in New Issue
Block a user