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

opt frame

This commit is contained in:
shaoying 2019-12-10 15:53:07 +08:00
parent 955211fe14
commit 2876565f22
13 changed files with 364 additions and 97 deletions

View File

@ -5,57 +5,7 @@ volcanos是一个前端框架。
通过插件化方式加载功能模块,每个模块都有框架与输入与输出。
通过模块化方式管理模块依赖,可以动态按需加载各种模块。
<svg vertion="1.1" xmlns="http://www.w3.org/2000/svg" width="666", height="924" style="">
<rect x="4" y="444" width="65" height="36" fill="red" />
<text x="36" y="462" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >chat</text>
<rect x="77" y="180" width="267" height="36" fill="red" />
<text x="210" y="198" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >proto</text>
<rect x="352" y="4" width="310" height="36" fill="red" />
<text x="507" y="22" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >ID 生成器</text>
<rect x="352" y="48" width="310" height="36" fill="red" />
<text x="507" y="66" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Log 日志器</text>
<rect x="352" y="92" width="310" height="36" fill="red" />
<text x="507" y="110" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Conf 配置器</text>
<rect x="352" y="136" width="310" height="36" fill="red" />
<text x="507" y="154" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Sync 同步器</text>
<rect x="352" y="180" width="310" height="36" fill="red" />
<text x="507" y="198" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Timer 定时器</text>
<rect x="352" y="224" width="310" height="36" fill="red" />
<text x="507" y="242" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Event 触发器</text>
<rect x="352" y="268" width="310" height="36" fill="red" />
<text x="507" y="286" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Dream 构造器</text>
<rect x="352" y="312" width="310" height="36" fill="red" />
<text x="507" y="330" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Cache 缓存器</text>
<rect x="352" y="356" width="310" height="36" fill="red" />
<text x="507" y="374" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Story 存储器</text>
<rect x="77" y="400" width="267" height="36" fill="red" />
<text x="210" y="418" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Plugin</text>
<rect x="77" y="532" width="267" height="36" fill="red" />
<text x="210" y="550" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Inputs</text>
<rect x="352" y="444" width="310" height="36" fill="red" />
<text x="507" y="462" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >onimport 导入数据</text>
<rect x="352" y="488" width="310" height="36" fill="red" />
<text x="507" y="506" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >onaction 控件交互</text>
<rect x="352" y="532" width="310" height="36" fill="red" />
<text x="507" y="550" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >onchoice 控件菜单</text>
<rect x="352" y="576" width="310" height="36" fill="red" />
<text x="507" y="594" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >ondetail 控件详情</text>
<rect x="352" y="620" width="310" height="36" fill="red" />
<text x="507" y="638" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >onexport 导出数据</text>
<rect x="77" y="664" width="267" height="36" fill="red" />
<text x="210" y="682" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Output</text>
<rect x="77" y="708" width="267" height="36" fill="red" />
<text x="210" y="726" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >base 基础模块</text>
<rect x="77" y="752" width="267" height="36" fill="red" />
<text x="210" y="770" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >core 核心模块</text>
<rect x="77" y="796" width="267" height="36" fill="red" />
<text x="210" y="814" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >misc 工具模块</text>
<rect x="77" y="840" width="267" height="36" fill="red" />
<text x="210" y="858" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >page 网页模块</text>
<rect x="77" y="884" width="267" height="36" fill="red" />
<text x="210" y="902" font-size="24" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >user 用户模块"</text>
</svg>
<embed src="miss.svg" type="image/svg+xml">
## 1 原型
### 1.1 ID 生成器
@ -69,14 +19,33 @@ volcanos是一个前端框架。
### 1.9 Story 存储器
## 2 框架
### 2.1 Plugin 插件
### 2.2 Inputs 控件
### 2.3 Output 组件
### 2.1 Page 页面
### 2.2 Pane 面板
### 2.3 Plugin 插件
### 2.4 Inputs 控件
### 2.5 Output 组件
## 3 模块
## 3 核心模块
### 3.1 base 模块
### 3.2 core 模块
### 3.3 misc 模块
### 3.4 page 模块
### 3.5 user 模块
## 4 事件模块
### 4.1 onimport 模块
### 4.2 onaction 模块
### 4.3 onchoice 模块
### 4.4 ondetail 模块
### 4.5 onexport 模块
## 5 配置
### 5.1 Header
### 5.2 Ocean
### 5.3 River
### 5.4 Target
### 5.5 Source
### 5.6 Action
### 5.7 Storm
### 5.8 Steam
### 5.9 Footer

View File

@ -1,67 +1,61 @@
var can = Volcanos("chat", {
Page: shy("构造网页", function(can, name, list, cb, target) {
Page: shy("构造网页", function(can, name, conf, cb, body) {
var page = Volcanos(name, {type: "local",
Plugin: can.Plugin,
Inputs: can.Inputs,
Output: can.Output,
run: function(event, option, cmds, cb) {
ctx.Run(event, option, cmds, cb)
Plugin: can.Plugin, Inputs: can.Inputs, Output: can.Output,
Report: function(event, value, key) {
kit.Item(page, function(index, item) {
item.Import && item.Import(event, value, key)
})
},
}, ["core", "page", "user", "page/"+name], function(page) {
can.core.Next(list, function(item, cb) {
page[item] = can.Pane(page, item, cb, can.page.Select(can, target, "fieldset."+item)[0] ||
can.page.AppendField(can, target, item+" dialog"))
run: function(event, option, cmds, cb) {ctx.Run(event, option, cmds, cb)},
}, Config.libs.concat(["page/"+name]), function(page) {
can.core.Next(conf.pane, function(item, cb) {
page[item.name] = can.Pane(page, item.name, item, cb, can.page.Select(can, body, "fieldset."+item.name)[0] ||
can.page.AppendField(can, body, item.name+" dialog", item))
}, function() {typeof cb == "function" && cb(page)})
})
return page
return page.target = body, page
}),
Pane: shy("构造面板", function(can, name, cb, field) {
Pane: shy("构造面板", function(can, name, meta, cb, field) {
var option = field.querySelector("form.option");
var action = field.querySelector("div.action");
var output = field.querySelector("div.output");
var river = "", storm = "";
var pane = Volcanos(name, {type: "local",
Save: function(name, output) {pane.Cache(name, output, "hi")},
Load: function(name, output) {pane.Cache(name, output)},
Plugin: can.Plugin, Inputs: can.Inputs, Output: can.Output,
Inputs: can.Inputs,
Output: can.Output,
Plugin: function(item, type, index) {var name = item.name;
pane[item.name] = can.Plugin(pane, item, type, function(event, cmds, cbs) {
pane.run(event, [item.river, item.storm, item.action].concat(cmds), cbs)
}, can.page.AppendField(can, output, "item "+item.group+" "+item.name, item))
Export: function(event, value, key) {can.Report(event, value, key)},
Import: function(event, value, key) {var cb = pane.onimport[key];
typeof cb == "function" && cb(event, pane, value, key, output);
},
Show: function(river, storm) {
if (river && storm && field.Pane.Load(river+"."+storm, output)) {return}
pane.run(event, [river, storm], function(msg) {
pane.onimport.init(pane, msg, output)
})
},
run: function(event, cmds, cb) {var msg = pane.Event(event)
can.page.Select(can, action, "input", function(item, index) {
msg.Option(item.name, item.value)
msg.Option(name, item.value)
})
can.run(event, option.dataset, cmds, cb)
},
}, ["core", "page", "user", "pane/"+name], function(pane) {
}, Config.libs.concat(["pane/"+name]), function(pane) {
typeof cb == "function" && cb(pane)
})
return pane.target = field, field.Pane = pane
return pane.target = field, pane
}),
Plugin: shy("构造插件", function(can, meta, type, run, field) {
Plugin: shy("构造插件", function(can, name, meta, run, field) {
var option = field.querySelector("form.option");
var action = field.querySelector("div.action");
var output = field.querySelector("div.output");
var history = []
var name = meta.name, args = meta.args || [];
var args = meta.args || [];
var feature = JSON.parse(meta.feature||'{}');
var plugin = Volcanos(name, {type: "local",
Inputs: can.Inputs,
Output: can.Output,
Inputs: can.Inputs, Output: can.Output,
Append: function(item, cb) {item = item || {type: "text", name: "", className: "args temp"};
var name = item.name || item.value || "args"+plugin.page.Select(can, option, "input.args.temp").length;
var count = plugin.page.Select(can, option, ".args").length, value = "";
@ -106,7 +100,7 @@ var can = Volcanos("chat", {
Show: function(type, msg, cb) {msg._plugin_name = name;
return plugin[type] = can.Output(plugin, type, msg, cb, output, option)
},
}, ["core", "page", "user", "plugin/"+type], function(plugin) {
}, Config.libs.concat(["plugin/"+(meta.type||"state")]), function(plugin) {
can.core.Next(JSON.parse(meta.inputs||"[]"), plugin.Append)
})
return plugin.target = field, field.Plugin = plugin
@ -121,9 +115,11 @@ var can = Volcanos("chat", {
(input[item.cb] || can[item.cb] || can.Check)(event, event.target, cb);
},
}, ["core", "page", "user", "plugin/"+type], function(input) {typeof cb == "function" && cb();
}, Config.libs.concat(["plugin/"+type]), function(input) {
var target = input.onimport.init(input, item, name, value, option);
input.target = target, target.Input = input;
typeof cb == "function" && cb();
})
return input
}),
@ -133,15 +129,18 @@ var can = Volcanos("chat", {
run: function(event, cmd, cb, silent) {
(output[cmd[1]] || can[cmd[1]] || can.Run)(event, cmd, cb, silent);
},
}, ["core", "page", "user", "plugin/"+type], function(output) {
}, Config.libs.concat(["plugin/"+type]), function(output) {
output.onimport.init(output, msg, cb, target, option);
}, msg)
return output.target = target, target.Output = output
}),
}, ["base", "core", "misc", "page", "user",
"plugin/state", "plugin/input", "plugin/table"], function(can) {
// can.Page(can, Config.main, Config.list, document.body)
}, Config.libs.concat(Config.list), function(can) {
if (ctx.Search("feature") != "") {
can[Config.main] = can.Page(can, Config.main, Config, function(chat) {
can.user.carte = page.carte.Pane.Show;
can.user.toast = page.toast.Pane.Show;
chat.River.Import(event||{}, "shy", "username")
}, document.body)
}
})

78
miss.svg Normal file
View File

@ -0,0 +1,78 @@
<svg vertion="1.1" xmlns="http://www.w3.org/2000/svg" width="561", height="1085" style="">
<rect x="4" y="529" width="84" height="27" fill="red" />
<text x="46" y="542" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >volcanos</text>
<rect x="96" y="144" width="84" height="27" fill="red" />
<text x="138" y="157" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >proto.js</text>
<rect x="188" y="4" width="152" height="27" fill="red" />
<text x="264" y="17" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >ID 生成器</text>
<rect x="188" y="39" width="152" height="27" fill="red" />
<text x="264" y="52" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Log 日志器</text>
<rect x="188" y="74" width="152" height="27" fill="red" />
<text x="264" y="87" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Conf 配置器</text>
<rect x="188" y="109" width="152" height="27" fill="red" />
<text x="264" y="122" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Sync 同步器</text>
<rect x="188" y="144" width="152" height="27" fill="red" />
<text x="264" y="157" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Timer 定时器</text>
<rect x="188" y="179" width="152" height="27" fill="red" />
<text x="264" y="192" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Event 触发器</text>
<rect x="188" y="214" width="152" height="27" fill="red" />
<text x="264" y="227" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Dream 构造器</text>
<rect x="188" y="249" width="152" height="27" fill="red" />
<text x="264" y="262" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Cache 缓存器</text>
<rect x="188" y="284" width="152" height="27" fill="red" />
<text x="264" y="297" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Story 存储器</text>
<rect x="96" y="529" width="84" height="27" fill="blue" />
<text x="138" y="542" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >frame.js</text>
<rect x="188" y="319" width="152" height="27" fill="blue" />
<text x="264" y="332" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Page</text>
<rect x="188" y="424" width="152" height="27" fill="blue" />
<text x="264" y="437" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Pane</text>
<rect x="348" y="354" width="209" height="27" fill="red" />
<text x="452" y="367" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >base 基础模块</text>
<rect x="348" y="389" width="209" height="27" fill="red" />
<text x="452" y="402" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >core 核心模块</text>
<rect x="348" y="424" width="209" height="27" fill="red" />
<text x="452" y="437" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >misc 工具模块</text>
<rect x="348" y="459" width="209" height="27" fill="red" />
<text x="452" y="472" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >page 网页模块</text>
<rect x="348" y="494" width="209" height="27" fill="red" />
<text x="452" y="507" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >user 用户模块</text>
<rect x="188" y="529" width="152" height="27" fill="blue" />
<text x="264" y="542" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Plugin</text>
<rect x="188" y="634" width="152" height="27" fill="blue" />
<text x="264" y="647" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Inputs</text>
<rect x="348" y="564" width="209" height="27" fill="red" />
<text x="452" y="577" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >onimport 导入数据</text>
<rect x="348" y="599" width="209" height="27" fill="red" />
<text x="452" y="612" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >onaction 控件交互</text>
<rect x="348" y="634" width="209" height="27" fill="red" />
<text x="452" y="647" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >onchoice 控件菜单</text>
<rect x="348" y="669" width="209" height="27" fill="red" />
<text x="452" y="682" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >ondetail 控件详情</text>
<rect x="348" y="704" width="209" height="27" fill="red" />
<text x="452" y="717" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >onexport 导出数据</text>
<rect x="188" y="739" width="152" height="27" fill="blue" />
<text x="264" y="752" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Output</text>
<rect x="96" y="914" width="84" height="27" fill="red" />
<text x="138" y="927" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >order.js</text>
<rect x="188" y="774" width="152" height="27" fill="red" />
<text x="264" y="787" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Header</text>
<rect x="188" y="809" width="152" height="27" fill="red" />
<text x="264" y="822" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Ocean</text>
<rect x="188" y="844" width="152" height="27" fill="red" />
<text x="264" y="857" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >River</text>
<rect x="188" y="879" width="152" height="27" fill="red" />
<text x="264" y="892" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Target</text>
<rect x="188" y="914" width="152" height="27" fill="red" />
<text x="264" y="927" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Source</text>
<rect x="188" y="949" width="152" height="27" fill="red" />
<text x="264" y="962" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Action</text>
<rect x="188" y="984" width="152" height="27" fill="red" />
<text x="264" y="997" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Storm</text>
<rect x="188" y="1019" width="152" height="27" fill="red" />
<text x="264" y="1032" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Steam</text>
<rect x="188" y="1054" width="152" height="27" fill="red" />
<text x="264" y="1067" font-size="16" style="dominant-baseline:middle;text-anchor:middle;" fill="white" >Footer</text>
</svg>

After

Width:  |  Height:  |  Size: 6.7 KiB

12
order.js Normal file
View File

@ -0,0 +1,12 @@
var Config = {
main: "chat", list: [
"page/chat", "pane/River", "pane/Storm", "pane/Action",
"plugin/state", "plugin/input", "plugin/table", "plugin/inner",
],
libs: ["lib/base", "lib/core", "lib/misc", "lib/page", "lib/user"],
pane: [
{group: "index", name: "River"},
{group: "index", name: "Storm"},
{group: "index", name: "Action"},
],
}

75
pane/Action.js Normal file
View File

@ -0,0 +1,75 @@
Volcanos("onimport", {help: "导入数据", list: [],
init: function(can, msg, output) {output.innerHTML = "";
msg.Table(function(item, index) {
can[item.name] = can.Plugin(can, item.name, item, function(event, cmds, cbs) {
can.run(event, [item.river, item.storm, item.action].concat(cmds), cbs)
}, can.page.AppendField(can, output, "item "+item.group+" "+item.name, item))
})
},
river: function(event, can, value, key, output) {
can.Conf("temp_river", value)
},
storm: function(event, can, value, key, output) {
can.Cache(can.Conf("river")+"."+can.Conf("storm"), output, "some");
can.Conf("river", can.Conf("temp_river"))
can.Conf("storm", value)
var data = can.Cache(can.Conf("river")+"."+can.Conf("storm"), output);
if (!data) {
can.run(event, [can.Conf("river"), can.Conf("storm")], function(msg) {
can.onimport.init(can, msg, output)
})
}
},
})
Volcanos("onaction", {help: "组件交互", list: [],
})
Volcanos("onchoice", {help: "组件菜单", list: ["返回", "清空", "复制", "下载", "表格", "绘图", "媒体"],
"返回": function(event, can, msg, value, target) {
can.run(event, ["", "Last"])
},
"清空": function(event, can, msg, value, target) {
can.target.innerHTML = "";
},
"复制": function(event, can, msg, value, target) {
var list = can.onexport.Format(can, msg, "data");
can.user.toast(can.page.CopyText(can, list[2]), "复制成功")
},
"下载": function(event, can, msg, value, target) {
var list = can.onexport.Format(can, msg, msg._plugin_name||"data");
can.page.Download(can, list[0]+list[1], list[2]);
},
})
Volcanos("ondetail", {help: "组件详情", list: ["选择", "修改", "删除", "复制", "下载"],
"选择": "select",
"删除": "delete",
"修改": function(event, can, msg, value, index, key, td) {
var text = td.innerHTML;
can.page.Appends(can, td, [{type: "input", style: {width: td.clientWidth+"px"}, data: {onkeydown: function(event) {
if (event.key != "Enter") {return}
can.run(event, [index, "modify", key == "value" && msg.key? msg[key][index]: key, event.target.value,], function(msg) {
td.innerHTML = event.target.value;
can.user.toast("修改成功")
}, true)
}}}])
},
"复制": function(event, can, msg, value, index, key, target) {
can.user.toast(can.page.CopyText(can, target.innerHTML), "复制成功")
},
"下载": function(event, can, msg, value, index, key, target) {
can.page.Download(can, key, target.innerHTML);
},
})
Volcanos("onexport", {help: "导出数据", list: [],
Format: function(can, msg, name) {
var ext = ".csv", txt = can.page.Select(can, can.target, "tr", function(tr) {
return can.page.Select(can, tr, "td,th", function(td) {return td.innerText}).join(",")
}).join("\n");
!txt && (ext = ".txt", txt = msg.result && msg.result.join("") || "");
return [name, ext, txt]
},
})

67
pane/River.js Normal file
View File

@ -0,0 +1,67 @@
Volcanos("onimport", {help: "导入数据", list: [],
init: function(can, msg, output) {output.innerHTML = "";
msg.Table(function(item, index) {
can.page.Append(can, output, [{view: ["item"], list: [{text: [item.nick||item.key]}], click: function(event) {
can.Export(event, item.key, "river")
}}])
})
},
username: function(event, can, value, key, output) {
can.run(event, [], function(msg) {
can.onimport.init(can, msg, output)
can.Export(event, msg.key[0], "river")
})
},
})
Volcanos("onaction", {help: "组件交互", list: [],
})
Volcanos("onchoice", {help: "组件菜单", list: ["返回", "清空", "复制", "下载", "表格", "绘图", "媒体"],
"返回": function(event, can, msg, value, target) {
can.run(event, ["", "Last"])
},
"清空": function(event, can, msg, value, target) {
can.target.innerHTML = "";
},
"复制": function(event, can, msg, value, target) {
var list = can.onexport.Format(can, msg, "data");
can.user.toast(can.page.CopyText(can, list[2]), "复制成功")
},
"下载": function(event, can, msg, value, target) {
var list = can.onexport.Format(can, msg, msg._plugin_name||"data");
can.page.Download(can, list[0]+list[1], list[2]);
},
})
Volcanos("ondetail", {help: "组件详情", list: ["选择", "修改", "删除", "复制", "下载"],
"选择": "select",
"删除": "delete",
"修改": function(event, can, msg, value, index, key, td) {
var text = td.innerHTML;
can.page.Appends(can, td, [{type: "input", style: {width: td.clientWidth+"px"}, data: {onkeydown: function(event) {
if (event.key != "Enter") {return}
can.run(event, [index, "modify", key == "value" && msg.key? msg[key][index]: key, event.target.value,], function(msg) {
td.innerHTML = event.target.value;
can.user.toast("修改成功")
}, true)
}}}])
},
"复制": function(event, can, msg, value, index, key, target) {
can.user.toast(can.page.CopyText(can, target.innerHTML), "复制成功")
},
"下载": function(event, can, msg, value, index, key, target) {
can.page.Download(can, key, target.innerHTML);
},
})
Volcanos("onexport", {help: "导出数据", list: [],
Format: function(can, msg, name) {
var ext = ".csv", txt = can.page.Select(can, can.target, "tr", function(tr) {
return can.page.Select(can, tr, "td,th", function(td) {return td.innerText}).join(",")
}).join("\n");
!txt && (ext = ".txt", txt = msg.result && msg.result.join("") || "");
return [name, ext, txt]
},
})

67
pane/Storm.js Normal file
View File

@ -0,0 +1,67 @@
Volcanos("onimport", {help: "导入数据", list: [],
init: function(can, msg, output) {output.innerHTML = "";
msg.Table(function(item, index) {
can.page.Append(can, output, [{view: ["item"], list: [{text: [item.key]}], click: function(event) {
can.Export(event, item.key, "storm")
}}])
})
},
river: function(event, can, value, key, output) {
can.run(event, [value], function(msg) {
can.onimport.init(can, msg, output)
can.Export(event, msg.key[0], "storm")
})
},
})
Volcanos("onaction", {help: "组件交互", list: [],
})
Volcanos("onchoice", {help: "组件菜单", list: ["返回", "清空", "复制", "下载", "表格", "绘图", "媒体"],
"返回": function(event, can, msg, value, target) {
can.run(event, ["", "Last"])
},
"清空": function(event, can, msg, value, target) {
can.target.innerHTML = "";
},
"复制": function(event, can, msg, value, target) {
var list = can.onexport.Format(can, msg, "data");
can.user.toast(can.page.CopyText(can, list[2]), "复制成功")
},
"下载": function(event, can, msg, value, target) {
var list = can.onexport.Format(can, msg, msg._plugin_name||"data");
can.page.Download(can, list[0]+list[1], list[2]);
},
})
Volcanos("ondetail", {help: "组件详情", list: ["选择", "修改", "删除", "复制", "下载"],
"选择": "select",
"删除": "delete",
"修改": function(event, can, msg, value, index, key, td) {
var text = td.innerHTML;
can.page.Appends(can, td, [{type: "input", style: {width: td.clientWidth+"px"}, data: {onkeydown: function(event) {
if (event.key != "Enter") {return}
can.run(event, [index, "modify", key == "value" && msg.key? msg[key][index]: key, event.target.value,], function(msg) {
td.innerHTML = event.target.value;
can.user.toast("修改成功")
}, true)
}}}])
},
"复制": function(event, can, msg, value, index, key, target) {
can.user.toast(can.page.CopyText(can, target.innerHTML), "复制成功")
},
"下载": function(event, can, msg, value, index, key, target) {
can.page.Download(can, key, target.innerHTML);
},
})
Volcanos("onexport", {help: "导出数据", list: [],
Format: function(can, msg, name) {
var ext = ".csv", txt = can.page.Select(can, can.target, "tr", function(tr) {
return can.page.Select(can, tr, "td,th", function(td) {return td.innerText}).join(",")
}).join("\n");
!txt && (ext = ".txt", txt = msg.result && msg.result.join("") || "");
return [name, ext, txt]
},
})

View File

@ -29,7 +29,7 @@ Volcanos("onimport", {help: "导入数据", list: [],
var target = can.Dream(option, "input", input)[input.name];
(item.type == "text" || item.type == "textarea") && !target.placeholder && (target.placeholder = item.name);
item.type == "text" && !target.title && (target.title = item.placeholder || item.name || "");
item.type == "button" && item.action == "auto" && can.run && can.run(event);
item.type == "button" && item.action == "auto" && can.run && can.run({});
return target;
}),
})