1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-25 16:58:06 +08:00
This commit is contained in:
shaoying 2021-05-16 15:50:09 +08:00
parent 4756adbd22
commit 20358167df
12 changed files with 66 additions and 43 deletions

View File

@ -19,7 +19,7 @@ Volcanos("onengine", {help: "搜索引擎", list: [], _init: function(can, meta,
var sub, mod = can, fun = can, key = ""; can.core.List(cmds[1].split("."), function(value) { var sub, mod = can, fun = can, key = ""; can.core.List(cmds[1].split("."), function(value) {
fun && (sub = mod, mod = fun, fun = mod[value], key = value) fun && (sub = mod, mod = fun, fun = mod[value], key = value)
}); if (!sub || !mod || !fun) { }); if (!sub || !mod || !fun) {
can.misc.Warn("not found", cmds[1]) can.misc.Warn("not found", cmds)
can.base.isFunc(cb) && cb(msg.Echo("warn: ", "not found: ", cmds[1])) can.base.isFunc(cb) && cb(msg.Echo("warn: ", "not found: ", cmds[1]))
return return
} }
@ -40,7 +40,7 @@ Volcanos("onengine", {help: "搜索引擎", list: [], _init: function(can, meta,
return typeof cb == "function" && cb(msg) return typeof cb == "function" && cb(msg)
} }
can.misc.Run(event, can, {names: (can.Conf("iceberg")||"/chat/")+panel._name, daemon: can._daemon+"."+msg._daemon}, cmds, function(msg) { can.misc.Run(event, can, {names: (can.Conf("iceberg")||"/chat/")+panel._name, daemon: can.ondaemon._list[0]+"."+msg._daemon}, cmds, function(msg) {
Volcanos.meta.pack[key] = msg Volcanos.meta.pack[key] = msg
can.base.isFunc(cb) && cb(msg) can.base.isFunc(cb) && cb(msg)
}) })
@ -193,7 +193,7 @@ Volcanos("ondaemon", {help: "推荐引擎", list: [], _init: function(can) {
} }
}) })
}, },
_list: [{}], _list: [""],
toast: function(can, msg, arg) { arg[0] = can toast: function(can, msg, arg) { arg[0] = can
Volcanos.meta.float.toast && can.page.Remove(can, Volcanos.meta.float.toast._target) Volcanos.meta.float.toast && can.page.Remove(can, Volcanos.meta.float.toast._target)
Volcanos.meta.float.toast = can.core.CallFunc(can.user.toast, {can: can, msg: msg, cmds: arg}) Volcanos.meta.float.toast = can.core.CallFunc(can.user.toast, {can: can, msg: msg, cmds: arg})
@ -206,8 +206,7 @@ Volcanos("ondaemon", {help: "推荐引擎", list: [], _init: function(can) {
out.onimport._grow(out, arg.join("")) out.onimport._grow(out, arg.join(""))
}, },
pwd: function(can, msg, arg) { pwd: function(can, msg, arg) {
can.misc.Log(msg) can.ondaemon._list[0] = arg[0]
can._daemon = arg[0]
}, },
}) })
Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta, list, cb, target, field) { Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta, list, cb, target, field) {

View File

@ -116,7 +116,7 @@ Volcanos("base", {help: "数据类型",
return res return res
}, },
AddUniq: function(list, value) { list = list || [] AddUniq: function(list, value) { list = list || []
return list.indexOf(value) > -1 && list.push(value), list return list.indexOf(value) == -1 && list.push(value), list
}, },
Date: function(time) { var now = new Date() Date: function(time) { var now = new Date()

View File

@ -4,7 +4,6 @@ Volcanos("core", {help: "数据结构",
switch (typeof v) { switch (typeof v) {
case "object": case "object":
for (var j = 0; j < v.length; j++) { for (var j = 0; j < v.length; j++) {
// list.push(arguments.callee.apply({}, v[j]))
list.push(v[j]) list.push(v[j])
} }
break break
@ -43,7 +42,7 @@ Volcanos("core", {help: "数据结构",
var sups = _list(arg[2]||"'\"`") // 引用符 var sups = _list(arg[2]||"'\"`") // 引用符
var res = [], begin = 0; function push(obj) { var res = [], begin = 0; function push(obj) {
obj != "" && res.push(typeof obj == "string" || opt.detail? obj: obj.text), begin = -1 obj && res.push(typeof obj == "string" || opt.detail? obj: obj.text), begin = -1
} }
// 开始分词 // 开始分词
@ -120,7 +119,7 @@ Volcanos("core", {help: "数据结构",
} else { // 选择序列 } else { // 选择序列
var slice = [], res var slice = [], res
for (var i = 0; i < list.length; i++) { for (var i = 0; i < list.length; i++) {
typeof cb == "function" && (res = cb(list[i], i, list)) != undefined? slice.push(res): slice.push(list[i]) typeof cb == "function"? (res = cb(list[i], i, list)) != undefined && slice.push(res): slice.push(list[i])
} }
list = slice list = slice
} }
@ -129,8 +128,8 @@ Volcanos("core", {help: "数据结构",
}), }),
Next: shy("迭代器", function(list, cb, cbs) { Next: shy("迭代器", function(list, cb, cbs) {
function next(i) { function next(i) {
i < list.length? cb(list[i], function(skip) { i < list.length? cb(list[i], function() {
next(i+1+(skip||0)) next(i+1)
}, i, list): typeof cbs == "function" && cbs(list) }, i, list): typeof cbs == "function" && cbs(list)
} }
@ -149,11 +148,12 @@ Volcanos("core", {help: "数据结构",
typeof cb == "function" && setTimeout(function() { loop(0) }, interval.interval||interval[0]) typeof cb == "function" && setTimeout(function() { loop(0) }, interval.interval||interval[0])
return timer return timer
}), }),
Delay: shy("延时器", function(list, interval, cb, cbs) { Delay: shy("延时器", function(list, interval, cb, cbs) { list = list || []
list.push(cb); this.Timer(interval, function() { list.push(cb); this.Timer(interval, function() {
var cb = list.pop(); list.length = 0 var cb = list.pop(); list.length = 0
typeof cb == "function" && cb() typeof cb == "function" && cb()
}, cbs) }, cbs)
return list
}), }),
Items: shy("迭代器", function(obj, cb) { var list = [] Items: shy("迭代器", function(obj, cb) { var list = []
for (var k in obj) { for (var k in obj) {

View File

@ -1,4 +1,4 @@
Volcanos("misc", {help: "工具模块", Message: function(event, can) { var msg = {} Volcanos("misc", {help: "通信协议", Message: function(event, can) { var msg = {}
var proto = {_event: event, _can: can, var proto = {_event: event, _can: can,
Option: function(key, val) { Option: function(key, val) {
if (key == undefined) { return msg && msg.option || [] } if (key == undefined) { return msg && msg.option || [] }
@ -132,21 +132,20 @@ Volcanos("misc", {help: "工具模块", Message: function(event, can) { var msg
var data = {"detail": [event.data]} var data = {"detail": [event.data]}
} }
var msg = can.request(event); msg.Reply = function() { var msg = can.request(event); msg.Reply = function() { // 回复命令
msg.result = (msg.result||[]).concat(can.core.List(arguments)) msg.result = (msg.result||[]).concat(can.core.List(arguments))
// 回复命令 msg.Option({_handle: true, _target: msg.Option("_source")})
delete(msg._can)
delete(msg._event)
msg.Option("_handle", true)
msg.Option("_target", msg.Option("_source"))
can.misc.Log("wss", "result", msg.result, msg) can.misc.Log("wss", "result", msg.result, msg)
delete(msg._event), delete(msg._can)
socket.send(JSON.stringify(msg)) socket.send(JSON.stringify(msg))
}, msg.detail = data.detail, msg.Copy(data) }, msg.detail = data.detail, msg.Copy(data)
// 执行命令 // 执行命令
try { can.misc.Log("wss", "detail", msg.detail, msg) try {
can.isFunc(cb) && cb(event, msg, msg.detail[0], msg.detail.slice(1)) can.misc.Log("wss", "detail", msg.detail, msg)
can.base.isFunc(cb) && cb(event, msg, msg.detail[0], msg.detail.slice(1))
} catch (e) { // 执行失败 } catch (e) { // 执行失败
can.misc.Log(e), msg.Reply(e) can.misc.Log(e), msg.Reply(e)
} }

View File

@ -24,12 +24,18 @@ Volcanos("page", {help: "网页模块", ClassList: {
target = typeof target == "string"? document.querySelector(target): target target = typeof target == "string"? document.querySelector(target): target
typeof value == "string"? (target.innerHTML = value): can.core.Item(value, function(key, val) { typeof value == "string"? (target.innerHTML = value): can.core.Item(value, function(key, val) {
typeof val != "object"? (target[key] = val): can.core.Item(val, function(k, v) { typeof val != "object"? (target[key] = val): can.core.Item(val, function(k, v) {
var size = {
"width": true, "max-width": true, "min-width": true,
"height": true, "max-height": true, "min-height": true,
}
if (size[k] && parseInt(v) < 0) { return target[key] && (target[key][k] = "") }
var size = { var size = {
"width": true, "max-width": true, "min-width": true, "width": true, "max-width": true, "min-width": true,
"height": true, "max-height": true, "min-height": true, "height": true, "max-height": true, "min-height": true,
"left": true, "right": true, "top": true, "bottom": true, "left": true, "right": true, "top": true, "bottom": true,
"margin-top": true, "margin-left": true, "margin-top": true, "margin-left": true,
}; if (size[k] && parseInt(v) < 0) { return target[key] && (target[key][k] = "") } }
if (size[k] && v && (typeof v == "number" || v.indexOf && v.indexOf("px") == -1)) { if (size[k] && v && (typeof v == "number" || v.indexOf && v.indexOf("px") == -1)) {
v += "px" v += "px"
@ -140,7 +146,7 @@ Volcanos("page", {help: "网页模块", ClassList: {
if (type == "input") { if (type == "input") {
data.type == "button" && (data.value = can.user.trans(can, data.value)) data.type == "button" && (data.value = can.user.trans(can, data.value))
data.type == "text" && (data.autocomplete = data.autocomplete||"off") data.type == "text" && (data.autocomplete = data.autocomplete||"off")
(data.placeholder = can.user.trans(can, (data.placeholder||data.name).split(".").pop())) data.placeholder = can.user.trans(can, (data.placeholder||data.name||"").split(".").pop())
data.title = can.user.trans(can, data.title||data.placeholder) data.title = can.user.trans(can, data.title||data.placeholder)
} }
@ -169,7 +175,7 @@ Volcanos("page", {help: "网页模块", ClassList: {
if (!msg.append || msg.append.length == 0) {return} if (!msg.append || msg.append.length == 0) {return}
var table = can.page.Append(can, target, "table") var table = can.page.Append(can, target, "table")
can.page.Append(can, table, [{type: "tr", {dataset: {index: -1}}, list: can.page.Append(can, table, [{type: "tr", data: {dataset: {index: -1}}, list:
can.core.List(list, function(key) { can.core.List(list, function(key) {
return key[0] == "_"? undefined: {text: [key.trim(), "th"]} return key[0] == "_"? undefined: {text: [key.trim(), "th"]}
}) })
@ -248,7 +254,7 @@ Volcanos("page", {help: "网页模块", ClassList: {
text = "<a href='"+ls[0]+"' target='_blank'>"+ls[0]+"</a>"+ls.slice(1).join(" ") text = "<a href='"+ls[0]+"' target='_blank'>"+ls[0]+"</a>"+ls.slice(1).join(" ")
}; text = text.replace(/\\n/g, "<br>") }; text = text.replace(/\\n/g, "<br>")
if (!text.indexOf("\033\[")) { return text } // if (!text.indexOf("\033\[")) { return text }
text = text.replace(/\033\[31m/g, "<span style='color:#f00'>") text = text.replace(/\033\[31m/g, "<span style='color:#f00'>")
text = text.replace(/\033\[32m/g, "<span style='color:#0f0'>") text = text.replace(/\033\[32m/g, "<span style='color:#0f0'>")
text = text.replace(/\033\[33m/g, "<span style='color:#ff0'>") text = text.replace(/\033\[33m/g, "<span style='color:#ff0'>")

View File

@ -1,4 +1,4 @@
Volcanos("user", {help: "用户模块", agent: { Volcanos("user", {help: "用户操作", agent: {
scanQRCode: function(cb, can) { scanQRCode: function(cb, can) {
can.user.input(event, can, [{type: "textarea"}], function(ev, button, data, list, args) { can.user.input(event, can, [{type: "textarea"}], function(ev, button, data, list, args) {
cb(list[0]) cb(list[0])
@ -62,7 +62,7 @@ Volcanos("user", {help: "用户模块", agent: {
]}, ]},
] }]) ] }])
var action = can.onappend._action(can, meta.action||["close"], ui.action, { var action = can.onappend._action(can, meta.action||[], ui.action, {
close: function(event) { can.page.Remove(can, action._target), action.timer.stop = true }, close: function(event) { can.page.Remove(can, action._target), action.timer.stop = true },
timer: can.core.Timer({interval: 100, length: (parseInt(meta.duration||1000))/100}, function(event, interval, index) { timer: can.core.Timer({interval: 100, length: (parseInt(meta.duration||1000))/100}, function(event, interval, index) {
if (index > 30) { ui.duration.innerHTML = parseInt(index/10)+"."+(index%10)+"s..." } if (index > 30) { ui.duration.innerHTML = parseInt(index/10)+"."+(index%10)+"s..." }
@ -79,7 +79,7 @@ Volcanos("user", {help: "用户模块", agent: {
can.run(msg._event, cmd||["action", "share"], function(msg) { can.run(msg._event, cmd||["action", "share"], function(msg) {
can.user.toast(can, {height: 300, width: 500, can.user.toast(can, {height: 300, width: 500,
title: msg.Append("name"), duration: -1, title: msg.Append("name"), duration: -1,
content: msg.Append("text"), button: ["close"], content: msg.Append("text"), action: ["close"],
}) })
}) })
}, },
@ -154,15 +154,18 @@ Volcanos("user", {help: "用户模块", agent: {
}, },
input: function(event, can, form, cb, button) { // form [ string, array, object, {_input: "select", values: []} input: function(event, can, form, cb, button) { // form [ string, array, object, {_input: "select", values: []}
var msg = can.request(event, can.Option()) var msg = can.request(event, can.Option())
var option = {}; can.core.List(msg.Option(), function(key) {
option[key] = msg.Option(key)
})
var ui = can.page.Append(can, document.body, [{view: ["input"], style: {left: 0, top: 0}, list: [ var ui = can.page.Append(can, document.body, [{view: ["input"], style: {left: 0, top: 0}, list: [
{view: ["option", "table"], list: can.core.List(form, function(item) { {view: ["option", "table"], list: can.core.List(form, function(item) {
item._input == "select" && (item = {select: [[item.name].concat(item.values)], data: item, name: item.name}) item._input == "select" && (item = {select: [[item.name].concat(item.values)], data: item, name: item.name})
item = typeof item == "string"? {input: item, name: item}: item.length > 0? {select: [item], name: item[0]}: item item = typeof item == "string"? {input: item, name: item}: item.length > 0? {select: [item], name: item[0]}: item
item.type = item.type||"input", item.type == "input" && (item.data=item.data||{}, item.data.type = item.data.type||"text") item.type = item.type||"input", item.type == "input" && (item.data=item.data||{}, item.data.type = item.data.type||"text")
item._init = item._init||function(target) { item._init = function(target) {
item.run = function(event, cmds, cb) { item.run = function(event, cmds, cb) {
var msg = can.request(event, function() { var value = {_handle: "true"} var res = can.request(event, msg, option, function() { var value = {_handle: "true"}
can.page.Select(can, ui.table, "textarea,input,select", function(item) { can.page.Select(can, ui.table, "textarea,input,select", function(item) {
item.name && item.value && (value[item.name] = item.value) item.name && item.value && (value[item.name] = item.value)
}); return value }); return value

View File

@ -196,7 +196,7 @@ h1 {
h2 { h2 {
clear:both; clear:both;
} }
h2 { h3 {
clear:both; clear:both;
} }
h1:hover { h1:hover {

View File

@ -140,12 +140,12 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
menu: function(can, cmds, cb) { // type item... menu: function(can, cmds, cb) { // type item...
return can.page.Append(can, can._output, [{type: cmds[0], list: can.core.List(cmds.slice(1), function(item) { return can.page.Append(can, can._output, [{type: cmds[0], list: can.core.List(cmds.slice(1), function(item) {
if (typeof item == "string") { if (typeof item == "string") {
return {view: ["menu", "div", item], onclick: function(event) { return {view: ["menu", "div", can.user.trans(can, item)], onclick: function(event) {
can.base.isFunc(cb) && cb(event, item) can.base.isFunc(cb) && cb(event, item)
}} }}
} else if (item.length > 0) { } else if (item.length > 0) {
return {view: ["menu", "div", item[0]], onmouseenter: function(event) { return {view: ["menu", "div", can.user.trans(can, item[0])], onmouseenter: function(event) {
can.onaction.carte(event, can, item.slice(1), cb) can.onaction.carte(event, can, item.slice(1), cb)
}} }}

View File

@ -65,6 +65,8 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
// 左键点击 // 左键点击
can.onaction.action(event, can, river, meta.hash) can.onaction.action(event, can, river, meta.hash)
can.user.title(can._main_title || meta.name) can.user.title(can._main_title || meta.name)
can.onmotion.select(can, event.target.parentNode, "div.item", event.target)
}, onmouseenter: function(event) { }, onmouseenter: function(event) {
can.onaction.carte(event, can, ["共享应用", "添加工具", "保存参数", "重命名应用", "删除应用"], function(event, button, module) { can.onaction.carte(event, can, ["共享应用", "添加工具", "保存参数", "重命名应用", "删除应用"], function(event, button, module) {
module[button](event, can, button, river, meta.hash) module[button](event, can, button, river, meta.hash)
@ -151,7 +153,7 @@ Volcanos("onaction", {help: "控件交互", list: [], _init: function(can, msg,
carte: function(event, can, list, cb) { carte: function(event, can, list, cb) {
var carte = can.user.carte(event, can, can.ondetail, list, cb) var carte = can.user.carte(event, can, can.ondetail, list, cb)
can.page.Modify(can, carte._target, {style: { can.page.Modify(can, carte._target, {style: {
left: event.clientX-event.offsetX+event.target.offsetWidth-3, top: event.clientY-event.offsetY, left: event.clientX-event.offsetX+event.target.offsetWidth-3,
}}) }})
}, },

View File

@ -17,7 +17,6 @@ Volcanos("onimport", {help: "导入数据", _init: function(can, msg, list, cb,
var height = can.Conf("height")-320; height < 240 && (height = 240) var height = can.Conf("height")-320; height < 240 && (height = 240)
can.page.Modify(can, can.ui.project, {style: {"max-height": height}}) can.page.Modify(can, can.ui.project, {style: {"max-height": height}})
can.page.Modify(can, can.ui.content, {style: {"max-height": height}}) can.page.Modify(can, can.ui.content, {style: {"max-height": height}})
// can.page.Modify(can, can.ui.content, {style: {"min-width": can.Conf("width")-170}})
can.page.Modify(can, can.ui.display, {style: {display: "none"}}) can.page.Modify(can, can.ui.display, {style: {display: "none"}})
}, },
_output: function(can, target) { _output: function(can, target) {

View File

@ -142,13 +142,25 @@ Volcanos("ondetail", {help: "用户交互", list: [],
plugin: function(event, can, args) { plugin: function(event, can, args) {
can.onappend.plugin(can, {type: "float", index: "web.code.inner", args: args, _action: ["关闭"]}, function(sub) { can.onappend.plugin(can, {type: "float", index: "web.code.inner", args: args, _action: ["关闭"]}, function(sub) {
sub.run = function(event, cmds, cb) { sub.run = function(event, cmds, cb) {
can.run(event, ["action", "inner"].concat(cmds), cb, true) can.run(event, ["action", "inner"].concat(cmds), function(msg) {
can.onlayout.figure(event, sub, sub._target) can.search(event, ["Action.onexport.size"], function(msg, left, top, width, height) { left = left||0
var top = 120; if (can.user.isMobile) {
if (can.user.isLandscape) {
sub.Conf("height", window.innerHeight+240), top = 0
} else {
sub.Conf("height", window.innerHeight+160), top = 48
}
} else {
sub.Conf("height", height+120)
}
// can.misc.Debug(sub.Conf("height"), cmds)
can.page.Modify(can, sub._target, {style: {position: "fixed", left: left+20, top: top}})
can.page.Modify(can, sub._output, {style: {"max-width": width-40}})
can.base.isFunc(cb) && cb(msg)
})
}, true)
can.search(event, ["Action.onexport.size"], function(msg, left, top, width, height) { left = left||0
can.page.Modify(can, sub._target, {style: {position: "fixed", left: left, top: can.user.isMobile&&can.user.isLandscape? 0: 120}})
can.page.Modify(can, sub._output, {style: {"max-width": width}})
})
} }
}) })
}, },

View File

@ -63,8 +63,11 @@ var Volcanos = shy("火山架", {args: {}, pack: {}, libs: [], cache: {}, float:
request: function(event, option) { event = event || {} request: function(event, option) { event = event || {}
event._msg = event._msg || can.misc.Message(event, can) event._msg = event._msg || can.misc.Message(event, can)
can.core.List(arguments, function(option, index) { can.core.List(arguments, function(option, index) { if (index == 0) { return }
index > 0 && can.core.Item(can.base.isFunc(option)? option(): option, event._msg.Option) can.base.isFunc(option.Option)? can.core.List(option.Option(), function(key) {
event._msg.Option(key, option.Option(key))
}): can.core.Item(can.base.isFunc(option)? option(): option, event._msg.Option)
}); return event._msg }); return event._msg
}, },
const: function() { const: function() {