From e6607bcd172f40ac272080393292c47a4060676c Mon Sep 17 00:00:00 2001 From: shy Date: Sun, 19 May 2024 23:49:45 +0800 Subject: [PATCH] add some --- core/chat/flows.go | 11 +--- core/chat/flows.js | 143 ++++++++++++++++++++------------------------- 2 files changed, 65 insertions(+), 89 deletions(-) diff --git a/core/chat/flows.go b/core/chat/flows.go index 9e67e844..6a0e2933 100644 --- a/core/chat/flows.go +++ b/core/chat/flows.go @@ -10,14 +10,7 @@ const FLOWS = "flows" func init() { Index.MergeCommands(ice.Commands{ - FLOWS: {Name: "flows zone hash auto", Help: "工作流", Icon: "Automator.png", Actions: ice.MergeActions(ice.Actions{ - mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) { - if mdb.IsSearchPreview(m, arg) { - mdb.HashSelects(m.Spawn()).Table(func(value ice.Maps) { - m.PushSearch(mdb.NAME, value[mdb.ZONE], value) - }) - } - }}, + FLOWS: {Name: "flows refresh", Help: "工作流", Icon: "Automator.png", Actions: ice.MergeActions(ice.Actions{ mdb.INSERT: {Name: "insert name space index* args", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(mdb.INSERT, m.ShortKey(), kit.KeyHash(m.Option(mdb.ZONE)), mdb.HASH, m.OptionSimple(mdb.Config(m, mdb.FIELDS))) }}, @@ -29,7 +22,7 @@ func init() { }}, }, mdb.ExportHashAction(mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,zone", mdb.FIELDS, "time,hash,name,space,index,args,prev,from,status")), Hand: func(m *ice.Message, arg ...string) { if arg = kit.Slice(arg, 0, 2); len(arg) == 0 || arg[0] == "" { - mdb.HashSelect(m).Option(ice.MSG_ACTION, "") + mdb.HashSelect(m).Action(mdb.CREATE) } else { m.Fields(len(arg)-1, mdb.Config(m, mdb.FIELDS), mdb.DETAIL) m.Cmdy(mdb.SELECT, m.ShortKey(), kit.KeyHash(arg[0]), mdb.HASH, arg[1:]) diff --git a/core/chat/flows.js b/core/chat/flows.js index 4e8455aa..fe979ae5 100644 --- a/core/chat/flows.js +++ b/core/chat/flows.js @@ -1,46 +1,56 @@ -(function() { const ACTION_STORE = "web.flows:action:" Volcanos(chat.ONIMPORT, { - _init: function(can, msg, cb) { can.ui = can.onappend.layout(can), cb && cb(msg) - can.core.Item(can.Action(), function(key) { can.onaction[key] = can.onaction[key]||can.onaction.refresh, can.Action(key, can.misc.localStorage(can, ACTION_STORE+key)) }) - if (can.Option(mdb.ZONE)) { can.onmotion.hidden(can, can.ui.project), can.onimport._content(can, msg, can.Option(mdb.ZONE)) } else { can.onimport._project(can, msg) } + _init: function(can, msg) { + if (can.Option(mdb.ZONE)) { + can.onimport._content(can, msg, can.db.value = {zone: can.Option(mdb.ZONE)}) + } else { + can.ui = can.onappend.layout(can), can.onimport._project(can, msg) + } }, - _project: function(can, msg) { msg.Table(function(value) { value._select = value.zone == can.Option(mdb.ZONE) - can.onimport.item(can, value, function(event, item) { can.Option(mdb.ZONE, value.zone) - if (can.onmotion.cache(can, function(save, load) { - save({db: can.db, toggle: can.ui.toggle, _display_class: can.ui.display.className, _profile_class: can.ui.profile.className}) - return load(value.zone, function(bak) { can.db = bak.db, can.ui.toggle = bak.toggle - can.ui.display.className = bak._display_class||can.ui.display.className - can.ui.profile.className = bak._profile_class||can.ui.profile.className - }) - }, can.ui.content, can.ui.display, can._status)) { return can.page.isDisplay(can.ui.profile) && can.onimport._profile(can, can.db.current), can.onimport.layout(can) } - can.run(event, [value.zone], function(msg) { can.onimport._content(can, msg, can.Option(mdb.ZONE)) }) + _project: function(can, msg) { msg.Table(function(value) { value._select = value.zone == can.db.hash[0] + can.onimport.item(can, value, function(event, item, show, target) { + can.onimport.tabsCache(can, can.request(), item.zone, item, target, function() { + can.run(event, [value.zone], function(msg) { can.onimport._content(can, msg, value) }) + }) }) }) }, - _content: function(can, msg, zone) { if (msg.Length() == 0) { return can.Update(can.request({target: can._legend}, {title: mdb.INSERT, zone: zone}), [ctx.ACTION, mdb.INSERT]) } - can.db.list = {}; msg.Table(function(value) { can.db.list[value.hash] = value }) - var root; can.core.Item(can.db.list, function(key, item) { if (!item.prev && !item.from) { return root = item } - try { if (item.prev) { can.db.list[item.prev].next = item } if (item.from) { can.db.list[item.from].to = item } } catch(e) { console.log(e) } - }), can.db.root = root, can.db.current = root - var _list = can.onexport.travel(can, can.db.root, true), _msg = can.request(); can.core.List(_list, function(item) { _msg.Push(item, msg.append) }) + _content: function(can, msg, value) { + if (msg.Length() == 0) { return can.Update(can.request({target: can._legend}, {title: mdb.INSERT, zone: value.zone}), [ctx.ACTION, mdb.INSERT]) } + var list = {}; msg.Table(function(value) { list[value.hash] = value }) + var root; can.core.Item(list, function(key, item) { if (!item.prev && !item.from) { return root = item } + try { if (item.prev) { list[item.prev].next = item } if (item.from) { list[item.from].to = item } } catch(e) { console.log(e) } + }), value._root = root, can.core.Item(list, function(key, item) { if (item.prev) { item.prev = list[item.prev] } if (item.from) { item.from = list[item.from] } }) + var _list = can.onexport.travel(can, root, true), _msg = can.request(); can.core.List(_list, function(item) { + _msg.Push(mdb.TIME, item.time) + _msg.Push(mdb.HASH, item.hash) + _msg.Push(ctx.INDEX, item.index||"") + _msg.Push(ctx.ARGS, item.args||"") + _msg.Push(ctx.ACTION, item.action||"") + }) var table = can.onappend.table(can, _msg, null, can.ui.display); can.page.Select(can, table, "tbody>tr", function(target, index) { _list[index]._tr = target }) can.onappend._status(can, can.base.Obj(msg.Option(ice.MSG_STATUS))) - can.core.Item(can.db.list, function(key, item) { if (item.prev) { item.prev = can.db.list[item.prev] } if (item.from) { item.from = can.db.list[item.from] } }) - can.onappend.plugin(can, {index: web.WIKI_DRAW, display: "/plugin/local/wiki/draw.js", style: html.OUTPUT}, function(sub) { can.ui.toggle = can.onappend.toggle(can, can.ui.content) - sub.onexport.output = function(_sub, _msg) { sub.Action(svg.GO, "manual"), sub.Action(ice.MODE, html.RESIZE), can.onmotion.hidden(can, _sub._action), can.db._content_plugin = _sub - can.onimport.layout(can), can.onimport._flows(can, _sub) - }, sub.run = function(event, cmds, cb) { cb(can.request(event)) } - }, can.ui.content) + can.onappend.plugin(can, {index: web.WIKI_DRAW, style: html.OUTPUT, display: "/plugin/local/wiki/draw.js", height: can.ui.content.offsetHeight, width: can.ui.content.offsetWidth}, function(sub) { + sub.run = function(event, cmds, cb) { cb(can.request(event)) } + sub.onexport.output = function(_sub, _msg) { + sub.Action(svg.GO, "manual"), sub.Action(ice.MODE, html.RESIZE), can.onmotion.hidden(can, sub._action) + value._content_plugin = sub, can.onimport.layout(can), can.onimport._flows(can, _sub, value) + } + can.ui.toggle = can.onappend.toggle(can, can.ui.content) + }, can.ui.content||can._output) }, - _profile: function(can, item) { if (!item.index) { return can.onmotion.hidden(can, can.ui.profile), can.onimport.layout(can) } - if (can.onmotion.cache(can, function() { return can.core.Keys(can.Option(mdb.ZONE), item.hash) }, can.ui.profile)) { return can.onmotion.toggle(can, can.ui.profile, true), can.onimport.layout(can) } - can.onappend.plugin(can, {space: item.space, index: item.index, args: item.args, width: (can.ConfWidth()-can.ui.project.offsetWidth)/2-1}, function(sub) { can.db._profile_plugin = sub - sub.run = function(event, cmds, cb) { can.runActionCommand(can.request(event, {pod: item.space}), item.index, cmds, function(msg) { can.onmotion.toggle(can, can.ui.profile, true), cb(msg) }) } + _profile: function(can, item) { + can.onexport.hash(can, can.db.value.zone, item.hash) + if (!item.index) { return can.onmotion.hidden(can, can.ui.profile), can.onimport.layout(can) } + can.onmotion.toggle(can, can.ui.profile, true), can.onimport.layout(can) + if (can.onmotion.cache(can, function() { return can.core.Keys(can.db.value.zone, item.hash) }, can.ui.profile)) { return } + can.onappend.plugin(can, {space: item.space, index: item.index, args: item.args, width: (can.ConfWidth()-can.ui.project.offsetWidth)/2-1}, function(sub) { can.db.value._profile_plugin = sub + sub.run = function(event, cmds, cb) { can.runActionCommand(can.request(event, {pod: item.space}), item.index, cmds, cb) } sub.onexport.output = function() { can.onmotion.toggle(can, can.ui.profile, true), can.onimport.layout(can) } sub.onaction._close = function() { can.onmotion.hidden(can, can.ui.profile), can.onimport.layout(can) } }, can.ui.profile) }, - _flows: async function(can, _sub) { var margin = can.onexport.margin(can), height = can.onexport.height(can), width = can.onexport.width(can) - var matrix = {}, horizon = can.Action("direct") == "horizon"; can.onmotion.clear(can, _sub.ui.svg), can.db._height = 0, can.db._width = 0 + _flows: async function(can, sub, value) { + var margin = can.onexport.margin(can), height = can.onexport.height(can), width = can.onexport.width(can) + var matrix = {}, horizon = can.Action("direct") == "horizon"; can.onmotion.clear(can, sub.ui.svg) async function sleep() { return new Promise(resolve => { setTimeout(resolve, can.Action("delay")) }) } async function show(item, main) { var prev = "from", from = "prev"; if (horizon) { var prev = "prev", from = "from" } while (matrix[can.core.Keys(item.x, item.y)]) { @@ -62,10 +72,10 @@ Volcanos(chat.ONIMPORT, { } } } matrix[can.core.Keys(item.x, item.y)] = item - if (item.from || item.prev) { item._line = _sub.onimport.draw(_sub, {shape: svg.LINE, points: + if (item.from || item.prev) { item._line = sub.onimport.draw(sub, {shape: svg.LINE, points: horizon && item.from || !horizon && !item.from? [{x: item.x*width+width/2, y: item.y*height-margin}, {x: item.x*width+width/2, y: item.y*height+margin}]: [{x: item.x*width-margin, y: item.y*height+height/2}, {x: item.x*width+margin, y: item.y*height+height/2}] - }) } can.onimport._block(can, _sub, item, item.x*width, item.y*height), await sleep() + }) } can.onimport._block(can, sub, item, item.x*width, item.y*height), await sleep() var next = 0, to = 1; if (horizon) { var next = 1, to = 0 } if (main) { var _item = item.to; if (_item) { _item.x = item.x+to, _item.y = item.y+next, await show(_item) } @@ -74,37 +84,30 @@ Volcanos(chat.ONIMPORT, { var _item = item.next; if (_item) { _item.x = item.x+next, _item.y = item.y+to, await show(_item, true) } var _item = item.to; if (_item) { _item.x = item.x+to, _item.y = item.y+next, await show(_item) } } - } can.db.root.x = 0, can.db.root.y = 0, await show(can.db.root, true) + } value._root.x = 0, value._root.y = 0, await show(value._root, true) }, - _block: function(can, _sub, item, x, y) { var margin = can.onexport.margin(can), height = can.onexport.height(can), width = can.onexport.width(can) - var rect = _sub.onimport.draw(_sub, {shape: svg.RECT, points: [{x: x+margin, y: y+margin}, {x: x+width-margin, y: y+height-margin}]}) - var text = _sub.onimport.draw(_sub, {shape: svg.TEXT, points: [{x: x+width/2, y: y+height/2}], style: {inner: item.name||item.index.split(nfs.PT).pop()}}) - item._rect = rect, item._text = text, can.core.ItemCB(can.ondetail, function(key, cb) { text[key] = rect[key] = function(event) { cb(event, can, _sub, item) } }) + _block: function(can, sub, item, x, y) { + var margin = can.onexport.margin(can), height = can.onexport.height(can), width = can.onexport.width(can) + var rect = sub.onimport.draw(sub, {shape: svg.RECT, points: [{x: x+margin, y: y+margin}, {x: x+width-margin, y: y+height-margin}]}) + var text = sub.onimport.draw(sub, {shape: svg.TEXT, points: [{x: x+width/2, y: y+height/2}], style: {inner: item.name||item.index.split(nfs.PT).pop()}}) + item._rect = rect, item._text = text, can.core.ItemCB(can.ondetail, function(key, cb) { text[key] = rect[key] = function(event) { cb(event, can, sub, item) } }) if (item.status) { item._line && item._line.Value(html.CLASS, item.status), rect.Value(html.CLASS, item.status), text.Value(html.CLASS, item.status) } - if (can.db._height < y+height) { can.db._height = y+height, can.onimport.layout(can), can.isCmdMode() && rect.scrollIntoView() } - if (can.db._width < x+width) { can.db._width = x+width, can.onimport.layout(can), can.isCmdMode() && rect.scrollIntoView() } - }, - layout: function(can) { - if (can.page.isDisplay(can.ui.profile)) { var profile = can.db._profile_plugin; can.page.styleWidth(can, can.ui.profile, (can.ConfWidth()-can.ui.project.offsetWidth)/2) } - can.page.isDisplay(can.ui.display) && can.page.SelectChild(can, can.ui.display, html.TABLE, function(target) { can.page.styleHeight(can, can.ui.display, can.base.Max(target.offsetHeight, can.ConfHeight()/2)+1) }) - can.ui.layout(can.ConfHeight(), can.ConfWidth(), 0, function(height, width) { can.ui.toggle && can.ui.toggle.layout() - var _sub = can.db._content_plugin; if (_sub) { _sub.sup.onimport.size(_sub.sup, height, width), _sub.ui.svg.Val(html.HEIGHT, can.db._height), _sub.ui.svg.Val(html.WIDTH, can.db._width) } - profile && profile.onimport.size(profile, can.ui.profile.offsetHeight, can.ui.profile.offsetWidth-1, true) - }) + if (can.db.value.zone == can.db.hash[0] && item.hash == can.db.hash[1]) { can.onmotion.delay(can, function() { can.onimport._profile(can, item) }) } }, }, [""]) Volcanos(chat.ONACTION, { + /* list: ["create", "play", "prev", "next", ["travel", "deep", "wide"], ["direct", "vertical", "horizon"], + [html.MARGIN, 10, 20, 40, 60], [html.HEIGHT, 80, 100, 120, 140, 200], [html.WIDTH, 200, 240, 280, 400], - [html.MARGIN, 10, 20, 40, 60], ["delay", 100, 200, 500, 1000], ], _trans: {play: "播放", prev: "上一步", next: "下一步"}, - refresh: function(event, can, button) { can.misc.localStorage(can, ACTION_STORE+button, can.Action(button)), can.onimport._flows(can, can.db._content_plugin) }, + */ travel: function() {}, delay: function() {}, - play: function(event, can) { var list = can.onexport.travel(can, can.db.root, true) + play: function(event, can) { var list = can.onexport.travel(can, can.db.value._root, true) can.core.List(list, function(item) { item._line && item._line.Value(html.CLASS, ""), item._rect.Value(html.CLASS, ""), item._text.Value(html.CLASS, "") }) can.core.Next(list, function(item, next, index, list) { item._line && item._line.Value(html.CLASS, "done"), item._rect.Value(html.CLASS, "done"), item._text.Value(html.CLASS, "done") @@ -132,30 +135,29 @@ Volcanos(chat.ONACTION, { }) Volcanos(chat.ONDETAIL, { _select: function(event, can, item) { if (!item) { return can.onmotion.hidden(can, can.ui.profile) } - can.isCmdMode() && item._rect.scrollIntoView(), can.db.current = item, can.onimport._profile(can, item) + can.isCmdMode() && item._rect.scrollIntoView(), can.db.value._current = item, can.onimport._profile(can, item) can.page.Select(can, item._rect.parentNode, "", function(target) { var _class = (target.Value(html.CLASS)||"").split(lex.SP) if (can.base.isIn(target, item._line, item._rect, item._text)) { if (_class.indexOf(html.SELECT) == -1) { target.Value(html.CLASS, _class.concat([html.SELECT]).join(lex.SP).trim()) } } else { if (_class.indexOf(html.SELECT) > -1) { target.Value(html.CLASS, _class.filter(function(c) { return c != html.SELECT }).join(lex.SP).trim()) } } - }), can.page.Select(can, item._tr.parentNode, "", function(target) { can.page.ClassList.set(can, target, html.SELECT, target == item._tr) }) + }) + // can.page.Select(can, item._tr.parentNode, "", function(target) { can.page.ClassList.set(can, target, html.SELECT, target == item._tr) }) }, - onclick: function(event, can, _sub, item) { switch (_sub.svg.style.cursor) { + onclick: function(event, can, sub, item) { switch (sub.ui.svg.style.cursor) { case "e-resize": can.Update(can.request(event, can.Action("direct") == "horizon"? {prev: item.hash}: {from: item.hash}), [ctx.ACTION, mdb.INSERT]); break case "s-resize": can.Update(can.request(event, can.Action("direct") == "horizon"? {from: item.hash}: {prev: item.hash}), [ctx.ACTION, mdb.INSERT]); break default: can.ondetail._select(event, can, item) } can.onkeymap.prevent(event) }, - oncontextmenu: function(event, can, _sub, item) { - can.user.carteItem(event, can, can.base.CopyStr({action: item.action, zone: can.Option(mdb.ZONE)}, item)) - }, + oncontextmenu: function(event, can, sub, item) { can.user.carteItem(event, can, can.base.CopyStr({action: item.action, zone: can.Option(mdb.ZONE)}, item)) }, }) Volcanos(chat.ONEXPORT, { - margin: function(can) { var margin = can.Action(html.MARGIN); return parseFloat(margin) }, - height: function(can) { var height = can.Action(html.HEIGHT); return parseFloat(height) }, - width: function(can) { var width = can.Action(html.WIDTH); return parseFloat(width) }, + margin: function(can) { var margin = can.Action(html.MARGIN); return parseFloat(margin)||10 }, + height: function(can) { var height = can.Action(html.HEIGHT); return parseFloat(height)||60 }, + width: function(can) { var width = can.Action(html.WIDTH); return parseFloat(width)||200 }, travel: function(can, root, main) { if (!root) { return [] } if (can.Action("travel") == "deep") { var list = [root] if (main) { @@ -175,22 +177,3 @@ Volcanos(chat.ONEXPORT, { return list }, }) -Volcanos(chat.ONKEYMAP, { - _mode: {plugin: { - Escape: shy("清屏", function(event, can) { can.onaction.clear(event, can) }), - g: shy("播放", function(event, can) { can.onaction.play(event, can) }), - v: shy("预览", function(event, can) { can.onaction.show(event, can) }), - r: shy("展示", function(event, can) { can.onaction.exec(event, can) }), - " ": shy("展示", function(event, can) { can.onaction.exec(event, can) }), - Enter: shy("预览", function(event, can) { can.onaction.show(event, can) }), - k: shy("上一步", function(event, can) { can.db.current && can.db.current.from? can.ondetail._select(event, can, can.db.current.from): can.onaction.prev(event, can) }), - h: shy("前一步", function(event, can) { can.db.current && can.db.current.prev? can.ondetail._select(event, can, can.db.current.prev): can.onaction.prev(event, can) }), - l: shy("后一步", function(event, can) { can.db.current && can.db.current.next? can.ondetail._select(event, can, can.db.current.next): can.onaction.next(event, can) }), - j: shy("下一步", function(event, can) { can.db.current && can.db.current.to? can.ondetail._select(event, can, can.db.current.to): can.onaction.next(event, can) }), - ArrowUp: shy("上一步", function(event, can) { can.db.current && can.db.current.from? can.ondetail._select(event, can, can.db.current.from): can.onaction.prev(event, can) }), - ArrowLeft: shy("前一步", function(event, can) { can.db.current && can.db.current.prev? can.ondetail._select(event, can, can.db.current.prev): can.onaction.prev(event, can) }), - ArrowRight: shy("后一步", function(event, can) { can.db.current && can.db.current.next? can.ondetail._select(event, can, can.db.current.next): can.onaction.next(event, can) }), - ArrowDown: shy("下一步", function(event, can) { can.db.current && can.db.current.to? can.ondetail._select(event, can, can.db.current.to): can.onaction.next(event, can) }), - }}, _engine: {}, -}) -})()