From 0fd53c1e2316be3f57c567363fc128370c622c48 Mon Sep 17 00:00:00 2001 From: shy Date: Tue, 21 May 2024 07:39:21 +0800 Subject: [PATCH] add some --- frame.js | 19 +++++-------------- index.css | 2 +- plugin/state.js | 25 +++++++++++++------------ plugin/table.js | 4 +--- proto.js | 8 ++++++-- 5 files changed, 26 insertions(+), 32 deletions(-) diff --git a/frame.js b/frame.js index 89b20f73..02b0e281 100644 --- a/frame.js +++ b/frame.js @@ -155,8 +155,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { }); return value } catch {} }, Action: function(key, value) { - // key && value && can.misc.sessionStorage(can, [sub.ConfIndex(), ctx.ACTION, key], value) - value && (value = can.user.trans(sub, value, null, html.INPUT)) + // value && (value = can.user.trans(sub, value, null, html.INPUT)) return can.page.SelectArgs(can, action, key, value)[0] }, Option: function(key, value) { @@ -214,9 +213,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { }}]) }) while (args.length > 0) { if (args[args.length-1] != "") { break } args.pop() } - if (args.slice) { - can.core.List(args.slice(can.core.List(meta.inputs, function(item) { if (can.base.isIn(item.type, html.TEXTAREA, html.TEXT, html.SELECT)) { return item } }).length), function(item, index) { meta.inputs.push({type: mdb.TEXT, name: "args"+index, value: item}) }) - } + args.slice && can.core.List(args.slice(can.core.List(meta.inputs, function(item) { if (can.base.isIn(item.type, html.TEXTAREA, html.TEXT, html.SELECT)) { return item } }).length), function(item, index) { meta.inputs.push({type: mdb.TEXT, name: "args"+index, value: item}) }) function add(item, next) { item = can.base.isString(item)? {type: html.TEXT, name: item}: item, item.type != html.BUTTON && index++ return Volcanos(item.name, {_root: can._root, _follow: can.core.Keys(can._follow, item.name), _target: can.onappend.input(can, item, args[index]||(typeof args[item.name] == code.STRING? args[item.name]: "")||opts[item.name], option||can._option), _option: option||can._option, _action: can._action, _output: can._output, _status: can._status, @@ -236,8 +233,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { can.core.ItemCB(item, function(key, cb) { sub._target[key] = function(event) { can.misc.Event(event, can, function(msg) { cb(event, sub, sub._target) })} }) item.action && can.onappend.figure(sub, item, sub._target, function(_sub, value) { can.Update() }); if (skip === true) { return } item.type == html.BUTTON && item.action == ice.AUTO && can.base.isUndefined(can._delay_init) && (auto = sub._target), next() - can.Conf(ice.AUTO) == item.name && (auto = sub._target) - can._auto = auto + can.Conf(ice.AUTO) == item.name && (auto = sub._target), can._auto = auto }) }; var auto; can.core.Next(can.core.Value(can, [chat.ONIMPORT, mdb.LIST])||meta.inputs, add, function() { @@ -268,16 +264,12 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { can.base.isString(item)? /* 2.按键 */ {type: html.BUTTON, name: item, value: can.user.trans(can, item, meta._trans), onclick: function(event) { run(event, item) }}: item.length > 0? /* 3.列表 */ {type: html.SELECT, name: item[0], values: item.slice(1), onchange: function(event) { can.misc.Event(event, can, function(msg) { - var button = event.target.value; + var button = event.target.value; can.onexport.session && can.onexport.session(can, "action:"+item[0], button) can.onaction._select && can.onaction._select(event, can, item[0], button) - can.onexport.session && can.onexport.session(can, "action:"+item[0], button) meta[item[0]]? can.core.CallFunc(meta[item[0]], [event, can, item[0], button]): meta[button]? can.core.CallFunc(meta[button], [event, can, button]): can.Action(item[0], button) })}, _init: function() { - if (can.onexport.session) { - var value = can.onexport.session(can, "action:"+item[0]) - value && can.Action(item[0], value) - } + if (can.onexport.session) { var value = can.onexport.session(can, "action:"+item[0]); value && can.Action(item[0], value) } }}: /* 4.其它 */(item.type == html.BUTTON && (item.value = item.value||can.user.trans(can, item.name, meta._trans), item.onclick = item.onclick||function(event) { run(event, item.name||item.value) }, item._init = item._init||function(target) { item.action && can.onappend.figure(sub, item, target, function(_sub, value) { can.Update() }) @@ -347,7 +339,6 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) { var list = can.base.Obj(msg.Option(ice.MSG_ACTION)||can.Conf(ice.MSG_ACTION), [])||[] can.onmotion.clear(can, can._action), sub.onappend._action(sub, list, action||can._action) sub.onappend._status(sub, sub.onexport&&sub.onexport.list||msg.Option(ice.MSG_STATUS), null, msg), can.user.isMobile || sub.onappend.tools(sub, msg) - can.core.Item(can.Action(), function(key) { var value = can.misc.sessionStorage(can, [can.ConfIndex(), ctx.ACTION, key]); value && can.Action(key, msg.Option(key)||value[0]) }) if (msg.Option("sess.online") == ice.TRUE) { can.ondaemon._online(can) } if (msg.Length() > 9 && !sub.ui.project && !can.user.isMobile) { can.onmotion.delay(can, function() { can.onappend._filter(can) }, 300) } } can.onappend.style(sub, sub.Conf(ctx.STYLE)), can.onmotion.story.auto(can, can._output) diff --git a/index.css b/index.css index 51a5a262..ba72b9ca 100644 --- a/index.css +++ b/index.css @@ -894,7 +894,7 @@ fieldset.draw>div.output>div.layout>div.layout>div.profile table { width:100%; } fieldset.draw>div.output>div.layout>div.layout>div.profile { width:var(--project-width); flex:0 0 var(--project-width); } fieldset.draw div.output svg { margin-bottom:-5px; } fieldset.draw div.output svg { min-height:100%; } -fieldset.draw div.output { display:flex; flex-direction:row; } +// fieldset.draw div.output { display:flex; flex-direction:row; } fieldset.draw.spides div.output svg text { cursor:pointer; } fieldset.draw.spides div.output svg path { stroke-width:1; } fieldset.draw.trends div.output { overflow:hidden; } diff --git a/plugin/state.js b/plugin/state.js index 7eea7304..8881bccb 100644 --- a/plugin/state.js +++ b/plugin/state.js @@ -314,31 +314,32 @@ Volcanos(chat.ONACTION, {list: ["刷新数据", recorder.onstop = function() { cb(blobs, nfs.WEBM) }, recorder.start(1) }) }, }) -Volcanos(chat.ONEXPORT, {_output: function(can, msg) {}, +Volcanos(chat.ONEXPORT, { + _output: function(can, msg) {}, output: function(can, msg) {}, action: function(can, button, data) {}, record: function(can, value, key, data) {}, - title: function(can, title) { - if (can.base.isIn(title, web.DESKTOP)) { return } - var pod = can.misc.Search(can, ice.POD) - can.isCmdMode() && can.user.title(title+(pod && title != pod? " "+pod: "")) }, - marginTop: function() { return 0 }, marginBottom: function() { return 0 }, + marginTop: function() { return 0 }, marginBottom: function() { return 0 }, outputMargin: function(can) { return 0 }, actionHeight: function(can) { return can.page.ClassList.has(can, can._target, html.OUTPUT)? 0: html.ACTION_HEIGHT }, outputHeight: function(can) { var height = can.ConfHeight() - can.onexport.actionHeight(can) - can.onexport.statusHeight(can) if (can.user.isMobile) { return height } height -= can.onexport.outputMargin(can) can.page.SelectChild(can, can._output, html.TABLE, function(target) { height -= target.offsetHeight }) return can.base.Max(can.base.Min(height, can.ConfHeight()/2), can.ConfHeight()-2*html.ACTION_HEIGHT, 320) }, - outputMargin: function(can) { return 0 }, statusHeight: function(can) { return can.page.ClassList.has(can, can._target, html.OUTPUT) || !can.page.isDisplay(can._status) || (can._target.offsetHeight > 0 && can._status.offsetHeight == 0) || - can._status.innerHTML == "" && !can.page.ClassList.has(can, can._target, html.PLUG)? 0: html.STATUS_HEIGHT }, + can._status.innerHTML == "" && !can.page.ClassList.has(can, can._target, html.PLUG)? 0: html.STATUS_HEIGHT + }, + session: function(can, key, value) { if (value) { value = JSON.stringify(value) } + return can.misc.sessionStorage(can, [can.ConfSpace()||can.misc.Search(can, ice.POD), can.ConfIndex(), key, location.pathname], value) + }, + title: function(can, title) { if (can.base.isIn(title, web.DESKTOP)) { return } + var pod = can.misc.Search(can, ice.POD); can.isCmdMode() && can.user.title(title+(pod && title != pod? " "+pod: "")) + }, + args: function(can) { return can.Option() }, link: function(can) { - if (can.sub && can.sub.onexport.link) { - return can.sub.onexport.link(can.sub) - } + if (can.sub && can.sub.onexport.link) { return can.sub.onexport.link(can.sub) } var args = can.Option(); args.pod = can.ConfSpace()||can.misc.Search(can, ice.POD), args.cmd = can.ConfIndex() can.core.Item(args, function(key, value) { key != ice.POD && !value && delete(args[key]) }) return can.misc.MergePodCmd(can, args, true) }, - args: function(can) { return can.Option() }, close: function(can, msg) {}, }) diff --git a/plugin/table.js b/plugin/table.js index 326789a8..30462353 100644 --- a/plugin/table.js +++ b/plugin/table.js @@ -273,9 +273,7 @@ Volcanos(chat.ONEXPORT, { hash: function(can, hash) { hash = typeof hash == code.STRING? hash.split(":").concat(can.core.List(arguments).slice(2)||[]): hash || can.core.Item(can.Option(), function(key, value) { return value||"" }) can.misc.SearchHash(can, hash), can.misc.localStorage(can, [can.ConfSpace()||can.misc.Search(can, ice.POD), can.ConfIndex(), "hash"], hash) }, - session: function(can, key, value) { if (value) { value = JSON.stringify(value) } - return can.misc.sessionStorage(can, [can.ConfSpace()||can.misc.Search(can, ice.POD), can.ConfIndex(), key, location.pathname].join(":"), value) - }, + session: function(can, key, value) { return can.sup.onexport.session(can.sup, key, value) }, table: function(can) { var msg = can._msg; if (msg.Length() == 0) { return } var res = [msg.append && msg.append.join(mdb.FS)] msg.Table(function(line, index, array) { res.push(can.core.Item(line, function(key, value) { return value }).join(ice.FS)) }) return res.join(lex.NL) diff --git a/proto.js b/proto.js index 6e2a6503..57012e7e 100644 --- a/proto.js +++ b/proto.js @@ -113,8 +113,12 @@ var Volcanos = shy({iceberg: "", volcano: "", frame: chat.FRAME_JS, _cache: {}, isAutoMode: function() { return can.Mode() == "" }, Mode: function(value) { return can.Conf(ice.MODE, value) }, ConfDefault: function(value) { can.core.Item(value, function(k, v) { can.Conf(k) || can.Conf(k, v) }) }, - ConfSpace: function() { return can.Conf("_space")||can.Conf(web.SPACE)||"" }, - ConfIndex: function() { return can.Conf("_command")||can.Conf(ctx.INDEX)||can.Conf("_index") }, + ConfSpace: function(space) { + if (space) { can.Conf(web.SPACE, space) } + return can.Conf("_space")||can.Conf(web.SPACE)||"" }, + ConfIndex: function(index) { + if (index) { can.Conf(ctx.INDEX, index) } + return can.Conf("_command")||can.Conf(ctx.INDEX)||can.Conf("_index") }, ConfHeight: function(value) { return can.Conf(html.HEIGHT, value) }, ConfWidth: function(value) { return can.Conf(html.WIDTH, value)||can._output.offsetWidth }, Conf: function(key, value) { var res = can._conf