From 43af770a5476da0c115825a139b472b327b45d31 Mon Sep 17 00:00:00 2001 From: "shylinux@163.com" Date: Tue, 13 Sep 2022 11:42:16 +0800 Subject: [PATCH] opt some --- frame.js | 2 +- lib/misc.js | 3 ++- plugin/local/code/xterm.js | 10 ++++++++-- plugin/local/wiki/word.css | 14 ++++++++------ plugin/local/wiki/word.js | 2 ++ plugin/state.js | 7 +++++-- 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/frame.js b/frame.js index f1b4ccfa..093002fa 100644 --- a/frame.js +++ b/frame.js @@ -216,7 +216,7 @@ Volcanos(chat.ONAPPEND, {help: "渲染引擎", _init: function(can, meta, list, var cb = meta[item]||meta[chat._ENGINE]; cb? can.core.CallFunc(cb, {event: event, can: can, button: item}): can.run(event, [ctx.ACTION, item].concat(can.sup.Input())) } - }}: item.length > 0? /*列表*/ {type: html.SELECT, name: item[0], values: item.slice(1), value: can.sup[item[0]], onchange: function(event) { + }}: item.length > 0? /*列表*/ {type: html.SELECT, name: item[0], values: item.slice(1), value: can.sup&&can.sup[item[0]]||"", onchange: function(event) { var which = item[event.target.selectedIndex+1] can.core.CallFunc(meta[which], [event, can, which]) can.core.CallFunc(meta[item[0]], [event, can, item[0], which]) diff --git a/lib/misc.js b/lib/misc.js index aeb7b90e..b19d2d0c 100644 --- a/lib/misc.js +++ b/lib/misc.js @@ -163,7 +163,8 @@ Volcanos("misc", {help: "通信协议", Message: function(event, can) { var msg try { var data = JSON.parse(event.data) } catch (e) { var data = {detail: [event.data]} } var msg = can.request(event); msg.Reply = function() { // 回复命令 - msg.Option({_handle: true, _source: (msg[ice.MSG_TARGET]||[]).reverse().slice(1).join(ice.PT)||"", _target: (msg[ice.MSG_SOURCE]||[]).reverse().join(ice.PT)}) + msg.Option({_handle: true, _target: (msg[ice.MSG_SOURCE]||[]).reverse().join(ice.PT)}) + msg._source = (msg[ice.MSG_TARGET]||[]).reverse().slice(1)||[] msg.result = (msg.result||[]).concat(can.core.List(arguments)), can.misc.Log(html.WSS, ice.MSG_RESULT, msg.result, msg) delete(msg._event), delete(msg._can), socket.send(JSON.stringify(msg)) }, msg.detail = data.detail, msg.Copy(data) diff --git a/plugin/local/code/xterm.js b/plugin/local/code/xterm.js index 1779a00d..eeaf9de8 100644 --- a/plugin/local/code/xterm.js +++ b/plugin/local/code/xterm.js @@ -22,6 +22,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar item._menu = shy(can.ondetail, can.ondetail.list, function(event, button, meta) { can.request(event, item, item.extra), meta[button](event, can, button, item) }) + item.nick = item.name+": "+item.type return item._item = can.onimport.item(can, item, function(event) { item._tabs? item._tabs.click(): item._tabs = can.onimport.tabs(can, [item], function(event) { can.onimport._connect(can, item) @@ -30,7 +31,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar }, _create: function(can, args, data) { can.runAction({}, mdb.CREATE, args, function(msg) { - var current = can.onimport._item(can, {hash: msg.Result(), name: msg.Option(mdb.NAME), extra: data}) + var current = can.onimport._item(can, {hash: msg.Result(), name: msg.Option(mdb.NAME), type: msg.Option(mdb.TYPE), extra: data}) can.page.insertBefore(can, current, can.ui.project.firstChild).click() }) }, @@ -73,6 +74,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar term.onTitleChange(function(title) { can.isCmdMode() && can.user.title(title) }) term.onCursorMove(function(e) { can.onexport.term(can, term) }) + can._current = item.hash can.term[item.hash] = item._term = target._term = term, term._target = target, term._item = item can.runAction(can.request(event, item), "select"), item._term.focus() return can.onimport._plug(can, item), can.onexport.term(can, term) @@ -95,7 +97,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar } }, }) -Volcanos(chat.ONACTION, {help: "操作数据", list: [mdb.CREATE, lex.SPLIT, mdb.PRUNES], +Volcanos(chat.ONACTION, {help: "操作数据", list: [mdb.CREATE, lex.SPLIT, mdb.PRUNES, "install"], _trans: {split: "分屏", theme: "主题"}, create: function(event, can) { can.user.input(event, can, [mdb.TYPE, mdb.NAME, "background", ctx.INDEX, ctx.ARGS], function(args, data) { @@ -113,6 +115,10 @@ Volcanos(chat.ONACTION, {help: "操作数据", list: [mdb.CREATE, lex.SPLIT, mdb }) }) }, + install: function(event, can) { + can.request(event, {"hash": can._current}) + can.runAction(event, "install") + }, }) Volcanos(chat.ONDETAIL, {help: "操作数据", list: ["share", "plugin", "theme", "rename", "remove"], share: function(event, can, button, item) { var msg = can.request(event); msg.Option("args", "") diff --git a/plugin/local/wiki/word.css b/plugin/local/wiki/word.css index ffb69e67..ec43a6a5 100644 --- a/plugin/local/wiki/word.css +++ b/plugin/local/wiki/word.css @@ -20,12 +20,14 @@ fieldset.word table.content { display:block; max-height:400px; } fieldset.word fieldset.story { margin:10px; } fieldset.word fieldset.story.full { margin:0px; } -body.white fieldset.word svg.story text { stroke:blue; fill:blue; } -body.white fieldset.word svg.story line { stroke:red; stroke-width:1; } -body.white fieldset.word svg.story path { stroke:red; stroke-width:1; } -fieldset.word svg.story text { stroke:yellow; fill:yellow; } -fieldset.word svg.story line { stroke:red; stroke-width:1; } -fieldset.word svg.story path { stroke:red; stroke-width:1; } +body.white fieldset.word svg.story.auto rect { stroke:blue; fill:yellow; } +body.white fieldset.word svg.story.auto text { stroke:blue; fill:blue; } +body.white fieldset.word svg.story.auto line { stroke:red; stroke-width:1; } +body.white fieldset.word svg.story.auto path { stroke:red; stroke-width:1; } +fieldset.word svg.story.auto rect { stroke:yellow; fill:black; } +fieldset.word svg.story.auto text { stroke:yellow; fill:yellow; } +fieldset.word svg.story.auto line { stroke:red; stroke-width:1; } +fieldset.word svg.story.auto path { stroke:red; stroke-width:1; } fieldset.word.float { padding:0; margin:0; width:-webkit-fill-available; position:fixed; left:0; top:0; z-index:10; } fieldset.word.float>div.action { display:contents; } diff --git a/plugin/local/wiki/word.js b/plugin/local/wiki/word.js index 3129bc3c..89d8e47e 100644 --- a/plugin/local/wiki/word.js +++ b/plugin/local/wiki/word.js @@ -100,6 +100,8 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar }) }, chart: function(can, data, target) { + if (!data.fg && !data.bg) { target.className.baseVal = "story auto" } + target.onclick = function(event) { can.runAction(can.request(event, data), "run", [data.index, "find", event.target.innerHTML]) } diff --git a/plugin/state.js b/plugin/state.js index 5cafc690..0b9dbc71 100644 --- a/plugin/state.js +++ b/plugin/state.js @@ -23,7 +23,10 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, conf, cb, ta _display: function(can, msg) { return can.onappend._output(can, msg, msg.Option(ice.MSG_DISPLAY)), true }, - _field: function(can, msg) { + _field: function(can, msg) { var opts = {} + can.page.Select(can, can._option, "input.args", function(target) { + var value = msg.Option(target.name); target.name && value && (opts[target.name] = value) + }) msg.Table(function(item) { item.type = chat.STORY, can.onappend._plugin(can, item, {type: chat.STORY, index: item.index, args: can.base.Obj(item[ice.ARG], [])}, function(sub, meta) { sub.Conf(can.base.Obj(item.conf)) if (sub.Conf("mode") == "simple") { (function() { @@ -35,7 +38,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, conf, cb, ta sub.ConfHeight(can.ConfHeight()) sub.ConfWidth(can.ConfWidth()-4*html.PLUGIN_MARGIN) sub.run = function(event, cmds, cb, silent) { - var res = can.request(event, can.Option(), {pid: msg.Option("pid")}) + var res = can.request(event, can.Option(), {pid: msg.Option("pid")}, opts) for (var i = 0; i < opt.length; i += 2) { res.Option(opt[i], opt[i+1]) } can.run(event, (msg[ice.MSG_PREFIX]||[]).concat(cmds), cb, true) }