From 21cc8ee8c5195f2667c947a253813fec9b75c11c Mon Sep 17 00:00:00 2001 From: harveyshao Date: Sun, 19 Feb 2023 19:14:21 +0800 Subject: [PATCH] opt code --- frame.js | 4 ++-- panel/action.css | 1 + panel/action.js | 2 +- plugin/input/key.js | 3 ++- plugin/local/code/vimer.js | 3 ++- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/frame.js b/frame.js index efacd75a..22519ec5 100644 --- a/frame.js +++ b/frame.js @@ -192,8 +192,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { } return can.onengine._plugin(event, can, msg, can, cmds, cb) || can.run(event, cmds, cb||function(msg) { if (silent) { return } var _can = can._fields? can.sup: can if (_can == (msg._can._fields? msg._can.sup: msg._can) && can.core.CallFunc([_can, chat.ONIMPORT, ice.MSG_PROCESS], {can: _can, msg: msg})) { return } - if (cmds && cmds[0] == ctx.ACTION) { if (msg.Length() == 0 && !msg.Result()) { return can.user.toastSuccess(can, cmds[1]), can.Update() } } - // if (cmds && cmds[0] == ctx.ACTION) { if (can.base.isIn(cmds[1], mdb.CREATE, mdb.INSERT, mdb.IMPORT, nfs.TRASH) || msg.Length() == 0 && msg.Result() == "") { return can.user.toastSuccess(can, cmds[1]), can.Update() } } + if (cmds && cmds[0] == ctx.ACTION) { if (can.base.isIn(cmds[1], mdb.CREATE, mdb.INSERT, mdb.IMPORT, nfs.TRASH) || msg.Length() == 0 && msg.Result() == "") { return can.user.toastSuccess(can, cmds[1]), can.Update() } } can.onappend._output(can, msg, meta.display||msg.Option(ice.MSG_DISPLAY)||meta.feature.display) }) }, @@ -345,6 +344,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { }, ondblclick: function(event) { if ([mdb.KEY, mdb.HASH, mdb.ID].indexOf(key) > -1) { return } var item = can.core.List(can.Conf([ctx.FEATURE, mdb.INSERT]), function(item) { if (item.name == key) { return item } })[0]||{name: key, value: value} item.run = function(event, cmds, cb) { can.run(can.request(event, line, can.Option()), cmds, cb, true) } + item._enter = function(event, value) { if (event.ctrlKey) { run(event, mdb.MODIFY, [key, value]) } } can.onmotion.modifys(can, event.target, function(event, value, old) { run(event, mdb.MODIFY, [key, value]) }, item) }} }); table && can.onappend.style(can, chat.CONTENT, table), msg.append && msg.append[msg.append.length-1] == ctx.ACTION && can.onappend.style(can, ctx.ACTION, table) diff --git a/panel/action.css b/panel/action.css index d21c83fe..8f1250fc 100644 --- a/panel/action.css +++ b/panel/action.css @@ -19,6 +19,7 @@ fieldset.Action.free>div.output>fieldset.plugin { position:absolute; } fieldset.Action.free>div.output>fieldset.plugin.select { z-index:10; } fieldset.Action.grid>div.output>fieldset.plugin { float:left; } fieldset.Action.free>div.output { overflow:hidden; } +fieldset.Action.grid>div.output>fieldset.plugin>form.option { display:none; } fieldset.Action.grid>div.output>fieldset.plugin>div.action { display:none; } fieldset.Action.grid>div.output>fieldset.plugin>div.status { display:none; } fieldset.Action.grid>div.output>fieldset.plugin>form.option input[type=text] { width:80px; } diff --git a/panel/action.js b/panel/action.js index bedc6eed..07575640 100644 --- a/panel/action.js +++ b/panel/action.js @@ -87,7 +87,7 @@ Volcanos(chat.ONLAYOUT, { horizon: function(can) { can.getActionSize(function(height, width) { can.ConfHeight(height), can.ConfWidth(width/2) }) }, vertical: function(can) { can.getActionSize(function(height, width) { can.ConfHeight(height/2), can.ConfWidth(width) }) }, grid: function(can) { can.getActionSize(function(height, width) { var m = can.user.isMobile? 1: 2, n = 2 - var h = height/n-4*html.PLUGIN_MARGIN-html.ACTION_HEIGHT, w = width/m-can.Conf(html.MARGIN_X); can.ConfHeight(h), can.ConfWidth(w) + var h = height/n-4*html.PLUGIN_MARGIN, w = width/m-can.Conf(html.MARGIN_X); can.ConfHeight(h), can.ConfWidth(w) }) }, free: function(can) { can.getActionSize(function(height, width) { can.ConfHeight(height-can.Conf(html.MARGIN_Y)), can.ConfWidth(width-can.Conf(html.MARGIN_Y)) can.core.List(can._plugins, function(sub, index, array) { can.onmotion.move(can, sub._target, {left: (width/array.length/8*5+20)*index, top: (height/array.length/8*5)*index}) }), can.onmotion.toggle(can, can._header_tabs, true) diff --git a/plugin/input/key.js b/plugin/input/key.js index 7084b64f..d19e6834 100644 --- a/plugin/input/key.js +++ b/plugin/input/key.js @@ -19,7 +19,8 @@ Volcanos(chat.ONFIGURE, {key: { }) }, onblur: function(event, can, sub) { sub && can.onmotion.delay(can, sub.close, 300) }, onkeydown: function(event, can, meta, cb, target, sub, last) { - if (event.key == lang.ENTER) { return meta._enter && (!can.page.tagis(event.target, html.TEXTAREA) || event.ctrlKey) && meta._enter(event)? sub.close(): last(event) } + if (event.key == lang.ENTER) { return meta._enter && (!can.page.tagis(event.target, html.TEXTAREA) || event.ctrlKey) && meta._enter(event, target.value)? sub.close(): last(event) } + if (!sub) { return } sub.hidden() || can.onkeymap.selectCtrlN(event, can, sub._output, "tr:not(.hidden)>td:first-child", function(td) { return cb(sub, td.innerText, target.value), td }) || can.onmotion.delayOnce(can, function() { can.onkeymap.selectInputs(event, sub, function() { sub._load(event, sub, cb, target, meta.name) }, target) }, target.value.length < 3? 500: 150) }, diff --git a/plugin/local/code/vimer.js b/plugin/local/code/vimer.js index ac685283..eacf9916 100644 --- a/plugin/local/code/vimer.js +++ b/plugin/local/code/vimer.js @@ -56,7 +56,7 @@ Volcanos(chat.ONFIGURE, { }) }}) }) }, }) -Volcanos(chat.ONACTION, { +Volcanos(chat.ONACTION, {list: ["提交", "调试", "首页", "官网", "源码", "百度"], _daemon: function(event, can, arg) { switch (arg[0]) { case web.DREAM: can.runAction({}, arg[0], arg.slice(1), function(msg) { can.onimport.tabview(can, can.Option(nfs.PATH), can.core.Keys(can.misc.Search(can, ice.POD), msg.Option(mdb.NAME)), web.DREAM) }); break case code.XTERM: can.runAction({}, arg[0], arg.slice(1), function(msg) { can.onimport.tabview(can, ctx.COMMAND, code.XTERM, msg.Result()) }); break @@ -106,6 +106,7 @@ Volcanos(chat.ONACTION, { }) }, "调试": function(event, can) { can.user.opens(location.href.replace("debug=true", "debug=false")) }, "首页": function(event, can) { can.user.open(location.origin+(can.misc.Search(can, log.DEBUG) == ice.TRUE? "?debug=true": "")) }, + "提交": function(event, can) { can.onimport.tabview(can, can.Option(nfs.PATH), "web.code.git.status", ctx.INDEX) }, "官网": function(event, can) { can.user.open("https://contexts.com.cn/") }, "源码": function(event, can) { can.user.open("https://shylinux.com/") }, "百度": function(event, can) { can.user.opens("https://baidu.com/") },