1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-25 16:58:06 +08:00
This commit is contained in:
shylinux 2020-05-02 20:45:38 +08:00
parent b0a8a74687
commit c2444a21d4
13 changed files with 274 additions and 282 deletions

View File

@ -1,3 +1,43 @@
Volcanos("onimport", {
_init: function(can, meta, list, cb, target) {
if (Volcanos.meta.follow[can._root]) { debugger }
can.core.Next(meta.panes, function(item, next) {
can.onappend._init(can, item, Config.libs.concat(item.list), function(pane) {
pane.run = function(event, cmds, cb) { var msg = pane.request(event);
if (can.onaction[cmds[0]]) {
can.onaction[cmds[0]](event, can, msg, pane, cmds, cb);
} else {
can.onaction[meta.main.engine](event, can, msg, pane, cmds, cb);
}
}, can[item.name] = pane, next();
}, can._target);
}, function() { can.onlayout._init(can, meta, list, function() {
if (Volcanos.meta.follow[can._root]) { debugger }
var pane = can[meta.main.name], msg = can.request(can._event);
pane.onaction._init(pane, msg, msg.option||[], cb, target);
}, target) });
},
})
Volcanos("onaction", {
search: function(event, can, msg, pane, cmds, cb) { var chain = cmds[1]
if (Volcanos.meta.follow[can._root]) { debugger }
var sub, mod = can, key, fun = can; can.core.List(chain.split("."), function(value, index, array) {
fun && (sub = mod, mod = fun, key = value, fun = mod[value])
}); if (!sub || !mod || !fun) { console.error("not found", chain); return }
Volcanos.meta.debug[can._root] && console.log(can._root, can._name, "engine", chain, "match", sub._name+"."+mod._name)
typeof fun == "function" && fun(sub, msg, cmds.slice(2), function(value) {
typeof cb == "function" && cb(value)
}, sub._target)
},
remote: function(event, can, msg, pane, cmds, cb) {
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) {
typeof cb == "function" && cb(msg);
})
},
})
Volcanos("onappend", {
_init: function(can, meta, list, cb, target) {
var field = can.onappend.field(can, target, meta.type, meta);
@ -6,22 +46,24 @@ Volcanos("onappend", {
var output = can.page.Select(can, field, "div.output")[0];
// 添加插件
if (Volcanos.meta.follow[can._root]) { debugger }
var sub = Volcanos(meta.name, { _help: meta.name, _target: field,
_option: option, _action: action, _output: output,
_history: [],
}, list, function(sub) { sub.Conf(meta);
sub.onimport && sub.onimport._init && sub.onimport._init(sub, meta, [], function() {
}, output, action, option, field);
_option: option, _action: action, _output: output, _history: [],
}, [Config.volcano].concat(list), function(sub) {
sub.onimport._init(sub, sub.Conf(meta), list, function() {
}, field);
// 添加控件
can.core.Next(typeof meta.inputs == "string"? JSON.parse(meta.inputs||"[]"): meta.inputs || [], function(item, next) {
sub[item.name] = Volcanos(item.name, {
_target: can.onappend.input(sub, sub._option, "input", item),
sub[item.name] = Volcanos(item.name, { _help: item.name,
_target: can.onappend.input(sub, option, item.type, item),
_option: option, _action: action, _output: output,
}, Config.libs.concat(["plugin/input.js"]), function(input) { input.Conf(item);
}, Config.libs.concat([item.display||"plugin/input.js"]), function(input) {
input.onimport._init(input, input.Conf(item), item.list||[], function() {
}, input._target);
// 事件回调
input.run = function(event, cmds, cb, silent) {
switch (item.name) {
case "返回":
// 历史命令
@ -47,63 +89,64 @@ Volcanos("onappend", {
sub[display] = Volcanos(display, { _target: output,
_option: option, _action: action, _output: output,
}, Config.libs.concat(["plugin/"+display]), function(table) {
//事件响应
table.onimport._init(table, msg, [], function() {
}, output, action, option)
table.onimport._init(table, msg, msg.append||[], function() {
}, output)
})
}, silent)
}
// 添加事件
can.core.Item(input.onaction, function(key, value) {
key.indexOf("on") == 0 && (input._target[key] = function(event) {
// 事件触发
value(event, input)
input._target && key.indexOf("on") == 0 && (input._target[key] = function(event) {
value(event, input);
})
}), next();
})
})
next()
})
})
})
cb(sub)
}); cb(sub);
},
item: function(can, target, type, item, cb, cbs) {
var ui = can.page.Append(can, target, [{view: ["item", "div", item.name], click: function(event) {
var ui = can.page.Append(can, target, [{view: [type, "div", item.nick||item.name],
oncontextmenu: function(event) { cbs(event, ui.item) },
click: function(event) {
can.page.Select(can, target, "div."+type, function(item) {
can.page.ClassList.del(can, item, "select");
}); can.page.ClassList.add(can, ui.item, "select");
cb(event, ui.item)
}}])
},
}])
return ui.item.Meta = item, ui.item
},
field: function(can, target, type, item) {
typeof item.help == "string" && item.help.startsWith("[") && (item.help = JSON.parse(item.help))
var dataset = {}; item && item.name && (dataset.names = item.name);
field: function(can, target, type, item) { var dataset = {}; item && item.name && (dataset.names = item.name);
item.help = typeof item.help == "string" && item.help.startsWith("[") && (item.help = JSON.parse(item.help)[0]) || item.help || ""
var field = can.page.Append(can, target, [{view: [(item.name||"")+" "+(type||"")+" "+(item.pos||""), "fieldset"], list: [
item.pos? undefined: {text: [(item.nick||item.name||"")+"("+((typeof item.help == "string"? item.help: item.help.length > 0 && item.help[0])||"")+")", "legend"]},
item.pos? undefined: {text: [(item.nick||item.name||"")+"("+(item.help||"")+")", "legend"]},
{view: ["option", "form"], dataset: dataset, list: []},
{view: ["action"]}, {view: ["output"]}, {view: ["status"]},
]}]).first;
return field.Meta = item, field;
},
input: function(can, option, type, item, cb) {
var input = {type: "input", name: item.name, data: item};
item.action = item.action || item.value || "";
item.figure = item.figure || item.value || "";
item.cb = item.cb || item.value || "";
item.name && item.name.indexOf("@") == 0 && (item.name = item.name.slice(1)) && (item.position = item.position || "opts")
item.figure = item.figure || item.value || "";
item.action = item.action || item.value || "";
item.cb = item.cb || item.value || "";
var input = {type: "input", name: item.name, data: item};
switch (item.type = item.type || item._type || item._input || "text") {
case "upfile": item.type = "file"; break
case "button":
item.value = item.name || item.value;
break
// case "button": item.value = item.value || item.name || "查看"; break
case "button": item.value = item.name || item.value || "查看"; break
case "select":
item.values = typeof item.values == "string"? item.values.split(" "): item.values;
if (!item.values && item.value) {
item.values = item.value.split("|")
item.value = item.values[0]
item.values = item.value.split("|");
item.value = item.values[0];
}
input.type = "select", input.list = item.values.map(function(value) {
return {type: "option", value: value, inner: value};
})
});
item.className || can.page.ClassList.add(can, item, item.position||"args");
break
case "textarea":
@ -117,34 +160,24 @@ Volcanos("onappend", {
break
}
if (item.value == "auto") {item.value = ""}
var target = can.page.Append(can, option, [{view: ["item "+item.type], list: [item.position && {text: item.name+": "}, input]}]).last
item.figure && item.figure.indexOf("@") == 0 && (item.figure = item.figure.slice(1)) && can.require(["plugin/input/"+item.figure], function() {
target.type != "button" && (target.value = "")
})
var list = [], style = ""
switch (type) {
case "option":
list.push({text: item.name+": "})
case "input":
style = " "+item.type
list.push(input)
break
}
var ui = can.page.Append(can, option, [{view: ["item"+style], list:list}])
var target = ui[item.name]
if (!target) { return }
item.type == "textarea" && can.page.Append(can, option, [{type: "br"}]);
item.type == "text" && !target.placeholder && (target.placeholder = item.name || "");
item.type != "button" && !target.title && (target.title = item.placeholder || item.name || "");
item.type == "textarea" && can.page.Append(can, option, [{type: "br"}])
item.type == "select" && (target.value = item.value || item.values[item.index||0])
item.type == "button" && item.action == "auto" && can.run && can.run({});
item.type != "button" && !target.title && (target.title = item.placeholder);
// item.type == "button" && item.action == "auto" && can.run && can.run({});
item.type == "select" && (target.value = item.value || item.values[item.index||0]);
return target;
},
}, [], function(can) {})
Volcanos("onlayout", {
start: function(can, target, width, height) {
_init: function(can, meta, list, cb, target) {
var width = can._width, height = can._height;
if (Volcanos.meta.follow[can._root]) { debugger }
can.page.Select(can, target, "fieldset.head", function(field) {
height -= field.offsetHeight;
})
@ -153,31 +186,19 @@ Volcanos("onlayout", {
})
can.page.Select(can, target, ["fieldset.left", "fieldset.middle", "fieldset.right"], function(field) {
var border = field.offsetHeight - field.clientHeight
var border = field.offsetHeight - field.clientHeight;
can.page.Modify(can, field, { style: {
height: height-border*2+"px",
} })
})
can.page.Select(can, target, ["fieldset.left>div.output", "fieldset.middle>div.output", "fieldset.right>div.output"], function(field) {
var border = field.offsetHeight - field.clientHeight
can.page.Select(can, field, "div.output", function(output) {
var border = output.offsetHeight - output.clientHeight;
can.page.Modify(can, field, { style: {
height: height-border*2-20+"px",
} })
})
})
typeof cb == "function" && cb()
},
})
Volcanos("onsearch", {
start: function(event, can, chain, cb) {
var sub, mod, fun = can, key;
can.core.List(chain.split("."), function(value, index, array) {
sub = mod, mod = fun, fun = mod[value], key = value
})
if (!sub || !mod) { console.error("not found", chain); return }
Volcanos.meta.debug["search"] && console.log("volcano", can._name, "search", chain, "match", sub._name+"."+mod._name)
typeof fun == "function" && fun(event, sub, key, function(value) {
Volcanos.meta.debug["search"] && console.log("volcano", can._name, "search", chain, "value", value)
cb(value)
})
},
})

View File

@ -10,7 +10,6 @@
<body>
<script src="proto.js"></script>
<script src="order.js"></script>
<script src="start.js"></script>
</body>

View File

@ -1,14 +1,25 @@
var Config = { volcano: "frame.js", iceberg: "/chat/", intshell: "plug.sh",
var Config = {name: "demo", volcano: "frame.js", iceberg: "/chat/", intshell: "plug.sh",
libs: ["lib/base", "lib/core", "lib/misc", "lib/page", "lib/user"], panes: [
{type: "pane", pos: "head", name: "Header", help: "标题栏", list: ["pane/Header.js", "pane/Header.css"], state: ["time"]},
{type: "pane", pos: "left", name: "River", help: "群聊", list: ["frame.js", "pane/River.js", "pane/River.css"]},
{type: "pane", pos: "right", name: "Storm", help: "应用", list: ["frame.js", "pane/Storm.js", "pane/Storm.css"]},
{type: "pane", pos: "middle", name: "Action", help: "工作台", list: ["frame.js", "pane/Action.js", "pane/Action.css"]},
{type: "pane", pos: "foot", name: "Footer", help: "状态栏", list: ["pane/Footer.js", "pane/Footer.css"]},
],
{type: "pane", name: "Header", help: "标题栏", pos: "head", list: ["pane/Header.js", "pane/Header.css"], state: ["time"]},
{type: "pane", name: "River", help: "群聊组", pos: "left", list: ["pane/River.js", "pane/River.css"]},
{type: "pane", name: "Storm", help: "应用流", pos: "right", list: ["pane/Storm.js", "pane/Storm.css"]},
{type: "pane", name: "Action", help: "工作台", pos: "middle", list: ["pane/Action.js", "pane/Action.css"]},
{type: "pane", name: "Footer", help: "状态条", pos: "foot", list: ["pane/Footer.js", "pane/Footer.css"]},
], main: {name: "Header", engine: "remote", list: []},
list: ["plugin/state.js", "plugin/input.js", "plugin/table.js"],
}
var Preload = []; Config.panes.forEach(function(pane) {
var Preload = Config.libs; Config.panes.forEach(function(pane) {
Preload = Preload.concat(pane.list);
}); Preload = Preload.concat(Config.list)
Volcanos(Config.name, { _target: document.body,
_head: document.head, _body: document.body,
_width: window.innerWidth, _height: window.innerHeight,
}, Preload.concat(Config.volcano), 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);
}, can._target)
})
Preload = Preload.concat(["plugin/input.js"])

View File

@ -1,25 +1,38 @@
Volcanos("onimport", {help: "导入数据", list: [],
_init: function(can, meta, list, cb, output, action, option, field) { output.innerHTML = "";
_init: function(can, meta, list, cb, target) {
},
})
Volcanos("onaction", {help: "交互操作", list: [],
_init: function(can, msg, list, cb, target) {
can.onexport._init(can, msg, list, cb, target)
},
})
Volcanos("onexport", {help: "导出数据", list: [],
action: function(event, can, key, cb) {
can.run(event, ["search", "River.onexport.river"], function(river) {
can.run(event, ["search", "Storm.onexport.storm"], function(storm) {
can.Cache(can.Conf("river")+can.Conf("storm"), can._output, true)
if (can.Cache(can.Conf("river", river)+can.Conf("storm", storm), can._output)) {
// 缓存恢复
return
_init: function(can, msg, list, cb, target) { var key = "action";
if (Volcanos.meta.follow[can._root]) { debugger }
can.run(msg._event, ["search", "Storm.onaction._init"], function(msg) {
if (Volcanos.meta.follow[can._root]) { debugger }
can.Cache(can.Conf("river")+can.Conf("storm"), can._output, can.Conf(key));
var river = can.Conf("river", msg.Option("river"));
var storm = can.Conf("storm", msg.Option("storm"));
console.log(can._root, can._name, "show", river, storm);
if (can.Conf(key, msg.Option(key, can.Cache(river+"."+storm, can._output)))) {
typeof cb == "function" && cb(msg); return
}
can.run(event, [river, storm], function(msg) { can._output.innerHTML = ""; msg.Table(function(value, index, array) {
can.onappend._init(can, value, Config.libs.concat([]), function(sub) {
can.run(msg._event, [river, storm], function(msg) { can._output.innerHTML = "";
if (Volcanos.meta.follow[can._root]) { debugger }
msg.Table(function(value, index, array) {
// 添加列表
can.onappend._init(can, value, Config.libs.concat([value.display||"plugin/state.js"]), function(sub) {
sub.run = function(event, cmds, cb, silent) {
can.run(event, [river, storm, index].concat(cmds), cb, silent)
}
console.log("volcano", can._name, "plugin", sub._name)
}, can._output)
}) })
can.Conf(key, "which")
});
msg.Option(key, can.Conf(key))
typeof cb == "function" && cb(msg)
})
})
},

View File

@ -1,26 +1,25 @@
Volcanos("onimport", {help: "导入数据", list: [],
_init: function(can, meta, list, cb, output, action, option, field) {output.innerHTML = "";
can.run({}, [], function(msg) {
console.log("volcano", "Footer", "display", msg.result)
_init: function(can, meta, list, cb, target) {
},
})
Volcanos("onaction", {help: "交互数据", list: [],
_init: function(can, msg, list, cb, target) {
can.onexport._init(can, msg, list, cb, target)
},
})
Volcanos("onexport", {help: "导出数据", list: [],
_init: function(can, msg, list, cb, target) { can._output.innerHTML = "";
can.run(msg._event, [], function(msg) {
console.log(can._root, can._name, "show", msg.result)
can.core.List(msg.result, function(title) {
can.page.Append(can, output, [{view: ["title", "div", title]}])
can.page.Append(can, can._output, [{view: ["title", "div", title]}])
})
console.log("volcano", "Footer", "display", meta.state)
can.ui = can.page.Append(can, output, [{view: "state", list: can.core.List(meta.state, function(item) {
return {text: meta[item]||"", className: item, click: function(event) {can.Export(event, meta[item], item)}};
console.log(can._root, can._name, "show", can.Conf("state"))
can.ui = can.page.Append(can, can._output, [{view: "state", list: can.core.List(can.Conf("state"), function(item) {
return {text: can.Conf(item)||"", className: item, click: function(event) {can.onaction[item](event, can, item)}};
})}])
})
},
ntxt: function(event, can, value, cmd, field) {var state = can.Conf(cmd);
can.ui[cmd].innerHTML = cmd+":"+ can.Conf(cmd, can.base.Int(value)+can.base.Int(state))
},
ncmd: function(event, can, value, cmd, field) {var state = can.Conf(cmd);
can.ui && (can.ui[cmd].innerHTML = cmd+":"+ can.Conf(cmd, can.base.Int(value)+can.base.Int(state)))
},
})
Volcanos("onaction", {help: "组件交互", list: []})
Volcanos("onchoice", {help: "组件菜单", list: []})
Volcanos("ondetail", {help: "组件详情", list: []})
Volcanos("onexport", {help: "导出数据", list: []})

View File

@ -1,25 +1,39 @@
Volcanos("onimport", {help: "导入数据", list: [],
_init: function(can, meta, list, cb, output, action, option, field) { output.innerHTML = "";
can.run({}, [], function(msg) {
console.log("volcano", "Header", "display", msg.result)
_init: function(can, meta, list, cb, target) {
},
})
Volcanos("onaction", {help: "交互数据", list: [],
_init: function(can, msg, list, cb, target) {
can.onexport._init(can, msg, list, cb, target)
can.run(msg._event, ["search", "Footer.onaction._init"], function(msg) {
})
can.run(msg._event, ["search", "Action.onaction._init"], function(msg) {
})
},
title: function(event, can, key) {
},
time: function(event, can, key) {
can.ui[key].innerHTML = can.base.Time().split(" ")[1]
},
})
Volcanos("onexport", {help: "导出数据", list: [],
_init: function(can, msg, list, cb, target) { can._output.innerHTML = "";
can.run(msg._event, [], function(msg) {
console.log(can._root, can._name, "show", msg.result)
can.core.List(msg.result, function(title) {
can.page.Append(can, output, [{view: ["title", "div", title],
click: function(event) {can.Export(event, meta.title, "title")},
can.page.Append(can, can._output, [{view: ["title", "div", title],
click: function(event) {can.onaction["title"](event, can, "title")},
}])
})
console.log("volcano", "Header", "display", meta.state)
can.ui = can.page.Append(can, output, [{view: "state", list: can.core.List(meta.state, function(item) {
return {text: meta[item]||"", className: item, click: function(event) {can.Export(event, meta[item], item)}};
console.log(can._root, can._name, "show", can.Conf("state"))
can.ui = can.page.Append(can, can._output, [{view: "state", list: can.core.List(can.Conf("state"), function(item) {
return {text: can.Conf(item)||"", className: item, click: function(event) {can.onaction[item](event, can, item)}};
})}])
can.timer = can.Timer({interval: 1000, length: -1}, function(event) {
can.onimport.time(event, can, can.base.Time().split(" ")[1], "time")
can.onaction.time(event, can, "time")
})
})
return
},
time: function(event, can, value, cmd, field) {
can.ui[cmd].innerHTML = value
},
})

View File

@ -1,31 +1,37 @@
Volcanos("onimport", {help: "导入数据", list: [],
_init: function(can, meta, list, cb, output, action, option, field) { output.innerHTML = "";
_init: function(can, meta, list, cb, target) {
},
})
Volcanos("onaction", {help: "交互数据", list: [],
_init: function(can, msg, list, cb, target) {
can.onexport._init(can, msg, list, cb, target)
},
})
Volcanos("onexport", {help: "导出数据", list: [],
river: function(event, can, key, cb) {
if (can.Conf(key)) { cb(can.Conf(key)); return }
_init: function(can, msg, list, cb, target) { var key = "river";
if (Volcanos.meta.follow[can._root]) { debugger }
if (msg.Option(key, can.Conf(key))) {
typeof cb == "function" && cb (msg); return
}
can.run({}, [], function(msg) { msg.Table(function(value, index, array) {
can.run(msg._event, [], function(msg) { can._output.innerHTML = "";
if (Volcanos.meta.follow[can._root]) { debugger }
var select; msg.Table(function(value, index, array) {
// 添加列表
var view = can.onappend.item(can, can._output, "item", value, function(event, item) {
// 左键点击
can.page.Select(can, can._output, "div.item", function(item) {
can.page.ClassList.del(can, item, "select");
}); can.page.ClassList.add(can, item, "select");
can.Conf(key, value.key); can.run({}, ["search", "Action.onexport.action"], function(action) {
can.Conf(key, value.key); can.run(event, ["search", "Storm.onaction._init"], function(action) {
// 切换群组
})
});
}, function(event) {
// 右键点击
});
if (index == 0 || [value.key, value.name].indexOf(can.user.Search(can, key)) > -1) {
view.click()
select = view
}
}); cb(can.Conf(key)); })
}); select.click();
typeof cb == "function" && cb(msg)
})
},
})

View File

@ -1,42 +1,41 @@
Volcanos("onimport", {help: "导入数据", list: [],
_init: function(can, meta, list, cb, output, action, option, field) { output.innerHTML = "";
_init: function(can, meta, list, cb, target) {
},
})
Volcanos("onaction", {help: "交互数据", list: [],
_init: function(can, msg, list, cb, target) {
can.onexport._init(can, msg, list, cb, target)
},
})
Volcanos("onexport", {help: "导出数据", list: [],
storm: function(event, can, key, cb) {
can.run({}, ["search", "River.onexport.river"], function(river) {
if (river == can.Conf("river")) {
cb(can.Conf(key))
return //当前应用
_init: function(can, msg, list, cb, target) { var key = "storm";
if (Volcanos.meta.follow[can._root]) { debugger }
can.run(msg._event, ["search", "River.onaction._init"], function(msg) {
if (Volcanos.meta.follow[can._root]) { debugger }
can.Cache(can.Conf("river"), can._output, can.Conf(key));
var river = can.Conf("river", msg.Option("river"));
console.log(can._root, can._name, "show", river);
if (can.Conf(key, msg.Option(key, can.Cache(river, can._output)))) {
typeof cb == "function" && cb (msg); return
}
can.Cache(can.Conf("river"), can._output, can.Conf(key))
if (can.Conf(key, can.Cache(can.Conf("river", river), can._output))) {
cb(can.Conf(key))
return // 缓存恢复
}
can.run({}, [river], function(msg) { msg.Table(function(value, index, array) {
can.run(msg._event, [river], function(msg) { can._output.innerHTML = "";
if (Volcanos.meta.follow[can._root]) { debugger }
var select; msg.Table(function(value, index, array) {
// 添加列表
var view = can.onappend.item(can, can._output, "item", value, function(event, item) {
// 左键点击
can.page.Select(can, can._output, "div.item", function(item) {
can.page.ClassList.del(can, item, "select");
}); can.page.ClassList.add(can, item, "select");
can.Conf(key, value.key); can.run({}, ["search", "Action.onexport.action"], function(action) {
// 切换应用
can.Conf(key, value.key); can.run(event, ["search", "Action.onaction._init"], function(msg) {
})
}, function(event) {
}, function(event, item) {
// 右键点击
});
if (index == 0 || [value.key, value.name].indexOf(can.user.Search(can, key)) > -1) {
view.click()
select = view
}
}); cb(can.Conf(key)); })
}); select.click();
typeof cb == "function" && cb(msg)
})
})
},
})

View File

@ -25,5 +25,3 @@ Volcanos("onaction", {help: "控件交互", list: [],
}
},
})

View File

@ -1,41 +1,5 @@
Volcanos("onimport", {help: "导入数据", list: []})
Volcanos("onaction", {help: "组件交互", list: []})
Volcanos("onchoice", {help: "组件菜单", list: ["执行", "返回", "共享", "重命名", "选项", "加参", "减参", "克隆", "删除"],
"执行": function(event, can, msg, cmd, field) {can.Runs(event)},
"返回": function(event, can, msg, cmd, field) {can.Last(event)},
"共享": function(event, can, msg, cmd, field) {
can.user.input(event, can, ["name", "text"], function(event, cmd, meta, list) {
var msg = can.Event(event);
msg.Option("name", meta.name)
msg.Option("text", meta.text)
can.Conf("args", JSON.stringify(can.Option()))
can.core.List(["node", "group", "index", "args"], function(key) {
msg.Option(key, can.Conf(key))
})
can.Export(event, "action", "share")
return true
})
Volcanos("onimport", {help: "导入数据", list: [],
_init: function(can, meta, list, cb, target) {
},
"重命名": function(event, can, msg, cmd, field) {var meta = field.Meta;
meta.help = can.user.prompt("", function(help) {
meta.help = help
}, meta.help)
},
"选项": function(event, can, msg, cmd, field) {
can.user.input(event, can, ["name", "value"], function(event, cmd, meta, list) {
var data = {type: "text", value: meta.value||""}
can.page.ClassList.add(can, data, "opts");
var input = {type: "input", name: meta.name, data: data};
var target = can.Dream(can.option, "option", input)[input.name];
return true
})
},
"加参": function(event, can, msg, cmd, field) {can.Append()},
"减参": function(event, can, msg, cmd, field) {can.Remove(event)},
"克隆": function(event, can, msg, cmd, field) {can.Clone(event)},
"删除": function(event, can, msg, cmd, field) {can.Delete(event)},
})
Volcanos("ondetail", {help: "组件详情", list: []})
Volcanos("onexport", {help: "导出数据", list: []})
})

View File

@ -4,10 +4,8 @@ Volcanos("onimport", {help: "导入数据", list: [],
can.page.Select(can, option, "input.args", function(input) { if (input.name == key) {
input.value = value
} })
}, function(event, value, key, index, tr, td) {
});
msg.result && can.page.AppendBoard(can, output, msg.result.join(""))
},
})

View File

@ -18,12 +18,13 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
volcano: false, config: true,
require: true, cache: false, frame: false,
request: true, search: true,
}}, [], function(name, can, libs, cb) {
var meta = arguments.callee.meta, list = arguments.callee.list;
}, follow: {
volcano: false, debug: true,
}}, [], function(name, can, libs, cb) { var meta = arguments.callee.meta, list = arguments.callee.list;
var conf = {}, conf_cb = {}, sync = {}, cache = {};
meta.debug["volcano"] && console.debug("volcano", name, "create");
can = can || {}, list.push(can) && (can.__proto__ = { _name: name, _create_time: new Date(), _load: function(name) {
meta.debug[can._root] && console.debug(can._root, name, "create");
can = can || {}, list.push(can) && (can.__proto__ = { _name: name, _root: "volcano", _create_time: new Date(), _load: function(name) {
for (var cache = meta.cache[name] || []; meta.index < list.length; meta.index++) {
if (list[meta.index] == can) {continue}
meta.debug["cache"] && console.debug("cache", name, "load", meta.index, list[meta.index]);
@ -43,7 +44,7 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
return // 加载完成
}
meta.debug["require"] && console.debug("volcano", can._name, "require", libs[0]); if (meta.cache[libs[0]]) {
meta.debug["require"] && console.debug(can._root, can._name, "require", libs[0]); if (meta.cache[libs[0]]) {
can._load(libs[0]), can.require(libs.slice(1), cb);
return // 缓存加载
}
@ -53,7 +54,6 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
if (source.endsWith(".js")) { var script = document.createElement("script");
script.src = source, script.onload = function() {
// meta.debug["require"] && console.debug("volcano", can._name, "required", libs[0]);
can._load(libs[0]), can.require(libs.slice(1), cb);
} // 加载脚本
target.appendChild(script);
@ -61,16 +61,15 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
} else if (source.endsWith(".css")) { var style = document.createElement("link");
style.rel = "stylesheet", style.type = "text/css";
style.href = source; style.onload = function() {
// meta.debug["require"] && console.debug("volcano", can._name, "required", libs[0]);
can._load(libs[0]), can.require(libs.slice(1), cb);
} // 加载样式
target.appendChild(style);
}
},
request: function(event, msg, proto) { event = event || {};
if (!msg && event.msg) { return event.msg }
if (!msg && event._msg) { return event._msg }
event.msg = msg = msg || {}, msg.event = event;
event._msg = msg = msg || {}, msg._event = event;
msg.__proto__ = proto || { _name: meta.order++, _create_time: new Date(),
Option: function(key, val) {
if (val == undefined) { return msg && msg[key] && msg[key][0] || "" }
@ -78,6 +77,7 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
if (k == key) {return k}
}).length > 0 || msg.option.push(key)
msg[key] = can.core.List(arguments).slice(1)
return val
},
Copy: function(res) { if (!res) { return msg }
res.result && (msg.result = res.result)
@ -103,14 +103,14 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
return msg
},
Conf: function(key, value, cb) { if (key == undefined) { return conf }
Conf: shy("配置器", function(key, value, cb) { if (key == undefined) { return conf }
if (typeof key == "object") { conf = key; return conf }
typeof cb == "function" && (conf_cb[key] = cb);
if (value != undefined) {var old = conf[key], res; meta.debug["config"] && console.debug("volcano", can._name, "config", key, value, old)
if (value != undefined) {var old = conf[key], res; meta.debug["config"] && console.debug(can._root, can._name, "config", key, value, old)
conf[key] = conf_cb[key] && (res = conf_cb[key](value, old, key)) != undefined && res || value
}
return conf[key] || ""
},
}),
Timer: shy("定时器, value, [1,2,3,4], {value, length}", function(interval, cb, cbs) { interval = typeof interval == "object"? interval || []: [interval];
var timer = {stop: false};
function loop(event, i) {if (timer.stop || i >= interval.length && interval.length >= 0) {return typeof cbs == "function" && cbs(event, interval)}
@ -132,13 +132,12 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
}
cache[name] = {node: temp, data: data}
console.log("volcano", can._name, "save", name, cache[name]);
console.log(can._root, can._name, "save", name, cache[name]);
return name
}
var list = cache[name];
if (!list) {return}
console.log("volcano", can._name, "load", name, cache[name]);
var list = cache[name]; if (!list) {return}
console.log(can._root, can._name, "load", name, cache[name]);
// 读缓存
while (list.node.childNodes.length>0) {

View File

@ -1,29 +0,0 @@
Volcanos("demo", { _head: document.head, _body: document.body, _target: document.body,
}, [Config.volcano].concat(Config.libs).concat(Preload), function(can) { can.Conf(Config); can.core.Next(can.Conf("panes"), function(item, next) {
can.onappend._init(can, item, Config.libs.concat(item.list), function(sub) {
sub.run = function(event, cmds, cb, silent) { var msg = sub.request(event);
switch (cmds[0]) {
case "search":
can.onsearch.start(event, can, cmds[1], cb)
return
}
// 发送请求
Volcanos.meta.debug["request"] && console.log("volcano", sub._name, "request", msg._name, cmds, msg);
can.misc.Run(event, can, {names: item.name}, cmds, function(msg) {
// 接收响应
Volcanos.meta.debug["request"] && console.log("volcano", sub._name, "response", msg._name, msg.result, msg);
cb(msg);
})
}
can[item.name] = sub, next()
}, can._target);
}, function() {
// 启动入口
can.onlayout.start(can, can._target, window.innerWidth, window.innerHeight);
console.log("volcano", "demo", "start", can);
can.Action.onexport.action({}, can.Action, function() {
})
})
})