From 83ca1d0398ee24a07607e26747cc38e36413521e Mon Sep 17 00:00:00 2001 From: shy Date: Fri, 5 Jan 2024 12:25:49 +0800 Subject: [PATCH] opt ice.MSG_DAEMON --- frame.js | 21 ++++++++++++--------- index.css | 14 ++++---------- panel/action.js | 4 ++-- panel/footer.js | 1 + plugin/local/code/inner.css | 30 ++++++++++++++++-------------- plugin/table.js | 3 +-- 6 files changed, 36 insertions(+), 37 deletions(-) diff --git a/frame.js b/frame.js index d3c9b1d5..1104e661 100644 --- a/frame.js +++ b/frame.js @@ -17,12 +17,13 @@ Volcanos(chat.ONENGINE, {_init: function(can, meta, list, cb, target) { if (!sub || !mod || !fun) { can.misc.Warn(ice.ErrNotFound, cmds); return can.base.isFunc(cb) && cb(msg.Echo(ice.ErrWarn, ice.ErrNotFound, cmds)) } return can.core.CallFunc(fun, {event: event, can: sub, msg: msg, cmds: cmds.slice(2), cb: cb, target: sub._target, button: key, cmd: key, arg: cmds.slice(2), list: cmds.slice(2)}, mod) }, - _remote: function(event, can, msg, panel, cmds, cb) { var sub = msg._can + _remote: function(event, can, msg, panel, cmds, cb) { var sub = msg._can._fields? msg._can.sup: msg._can if (panel.onengine._plugin(event, can, msg, panel, cmds, cb)) { return } if (panel.onengine._engine(event, can, msg, panel, cmds, cb)) { return } if (panel.onengine._static(event, can, msg, panel, cmds, cb)) { return } var toast, _toast = msg.Option(chat._TOAST); if (_toast) { can.onmotion.delay(can, function() { if (msg._can && msg._can._toast) { return } toast = toast||can.user.toastProcess(msg._can, _toast) }, 300) } - if (can.base.isUndefined(msg[ice.MSG_DAEMON])) { can.base.isUndefined(sub._daemon) && can.ondaemon._list[0] && (sub._daemon = can.ondaemon._list.push(sub)-1) + if (can.base.isUndefined(msg[ice.MSG_DAEMON])) { + can.base.isUndefined(sub._daemon) && can.ondaemon._list[0] && (sub._daemon = can.ondaemon._list.push(sub)-1) if (sub._daemon) { msg.Option(ice.MSG_DAEMON, can.core.Keys(can.ondaemon._list[0], sub._daemon)) } } if (!can.misc.CookieSessid(can) && can.user.info.sessid) { msg.Option(ice.MSG_SESSID, can.user.info.sessid) } var names = msg.Option(chat._NAMES)||panel._names||((can.Conf("iceberg")||Volcanos.meta.iceberg)+"/chat/"+panel._name+nfs.PS) @@ -68,18 +69,18 @@ Volcanos(chat.ONENGINE, {_init: function(can, meta, list, cb, target) { }, }) Volcanos(chat.ONDAEMON, {_init: function(can, name, type, cbs) { if (can.user.isLocalFile) { return } - return can.misc.WSS(can, {type: type||web.PORTAL, name: can.misc.Search(can, cli.DAEMON)||name||""}, function(event, msg, cmd, arg, cb) { + return can.misc.WSS(can, {type: type||web.PORTAL, name: name||can.misc.Search(can, cli.DAEMON)||can.misc.sessionStorage(can, "can.daemon")||""}, function(event, msg, cmd, arg, cb) { if (cbs && can.core.CallFunc(cbs, {event: event, msg: msg, cmd: cmd, arg: arg, cb: cb})) { return } - var sub = can.ondaemon._list[msg.Option(ice.MSG_TARGET)]||can; can.base.isFunc(sub.ondaemon[cmd])? + var sub = can.ondaemon._list[can.core.Keys(msg[ice.MSG_TARGET])]||can; can.base.isFunc(sub.ondaemon[cmd])? can.core.CallFunc(sub.ondaemon[cmd], {can: can, msg: msg, sub: sub, cmd: cmd, arg: arg, cb: cb}): - can.onengine._search({}, can, msg, can, [chat._SEARCH, cmd].concat(arg), cb) + can.onengine._search({}, can, msg, can, [chat._SEARCH, cmd].concat(arg), cb) }) - }, _list: [""], pwd: function(can, arg) { can._wss_name = can.ondaemon._list[0] = arg[0] }, + }, _list: [""], pwd: function(can, arg) { can.misc.sessionStorage(can, "can.daemon", can._wss_name = can.ondaemon._list[0] = arg[0]) }, close: function(can, msg, sub) { can.user.close() }, exit: function(can, msg, sub) { can.user.close() }, toast: function(can, sub, arg, cb) { can.core.CallFunc(can.user.toast, [sub].concat(arg)) }, grow: function(can, msg, sub, arg) { var _can = sub._fields && sub.sup? sub.sup: sub; _can.onimport._grow(_can, msg, arg.join("")) }, rich: function(can, msg, sub, arg) { var _can = sub._fields && sub.sup? sub.sup: sub; _can.onimport._rich(_can, msg, arg) }, - refresh: function(can, sub) { can.base.isFunc(sub.Update) && sub.Update() }, + refresh: function(can, sub) { can.base.isFunc(sub.Update) && sub.Update(), can.user.toastSuccess(can) }, action: function(can, msg, sub, arg) { if (arg[0] == "ctrl") { var list = [] can.page.Select(can, can._root._target, html.INPUT, function(target, index) { list[index] = target @@ -121,8 +122,10 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { return can.page.SelectArgs(can, action, key, value)[0] }, Option: function(key, value) { value && (value = can.user.trans(sub, value, null, html.INPUT)); return can.page.SelectArgs(can, option, key, value)[0] }, - Update: function(event, cmds, cb, silent) { event = event||{}, sub.request(event, {_toast: event.isTrusted? ice.PROCESS: ""}, - can.core.Value(sub, "sub.db._checkbox"))._caller(), sub.onappend._output0(sub, sub.Conf(), event||{}, cmds||sub.Input([], !silent), cb, silent); return true }, + Update: function(event, cmds, cb, silent) { event = event||{} + // sub.request(event, {_toast: event.isTrusted? ice.PROCESS: ""}, can.core.Value(sub, "sub.db._checkbox"))._caller(), + sub.request(event, can.core.Value(sub, "sub.db._checkbox"))._caller(), + sub.onappend._output0(sub, sub.Conf(), event||{}, cmds||sub.Input([], !silent), cb, silent); return true }, Focus: function() { can.page.SelectOne(can, option, html.INPUT_ARGS, function(target) { target.focus() }) }, Input: function(cmds, save, opts) { cmds = cmds && cmds.length > 0? cmds: can.page.SelectArgs(sub), cmds && cmds[0] != ctx.ACTION && (cmds = can.base.trim(cmds)), cmds._opts = opts return !save || cmds[0] == ctx.ACTION || can.base.Eq(sub._history[sub._history.length-1], cmds) || sub._history.push(cmds), cmds diff --git a/index.css b/index.css index d0d526ff..6b46f256 100644 --- a/index.css +++ b/index.css @@ -50,13 +50,10 @@ body { input { font-family:var(--input-font-family); } body { font-family:var(--body-font-family); } body { background-color:var(--body-bg-color); color:var(--body-fg-color); } -// body { background-color:var(--body-bg-color); color:var(--body-fg-color); background-position: center; background-image: url(/require/usr/icons/background.jpg); } body.windows { --code-font-family:"Courier New"; } body.mobile { --qrcode-height:284px; } -body.cmd { - background-color:var(--plugin-bg-color); - --plug-width:1200px; --plug-height:480px; -} +body.cmd { background-color:var(--plugin-bg-color); } +body.cmd { --plug-width:1200px; --plug-height:480px; } body.width1 { /* 320-640 手机竖屏 */ --svg-font-size:13px; --river-width:280px;; --project-width:120px; --input-width:80px; @@ -83,7 +80,6 @@ body.width6 { /* 1920-2240 显示器 */ --plugin-padding:10px; --river-width:280px; --input-width:180px; } - /* element */ * { tab-size:4; box-sizing:border-box; padding:0; border:0; margin:0; } legend { font-family:var(--legend-font-family); padding:0 var(--legend-padding); } @@ -127,11 +123,11 @@ ol, ul { margin-left:var(--title-margin); } a { color:var(--body-fg-color); font-style:italic; } p { margin:var(--title-margin) 0; } kbd { font-family:var(--code-font-family); padding:0 var(--input-padding); } +div.output>div.code>img { margin-bottom:-3px; } iframe { height:var(--iframe-height); width:100%; } /* fieldset */ fieldset>legend { box-shadow:var(--box-shadow); } fieldset>form.option>div.item:not(.icon) { margin-right:var(--button-margin); box-shadow:var(--box-shadow); } -/* fieldset.story:not(.float)>form.option>div.item.icons:not(.icon) { margin-right:0; } */ fieldset>form.option>div.item.textarea { width:100%; height:var(--textarea-height); } fieldset>form.option>div.item.text.cmd { width:100%; } fieldset>form.option>div.item.text.cmd>input { background-color:var(--code-bg-color); color:var(--code-fg-color); width:100%; } @@ -382,9 +378,7 @@ div.project:not(.toggle) { border-right:var(--box-border); width:var(--project-w div.profile:not(.toggle) { border-left:var(--box-border); width:50%; flex:0 0 50%; } div.display:not(.toggle) { border-top:var(--box-border); } /* output style */ -body.mobile div.output.card { - overflow-x:hidden; -} +body.mobile div.output.card { overflow-x:hidden; } div.output.card>div.item { background-color:var(--plugin-bg-color); padding:var(--plugin-padding); margin:var(--plugin-padding); border:var(--box-border); border-radius:var(--plugin-radius); box-shadow:var(--box-shadow); diff --git a/panel/action.js b/panel/action.js index e51b9b43..5bb7f88c 100644 --- a/panel/action.js +++ b/panel/action.js @@ -1,9 +1,9 @@ (function() { const TABS = "tabs", TABVIEW = "tabview", HORIZON = "horizon", VERTICAL = "vertical", GRID = "grid", FREE = "free", FLOW = "flow", PAGE = "page", CAN_LAYOUT = "can.layout" Volcanos(chat.ONIMPORT, {_init: function(can, msg) { var river = can.Conf(chat.RIVER), storm = can.Conf(chat.STORM), list = can.misc.SearchHash(can) - can.onmotion.clear(can), can.core.Next(msg.Table(), function(item, next) { item.type = chat.PLUGIN, item.mode = can.Mode(); if (item.deleted == ice.TRUE) { return next() } + can.onmotion.clear(can), can.core.Next(msg.Table(), function(item, next, index) { item.type = chat.PLUGIN, item.mode = can.Mode(); if (item.deleted == ice.TRUE) { return next() } item.width = can.ConfWidth()-can.Conf(html.MARGIN_X); if (item.style == html.OUTPUT) { item.width = can.ConfWidth()-2*html.PLUGIN_MARGIN-2*html.PLUGIN_PADDING } if (msg.Length() == 1) { item.height = can.ConfHeight()-(can.user.isMobile? 1: 1)*html.ACTION_HEIGHT-can.Conf(html.MARGIN_Y) } - can.onappend.plugin(can, item, function(sub, meta, skip) { + can.onappend.plugin(can, item, function(sub, meta, skip) { can.ondaemon._list[sub._daemon = can.core.Keys(river, storm, index)] = sub can._plugins = (can._plugins||[]).concat([sub]), can.onimport._tabs(can, sub, meta), skip || next() sub.onaction._close = function() { can.onengine.signal(can, chat.ONACTION_REMOVE, can.request({river: river, storm: storm}, item)), can.page.Remove(can, sub._target) } sub.run = function(event, cmds, cb) { return can.run(can.request(event, {pod: meta.space||meta.pod}), diff --git a/panel/footer.js b/panel/footer.js index 9a8b0842..ab893011 100644 --- a/panel/footer.js +++ b/panel/footer.js @@ -158,6 +158,7 @@ Volcanos(chat.ONPLUGIN, { userAgent: navigator.userAgent, history: history.length, boot: can.db._boot, + daemon: can.misc.sessionStorage(can, "can.daemon"), })).Display("/plugin/story/json.js") }), dir: shy("网页目录", [nfs.PATH, ice.LIST, ice.BACK], async function(can, msg, arg, cb) { var can = msg._can._fields? msg._can.sup: msg._can diff --git a/plugin/local/code/inner.css b/plugin/local/code/inner.css index 20a069d0..8284a78c 100644 --- a/plugin/local/code/inner.css +++ b/plugin/local/code/inner.css @@ -8,13 +8,14 @@ fieldset.inner>div.output div.content td.text span.object { color:var(--code-obj fieldset.inner>div.output div.content td.text span.datatype { color:var(--code-datatype); } fieldset.inner>div.output div.content td.text span.package { color:var(--code-package); } fieldset.inner>div.output>div.project div.zone div.action:not(.hide) { width:100%; } -fieldset.inner>div.output>div.project div.zone div.action>div.item { padding-right:0; width:100%; } +fieldset.inner>div.output>div.project div.zone div.action>div.item { padding-right:0; width:100%; overflow:hidden; } fieldset.inner>div.output>div.project div.zone div.action>div.item>input { padding-left:25px; width:100%; } fieldset.inner>div.output>div.layout>div.tabs { font-size:var(--code-font-size); display:none; } fieldset.inner>div.output>div.layout>div.tabs>div.tabs>div.tabs { padding-right:0; margin-left:5px; } fieldset.inner>div.output>div.layout>div.tabs>div.tabs>div.tabs:hover { background-color:var(--output-bg-color); border-top-left-radius:var(--plugin-radius); border-top-right-radius:var(--plugin-radius); box-shadow:var(--box-shadow); } fieldset.inner>div.output>div.layout>div.tabs>div.tabs>div.tabs.select { background-color:var(--output-bg-color); border-top-left-radius:var(--plugin-radius); border-top-right-radius:var(--plugin-radius); border-bottom:lightgray solid 2px; box-shadow:var(--box-shadow);} fieldset.inner>div.output>div.layout>div.path { font-size:var(--code-font-size); display:none; } +fieldset.inner.float>div.output>div.layout>div.path { font-size:var(--code-font-size); display:flex; } fieldset.inner>div.output>div.layout>div.display h1 { border-bottom:var(--box-border); margin:var(--title-margin) 0; } fieldset.inner>div.output>div.layout>div.display h2 { border-bottom:var(--box-border); margin:var(--title-margin) 0; } fieldset.inner>div.output>div.layout>div.display pre>code { padding-left:var(--table-padding); border-left:var(--code-border-color) solid 5px; display:block; } @@ -37,19 +38,20 @@ fieldset.inner.cmd>div.output>div.layout>div.tabs>div.tabs>div.tabs { padding:va fieldset.inner.cmd>div.output>div.layout>div.tabs>div.head>div { white-space:pre; padding:10px; height:var(--code-tabs-height); } fieldset.inner.cmd>div.output>div.layout>div.tabs>div.head>div.avatar { padding:0; } fieldset.inner.cmd>div.output>div.layout>div.tabs>div.head>div.avatar>img { height:var(--code-tabs-height); clip-path:circle(40%); } -fieldset.inner.cmd>div.output>div.layout>div.path:not(.hide) { font-style:italic; box-shadow:var(--box-shadow); display:flex; cursor:pointer; justify-content:flex-start; } -fieldset.inner.cmd>div.output>div.layout>div.path>a { padding:var(--input-padding) var(--button-padding); } -fieldset.inner.cmd>div.output>div.layout>div.path>a:hover { background-color:var(--hover-bg-color); } -fieldset.inner.cmd>div.output>div.layout>div.path>span { padding:var(--input-padding); } -fieldset.inner.cmd>div.output>div.layout>div.path>span:hover { background-color:var(--hover-bg-color); } -fieldset.inner.cmd>div.output>div.layout>div.path span.func { padding:var(--input-padding); margin-left:80px; } -fieldset.inner.cmd>div.output>div.layout>div.path span.mode { padding:var(--input-padding); margin-left:80px; } -body.mobile fieldset.inner.cmd>div.output>div.layout>div.path span.func { display:none; } -body.mobile fieldset.inner.cmd>div.output>div.layout>div.path span.mode { display:none; } -body:not(.mobile) fieldset.inner.cmd>div.output>div.layout>fieldset.plug { bottom:var(--action-height); } -fieldset.inner.cmd>div.output>div.layout>div.path span.space { flex-grow:1; } -fieldset.inner.cmd>div.output>div.layout>div.path span.view { font-size:22px; padding:0 var(--input-padding); margin-top:-5px; float:right; } -fieldset.inner.cmd>div.output>div.layout>fieldset.plug.output { white-space:pre; } +fieldset.inner.cmd>div.output>div.layout>div.path:not(.hide) { display:flex; } +fieldset.inner>div.output>div.layout>div.path:not(.hide) { font-style:italic; box-shadow:var(--box-shadow); cursor:pointer; justify-content:flex-start; } +fieldset.inner>div.output>div.layout>div.path>a { padding:var(--input-padding) var(--button-padding); } +fieldset.inner>div.output>div.layout>div.path>a:hover { background-color:var(--hover-bg-color); } +fieldset.inner>div.output>div.layout>div.path>span { padding:var(--input-padding); } +fieldset.inner>div.output>div.layout>div.path>span:hover { background-color:var(--hover-bg-color); } +fieldset.inner>div.output>div.layout>div.path span.func { padding:var(--input-padding); margin-left:80px; } +fieldset.inner>div.output>div.layout>div.path span.mode { padding:var(--input-padding); margin-left:80px; } +body.mobile fieldset.inner>div.output>div.layout>div.path span.func { display:none; } +body.mobile fieldset.inner>div.output>div.layout>div.path span.mode { display:none; } +body:not(.mobile) fieldset.inner>div.output>div.layout>fieldset.plug { bottom:var(--action-height); } +fieldset.inner>div.output>div.layout>div.path span.space { flex-grow:1; } +fieldset.inner>div.output>div.layout>div.path span.view { font-size:22px; padding:0 var(--input-padding); margin-top:-5px; float:right; } +fieldset.inner>div.output>div.layout>fieldset.plug.output { white-space:pre; } fieldset.inner.cmd>div.output>div.layout>div.plug { height:var(--action-height); position:fixed; right:0; bottom:0; overflow:auto; } fieldset.inner.cmd>div.output>div.layout>div.plug>legend { font-size:var(--legend-font-size); font-style:italic; float:right; } fieldset.inner.cmd>div.output>div.layout>div.plug>legend { padding:0 var(--input-padding); } diff --git a/plugin/table.js b/plugin/table.js index ce9143aa..80fbf3c1 100644 --- a/plugin/table.js +++ b/plugin/table.js @@ -47,7 +47,7 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { }) count && can.page.SelectChild(can, target, "", function(target) { can.page.SelectChild(can, target, html.DIV_LIST, function(target) { - can.page.style(can, target, html.HEIGHT, can.page.isDisplay(target)? can.base.Min(height/count, 120): "") + can.page.style(can, target, html.HEIGHT, can.page.isDisplay(target)? can.base.Min(height/count, 180): "") }) }) } @@ -181,7 +181,6 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, target) { can.onimport.plug(can, meta, function(sub) { sub.onexport.output = function() { can.page.style(can, sub._output, html.MAX_HEIGHT, "", html.HEIGHT, "", html.WIDTH, "", html.MAX_WIDTH, "") var height = can.base.Max(html.PLUG_HEIGHT, can._output.offsetHeight, 240), width = can.base.Max(html.PLUG_WIDTH, can.ConfWidth()-(can.user.isMobile? 0: html.PROJECT_WIDTH)) - // var height = can.base.Min(html.PLUG_HEIGHT, 240, can.ConfHeight()-html.ACTION_HEIGHT), width = can.base.Max(html.PLUG_WIDTH, can.ConfWidth()-html.PROJECT_WIDTH) sub.onimport.size(sub, height, width, false), can.onmotion.delay(can, function() { sub.onimport.size(sub, height, width, false) }) } can.onmotion.hidden(can, sub._target), sub._legend._target = sub._target, sub._legend._meta = {index: meta.index}