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

opt m.FormatMeta

This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-12-09 08:32:08 +08:00
parent 1d3975e844
commit b3a09d726f
6 changed files with 18 additions and 19 deletions

View File

@ -43,6 +43,7 @@ var ice = {
MSG_USERNICK: "user.nick", MSG_USERNAME: "user.name", MSG_USERROLE: "user.role", MSG_LANGUAGE: "user.lang", MSG_USERNICK: "user.nick", MSG_USERNAME: "user.name", MSG_USERROLE: "user.role", MSG_LANGUAGE: "user.lang",
MSG_MODE: "sess.mode", MSG_THEME: "sess.theme", MSG_TITLE: "sess.title", MSG_RIVER: "sess.river", MSG_STORM: "sess.storm", MSG_MODE: "sess.mode", MSG_THEME: "sess.theme", MSG_TITLE: "sess.title", MSG_RIVER: "sess.river", MSG_STORM: "sess.storm",
MSG_DAEMON: "sess.daemon", LOG_DISABLE: "log.disable", LOG_TRACEID: "log.id", MSG_DAEMON: "sess.daemon", LOG_DISABLE: "log.disable", LOG_TRACEID: "log.id",
MSG_COST: "sess.cost",
MSG_DEBUG: "debug", MSG_DEBUG: "debug",
ErrWarn: "warn: ", ErrNotLogin: "not login: ", ErrNotRight: "not right: ", ErrNotValid: "not valid: ", ErrNotFound: "not found: ", ErrWarn: "warn: ", ErrNotLogin: "not login: ", ErrNotRight: "not right: ", ErrNotValid: "not valid: ", ErrNotFound: "not found: ",
@ -74,7 +75,7 @@ var web = {CHAT: "chat", PORTAL: "portal", STUDIO: "studio", SERVICE: "service",
VENDOR: "vendor", VENDOR: "vendor",
SERVE: "serve", SPACE: "space", ROUTE: "route", DREAM: "dream", SERVE: "serve", SPACE: "space", ROUTE: "route", DREAM: "dream",
SPIDE: "spide", TOKEN: "token", SHARE: "share", COUNT: "count", SPIDE: "spide", TOKEN: "token", SHARE: "share", COUNT: "count",
ADMIN: "admin", STATS: "stats", ADMIN: "admin",
WORKER: "worker", SERVER: "server", GATEWAY: "gateway", WORKER: "worker", SERVER: "server", GATEWAY: "gateway",
ONLINE: "online", OFFLINE: "offline", ONLINE: "online", OFFLINE: "offline",
OPEN: "open", LINK: "link", HTTP: "http", DOMAIN: "domain", URL: "url", OPEN: "open", LINK: "link", HTTP: "http", DOMAIN: "domain", URL: "url",

View File

@ -17,18 +17,16 @@ Volcanos(chat.ONENGINE, {_init: function(can, meta, list, cb, target) {
if (!sub || !mod || !fun) { can.misc.Warn(ice.ErrNotFound, cmds); return can.base.isFunc(cb) && cb(msg.Echo(ice.ErrWarn, ice.ErrNotFound, cmds)) } if (!sub || !mod || !fun) { can.misc.Warn(ice.ErrNotFound, cmds); return can.base.isFunc(cb) && cb(msg.Echo(ice.ErrWarn, ice.ErrNotFound, cmds)) }
return can.core.CallFunc(fun, {event: event, can: sub, msg: msg, cmds: cmds.slice(2), cb: cb, target: sub._target, button: key, cmd: key, arg: cmds.slice(2), list: cmds.slice(2)}, mod) return can.core.CallFunc(fun, {event: event, can: sub, msg: msg, cmds: cmds.slice(2), cb: cb, target: sub._target, button: key, cmd: key, arg: cmds.slice(2), list: cmds.slice(2)}, mod)
}, },
_remote: function(event, can, msg, panel, cmds, cb) { var sub = msg._can; _remote: function(event, can, msg, panel, cmds, cb) { var sub = msg._can
if (panel.onengine._plugin(event, can, msg, panel, cmds, cb)) { return } if (panel.onengine._plugin(event, can, msg, panel, cmds, cb)) { return }
if (panel.onengine._engine(event, can, msg, panel, cmds, cb)) { return } if (panel.onengine._engine(event, can, msg, panel, cmds, cb)) { return }
if (panel.onengine._static(event, can, msg, panel, cmds, cb)) { return } if (panel.onengine._static(event, can, msg, panel, cmds, cb)) { return }
var toast, _toast = msg.Option(chat._TOAST); if (_toast) { can.onmotion.delay(can, function() { if (msg._can && msg._can._toast) { return } toast = toast||can.user.toastProcess(msg._can, _toast) }, 500) } var toast, _toast = msg.Option(chat._TOAST); if (_toast) { can.onmotion.delay(can, function() { if (msg._can && msg._can._toast) { return } toast = toast||can.user.toastProcess(msg._can, _toast) }, 500) }
if (can.base.isUndefined(msg[ice.MSG_DAEMON])) { can.base.isUndefined(sub._daemon) && can.ondaemon._list[0] && (sub._daemon = can.ondaemon._list.push(sub)-1) if (can.base.isUndefined(msg[ice.MSG_DAEMON])) { can.base.isUndefined(sub._daemon) && can.ondaemon._list[0] && (sub._daemon = can.ondaemon._list.push(sub)-1)
if (sub._daemon) { msg.Option(ice.MSG_DAEMON, can.core.Keys(can.ondaemon._list[0], sub._daemon)) } if (sub._daemon) { msg.Option(ice.MSG_DAEMON, can.core.Keys(can.ondaemon._list[0], sub._daemon)) }
} can.page.exportValue(sub, msg) } if (!can.misc.CookieSessid(can) && can.user.info.sessid) { msg.Option(ice.MSG_SESSID, can.user.info.sessid) }
if (!can.misc.CookieSessid(can) && can.user.info.sessid) { msg.Option(ice.MSG_SESSID, can.user.info.sessid) }
msg.OptionDefault(ice.MSG_THEME, can.getHeaderTheme())
var names = msg.Option(chat._NAMES)||panel._names||((can.Conf("iceberg")||Volcanos.meta.iceberg)+"/chat/"+panel._name+"/") var names = msg.Option(chat._NAMES)||panel._names||((can.Conf("iceberg")||Volcanos.meta.iceberg)+"/chat/"+panel._name+"/")
names = can.base.MergeURL(names, ice.MSG_INDEX, sub.ConfIndex(), ice.MSG_LANGUAGE, can.user.info.language, ice.MSG_THEME, can.getHeader(chat.THEME)) names = can.base.MergeURL(names, ice.MSG_INDEX, sub.ConfIndex()), can.page.exportValue(sub, msg)
can.onengine.signal(panel, chat.ONREMOTE, can.request({}, {_follow: panel._follow, _msg: msg, _cmds: cmds, names: names})) can.onengine.signal(panel, chat.ONREMOTE, can.request({}, {_follow: panel._follow, _msg: msg, _cmds: cmds, names: names}))
can.misc.Run(event, can, {names: names}, cmds, function(msg) { toast && toast.close && toast.close(), toast = true can.misc.Run(event, can, {names: names}, cmds, function(msg) { toast && toast.close && toast.close(), toast = true
can.base.isFunc(cb) && cb(msg), Volcanos.meta.pack[can.core.Keys(panel._name, cmds.join(mdb.FS))] = msg can.base.isFunc(cb) && cb(msg), Volcanos.meta.pack[can.core.Keys(panel._name, cmds.join(mdb.FS))] = msg
@ -247,7 +245,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
can.core.CallFunc([sub, chat.ONIMPORT, chat._INIT], {can: sub, msg: msg, cb: function(msg) { can.core.CallFunc([sub, chat.ONIMPORT, chat._INIT], {can: sub, msg: msg, cb: function(msg) {
if (action !== false) { can.onkeymap._build(sub) if (action !== false) { can.onkeymap._build(sub)
can.onmotion.clear(can, can._action), sub.onappend._action(sub, can.Conf(ice.MSG_ACTION)||msg.Option(ice.MSG_ACTION), action||can._action) can.onmotion.clear(can, can._action), sub.onappend._action(sub, can.Conf(ice.MSG_ACTION)||msg.Option(ice.MSG_ACTION), action||can._action)
sub.onappend._status(sub, sub.onexport&&sub.onexport.list||msg.Option(ice.MSG_STATUS)), can.user.isMobile || sub.onappend.tools(sub, msg) sub.onappend._status(sub, sub.onexport&&sub.onexport.list||msg.Option(ice.MSG_STATUS), null, msg), can.user.isMobile || sub.onappend.tools(sub, msg)
can.core.Item(can.Action(), function(key) { var value = can.misc.sessionStorage(can, [can.ConfIndex(), ctx.ACTION, key]); value && can.Action(key, value[0]) }) can.core.Item(can.Action(), function(key) { var value = can.misc.sessionStorage(can, [can.ConfIndex(), ctx.ACTION, key]); value && can.Action(key, value[0]) })
} can.onappend.style(sub, sub.Conf(ctx.STYLE)), can.onmotion.story.auto(can, can._output) } can.onappend.style(sub, sub.Conf(ctx.STYLE)), can.onmotion.story.auto(can, can._output)
if (can.onimport.size) { if (can.onimport.size) {
@ -260,13 +258,14 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
}, target: output}) }, target: output})
}) })
}, },
_status: function(can, list, status) { status = status||can._status, can.onmotion.clear(can, status); var keys = {} _status: function(can, list, status, msg) { status = status||can._status, can.onmotion.clear(can, status); var keys = {}
can.core.List((can.base.Obj(list, can.core.Value(can, [chat.ONEXPORT, mdb.LIST]))||[]).concat(can.misc.Search(can, log.DEBUG)==ice.TRUE? [ can.core.List((can.base.Obj(list, can.core.Value(can, [chat.ONEXPORT, mdb.LIST]))||[]).concat(can.misc.Search(can, log.DEBUG)==ice.TRUE? [
{name: html.HEIGHT, value: can.ConfHeight()}, {name: html.WIDTH, value: can.ConfWidth()}, {name: html.HEIGHT, value: can.ConfHeight()}, {name: html.WIDTH, value: can.ConfWidth()},
]: []), function(item) { item = can.base.isString(item)? {name: item}: item ]: []), function(item) { item = can.base.isString(item)? {name: item}: item
if (item && item.name == web.SPACE && item.value) { item.value = can.page.Format(html.A, can.misc.MergePodCmd(can, {pod: item.value}), item.value) } if (item && item.name == web.SPACE && item.value) { item.value = can.page.Format(html.A, can.misc.MergePodCmd(can, {pod: item.value}), item.value) }
if (can.base.beginWith(item.value, nfs.PS, ice.HTTP)) { item.value = can.page.Format(html.A, item.value, item.value.split("?")[0]) } if (can.base.beginWith(item.value, nfs.PS, ice.HTTP)) { item.value = can.page.Format(html.A, item.value, item.value.split("?")[0]) }
if (keys[item.name]) { return can.Status(item.name, item.value) } keys[item.name] = item if (keys[item.name]) { return can.Status(item.name, item.value) } keys[item.name] = item
msg && item.name == cli.COST && (item.value = msg.Option(ice.MSG_COST)||item.value)
can.page.Append(can, status, [{view: html.ITEM, list: [ can.page.Append(can, status, [{view: html.ITEM, list: [
{text: [can.page.Color(can.user.trans(can, item.name, null, html.INPUT)), html.LABEL]}, {text: [": ", html.LABEL]}, {text: [(item.value == undefined? "": (item.value+"").trim())+"", html.SPAN, item.name]}, {text: [can.page.Color(can.user.trans(can, item.name, null, html.INPUT)), html.LABEL]}, {text: [": ", html.LABEL]}, {text: [(item.value == undefined? "": (item.value+"").trim())+"", html.SPAN, item.name]},
], onclick: function(event) { can.user.copy(event, can, item.value) }}]) ], onclick: function(event) { can.user.copy(event, can, item.value) }}])

View File

@ -108,7 +108,7 @@ Volcanos("base", {
h = parseInt(n/3600000/24), h > 0 && (res += h+"d"), n = n % (3600000*24) h = parseInt(n/3600000/24), h > 0 && (res += h+"d"), n = n % (3600000*24)
h = parseInt(n/3600000), h > 0 && (res += h+"h"), n = n % 3600000 h = parseInt(n/3600000), h > 0 && (res += h+"h"), n = n % 3600000
h = parseInt(n/60000), h > 0 && (res += h+"m"), n = n % 60000 h = parseInt(n/60000), h > 0 && (res += h+"m"), n = n % 60000
h = parseInt(n/1000), h > 0 && (res += h), n = n % 1000 h = parseInt(n/1000), h > 0 && (res += h+"s"), n = n % 1000
return res + (n > 0? nfs.PT+parseInt(n/10): "") + "s" return res + (n > 0? nfs.PT+parseInt(n/10): "") + "s"
}, },
isNight: function() { var now = new Date(); return now.getHours() < 7 || now.getHours() > 17 }, isNight: function() { var now = new Date(); return now.getHours() < 7 || now.getHours() > 17 },
@ -116,7 +116,6 @@ Volcanos("base", {
isString: function(val) { return typeof val == code.STRING }, isString: function(val) { return typeof val == code.STRING },
isObject: function(val) { return typeof val == code.OBJECT }, isObject: function(val) { return typeof val == code.OBJECT },
isArray: function(val) { return Array.isArray(val) }, isArray: function(val) { return Array.isArray(val) },
// isArray: function(val) { return typeof val == code.OBJECT && val.length != undefined },
isFunc: function(val) { return typeof val == code.FUNCTION }, isFunc: function(val) { return typeof val == code.FUNCTION },
isUndefined: function(val) { return val == undefined }, isUndefined: function(val) { return val == undefined },
isNull: function(val) { return val == null }, isNull: function(val) { return val == null },

View File

@ -94,6 +94,7 @@ Volcanos("misc", {
}) })
}, },
POST: function(can, msg, url, form, cb, cbs) { var xhr = new XMLHttpRequest(), begin = new Date(); msg._xhr = xhr POST: function(can, msg, url, form, cb, cbs) { var xhr = new XMLHttpRequest(), begin = new Date(); msg._xhr = xhr
xhr._begin = begin
var data = can.core.ItemForm(form, function(v, i, k) { return k+mdb.EQ+encodeURIComponent(v) }).join("&") var data = can.core.ItemForm(form, function(v, i, k) { return k+mdb.EQ+encodeURIComponent(v) }).join("&")
if (data && can.base.isIn(msg._method, http.GET, http.DELETE)) { url += (url.indexOf("?") == -1? "?": "&")+data, data = "" } if (data && can.base.isIn(msg._method, http.GET, http.DELETE)) { url += (url.indexOf("?") == -1? "?": "&")+data, data = "" }
xhr.open(msg._method||http.POST, url), xhr.onreadystatechange = function() { if (xhr.readyState != 4) { return } xhr.open(msg._method||http.POST, url), xhr.onreadystatechange = function() { if (xhr.readyState != 4) { return }
@ -116,7 +117,7 @@ Volcanos("misc", {
} try { xhr.send(data) } catch(e) { can.misc.Warn(e), cbs && cbs(e) } } try { xhr.send(data) } catch(e) { can.misc.Warn(e), cbs && cbs(e) }
}, },
WSS: function(can, args, cb, onopen, onclose, onerror, _msg) { if (can.user.isIE) { return } WSS: function(can, args, cb, onopen, onclose, onerror, _msg) { if (can.user.isIE) { return }
var msg = can.request(); can.page.exportValue(can, msg), args[ice.MSG_THEME] = can.getHeaderTheme() var msg = can.request(); can.page.exportValue(can, msg)
can.core.List(msg.Option(), function(value) { args[value] = msg.Option(value) }) can.core.List(msg.Option(), function(value) { args[value] = msg.Option(value) })
var url = location.protocol.replace(ice.HTTP, "ws")+"//"+location.host+"/space/" var url = location.protocol.replace(ice.HTTP, "ws")+"//"+location.host+"/space/"
if (url.indexOf(html.CHROME) == 0) { url = "ws://localhost:9020/space/" } if (url.indexOf(html.CHROME) == 0) { url = "ws://localhost:9020/space/" }

View File

@ -381,8 +381,10 @@ Volcanos("page", {
can.base.isIn(name, mdb.REMOVE, mdb.DELETE, mdb.PRUNES, mdb.PRUNE, nfs.TRASH, "drop", cli.STOP, "stopall")? "danger": "" can.base.isIn(name, mdb.REMOVE, mdb.DELETE, mdb.PRUNES, mdb.PRUNE, nfs.TRASH, "drop", cli.STOP, "stopall")? "danger": ""
}, },
exportValue: function(can, msg, target) { target = target||can._output exportValue: function(can, msg, target) { target = target||can._output
msg.OptionDefault(ice.MSG_THEME, can.getHeaderTheme())
msg.OptionDefault(ice.MSG_BG, can.page.styleValue(can, "--plugin-bg-color", target)) msg.OptionDefault(ice.MSG_BG, can.page.styleValue(can, "--plugin-bg-color", target))
msg.OptionDefault(ice.MSG_FG, can.page.styleValue(can, "--plugin-fg-color", target)) msg.OptionDefault(ice.MSG_FG, can.page.styleValue(can, "--plugin-fg-color", target))
msg.OptionDefault(ice.MSG_LANGUAGE, can.user.info.language)
return msg return msg
}, },
styleValue: function(can, key, target) { const styles = getComputedStyle(target||document.body); return styles.getPropertyValue(key) }, styleValue: function(can, key, target) { const styles = getComputedStyle(target||document.body); return styles.getPropertyValue(key) },

View File

@ -1,12 +1,9 @@
Volcanos(chat.ONIMPORT, { Volcanos(chat.ONIMPORT, {
_init: function(can, msg) { can.onappend.style(can, ["stats", html.FLEX], can._output) _init: function(can, msg) { can.onappend.style(can, [web.STATS, html.FLEX], can._output)
var list = {} var list = {}, stats = {}, units = {}, trans = {}, index = {}; msg.Table(function(value) {
var stats = {}, units = {}, trans = {}, index = {}; msg.Table(function(value) {
stats[value.name] = parseFloat(stats[value.name]||"0") + parseFloat(value.value) stats[value.name] = parseFloat(stats[value.name]||"0") + parseFloat(value.value)
units[value.name] = value.units units[value.name] = value.units, trans[value.name] = value._trans
trans[value.name] = value._trans index[value.name] = value.index, list[value.name] = value
index[value.name] = value.index
list[value.name] = value
}) })
function fmts(value) { var ls = [] function fmts(value) { var ls = []
while (value > 0) { ls.push(value%1000) while (value > 0) { ls.push(value%1000)
@ -16,7 +13,7 @@ Volcanos(chat.ONIMPORT, {
} }
can.user.trans(can, trans, null, html.INPUT) can.user.trans(can, trans, null, html.INPUT)
can.core.Item(stats, function(name, value) { can.page.Append(can, can._output, [{view: [[html.ITEM, name, html.FLEX]], list: [ can.core.Item(stats, function(name, value) { can.page.Append(can, can._output, [{view: [[html.ITEM, name, html.FLEX]], list: [
{view: mdb.VALUE, list: [{text: can.base.trimSuffix(fmts(parseFloat(value).toFixed(2))+"", ".00")}, {text: [units[name], "", "units"]}]}, {view: mdb.VALUE, list: [{text: can.base.trimSuffix(fmts(parseFloat(value).toFixed(2))+"", ".00")}, {text: [units[name], "", mall.UNITS]}]},
{view: [mdb.NAME, "", can.user.trans(can, name, trans[name]||null, html.INPUT)]}, {view: [mdb.NAME, "", can.user.trans(can, name, trans[name]||null, html.INPUT)]},
], onclick: function() { ], onclick: function() {
can.onappend.plugin(can, {space: list[name].space, index: index[name], style: html.FLOAT}) can.onappend.plugin(can, {space: list[name].space, index: index[name], style: html.FLOAT})