1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-25 16:58:06 +08:00

opt field

This commit is contained in:
harveyshao 2021-08-25 11:06:12 +08:00
parent 3c80826682
commit 1da76c827b
17 changed files with 61 additions and 28 deletions

View File

@ -346,7 +346,7 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta,
can.core.List(array, function(item, index) { line[item.key||line.name] = item.value })
key == "extra.cmd" && can.onappend.plugin(can, {ctx: line["extra.ctx"], cmd: line["extra.cmd"], arg: line["extra.arg"]}, function(sub) {
sub.run = function(event, cmds, cb) { var msg = can.request(event, can.Option(), line)
can.run(event, (cmds[0] == "_search"? []: [ctx.ACTION, cli.RUN]).concat(cmds), function(msg) {
can.run(event, can.misc.Concat([ctx.ACTION, cli.RUN], cmds), function(msg) {
can.base.isFunc(cb) && cb(msg)
}, true)
}

View File

@ -158,6 +158,11 @@ Volcanos("misc", {help: "通信协议", Message: function(event, can) { var msg
}
},
Concat: function(to, from) {
if (from[0] == "_search") { return from }
return to.concat(from)
},
Log: function() {
var args = [this._time(), this.FileLine(2, 3)]
for (var i in arguments) { args.push(arguments[i]) }

View File

@ -656,3 +656,7 @@ body.print fieldset.River>div.output div.item.select {
background-color:white;
border:solid 2px red;
}
div.output fieldset.left>fieldset {
float:left; overflow:auto;
}

View File

@ -19,6 +19,7 @@ Volcanos({name: "chat", iceberg: "/chat/", volcano: "/frame.js",
"/plugin/local/wiki/draw.js",
"/plugin/local/wiki/word.js",
"/plugin/local/team/plan.js",
"/plugin/local/chat/div.js",
], river: {
"serivce": {name: "运营群", storm: {
"wx": {name: "公众号 wx", action: [

View File

@ -19,7 +19,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg)
_plugin: function(can, river, storm, sub, meta) {
sub.run = function(event, cmds, cb) { var msg = sub.request(event); cmds = cmds || [];
var toast = msg.Option("_toast") && can.user.toast(can, msg.Option("_toast"), "", -1)
return can.run(event, (can.onengine[cmds[0]]? []: [river, storm, meta.id||meta.index||can.core.Keys(meta.key, meta.name)]).concat(cmds), function(msg) {
return can.run(event, can.misc.Concat([river, storm, meta.id||meta.index||can.core.Keys(meta.key, meta.name)], cmds), function(msg) {
toast && toast.close(), can.base.isFunc(cb) && cb(msg)
})
}, can._plugins = (can._plugins||[]).concat([sub])

View File

@ -17,7 +17,7 @@ Volcanos("onaction", {help: "交互操作", list: [], _init: function(can, msg,
_plugin: function(can, index, args, next) {
can.onappend.plugin(can, {type: "plugin", index: index, args: args, opts: can.user.Search(), width: window.innerWidth}, function(sub, meta) {
sub.run = function(event, cmds, cb) {
can.run(event, (can.onengine[cmds[0]]? []: [ctx.ACTION, "run", index]).concat(cmds), cb)
can.run(event, can.misc.Concat([ctx.ACTION, "run", index], cmds), cb)
}
// can.onmotion.hidden(can, sub._legend)
can.user.title(meta.name)

View File

@ -17,12 +17,14 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
{text: [item, html.LABEL]}, {text: [": ", html.LABEL]}, {text: [can.Conf(item)||"", html.SPAN, item]},
], onclick: function(event) {
can.show = can.show? (can.page.Remove(can, can.show), null): can.onaction._cmd(can)
can.page.Modify(can, can.show, {style: {left: "", top: "", right: 0, bottom: 32}})
}}])
})
},
_toast: function(can, msg, target) {
can.toast = can.page.Append(can, target, [{view: "toast", onclick: function(event) {
can.show = can.show? (can.page.Remove(can, can.show), null): can.onappend.float(can, can._toast).first
can.page.Modify(can, can.show, {style: {left: "", top: "", right: 0, bottom: 32}})
}}]).first
},
_cli: function(can, msg, target) {
@ -73,7 +75,7 @@ Volcanos("onaction", {help: "交互数据", list: [], _init: function(can, msg,
can.search({}, ["Action.onexport.size"], function(msg, top, left, width, height) {
can.onappend.plugin(can, {index: commands[0], args: commands.slice(1), width: width, height: height-100}, function(sub) {
sub.run = function(event, cmds, cb) {
can.run(event, [ctx.ACTION, cli.RUN, commands[0]].concat(cmds), cb)
can.run(event, can.misc.Concat([ctx.ACTION, cli.RUN, commands[0]], cmds), cb)
}
can.page.Modify(can, sub._output, {style: {"max-width": width}})

View File

@ -83,7 +83,7 @@ Volcanos("onaction", {help: "交互操作", list: ["关闭", "清空", "完成"]
var cmd = line.cmd == "command"? can.core.Keys(line.text, line.name): can.core.Keys(line.ctx, line.cmd)
can.onappend.plugin(can, {type: "plugin", index: cmd||msg.Option("index")}, function(sub, meta) {
sub.run = function(event, cmds, cb) { var msg = can.request(event, line)
can.run(event, [ctx.ACTION, cli.RUN, meta.index].concat(cmds), cb)
can.run(event, can.misc.Concat([ctx.ACTION, cli.RUN, meta.index], cmds), cb)
}
}, can.ui.preview)
},

View File

@ -1,7 +1,7 @@
fieldset.div div.output td {
vertical-align:top;
}
fieldset.div div.output fieldset.left>fieldset {
fieldset.div div.output fieldset.float>fieldset {
float:left; overflow:auto;
}
fieldset.panel.cmd.main fieldset.div {

View File

@ -3,23 +3,31 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
can._meta = can.base.Obj(meta.text, {meta: {name: meta.name}, list: []})
can.base.isFunc(cb) && cb(msg)
var width = can.Conf("width")-260, height = can.Conf("height")-100
if (location.pathname.indexOf("/chat/cmd") == 0) {
width = window.innerWidth, height = window.innerHeight
can.page.Modify(can, target, {style: {width: width, height: height}})
}
can.ui = can.page.Appends(can, target, [{view: ["layout", "table"], list: [{type: "tr", list: [
{type: "td", list: [{view: "project"}]},
{type: "td", list: [{view: "display"}]},
{type: "td", list: [{view: "profile"}]},
]}] }]), can.ui.project._fieldset = can.ui.display
can.onimport._item(can, can._meta, can.ui.project, width).click()
can.onimport._item(can, can._meta, can.ui.project, can.onimport._size(can)).click()
},
_item: function(can, node, target, width) {
width = node.meta.width||width
var ui = can.page.Append(can, target, [{view: ["item", "div", node.meta.name]}, {view: ["list"]}])
_size: function(can) {
var width = can.Conf("width")-260, height = can.Conf("height")-100
if (can.Conf("auto.cmd")) {
can.onmotion.hidden(can, can.ui.project)
can.onmotion.hidden(can, can.ui.profile)
can.onmotion.hidden(can, can._option)
can.onmotion.hidden(can, can._action)
width = can.Conf("width"), height = can.Conf("height")
}
if (location.pathname.indexOf("/chat/cmd") == 0) {
width = window.innerWidth, height = window.innerHeight
can.page.Modify(can, can._output, {style: {width: width, height: height}})
}
return width
},
_item: function(can, node, target, width) { width = node.meta.width||width
var ui = can.page.Append(can, target, [{view: ["item", "div", node.meta.name||"some"]}, {view: ["list"]}])
ui.list._fieldset = can.onimport._field(can, node.meta, target._fieldset, width)
var msg = can.request({}); msg.Push(node.meta, "", true)
@ -35,8 +43,12 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
}, can.ui.profile)
}
ui.item._add = function(data) { node.list.push(data)
can.onimport._item(can, data, ui.list, width)
ui.item._add = function(data) {
if (node.meta.style == "left") { width = width * node.list.length }
node.list.push(data)
if (node.meta.style == "left") { width = width / node.list.length }
can.onmotion.clear(can, ui.list), can.onmotion.clear(can, ui.list._fieldset)
can.core.List(node.list, function(node) { can.onimport._item(can, node, ui.list, width) })
}
if (node.meta.style == "left") { width = width / node.list.length }
can.core.List(node.list, function(node) { can.onimport._item(can, node, ui.list, width) })
@ -56,7 +68,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
}, size), ["/plugin/state.js"], function(sub) {
can.page.Modify(can, sub._output, {style: size})
sub.run = function(event, cmds, cb) {
can.run(event, [ctx.ACTION, cli.RUN, meta.index].concat(cmds), cb, true)
can.run(event, can.misc.Concat([ctx.ACTION, cli.RUN, meta.index], cmds), cb, true)
}
}, target, field)
}, true)
@ -65,12 +77,12 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
}, ["/plugin/local/chat/div.css"])
Volcanos("onaction", {help: "操作数据", list: [],
"添加": function(event, can) {
can.user.input(event, can, ["name", "index", "args", "width", "height", "style"], function(event, button, data, list, args) {
can.user.input(event, can, ["name", "index", "args", "style", "width", "height"], function(event, button, data, list, args) {
can.current._add({meta: data, list: []})
})
},
"保存": function(event, can) { var msg = can.request(event, can.Option())
can.run(event, ["modify", "text", JSON.stringify(can._meta)], function(msg) {
can.run(event, [mdb.MODIFY, "text", JSON.stringify(can._meta)], function(msg) {
can.user.toast(can, "保存成功")
}, true)
},

View File

@ -52,7 +52,7 @@ Volcanos("onimport", {help: "导入数据", _init: function(can, msg, list, cb,
case "inner": can.onimport.tabview(can, msg.Option("path"), msg.Option("file"), msg.Option("line")); return
} }
can.run(event, [ctx.ACTION, "favor"].concat(cmds), function(msg) {
can.run(event, can.misc.Concat([ctx.ACTION, "favor"], cmds), function(msg) {
can.base.isFunc(cb) && cb(msg)
can.core.Timer(10, function() {
can.onappend._action(sub, ["关闭"], sub._action, {

View File

@ -4,7 +4,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
can.onappend.plugins(can, {index: "web.code.vimer"}, function(sub) {
sub.run = function(event, cmds, cb) { var res = can.request(event)
if (cmds[1] == "plugin") {
can.run(event, ["action", "vimer"].concat(cmds), cb, true)
can.run(event, can.misc.Concat(["action", "vimer"], cmds), cb, true)
return
}
if (cmds[1] == "main.go") { res.Echo(msg.Option("content"))

View File

@ -86,7 +86,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
task["extra.cmd"] && can.onappend.plugin(can, {ctx: task["extra.ctx"], cmd: task["extra.cmd"], arg: task["extra.arg"]}, function(sub, meta) {
sub.run = function(event, cmds, cb) { var msg = can.request(event, {"task.zone": task.zone, "task.id": task.id})
can.run(event, (cmds[0] == "_search"? []: [ctx.ACTION, cli.RUN]).concat(cmds), function(msg) {
can.run(event, can.misc.Concat([ctx.ACTION, cli.RUN], cmds), function(msg) {
can.base.isFunc(cb) && cb(msg)
}, true)
}

View File

@ -45,13 +45,19 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
item.type = "story"
can.onappend._init(can, item, ["/plugin/state.js"], function(sub) {
sub.run = function(event, cmds, cb, silent) {
can.run(event, (cmds && can.onengine[cmds[0]]? []: [ctx.ACTION, "story", data.type, data.name, data.text]).concat(cmds), cb, true)
can.run(event, can.misc.Concat([ctx.ACTION, "story", data.type, data.name, data.text], cmds), cb, true)
}
sub.Conf("width", item.width=can.Conf("width")-20)
can.onengine.listen(can, "onaction_resize", function(width, height) {
can.page.Modify(can, sub._output, {style: {"max-width": sub.Conf("width", item.width=width-80)}})
})
if (can.core.Value(item, "auto.cmd")) {
can.core.Timer(100, function() {
var msg = sub.request({}, can.core.Value(item, "opts")); msg.Option("_handle", "true")
sub.Update(msg._event, [ctx.ACTION, can.core.Value(item, "auto.cmd")])
})
}
}, can._output, target)
},

View File

@ -23,6 +23,9 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, conf,
},
_display: function(can, msg) {
Volcanos("some", {}, [msg.Option("_display")].concat(Volcanos.meta.volcano, Volcanos.meta.libs), function(sub) {
sub.Conf(can.Conf()), sub.run = can.run
sub._option = can._option
sub._action = can._action
sub.onimport._init(sub, msg, [], function() {}, can._output)
})
return true

View File

@ -142,7 +142,7 @@ Volcanos("ondetail", {help: "用户交互", list: [],
plugin: function(event, can, args) {
can.onappend.plugin(can, {type: "float", index: "web.code.inner", args: args, _action: ["关闭"]}, function(sub) {
sub.run = function(event, cmds, cb) {
can.run(event, [ctx.ACTION, "inner"].concat(cmds), function(msg) {
can.run(event, can.misc.Concat([ctx.ACTION, "inner"], cmds), function(msg) {
can.search(event, ["Action.onexport.size"], function(msg, left, top, width, height) { left = left||0
var top = 120, margin = 20; if (can.user.isMobile) { margin = 0
if (can.user.isLandscape) {

View File

@ -68,7 +68,7 @@ Volcanos("chrome", {
}, msg.Option("selection")||sub._legend.onclick()
sub.run = function(event, cmds, cb) { if (cmds[0] == "_search") { return }
can.run(event, [ctx.ACTION, cli.RUN, meta.index].concat(cmds), cb)
can.run(event, can.misc.Concat([ctx.ACTION, cli.RUN, meta.index], cmds), cb)
}
can.onmotion.move(can, sub._target, {})
@ -95,7 +95,7 @@ Volcanos("chrome", {
})
can.run = function(event, cmds, cb) { if (cmds[0] == "_search") { return }
var msg = can.request(event, {hostname: location.hostname}); msg.detail = ["page"].concat(cmds)
var msg = can.request(event, {hostname: location.hostname}); msg.detail = can.misc.Concat(["page"], cmds)
chrome.runtime.sendMessage(msg, function(res) { can.base.isFunc(cb) && cb(msg.Copy(res)) })
}
can.run({}, [ctx.ACTION, ctx.COMMAND], function(msg) {