mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 16:58:06 +08:00
add engine
This commit is contained in:
parent
be7cb7ce4f
commit
4a04a8f5b4
60
frame.js
60
frame.js
@ -6,6 +6,23 @@ Volcanos("onaction", { _init: function(can, meta, list, cb, target) {
|
|||||||
}, can[item.name] = pane, next();
|
}, can[item.name] = pane, next();
|
||||||
}, can._target);
|
}, can._target);
|
||||||
}, function() { can.onlayout._init(can, meta, list, function() {
|
}, function() { can.onlayout._init(can, meta, list, function() {
|
||||||
|
function getAction() {}
|
||||||
|
function getStorm(storm) { can.core.Item(storm, function(key, value) {
|
||||||
|
value._link? can.require([value._link], function(can) {
|
||||||
|
}, function(can, name, sub) {
|
||||||
|
getAction(value.action = sub.action)
|
||||||
|
return true
|
||||||
|
}): getAction(value.action)
|
||||||
|
}) }
|
||||||
|
function getRiver(river) { can.core.Item(river, function(key, value) {
|
||||||
|
value._link? can.require([value._link], function(can) {
|
||||||
|
}, function(can, name, sub) {
|
||||||
|
getStorm(value.storm = sub.storm)
|
||||||
|
return true
|
||||||
|
}): getStorm(value.storm)
|
||||||
|
}) }
|
||||||
|
can.onengine && getRiver(can.onengine.river)
|
||||||
|
|
||||||
var pane = can[meta.main.name], msg = can.request(can._event);
|
var pane = can[meta.main.name], msg = can.request(can._event);
|
||||||
pane.onaction._init(pane, msg, msg.option||[], cb, target);
|
pane.onaction._init(pane, msg, msg.option||[], cb, target);
|
||||||
}, target) });
|
}, target) });
|
||||||
@ -17,8 +34,49 @@ Volcanos("onaction", { _init: function(can, meta, list, cb, target) {
|
|||||||
|
|
||||||
typeof fun == "function" && fun(sub, msg, cmds.slice(2), cb, sub._target)
|
typeof fun == "function" && fun(sub, msg, cmds.slice(2), cb, sub._target)
|
||||||
},
|
},
|
||||||
|
engine: function(event, can, msg, pane, cmds, cb) {
|
||||||
|
switch (pane._name) {
|
||||||
|
case "River":
|
||||||
|
if (cmds.length == 0) {
|
||||||
|
can.core.Item(can.onengine.river, function(key, value) {
|
||||||
|
msg.Push("key", key)
|
||||||
|
msg.Push("name", value.name)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case "Storm":
|
||||||
|
var river = can.onengine.river[cmds[0]]
|
||||||
|
if (!river) { break }
|
||||||
|
can.core.Item(river.storm, function(key, value) {
|
||||||
|
msg.Push("key", key)
|
||||||
|
msg.Push("name", value.name)
|
||||||
|
})
|
||||||
|
typeof cb == "function" && cb(msg)
|
||||||
|
return true
|
||||||
|
case "Action":
|
||||||
|
var river = can.onengine.river[cmds[0]];
|
||||||
|
var storm = river && river.storm[cmds[1]];
|
||||||
|
var action = storm && storm.action[cmds[2]];
|
||||||
|
if (!storm) { break } if (cmds.length == 2) {
|
||||||
|
can.core.List(storm.action, function(value) {
|
||||||
|
msg.Push("name", value.name||"");
|
||||||
|
msg.Push("help", value.help||"");
|
||||||
|
msg.Push("inputs", JSON.stringify(value.inputs||[]));
|
||||||
|
})
|
||||||
|
typeof cb == "function" && cb(msg);
|
||||||
|
} else if (action.engine) {
|
||||||
|
action.engine(event, can, msg, pane, cmds, cb);
|
||||||
|
} else {
|
||||||
|
msg.Option("group", action.group)
|
||||||
|
msg.Option("index", action.index)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
remote: function(event, can, msg, pane, cmds, cb) {
|
remote: function(event, can, msg, pane, cmds, cb) {
|
||||||
if (can.onengine && can.onengine.remote(event, can, msg, pane, cmds, cb)) { return }
|
if (can.onaction.engine(event, can, msg, pane, cmds, cb)) { return }
|
||||||
if (location.protocol == "file:") { typeof cb == "function" && cb(msg); return }
|
if (location.protocol == "file:") { typeof cb == "function" && cb(msg); return }
|
||||||
can.misc.Run(event, can, {names: pane._name}, cmds, cb)
|
can.misc.Run(event, can, {names: pane._name}, cmds, cb)
|
||||||
},
|
},
|
||||||
|
12
proto.js
12
proto.js
@ -25,7 +25,7 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
|
|||||||
|
|
||||||
var conf = {}, conf_cb = {}, sync = {}, cache = {};
|
var conf = {}, conf_cb = {}, sync = {}, cache = {};
|
||||||
meta.debug[can._root] && console.debug(can._root, name, "create");
|
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) {
|
can = can || {}, list.push(can) && (can.__proto__ = { _name: name, _root: "volcano", _create_time: new Date(), _load: function(name, cb) {
|
||||||
for (var cache = meta.cache[name] || []; meta.index < list.length; meta.index++) {
|
for (var cache = meta.cache[name] || []; meta.index < list.length; meta.index++) {
|
||||||
if (list[meta.index] == can) {continue}
|
if (list[meta.index] == can) {continue}
|
||||||
meta.debug["cache"] && console.debug("cache", name, "load", meta.index, list[meta.index]);
|
meta.debug["cache"] && console.debug("cache", name, "load", meta.index, list[meta.index]);
|
||||||
@ -35,18 +35,18 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
|
|||||||
|
|
||||||
for (var i = 0; i < cache.length; i++) {
|
for (var i = 0; i < cache.length; i++) {
|
||||||
meta.debug["frame"] && console.debug("frame", can._name, "load", i, cache[i]);
|
meta.debug["frame"] && console.debug("frame", can._name, "load", i, cache[i]);
|
||||||
can[cache[i]._name] = cache[i];
|
typeof cb == "function" && cb(can, name, cache[i]) || (can[cache[i]._name] = cache[i]);
|
||||||
// 加载索引
|
// 加载索引
|
||||||
}
|
}
|
||||||
meta.cache[name] = cache;
|
meta.cache[name] = cache;
|
||||||
},
|
},
|
||||||
require: function(libs, cb) { if (!libs || libs.length == 0) {
|
require: function(libs, cb, each) { if (!libs || libs.length == 0) {
|
||||||
typeof cb == "function" && setTimeout(function() {cb(can)}, 10);
|
typeof cb == "function" && setTimeout(function() {cb(can)}, 10);
|
||||||
return // 加载完成
|
return // 加载完成
|
||||||
}
|
}
|
||||||
|
|
||||||
meta.debug["require"] && console.debug(can._root, 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);
|
can._load(libs[0], each), can.require(libs.slice(1), cb, each);
|
||||||
return // 缓存加载
|
return // 缓存加载
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,14 +55,14 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
|
|||||||
|
|
||||||
if (source.endsWith(".js")) { var script = document.createElement("script");
|
if (source.endsWith(".js")) { var script = document.createElement("script");
|
||||||
script.src = source, script.onload = function() {
|
script.src = source, script.onload = function() {
|
||||||
can._load(libs[0]), can.require(libs.slice(1), cb);
|
can._load(libs[0], each), can.require(libs.slice(1), cb, each);
|
||||||
} // 加载脚本
|
} // 加载脚本
|
||||||
target.appendChild(script);
|
target.appendChild(script);
|
||||||
|
|
||||||
} else if (source.endsWith(".css")) { var style = document.createElement("link");
|
} else if (source.endsWith(".css")) { var style = document.createElement("link");
|
||||||
style.rel = "stylesheet", style.type = "text/css";
|
style.rel = "stylesheet", style.type = "text/css";
|
||||||
style.href = source; style.onload = function() {
|
style.href = source; style.onload = function() {
|
||||||
can._load(libs[0]), can.require(libs.slice(1), cb);
|
can._load(libs[0], each), can.require(libs.slice(1), cb, each);
|
||||||
} // 加载样式
|
} // 加载样式
|
||||||
target.appendChild(style);
|
target.appendChild(style);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user