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

opt index.js

This commit is contained in:
shylinux 2020-05-27 10:50:34 +08:00
parent cf95a9ca79
commit 86badb0c38
10 changed files with 52 additions and 55 deletions

View File

@ -1,12 +1,12 @@
Volcanos("onaction", { _init: function(can, meta, list, cb, target) { Volcanos("onaction", { _init: function(can, meta, list, cb, target) {
can.core.Next(meta.panes, function(item, next) { can.core.Next(meta.panes, function(item, next) {
can.onappend._init(can, item, Config.libs.concat(item.list), function(pane) { can.onappend._init(can, item, meta.libs.concat(item.list), function(pane) {
pane.Conf(item), pane.run = function(event, cmds, cb) { pane.Conf(item), pane.run = function(event, cmds, cb) {
(can.onaction[cmds[0]]||can.onaction[meta.main.engine])(event, can, pane.request(event), pane, cmds, cb); (can.onaction[cmds[0]]||can.onaction[meta.main.engine])(event, can, pane.request(event), pane, cmds, cb);
}, 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() {
can.require(["/publish/order.js"], function(can) { can.require(meta.main.list, function(can) {
function getAction() {} function getAction() {}
function getStorm(storm) { can.core.Item(storm, function(key, value) { function getStorm(storm) { can.core.Item(storm, function(key, value) {
value._link? can.require([value._link], function(can) { value._link? can.require([value._link], function(can) {
@ -100,7 +100,7 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) {
var sub = Volcanos(meta.name, { _help: meta.name, _target: field, var sub = Volcanos(meta.name, { _help: meta.name, _target: field,
_option: option, _action: action, _output: output, _history: [], _option: option, _action: action, _output: output, _history: [],
_follow: can._follow+"."+meta.name, _follow: can._follow+"."+meta.name,
}, [Config.volcano].concat(list), function(sub) { }, [Volcanos.meta.volcano].concat(list), function(sub) {
meta.feature = can.base.Obj(meta.feature, {}) meta.feature = can.base.Obj(meta.feature, {})
meta.detail = meta.feature["detail"] || {} meta.detail = meta.feature["detail"] || {}
sub.onimport._init(sub, sub.Conf(meta), list, function() {}, field); sub.onimport._init(sub, sub.Conf(meta), list, function() {}, field);
@ -112,7 +112,7 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) {
_target: can.onappend.input(sub, option, item.type, item, args[index]), _target: can.onappend.input(sub, option, item.type, item, args[index]),
_option: option, _action: action, _output: output, _option: option, _action: action, _output: output,
_follow: can._follow+"."+meta.name+"."+item.name, _follow: can._follow+"."+meta.name+"."+item.name,
}, Config.libs.concat([item.display||"/plugin/input.js"]), function(input) { }, Volcanos.meta.libs.concat([item.display||"/plugin/input.js"]), function(input) {
input.onimport._init(input, input.Conf(item), item.list||[], function() {}, input._target); input.onimport._init(input, input.Conf(item), item.list||[], function() {}, input._target);
input.run = function(event, cmds, cb, silent) { input.run = function(event, cmds, cb, silent) {
@ -144,7 +144,7 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) {
sub[display] = Volcanos(display, { _target: output, sub[display] = Volcanos(display, { _target: output,
_option: option, _action: action, _output: output, _option: option, _action: action, _output: output,
_follow: can._follow+"."+meta.name+"."+display, _follow: can._follow+"."+meta.name+"."+display,
}, Config.libs.concat(["/frame.js", display]), function(table) { table.Conf(sub.Conf()) }, Volcanos.meta.libs.concat(["/frame.js", display]), function(table) { table.Conf(sub.Conf())
table.onimport._init(table, msg, msg.append||[], function() {}, output) table.onimport._init(table, msg, msg.append||[], function() {}, output)
table.run = function(event, cmds, cb, silent) { table.run = function(event, cmds, cb, silent) {
@ -233,7 +233,7 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) {
item.type == "textarea" && can.page.Append(can, option, [{type: "br"}]); item.type == "textarea" && can.page.Append(can, option, [{type: "br"}]);
item.type == "text" && !target.placeholder && (target.placeholder = item.name || ""); item.type == "text" && !target.placeholder && (target.placeholder = item.name || "");
item.type != "button" && !target.title && (target.title = item.placeholder); item.type != "button" && !target.title && (target.title = target.placeholder);
// item.type == "button" && item.action == "auto" && can.run && can.run({}); // item.type == "button" && item.action == "auto" && can.run && can.run({});
item.type == "select" && (target.value = item.value || item.values[item.index||0]); item.type == "select" && (target.value = item.value || item.values[item.index||0]);
return target; return target;
@ -354,7 +354,6 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) {
}, [], function(can) {}) }, [], function(can) {})
Volcanos("onlayout", { _init: function(can, meta, list, cb, target) { Volcanos("onlayout", { _init: function(can, meta, list, cb, target) {
var width = can._width, height = can._height; var width = can._width, height = can._height;
if (Volcanos.meta.follow[can._root]) { debugger }
can.page.Select(can, target, "fieldset.head", function(field) { can.page.Select(can, target, "fieldset.head", function(field) {
height -= field.offsetHeight; height -= field.offsetHeight;

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="/style.css"> <link rel="stylesheet" type="text/css" href="/index.css">
</head> </head>
<body> <body>
<script src="/proto.js"></script> <script src="/proto.js"></script>

View File

@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="/style.css"> <link rel="stylesheet" type="text/css" href="/index.css">
</head> </head>
<body style="min-height:400px"> <body style="min-height:400px">
<script src="/proto.js"></script> <script src="/proto.js"></script>

View File

@ -5,7 +5,7 @@
<title>volcanos</title> <title>volcanos</title>
<link rel="shortcut icon" type="image/ico" href="/static/volcanos/favicon.ico"> <link rel="shortcut icon" type="image/ico" href="/static/volcanos/favicon.ico">
<link rel="stylesheet" type="text/css" href="/static/volcanos/style.css"> <link rel="stylesheet" type="text/css" href="/static/volcanos/index.css">
</head> </head>
<body> <body>
<script src="/static/volcanos/page/share.js"></script> <script src="/static/volcanos/page/share.js"></script>

View File

@ -3,8 +3,8 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=0.7,user-scalable=no"> <meta name="viewport" content="width=device-width,initial-scale=0.7,user-scalable=no">
<title>volcanos</title> <title>volcanos</title>
<link rel="shortcut icon" type="image/ico" href="favicon.ico"> <link rel="shortcut icon" type="image/ico" href="/favicon.ico">
<link rel="stylesheet" type="text/css" href="/style.css"> <link rel="stylesheet" type="text/css" href="/index.css">
</head> </head>
<body> <body>
<script src="/proto.js"></script> <script src="/proto.js"></script>

View File

@ -1,4 +1,4 @@
var Config = {name: "demo", volcano: "/frame.js", iceberg: "/chat/", intshell: "plug.sh", Volcanos({name: "demo", volcano: "/frame.js", iceberg: "/chat/", intshell: "plug.sh",
libs: ["/lib/base", "/lib/core", "/lib/misc", "/lib/page", "/lib/user"], panes: [ libs: ["/lib/base", "/lib/core", "/lib/misc", "/lib/page", "/lib/user"], panes: [
{type: "pane", name: "Header", help: "标题栏", pos: "head", list: ["/pane/Header.js", "/pane/Header.css"], state: [ {type: "pane", name: "Header", help: "标题栏", pos: "head", list: ["/pane/Header.js", "/pane/Header.css"], state: [
"time", "username", "time", "username",
@ -9,26 +9,13 @@ var Config = {name: "demo", volcano: "/frame.js", iceberg: "/chat/", intshell: "
{type: "pane", name: "Footer", help: "状态条", pos: "foot", list: ["/pane/Footer.js", "/pane/Footer.css"], state: [ {type: "pane", name: "Footer", help: "状态条", pos: "foot", list: ["/pane/Footer.js", "/pane/Footer.css"], state: [
"ncmd", "ncmd",
]}, ]},
], main: {name: "Header", engine: "remote", list: []}, ], main: {name: "Header", engine: "remote", list: ["/publish/order.js"]}, plugin: [
list: ["/plugin/state.js", "/plugin/input.js", "/plugin/table.js", "/plugin/state.js",
"/plugin/input.js",
"/plugin/table.js",
"/plugin/input/key", "/plugin/input/key",
"/plugin/input/date", "/plugin/input/date",
"/plugin/input/upload", "/plugin/input/upload",
"/plugin/input/province", "/plugin/input/province",
], ],
}
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, _follow: "demo",
_head: document.head, _body: document.body,
_width: window.innerWidth, _height: window.innerHeight,
}, Preload.concat(Config.volcano), function(can) { // 程序入口
can.onaction._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)
}) })

View File

@ -5,7 +5,7 @@
<title>volcanos</title> <title>volcanos</title>
<link rel="shortcut icon" type="image/ico" href="/static/volcanos/favicon.ico"> <link rel="shortcut icon" type="image/ico" href="/static/volcanos/favicon.ico">
<link rel="stylesheet" type="text/css" href="/style.css"> <link rel="stylesheet" type="text/css" href="/index.css">
<link rel="stylesheet" type="text/css" href="/page/share.css"> <link rel="stylesheet" type="text/css" href="/page/share.css">
</head> </head>
<body> <body>

View File

@ -27,9 +27,12 @@ Volcanos("onexport", {help: "导出数据", list: [],
if (position) { can._output.scrollTo(0, position-1); return } if (position) { can._output.scrollTo(0, position-1); return }
msg.Clear("option"), can.run(msg._event, [river, storm], function(sup) { can._output.innerHTML = ""; sup.Table(function(value, index, array) { msg.Clear("option"), can.run(msg._event, [river, storm], function(sup) { can._output.innerHTML = ""; sup.Table(function(value, index, array) {
value.inputs = can.base.Obj(value.inputs, []) value.inputs = can.base.Obj(value.inputs, []), value.inputs.length == 0 && (value.inputs = [
value.inputs.length == 0 && (value.inputs = [{type: "text"}, {type: "button", name: "查看"}]) {type: "text", name: "name", action: "auto"},
can.onappend._init(can, value, Config.libs.concat(["/plugin/state.js"]), function(sub) { {type: "button", name: "查看", action: "auto"},
{type: "button", name: "返回"},
]);
can.onappend._init(can, value, Volcanos.meta.libs.concat(["/plugin/state.js"]), function(sub) {
sub.run = function(event, cmds, cb, silent) { var msg = can.request(event, {_msg: sup}); sub.run = function(event, cmds, cb, silent) { var msg = can.request(event, {_msg: sup});
// 插件回调 // 插件回调
can.run(event, [river, storm, index].concat(cmds), function(msg) { can.run(event, [river, storm, index].concat(cmds), function(msg) {

View File

@ -9,7 +9,7 @@ function shy(help, meta, list, cb) {
} }
var cb = arguments[arguments.length-1] || function() {}; var cb = arguments[arguments.length-1] || function() {};
cb.help = next("string") || "还没有写"; cb.help = next("string") || cb.name;
cb.meta = next("object") || {}; cb.meta = next("object") || {};
cb.list = next("object") || []; cb.list = next("object") || [];
return cb; return cb;
@ -18,23 +18,31 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
volcano: false, config: true, volcano: false, config: true,
require: true, cache: false, frame: false, require: true, cache: false, frame: false,
request: true, search: true, request: true, search: true,
}, follow: { }, libs: []}, [], function(name, can, libs, cb) { var meta = arguments.callee.meta, list = arguments.callee.list;
volcano: false, debug: true, if (typeof name == "object") { var Config = name;
// volcano: true, debug: true, meta.volcano = Config.volcano, meta.libs = Config.libs;
}}, [], function(name, can, libs, cb) { var meta = arguments.callee.meta, list = arguments.callee.list; var Preload = Config.libs; Config.panes.forEach(function(pane) {
Preload = Preload.concat(pane.list);
}); Preload = Preload.concat(Config.plugin)
var conf = {}, conf_cb = {}, sync = {}, cache = {}; name = Config.name, can = { _target: document.body, _follow: Config.name,
meta.debug[can._root] && console.debug(can._root, name, "create"); _head: document.head, _body: document.body,
can = can || {}, list.push(can) && (can.__proto__ = { _name: name, _root: "volcano", _create_time: new Date(), _load: function(name, cb) { _width: window.innerWidth, _height: window.innerHeight,
}, libs = Preload.concat(Config.volcano), cb = function(can) {
can.onaction._init(can, can.Conf(Config), [], function(msg) {
}, can._target)
}
}
var conf = {}, conf_cb = {}, cache = {};
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]);
cache.push(list[meta.index]); cache.push(list[meta.index]);
// 加载缓存 // 加载缓存
} }
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]);
typeof cb == "function" && cb(can, name, cache[i]) || (can[cache[i]._name] = cache[i]); typeof cb == "function" && cb(can, name, cache[i]) || (can[cache[i]._name] = cache[i]);
// 加载索引 // 加载索引
} }
@ -159,16 +167,6 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
} }
return conf[key] || "" 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)}
return typeof cb == "function" && cb(event, interval.value||interval[i], i, interval)?
typeof cbs == "function" && cbs(event, interval):
setTimeout(function() {loop(event, i+1)}, interval.value||interval[i+1]);
}
setTimeout(function(event) {loop(event, 0)}, interval.value||interval[0]);
return timer;
}),
Cache: shy("缓存器", function(name, output, data) { Cache: shy("缓存器", function(name, output, data) {
if (data) { if (output.children.length == 0) { return } if (data) { if (output.children.length == 0) { return }
// 写缓存 // 写缓存
@ -196,6 +194,16 @@ var Volcanos = shy("火山架", {cache: {}, index: 1, order: 1, debug: {
delete(cache[name]); delete(cache[name]);
return list.data; return list.data;
}), }),
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)}
return typeof cb == "function" && cb(event, interval.value||interval[i], i, interval)?
typeof cbs == "function" && cbs(event, interval):
setTimeout(function() {loop(event, i+1)}, interval.value||interval[i+1]);
}
setTimeout(function(event) {loop(event, 0)}, interval.value||interval[0]);
return timer;
}),
}); });
return can.require(libs, cb), can return can.require(libs, cb), can