1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-25 16:58:06 +08:00
This commit is contained in:
harveyshao 2022-11-23 13:37:31 +08:00
parent db406e7a64
commit ef5b194859
6 changed files with 18 additions and 9 deletions

View File

@ -1,6 +1,8 @@
Volcanos(chat.ONENGINE, {_init: function(can, meta, list, cb, target) {
can.user.isMobile && can.require(["https://unpkg.com/vconsole@latest/dist/vconsole.min.js"], function() { new window.VConsole() })
if (can.misc.Search(can, ice.MSG_SESSID)) { can.misc.CookieSessid(can, can.misc.Search(can, ice.MSG_SESSID)); return can.misc.Search(can, ice.MSG_SESSID, "") }
can.user.isMobile && can.require(["https://unpkg.com/vconsole@latest/dist/vconsole.min.js"], function() { return window.VConsole() })
if (!can.user.isMailMaster) {
if (can.misc.Search(can, ice.MSG_SESSID)) { can.misc.CookieSessid(can, can.misc.Search(can, ice.MSG_SESSID)); return can.misc.Search(can, ice.MSG_SESSID, "") }
}
can.user.title(can.misc.Search(can, chat.TITLE)||can.misc.Search(can, ice.POD)||location.host)
can.run = function(event, cmds, cb) { var msg = can.request(event); cmds = cmds||[]; return (can.onengine[cmds[0]]||can.onengine._remote)(event, can, msg, can, cmds, cb) }
can.require([can.volcano], null, function(can, key, sub) { can[key] = sub })

View File

@ -108,12 +108,15 @@ Volcanos("misc", {Message: function(event, can) { var msg = {}
), form, cb)
},
POST: function(can, msg, url, form, cb) { var xhr = new XMLHttpRequest(), begin = new Date(); msg._xhr = xhr
if (can.user.isMailMaster && !msg._upload) {
var data = can.core.Items(form, function(value, index, key) { return key+ice.EQ+encodeURIComponent(value) }).join("&")
if (data) { url += (url.indexOf(url, "?") == -1? "?": "&")+data }
}
xhr.open(msg._method||web.POST, url), xhr.onreadystatechange = function() { if (xhr.readyState != 4) { return }
try { var res = JSON.parse(xhr.responseText) } catch (e) { var res = {result: [xhr.responseText]} } msg.Option("_cost", new Date() - begin)
if (xhr.status == 200) { return can.base.isFunc(cb) && cb(msg.Copy(res)) }
can.user.toastFailure(can, xhr.response), can.misc.Warn(xhr.status, res, url, form)
}, xhr.setRequestHeader(web.Accept, msg._accept||web.ContentJSON)
if (msg._upload) {
var data = new FormData(); can.core.Items(form, function(value, index, key) { data.append(key, value) })
data.append(ice.MSG_UPLOAD, web.UPLOAD), data.append(web.UPLOAD, msg._upload)
@ -181,8 +184,8 @@ Volcanos("misc", {Message: function(event, can) { var msg = {}
return can.core.Split(decodeURIComponent(location.hash.slice(1)))||[]
},
Search: function(can, key, value) { var args = {}
if (value == undefined && can.base.isString(key)) { var ls = location.pathname.split(ice.PS); if (ls[1] == chat.SHARE) { args[chat.SHARE] = ls[2] }
for (var i = 2; i < ls.length; i += 2) { if (kit.Dict(ice.POD, true, ice.CMD, true, web.WEBSITE, true)[ls[i]]) { args[ls[i]] = ls[i+1] } }
if (value == undefined && can.base.isString(key)) { var ls = can.core.Split(location.pathname, ice.PS); if (ls[0] == chat.SHARE) { args[chat.SHARE] = ls[1] }
for (var i = 1; i < ls.length; i += 2) { if (kit.Dict(ice.POD, true, ice.CMD, true, web.WEBSITE, true)[ls[i]]) { args[ls[i]] = ls[i+1] } }
} location.search && location.search.slice(1).split("&").forEach(function(item) { var x = item.split(ice.EQ); x[1] != "" && (args[x[0]] = decodeURIComponent(x[1])) })
if (can.base.isUndefined(key)) { return args } else if (can.base.isObject(key)) {

View File

@ -12,6 +12,7 @@ Volcanos("user", {info: {}, agent: {
},
},
isTesla: navigator.userAgent.indexOf("Tesla") > -1,
isMailMaster: navigator.userAgent.indexOf("MailMaster") > -1,
isWeiXin: navigator.userAgent.indexOf("MicroMessenger") > -1,
isIPhone: navigator.userAgent.indexOf("iPhone") > -1,
isMobile: navigator.userAgent.indexOf("Mobile") > -1,
@ -34,7 +35,7 @@ Volcanos("user", {info: {}, agent: {
prompt: function(tip, def, cb, silent) { (text = silent? def: prompt(tip, def||"")) != undefined && typeof cb == lang.FUNCTION && cb(text); return text },
reload: function(force) { (force || confirm("重新加载页面?")) && location.reload() },
jumps: function(url) { location.href = url },
open: function(url) { window.open(url) },
open: function(url) { window.open(url) || (location.href = url) },
close: function(url) { window.close() },
title: function(text) { if (window.webview) { return title(text) } return text && (document.title = text), document.title },

View File

@ -275,7 +275,7 @@ Volcanos(chat.ONACTION, {
},
save: function(event, can, button) { can.request(event, {file: can.Option(nfs.FILE), content: can.onexport.content(can)})
can.onaction._run(event, can, button, [can.parse, can.Option(nfs.FILE), can.Option(nfs.PATH)], function() { can.user.toastSuccess(can, button) })
can.onaction._run(event, can, button, [can.parse, can.Option(nfs.FILE), can.Option(nfs.PATH)], function() { can.user.toastSuccess(can, button, can.Option(nfs.PATH)+can.Option(nfs.FILE)) })
},
compile: function(event, can, button) { var _toast = can.user.toastProcess(can, "编译中...")
can.runAction(can.request(event), button, [], function(msg) { _toast.close()

View File

@ -1,5 +1,6 @@
Volcanos(chat.ONIMPORT, {_process: function(can, msg) {
msg.OptionStatus() && can.onmotion.clear(can, can._status) && can.onappend._status(can, msg.OptionStatus())
console.log("what", msg)
return can.core.CallFunc([can.onimport, msg.OptionProcess()], {can: can, msg: msg})
},
_location: function(can, msg, _arg) { can.user.jumps(_arg); return true },
@ -71,7 +72,9 @@ Volcanos(chat.ONIMPORT, {_process: function(can, msg) {
return can.page.style(can, div, html.MAX_HEIGHT, 400), can.page.Append(can, div, [{text: _arg}]), div.scrollBy(0, 10000), true
}).length == 0) { can.onappend.board(can, _arg) } return true
},
_open: function(can, msg, _arg) { return can.user.open(_arg), true },
_open: function(can, msg, _arg) {
console.log("what", _arg)
return can.user.open(_arg), true },
size: function(can, height, width, auto, mode) {
if (auto) {

View File

@ -282,7 +282,7 @@ var Volcanos = shy({iceberg: "/chat/", volcano: "/frame.js", cache: {}, pack: {}
if (libs[0] == undefined) { return can.require(libs.slice(1), cb, cbs) }
if (libs[0] == "") { libs[0] = can._path.replace(nfs._JS, nfs._CSS) }
if (libs[0][0] != ice.PS && libs[0].indexOf(ice.HTTP) != 0) { libs[0] = can._path.slice(0, can._path.lastIndexOf(ice.PS)+1)+libs[0] }
var name = (libs[0].indexOf(ice.HTTP) == 0? libs[0]: libs[0].split("?")[0]).toLowerCase()
var name = (libs[0].indexOf(ice.HTTP) == 0? libs[0]: libs[0].split("?")[0]).toLowerCase(); meta.debug == true && (name += "?_="+Date.now())
function next() { can._load(name, cbs), can.require(libs.slice(1), cb, cbs) }
meta.cache[name]? next(): (_can_path = libs[0], meta._load(name, next))
},