diff --git a/plugin/state.js b/plugin/state.js
index 01c9c013..209009e8 100644
--- a/plugin/state.js
+++ b/plugin/state.js
@@ -81,14 +81,10 @@ Volcanos(chat.ONIMPORT, {
})
Volcanos(chat.ONACTION, {list: [
"刷新数据", "刷新界面", "切换浮动", "切换全屏",
- // "远程控制",
- "共享工具", "打开链接", "生成链接",
- "生成脚本",
- // "生成图片",
+ "共享工具", "打开链接", "生成链接", // "生成脚本", // "生成图片", // "远程控制",
["视图", "参数", "操作", "状态", "专注", "项目", "预览", "演示"],
["数据", "保存参数", "清空参数", "复制数据", "下载数据", "添加工具", "清空数据"],
["调试", "查看文档", "查看脚本", "查看源码", "查看配置", "删除工具"],
- // ["调试", "打包页面", "查看文档", "查看脚本", "查看源码", "查看配置", "查看日志"],
// ["调试", "打包页面", "查看文档", "查看脚本", "查看源码", "查看配置", "查看日志", "添加工具"],
],
_engine: function(event, can, button) { can.Update(event, [ctx.ACTION, button].concat(can.Input())) },
diff --git a/publish/client/mp/app.wxml b/publish/client/mp/app.wxml
index 4ec3b7f4..3cd8643a 100644
--- a/publish/client/mp/app.wxml
+++ b/publish/client/mp/app.wxml
@@ -29,3 +29,49 @@
+
+
+
+
+
+
+
+ {{field.name}}({{field.help}})
+
+
+
+
+
+
+
+ {{item.value||item.values[item.index||0]}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{item.name}}: {{item.value}}
+
+
+
+
+
+
diff --git a/publish/client/mp/pages/action/action.js b/publish/client/mp/pages/action/action.js
index 649ee970..8300cc4f 100644
--- a/publish/client/mp/pages/action/action.js
+++ b/publish/client/mp/pages/action/action.js
@@ -1,126 +1,9 @@
const {ice, ctx, mdb, web, code, chat, http, html} = require("../../utils/const.js")
const {shy, Volcanos} = require("../../utils/proto.js")
Volcanos._page = {}
-Volcanos(chat.ONIMPORT, {
- _init: function(can, msg) { can.ui.data.list = []
- msg.Table(function(field, order) { can.ui.data.list.push(field)
- field.feature = can.base.Obj(field.meta, {})
- field.inputs = can.base.Obj(field.list, [])
- field.name = can.core.Split(field.name)[0]
- if (!field.inputs || field.inputs.length === 0) {
- return can.core.Timer(30, function() {
- can.onaction._refresh({}, can, order)
- })
- }
- can.core.List(field.inputs, function(input) {
- input.action = input.action || input.value
- input.value == ice.AUTO && (input.value = "")
- if (input.value && input.value.indexOf("@") == 0) {
- input.action = input.value.slice(1), input.value = ""
- }
- if (input.type == html.SELECT) {
- input.values = input.values || can.core.Split(input.value)
- }
- if (can.base.isIn(input.type, html.TEXT, html.TEXTAREA)) {
- input.placeholder = can.user.trans(can, input.placeholder||input.name, field, html.INPUT)
- }
- if (input.type == html.BUTTON) {
- input.value = can.user.trans(can, input.value||input.name, field)
- } else {
- if (can.db.cmd||can.db.index) { input.value = input.value||can.db[input.name] }
- }
- input.type == html.BUTTON && input.action == ice.AUTO && can.core.Timer(30, function() {
- can.onaction._refresh({}, can, order)
- })
- })
- }), can.page.setData(can), can.user.toast(can, "加载成功")
- },
-})
Volcanos(chat.ONACTION, {list: ["刷新", "扫码", "清屏"],
"刷新": function(event, can) { can.onaction.refresh(event, can) },
"扫码": function(event, can) { can.user.agent.scanQRCode(can) },
"清屏": function(event, can) { can.core.List(can.ui.data.list, function(item) { delete(item.msg) }), can.page.setData(can) },
- _refresh: function(event, can, order) { can.page.setData(can)
- can.onaction.onAction({}, can, ice.LIST, {order: order, name: ice.LIST})
- },
- refresh: function(event, can) { can.onaction._apis = "", can.onaction._cmds = []
- if (can.db.share) { can.onaction._apis = "/share/"+can.db.share
- can.run(event, [ctx.ACTION, ctx.COMMAND], function(msg) {
- can.onaction._cmds = [ctx.ACTION, ctx.RUN], can.onimport._init(can, msg)
- })
- } else if (can.db.river && can.db.storm) {
- can.onaction._cmds = [can.db.river, can.db.storm]
- can.run(event, [], function(msg) { can.onimport._init(can, msg) })
- } else {
- can.run(event, [ctx.ACTION, ctx.COMMAND, can.db.cmd||can.db.index||"cli.qrcode"], function(msg) {
- can.onaction._cmds = [ctx.ACTION, ctx.RUN], can.onimport._init(can, msg)
- })
- }
- },
- onaction: function(event, can, button, data) { var name = data.name;
- (can.onaction[name]||function(event) { can.run(event, [ctx.ACTION, name]) })(event, can)
- },
- onInputs: function(event, can, button, data) { var order = data.order, index = data.index
- var input = can.ui.data.list[order||0].inputs[index||0]
- input.value = event.detail.value
- },
- onChange: function(event, can, button, data) { var order = data.order, index = data.index
- var input = can.ui.data.list[order||0].inputs[index||0]
- input.value = input.values[parseInt(event.detail.value)]
- can.onaction._refresh(event, can, order)
- },
- onAction: function(event, can, button, data) { var order = data.order, name = data.name
- var field = can.ui.data.list[order||0], msg = can.request(event)
- if (field.feature[name]) { if (can.base.isIn(name, mdb.CREATE, mdb.INSERT)) { msg._method = http.PUT }
- return can.data.insert = {field: field, name: name, list: field.feature[name], cb: function(res) {
- can.run(event, can.base.Simple([field.id||field.index, ctx.ACTION, name], res), function(msg) {
- can.onaction._refresh(event, can, order)
- })
- }}, can.user.jumps(chat.PAGES_INSERT)
- } field._history = field._history||[]
- switch (name) {
- case ice.BACK: field._history.pop(); var ls = field._history.pop()||[], i = 0
- can.core.List(field.inputs, function(input) { if (input.type != html.BUTTON) { input.value = ls[i++]||"" } })
- can.onaction._refresh(event, can, order); break
- case ctx.RUN: break
- case ice.LIST:
- case web.REFRESH: msg._method = http.GET; break
- default: msg.Option(ctx.ACTION, name)
- }
- var cmd = can.core.List(field.inputs, function(input) { if (input.type != html.BUTTON) { return input.value } })
- for (var i = cmd.length-1; i > 0; i--) { if (cmd[i] === "") { cmd.pop() } else { break } }
- function eq(to, from) { if (!to) { return false } if (to.length != from.length) { return false }
- for (var i = 0; i < to.length; i++) { if (to[i] != from[i]) { return false } } return true
- } eq(field._history[field._history.length-1], cmd) || field._history.push(cmd)
- can.run(event, [field.id||field.index].concat(cmd), function(msg) {
- msg._head = can.core.List(msg.append, function(item) { return can.user.trans(can, item, field, html.INPUT) })
- can.core.Item(msg._view, function(key, value) { can.core.List(value, function(value) { can.core.List(value, function(input, i) {
- if (input.type == html.BUTTON) { input.value = can.user.trans(can, input.value||input.name, field) }
- if (input._type == html.TEXT) { input._text = can.user.trans(can, input._text, field, html.VALUE) }
- }) }) })
- msg._status = can.core.List(can.base.Obj(msg.Option(ice.MSG_STATUS)), function(item) { return item })
- msg._action = can.core.List(can.base.Obj(msg.Option(ice.MSG_ACTION)), function(item) {
- if (typeof item == code.STRING) { return {type: html.BUTTON, name: item, value: can.user.trans(can, item)} }
- return item.value = can.user.trans(can, item.value||item.name), item
- }), field.msg = msg, can.page.setData(can)
- })
- },
- onDetail: function(event, can, button, data) { var order = data.order, name = data.name, value = data.value, input = data.input
- var field = can.ui.data.list[order||0]
- if (input && input.type == html.BUTTON) { var msg = can.request(event, field.msg.Table()[data.index])
- if (can.base.isIn(name, mdb.REMOVE, mdb.DELETE)) { msg._method = http.DELETE }
- var _input = {}; can.core.List(field.inputs, function(input) { if (input.type != html.BUTTON) { _input[input.name] = input.value } }), can.request(event, _input)
- if (field.feature[input.name]) {
- can.onAction(event, can, input.name, {order: order, name: input.name})
- } else {
- can.run(event, [field.id||field.index, ctx.ACTION, input.name], function(msg) {
- can.onaction._refresh(event, can, order)
- })
- } return
- }
- can.core.List(field.inputs, function(input) {
- if (input.name == name) { input.value = value, can.onaction._refresh(event, can, order) }
- })
- },
})
Volcanos._init()
diff --git a/publish/client/mp/pages/action/action.wxml b/publish/client/mp/pages/action/action.wxml
index 8813c7f9..9cf0e762 100644
--- a/publish/client/mp/pages/action/action.wxml
+++ b/publish/client/mp/pages/action/action.wxml
@@ -1,44 +1,2 @@
-
-
-
-
-
- {{field.name}}({{field.help}})
-
-
-
-
-
-
-
- {{item.value||item.values[item.index||0]}}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{item.name}}: {{item.value}}
-
-
-
-
-
+
diff --git a/publish/client/mp/utils/lib/misc.js b/publish/client/mp/utils/lib/misc.js
index 98d31a93..b2ea505b 100644
--- a/publish/client/mp/utils/lib/misc.js
+++ b/publish/client/mp/utils/lib/misc.js
@@ -50,6 +50,39 @@ Volcanos("misc", {
}); return msg },
Echo: function(res) { msg.result = (msg.result||[]).concat(can.core.List(arguments)); return msg._hand = true, msg },
}); return msg },
+ ParseCmd: function(can, msg) { can.ui.data.list = []
+ msg.Table(function(field, order) { can.ui.data.list.push(field)
+ field.feature = can.base.Obj(field.meta, {})
+ field.inputs = can.base.Obj(field.list, [])
+ field.name = can.core.Split(field.name)[0]
+ if (!field.inputs || field.inputs.length === 0) {
+ return can.core.Timer(30, function() {
+ can.onaction._refresh({}, can, order)
+ })
+ }
+ can.core.List(field.inputs, function(input) {
+ input.action = input.action || input.value
+ input.value == ice.AUTO && (input.value = "")
+ if (input.value && input.value.indexOf("@") == 0) {
+ input.action = input.value.slice(1), input.value = ""
+ }
+ if (input.type == html.SELECT) {
+ input.values = input.values || can.core.Split(input.value)
+ }
+ if (can.base.isIn(input.type, html.TEXT, html.TEXTAREA)) {
+ input.placeholder = can.user.trans(can, input.placeholder||input.name, field, html.INPUT)
+ }
+ if (input.type == html.BUTTON) {
+ input.value = can.user.trans(can, input.value||input.name, field)
+ } else {
+ if (can.db.cmd||can.db.index) { input.value = input.value||can.db[input.name] }
+ }
+ input.type == html.BUTTON && input.action == ice.AUTO && can.core.Timer(30, function() {
+ can.onaction._refresh({}, can, order)
+ })
+ })
+ }), can.page.setData(can), can.user.toast(can, "加载成功")
+ },
ParseURL: function(can, url) { url = url||location&&location.href; var args = can.base.ParseURL(url)
delete(args.link), delete(args.origin), delete(args._origin)
var ls = can.core.Split(url.split("://")[1].split("?")[0].split("#")[0], nfs.PS).slice(1)
diff --git a/publish/client/mp/utils/proto.js b/publish/client/mp/utils/proto.js
index 1f807dd3..58414b8e 100644
--- a/publish/client/mp/utils/proto.js
+++ b/publish/client/mp/utils/proto.js
@@ -1,4 +1,4 @@
-const {kit, ice, ctx, mdb, nfs, code, chat} = require("const.js")
+const {kit, ice, ctx, mdb, web, nfs, code, chat, http, html} = require("const.js")
function shy(help, meta, list, cb) { var arg = arguments, i = 0; function next(type) {
if (type == code.OBJECT) { if (typeof arg[i] == code.OBJECT && arg[i].length == undefined) { return arg[i++] }
} else if (type == code.ARRAY) { if (typeof arg[i] == code.OBJECT && arg[i].length != undefined) { return arg[i++] }
@@ -25,15 +25,112 @@ Volcanos._init = function() {
msg.Dump = function() { can.ui.setData({list: msg.Table()}) }, cb(msg)
})
},
- }; Volcanos._page.__proto__ = getApp(), delete(Volcanos._page)
+ }; Volcanos._page.__proto__ = getApp()
+ Volcanos._page.onimport = Volcanos._page.onimport||{}
+ Volcanos._page.onaction = can.base.Copy({
+ _refresh: function(event, can, order) { can.page.setData(can)
+ can.onaction.onAction({}, can, ice.LIST, {order: order, name: ice.LIST})
+ },
+ _reload: function(can, msg) {
+ can.misc.ParseCmd(can, msg)
+ },
+ refresh: function(event, can) {
+ can.onaction._apis = "", can.onaction._cmds = []
+ if (can.db.share) { can.onaction._apis = "/share/"+can.db.share
+ can.run(event, [ctx.ACTION, ctx.COMMAND], function(msg) {
+ can.onaction._cmds = [ctx.ACTION, ctx.RUN], can.onaction._reload(can, msg)
+ })
+ } else if (can.db.river && can.db.storm) {
+ can.onaction._cmds = [can.db.river, can.db.storm]
+ can.run(event, [], function(msg) { can.onaction._reload(can, msg) })
+ } else {
+ can.run(event, [ctx.ACTION, ctx.COMMAND, can.db.cmd||can.db.index||"cli.qrcode"], function(msg) {
+ can.onaction._cmds = [ctx.ACTION, ctx.RUN], can.onaction._reload(can, msg)
+ })
+ }
+ },
+ onaction: function(event, can, button, data) { var name = data.name;
+ (can.onaction[name]||function(event) { can.run(event, [ctx.ACTION, name]) })(event, can)
+ },
+ onInputs: function(event, can, button, data) { var order = data.order, index = data.index
+ var input = can.ui.data.list[order||0].inputs[index||0]
+ input.value = event.detail.value
+ },
+ onChange: function(event, can, button, data) { var order = data.order, index = data.index
+ var input = can.ui.data.list[order||0].inputs[index||0]
+ input.value = input.values[parseInt(event.detail.value)]
+ can.onaction._refresh(event, can, order)
+ },
+ onAction: function(event, can, button, data) { var order = data.order, name = data.name
+ var field = can.ui.data.list[order||0], msg = can.request(event)
+ if (field.feature[name]) { if (can.base.isIn(name, mdb.CREATE, mdb.INSERT)) { msg._method = http.PUT }
+ return can.data.insert = {field: field, name: name, list: field.feature[name], cb: function(res) {
+ can.run(event, can.base.Simple([field.id||field.index, ctx.ACTION, name], res), function(msg) {
+ can.onaction._refresh(event, can, order)
+ })
+ }}, can.user.jumps(chat.PAGES_INSERT)
+ } field._history = field._history||[]
+ switch (name) {
+ case ice.BACK: field._history.pop(); var ls = field._history.pop()||[], i = 0
+ can.core.List(field.inputs, function(input) { if (input.type != html.BUTTON) { input.value = ls[i++]||"" } })
+ can.onaction._refresh(event, can, order); break
+ case ctx.RUN: break
+ case ice.LIST:
+ case web.REFRESH: msg._method = http.GET; break
+ default: msg.Option(ctx.ACTION, name)
+ }
+ var cmd = can.core.List(field.inputs, function(input) { if (input.type != html.BUTTON) { return input.value } })
+ for (var i = cmd.length-1; i > 0; i--) { if (cmd[i] === "") { cmd.pop() } else { break } }
+ function eq(to, from) { if (!to) { return false } if (to.length != from.length) { return false }
+ for (var i = 0; i < to.length; i++) { if (to[i] != from[i]) { return false } } return true
+ } eq(field._history[field._history.length-1], cmd) || field._history.push(cmd)
+ can.run(event, [field.id||field.index].concat(cmd), function(msg) { can.onimport._init && can.onimport._init(can, msg)
+ msg._head = can.core.List(msg.append, function(item) { return can.user.trans(can, item, field, html.INPUT) })
+ can.core.Item(msg._view, function(key, value) { can.core.List(value, function(value) { can.core.List(value, function(input, i) {
+ if (input.type == html.BUTTON) { input.value = can.user.trans(can, input.value||input.name, field) }
+ if (input._type == html.TEXT) { input._text = can.user.trans(can, input._text, field, html.VALUE) }
+ }) }) })
+ msg._status = can.core.List(can.base.Obj(msg.Option(ice.MSG_STATUS)), function(item) { return item })
+ msg._action = can.core.List(can.base.Obj(msg.Option(ice.MSG_ACTION)), function(item) {
+ if (typeof item == code.STRING) { return {type: html.BUTTON, name: item, value: can.user.trans(can, item)} }
+ return item.value = can.user.trans(can, item.value||item.name), item
+ }), field.msg = msg, can.page.setData(can)
+ })
+ },
+ onDetail: function(event, can, button, data) { var order = data.order, name = data.name, value = data.value, input = data.input
+ var field = can.ui.data.list[order||0]
+ if (input && input.type == html.BUTTON) { var msg = can.request(event, field.msg.Table()[data.index])
+ if (can.base.isIn(name, mdb.REMOVE, mdb.DELETE)) { msg._method = http.DELETE }
+ var _input = {}; can.core.List(field.inputs, function(input) { if (input.type != html.BUTTON) { _input[input.name] = input.value } }), can.request(event, _input)
+ if (field.feature[input.name]) {
+ can.onAction(event, can, input.name, {order: order, name: input.name})
+ } else {
+ can.run(event, [field.id||field.index, ctx.ACTION, input.name], function(msg) {
+ can.onaction._refresh(event, can, order)
+ })
+ } return
+ }
+ can.core.List(field.inputs, function(input) {
+ if (input.name == name) { input.value = value, can.onaction._refresh(event, can, order) }
+ })
+ }}, Volcanos._page.onaction||{})
+ delete(Volcanos._page)
var page = {data: {action: can.onaction.list, list: []},
onLoad: function(options) { can.ui = this, can.db = options, can.db.serve = can.db.serve||can.conf.serve
can.core.Item(can.db, function(key, value) { can.db[key] = decodeURIComponent(value) })
can.core.Item(can.db, function(key, value) { can.db[key] = decodeURIComponent(value) })
- can.misc.Info("app show", can.ui.route, can.db), can.user.agent.enableDebug(can)
+ can.misc.Info("app show", can.ui.route, can.db, can.user.info), can.user.agent.enableDebug(can)
can.user.title(can.db.title||can.db.pod||can.db.space||(can.db.serve||can.conf.serve).split("://")[1])
function refresh() { can.ui.setData({conf: can.db}), can.user.login(can, function() {
- can.misc.WSS(can), can.core.Timer(300, function() { can.onaction.refresh({}, can) })
+ can.misc.WSS(can), can.core.Timer(300, function() {
+ if (can.onaction.refresh) {
+ can.onaction.refresh({}, can)
+ } else {
+ can.run({}, [ctx.ACTION, ctx.COMMAND, can.db.index], function(msg) {
+ can.misc.ParseCmd(can, msg)
+ })
+ }
+ })
}) }
function wifi(cb) { can.db.ssid && can.db.password != "******"? can.user.agent.connectWifi(can, can.db.ssid, can.db.password||"", function() { can.db.password = "******", cb() }): cb() }
if (can.db.scene) { var ls = can.db.scene.split(nfs.PS); can.db.scene = ls[2]