From 601c5d2d1c74ae7bba030dcf0b27e2713d6b78e6 Mon Sep 17 00:00:00 2001 From: shaoying Date: Sun, 3 May 2020 21:58:25 +0800 Subject: [PATCH] add order.js --- frame.js | 4 +++ page/index.html => index.html | 2 +- page/index.js => index.js | 2 +- proto.js | 36 +++++++++++++++++++++++++ publish/order.js | 49 +++++++++++++++++++++++++++++++++++ 5 files changed, 91 insertions(+), 2 deletions(-) rename page/index.html => index.html (89%) rename page/index.js => index.js (94%) create mode 100644 publish/order.js diff --git a/frame.js b/frame.js index 2281f210..3a992d85 100644 --- a/frame.js +++ b/frame.js @@ -31,6 +31,10 @@ Volcanos("onaction", { }, sub._target) }, remote: function(event, can, msg, pane, cmds, cb) { + if (can.onengine && can.onengine.remote(event, can, msg, pane, cmds, cb)) { + return + } + if (Volcanos.meta.follow[can._root]) { debugger } Volcanos.meta.debug[can._root] && console.log(can._root, pane._name, "remote", msg._name, "detail", cmds); can.misc.Run(event, can, {names: pane._name}, cmds, function(msg) { diff --git a/page/index.html b/index.html similarity index 89% rename from page/index.html rename to index.html index 99c68d07..7703b591 100644 --- a/page/index.html +++ b/index.html @@ -9,7 +9,7 @@ - + diff --git a/page/index.js b/index.js similarity index 94% rename from page/index.js rename to index.js index 40709b19..ec83c1be 100644 --- a/page/index.js +++ b/index.js @@ -16,7 +16,7 @@ var Preload = Config.libs; Config.panes.forEach(function(pane) { Volcanos(Config.name, { _target: document.body, _head: document.head, _body: document.body, _width: window.innerWidth, _height: window.innerHeight, -}, Preload.concat(Config.volcano), function(can) { // 程序入口 +}, Preload.concat(Config.volcano, "publish/order.js"), function(can) { // 程序入口 can.onimport._init(can, can.Conf(Config), [], function(msg) { console.log(can._root, can._name, "start", can, msg); can.Footer.onaction._init(can.Footer, msg); diff --git a/proto.js b/proto.js index 6a993aaa..d825aa75 100644 --- a/proto.js +++ b/proto.js @@ -99,6 +99,42 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: { return typeof cb == "function" && (res = cb(one, index, array)) && res != undefined && res || one }) }), + Clear: function(key) { + switch (key) { + case "append": + case "option": + can.core.List(msg[key], function(item) { + delete(msg[item]) + }) + default: + msg[key] = [] + } + }, + Push: function(key, value, detail) {msg.append = msg.append || [] + if (typeof key == "object") { + value = value || can.core.Item(key) + can.core.List(value, function(item) { + detail? msg.Push("key", item).Push("value", key[item]||""): + msg.Push(item, key[item]||"") + }) + return + } + + for (var i = 0; i < msg.append.length; i++) { + if (msg.append[i] == key) { + break + } + } + if (i >= msg.append.length) {msg.append.push(key)} + msg[key] = msg[key] || [] + msg[key].push(""+value+"") + return msg + }, + Echo: shy("输出响应", function(res) {msg.result = msg.result || [] + msg._hand = true + for (var i = 0; i < arguments.length; i++) {msg.result.push(arguments[i])} + return msg; + }), } return msg }, diff --git a/publish/order.js b/publish/order.js new file mode 100644 index 00000000..bcfcd856 --- /dev/null +++ b/publish/order.js @@ -0,0 +1,49 @@ +Volcanos("onengine", { + river: { + one: {name: "some", storm: { + one: {name: "some", action: [ + {name: "show", help: "some"}, + ]}, + two: {name: "some"}, + }}, + two: {name: "some", storm: { + one: {name: "some"}, + two: {name: "two", action: { + show: {name: "show", help: "some", inputs: [ + {type: "text", name: "arg"}, + ]}, + }}, + }}, + three: {name: "some"}, + }, + + remote: function(event, can, msg, pane, cmds, cb) { var meta = can.onengine; + return false + var river = meta.river[msg.Option("river")] + var storm = river && river.storm[msg.Option("storm")] + + msg.Clear("append"); switch (pane._name) { + case "River": + can.core.Item(meta.river, function(key, value) { + msg.Push("key", key) + msg.Push("name", value.name) + }) + break + case "Storm": + river && can.core.Item(river.storm, function(key, value) { + msg.Push("key", key) + msg.Push("name", value.name) + }) + break + case "Action": + storm && can.core.List(storm.action, function(value) { + msg.Push("name", value.name) + msg.Push("help", value.help) + }) + break + } + typeof cb == "function" && cb(msg); + return true + }, +}, [], function(can) { }) +