From 43824fddb39e1f0a8d27e24e56e1e2c4b1ab3385 Mon Sep 17 00:00:00 2001 From: harveyshao Date: Thu, 20 Oct 2022 13:57:08 +0800 Subject: [PATCH] opt some --- frame.js | 53 +++++++++++++++---------------------- lib/user.js | 16 +++++------ plugin/local/code/inner.js | 2 +- plugin/local/code/vimer.css | 1 + plugin/local/code/vimer.js | 5 +++- 5 files changed, 36 insertions(+), 41 deletions(-) diff --git a/frame.js b/frame.js index eb0efa05..2820b215 100644 --- a/frame.js +++ b/frame.js @@ -187,7 +187,7 @@ Volcanos(chat.ONAPPEND, {help: "渲染引擎", _init: function(can, meta, list, meta.type != sub.Mode() && can.page.ClassList.add(can, field, sub.Mode()) meta.inputs && sub.onappend._option(sub, meta, sub._option, meta.msg) - if (meta.msg) { var msg = sub.request(); msg.Copy(can.base.Obj(meta.msg)), sub.onappend._output(sub, msg, msg.Option(ice.MSG_DISPLAY)||meta.feature.display) } + if (meta.msg) { var msg = sub.request(); msg.Copy(can.base.Obj(meta.msg)), sub.onappend._output(sub, msg, meta.display||msg.Option(ice.MSG_DISPLAY)||meta.feature.display) } can.page.Modify(can, sub._legend, kit.Dict(can.Conf("legend_event")||chat.ONMOUSEENTER, function(event) { can.user.carte(event, sub, sub.onaction, sub.onaction.list.concat([["所有"].concat(can.core.Item(meta.feature._trans))]), function(event, item, meta) { @@ -265,7 +265,7 @@ Volcanos(chat.ONAPPEND, {help: "渲染引擎", _init: function(can, meta, list, if (meta && meta.index && meta.index.indexOf("can.") == 0) { can.onengine._plugin(event, can, msg, can, can.misc.concat(can, [meta.index], cmds), function(msg) { if (can.base.isFunc(cb)) { can.core.CallFunc(cb, {can: can, msg: msg}); return } - !silent && can.onappend._output(can, msg, msg.Option(ice.MSG_DISPLAY)||meta.display||meta.feature.display) + !silent && can.onappend._output(can, msg, meta.display||msg.Option(ice.MSG_DISPLAY)||meta.feature.display) }) return } @@ -282,43 +282,34 @@ Volcanos(chat.ONAPPEND, {help: "渲染引擎", _init: function(can, meta, list, if (process && can.core.CallFunc([sub, chat.ONIMPORT, ice.MSG_PROCESS], {can: sub, msg: msg})) { return } if (process && can.core.CallFunc([can, chat.ONIMPORT, ice.MSG_PROCESS], {can: can, msg: msg})) { return } if (cmds && cmds[0] == ctx.ACTION && msg.Result() == "" && msg.Length() == 0) { return can.Update() } - !silent && can.onappend._output(can, msg, meta.display||msg.Option(ice.MSG_DISPLAY)||meta.feature.display, can._output, can._action) + !silent && can.onappend._output(can, msg, meta.display||msg.Option(ice.MSG_DISPLAY)||meta.feature.display) }) }, _output: function(can, msg, display, output, action, cb) { display = display||chat.PLUGIN_TABLE_JS, output = output||can._output - can._display = display - Volcanos(display, {_follow: can.core.Keys(can._follow, display), _target: output, _fields: can._target, _display: display, - _legend: can._legend, _option: can._option, _action: can._action, _output: can._output, _status: can._status, _root: can._root, + Volcanos(display, {_follow: can.core.Keys(can._follow, display), _target: output, _fields: can._target, + _legend: can._legend, _option: can._option, _action: can._action, _output: output, _status: can._status, Update: can.Update, Option: can.Option, Action: can.Action, Status: can.Status, - }, [display, chat.PLUGIN_TABLE_JS], function(table) { table.Conf(can.Conf()) - table.run = function(event, cmds, cb, silent) { var msg = can.request(event) - if (msg.RunAction(event, table, cmds)) { return } + }, [display, chat.PLUGIN_TABLE_JS], function(sub) { sub.Conf(can.Conf()) + sub.run = function(event, cmds, cb, silent) { + if (msg.RunAction(can.request(event), sub, cmds)) { return } return can.Update(event, can.Input(cmds, silent), cb, silent) - }, can._outputs && can._outputs.push(table), table.sup = can, table._msg = msg - - table._index = can._index - table.Mode(can.Mode()), table.Conf(table._args = can.base.ParseURL(table._display)) - table._trans = can.base.Copy(table._trans||{}, can.core.Value(table, "onaction._trans")) - if (table.onimport && can.base.isArray(table.onimport.list) && table.onimport.list.length > 0) { - can.onmotion.clear(can, can._option), can.onappend._option(can, {inputs: can.page.inputs(can, table.onimport.list) }) + }, can._outputs && can._outputs.push(sub), sub.sup = can, sub._root = can._root + sub._index = can._index, sub._msg = msg, sub.Conf(sub._args = can.base.ParseURL(display)), sub.Mode(can.Mode()), + + sub._trans = can.base.Copy(sub._trans||{}, can.core.Value(sub, "onaction._trans")) + if (sub.onimport && can.base.isArray(sub.onimport.list) && sub.onimport.list.length > 0) { + can.onmotion.clear(can, can._option), can.onappend._option(can, {inputs: can.page.inputs(can, sub.onimport.list) }) } - can.onmotion.clear(can, can._action) - can._display_output? can._display_output(table, msg): - can.core.CallFunc([table, chat.ONIMPORT, chat._INIT], {can: table, msg: msg, cb: function(msg) { - action === false || table.onappend._action(table, msg.Option(ice.MSG_ACTION)||can.Conf(ice.MSG_ACTION), action) - action === false || table.onappend._status(table, msg.Option(ice.MSG_STATUS)) - // action === false || table.onimport.tool(table, can.base.Obj(msg.Option(ice.MSG_TOOLKIT))) - var mode= ["float", "full", "cmd"]; for (var i in mode) { - if (can.page.ClassList.has(can, can._target, mode[i])) { table.onlayout[mode[i]](table); break } - } - can.page.Select(can, can._output, "input[type=button]", function(target) { - if (target.value == target.name) { target.value = can.user.trans(can, target.name) } - }) - table.onappend.tools(table, msg) - can.user.isMobile && can.ConfHeight() > can.ConfWidth() && can.onmotion.hidden(can, can._action) + can.onmotion.clear(can, can._action), can.user.isMobile && can.ConfHeight() > can.ConfWidth() && can.onmotion.hidden(can, can._action) + can._display_output? can._display_output(sub, msg): can.core.CallFunc([sub, chat.ONIMPORT, chat._INIT], {can: sub, msg: msg, cb: function(msg) { + action === false || sub.onappend._action(sub, msg.Option(ice.MSG_ACTION)||can.Conf(ice.MSG_ACTION), action||can._action) + action === false || sub.onappend._status(sub, msg.Option(ice.MSG_STATUS)), sub.onappend.tools(sub, msg) + + can.page.Select(can, output, "input[type=button]", function(target) { if (target.value == target.name) { target.value = can.user.trans(can, target.name) } }) + var mode= ["float", "full", "cmd"]; for (var i in mode) { if (can.page.ClassList.has(can, can._target, mode[i])) { sub.onlayout[mode[i]](sub); break } } can.onaction._output(can, msg), can.base.isFunc(cb) && cb(msg) - }, target: output||can._output}) + }, target: output}) }) }, _status: function(can, list, status) { status = status||can._status, can.onmotion.clear(can, status) diff --git a/lib/user.js b/lib/user.js index 3a6dba96..d132ec4d 100644 --- a/lib/user.js +++ b/lib/user.js @@ -58,16 +58,16 @@ Volcanos("user", {help: "用户操作", info: {}, agent: { return {} }, - title: function(text) { - if (window.webview) { return title(text) } + title: function(text) { if (window.webview) { return title(text) } return text && (document.title = Volcanos.meta.args.name||text), document.title }, - topic: function(can, name) { can.base.isArray(name) && (name = can.base.join(name)) - can.user.isMobile && (name += " mobile") && can.user.isLandscape() && (name += " landscape") - can.user.language(can) && (name += " "+can.user.language(can)) - can.Conf("display") && (name += " "+can.Conf("display")) - can.user.mod.isCmd && (name += " simple") - can.page.styleClass(can, can._root._target, name) + topic: function(can, name) { can.base.isString(name) && (name = [name]) || name || [] + can.user.isMobile && name.push("mobile") && can.user.isLandscape() && name.push("landscape") + can.user.language(can) && name.push(can.user.language(can)) + can.Conf("display") && name.push(can.Conf("display")) + can.user.mod.isCmd && name.push("simple") + window.webview && name.push("webview") + can.page.styleClass(can, can._root._target, name.join(ice.SP)) }, language: function(can) { return can.misc.Search(can, "language") }, trans: function(can, text, list) { if (can.base.isObject(text)) { diff --git a/plugin/local/code/inner.js b/plugin/local/code/inner.js index 2f8947b3..cc3e2c25 100644 --- a/plugin/local/code/inner.js +++ b/plugin/local/code/inner.js @@ -113,7 +113,7 @@ Volcanos(chat.ONSYNTAX, {help: "语法高亮", _init: function(can, msg, cb) { } return can.onimport.plug(can, meta, can.ui._content, function(sub) { - sub.onimport.size(sub, sub.ConfHeight(can.ui.content.offsetHeight-3*html.ACTION_HEIGHT+sub.onexport.statusHeight(sub)), sub.ConfWidth(can.ui.content.offsetWidth), true) + sub.onimport.size(sub, sub.ConfHeight(can.ui.content.offsetHeight-html.ACTION_HEIGHT-sub.onexport.statusHeight(sub)), sub.ConfWidth(can.ui.content.offsetWidth), true) msg._plugin = sub, can.base.isFunc(cb) && cb(msg._content = can.ui._content), can.onmotion.delay(can, function() { sub.Focus() }) sub.onaction.close = function() { can.onaction.back(can), msg._tab._close() } sub.onimport.title = function(_, title) { can.page.Modify(can, msg._tab, title) } diff --git a/plugin/local/code/vimer.css b/plugin/local/code/vimer.css index a2dfab9d..fc465113 100644 --- a/plugin/local/code/vimer.css +++ b/plugin/local/code/vimer.css @@ -43,4 +43,5 @@ body.white fieldset.vimer>div.output input.current.insert { caret-color:black; } body.white fieldset.vimer>div.output input.current.normal { caret-color:lightgray; } div.project div.zone.create>div.list div.item { padding:5px; float:left; clear:none; } +body.webview div.project div.zone.create>div.list div.item { padding:2px; } div.project div.zone.create>div.action { display:none; } diff --git a/plugin/local/code/vimer.js b/plugin/local/code/vimer.js index cdf70ddf..ee5c65dc 100644 --- a/plugin/local/code/vimer.js +++ b/plugin/local/code/vimer.js @@ -27,7 +27,7 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg, cb, tar }, [""]) Volcanos(chat.ONFIGURE, {help: "索引导航", create: function(can, target, zone, path) { - can.isCmdMode()? can.onappend._action(can, can.base.Obj(can._msg.Option(ice.MSG_ACTION)).concat(window.webview? ["查找", "vim", "录屏", "日志", "编辑器", "浏览器"]: ["查找"]), target): can.onmotion.hidden(can, target.parentNode) + can.isCmdMode()? can.onappend._action(can, can.base.Obj(can._msg.Option(ice.MSG_ACTION)).concat(window.webview? ["查找", "git", "vim", "录屏", "日志", "编辑器", "浏览器"]: ["查找"]), target): can.onmotion.hidden(can, target.parentNode) }, recent: function(can, target, zone, path) { var total = 0 function show(msg, cb) { @@ -329,6 +329,9 @@ Volcanos(chat.ONACTION, {help: "控件交互", can.onimport.exts(can, list[0]) }) }, + "git": function(event, can) { + can.onimport.tabview(can, can.Option(nfs.PATH), "web.code.git.status", ctx.INDEX) + }, "vim": function(event, can) { can.onaction._run(can.request(event, can.Option()), can, code.XTERM, [mdb.TYPE, "vim +"+can.Option(nfs.LINE)+" "+can.Option(nfs.PATH)+can.Option(nfs.FILE)], function(msg) { can.onimport.tabview(can, can.Option(nfs.PATH), msg.Result(), code.XTERM)