From b3e1cb739d156b840f1c18bf02fc5b2414a68844 Mon Sep 17 00:00:00 2001 From: shaoying Date: Wed, 21 Apr 2021 23:18:42 +0800 Subject: [PATCH] add daemon --- frame.js | 6 +++++- lib/core.js | 3 ++- lib/user.js | 2 +- panel/Header.js | 10 +++++++--- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/frame.js b/frame.js index 73a1d3e2..54169a10 100644 --- a/frame.js +++ b/frame.js @@ -18,7 +18,11 @@ Volcanos("onengine", {help: "解析引擎", list: [], _init: function(can, meta, search: function(event, can, msg, panel, cmds, cb) { var sub, mod = can, fun = can, key = ""; can.core.List(cmds[1].split("."), function(value) { fun && (sub = mod, mod = fun, fun = mod[value], key = value) - }); if (!sub || !mod || !fun) { can.base.Warn("not found", cmds[1]); return } + }); if (!sub || !mod || !fun) { + can.base.Warn("not found", cmds[1]) + cb(msg.Echo("warn: ", "not found: ", cmds[1])) + return + } return can.core.CallFunc(fun, { "event": event, "can": sub, "msg": msg, diff --git a/lib/core.js b/lib/core.js index 1ceece73..0680b7e9 100644 --- a/lib/core.js +++ b/lib/core.js @@ -166,6 +166,7 @@ Volcanos("core", {help: "数据结构", }), CallFunc: shy("调用器", function(func, args, mod) { args = args||{} var can = args["can"]||args[0], msg = args["msg"]||args[1] + var cmds = args["cmds"]||[] func = typeof func == "function"? func: typeof func == "string"? this.Value(mod||can, func): typeof func == "object" && func.slice? this.Value(func[0], this.Keys(func.slice(1))): null @@ -174,7 +175,7 @@ Volcanos("core", {help: "数据结构", var cb = args["cb"] var ls = func.toString().split(")")[0].split("(")[1].split(",") var list = [], echo = false; this.List(ls, function(item, index) { item = item.trim() - list.push(args[item] || args[index] || msg&&msg.Option&&msg.Option(item) || can&&can.Conf&&can.Conf(item) || null) + list.push(args[item] || msg&&msg.Option&&msg.Option(item) || can&&can.Conf&&can.Conf(item) || cmds[index] || args[index] || null) if (item == "cb") { echo = true } }) diff --git a/lib/user.js b/lib/user.js index 58371b85..8a4fd712 100644 --- a/lib/user.js +++ b/lib/user.js @@ -78,7 +78,7 @@ Volcanos("user", {help: "用户模块", agent: { ] }]); can.onmotion.story(can, ui.first) ui.Close = function() { can.page.Remove(can, ui.first), timer.stop = true } - var timer = can.core.Timer({interval: 100, length: (meta.duration||1000)/100}, function(event, interval, index) { + var timer = can.core.Timer({interval: 100, length: (parseInt(meta.duration||1000))/100}, function(event, interval, index) { if (index > 20) { ui.duration.innerHTML = parseInt(index/10)+"."+(index%10)+"s..." } }, ui.Close) diff --git a/panel/Header.js b/panel/Header.js index 1aa9dafd..1b3f405f 100644 --- a/panel/Header.js +++ b/panel/Header.js @@ -24,6 +24,10 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, can.page.Modify(can, can._output, {onmouseover: function(event) { can.menu && can.page.Remove(can, can.menu.first) }}) + + can.core.Timer(1000, function() { + can.onimport._daemon(can, msg, target) + }) }, _title: function(can, msg, target) { can.user.title(can.user.Search(can, "title")||can.user.Search(can, "pod")) @@ -80,9 +84,9 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, }) }, - _daemon: function(can, name, cb) { - can.misc.WSS(can, {type: "chrome", name: name}, cb||function(event, msg, cmd, arg) { - msg && can.run(event, ["search"].concat(msg["detail"]||[]), function(msg) { + _daemon: function(can, msg, target) { + can.misc.WSS(can, {type: "chrome", name: can.user.Search(can, "daemon")}, function(event, msg, cmd, arg) { if (!msg) { return } + can.run(event, ["search"].concat(msg["detail"]||[]), function(msg) { msg.Reply() }) })