mirror of
https://shylinux.com/x/volcanos
synced 2025-04-25 08:48:06 +08:00
opt wx.ide
This commit is contained in:
parent
fd85b603ad
commit
ebdd932d40
14
frame.js
14
frame.js
@ -382,7 +382,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
|
||||
can.page.ClassList.set(can, target, "will", can.page.ClassList.has(can, target, key))
|
||||
})
|
||||
}, title: can.user.trans(can, can.Option(key) == undefined? key: "click to detail", null, html.INPUT), _init: function(target) {
|
||||
key == ctx.ACTION && can.onappend.mores(can, target, data, can.user.isMobile && !can.user.isLandscape()? 2: can.isCmdMode()? 5: 3)
|
||||
key == ctx.ACTION && can.onappend.mores(can, target, data, can.user.isMobile && !can.user.isLandscape()? 2: can.isCmdMode() || msg.IsDetail()? 5: 3)
|
||||
can.page.style(can, target, "cursor", key == mdb.KEY? "default": can.Option(key) != undefined? "pointer": "text")
|
||||
}}
|
||||
}); table && can.onappend.style(can, chat.CONTENT, table), table && msg.IsDetail() && can.onappend.style(can, mdb.DETAIL, table)
|
||||
@ -474,8 +474,7 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
|
||||
if (item.index) { item._index = count++, ui.size[item._index] = item.height||item.width
|
||||
can.onmotion.hidden(can, target)
|
||||
can.onappend.plugin(can, item, function(sub) { can._plugins = (can._plugins||[]).concat([sub])
|
||||
item.layout = function(height, width) {
|
||||
sub.onimport.size(sub, height, width) }
|
||||
item.layout = function(height, width) { sub.onimport.size(sub, height, width) }
|
||||
sub.onexport._output = function() { can.onmotion.toggle(can, target, true) }
|
||||
}, target, ui[item._index] = can.onappend.field(can, item.type, {index: item.index, name: item.index.split(nfs.PT).pop(), help: item.help}, target)._target)
|
||||
} else { can.page.Append(can, target, [item]) }
|
||||
@ -484,15 +483,18 @@ Volcanos(chat.ONAPPEND, {_init: function(can, meta, list, cb, target, field) {
|
||||
function calc(item, size, total) { return !ui.size[item]? can.base.isString(size)? parseInt(can.base.trimSuffix(size, "px")): size: ui.size[item] < 1? total*ui.size[item]: ui.size[item] }
|
||||
var defer = [], content_height, content_width; function layout(type, list, height, width) { var _width = width, _height = height; can.core.List(list, function(item) {
|
||||
if (can.base.isArray(item)) { return } if (can.base.isObject(item)) { var meta = item; item = item._index }
|
||||
var target = ui[item]; if (!can.page.isDisplay(target)) { return }
|
||||
var target = ui[item]
|
||||
if (!can.page.isDisplay(target)) { return }
|
||||
if (item == html.CONTENT || item == "main") { return defer.push(function() { can.page.style(can, target, html.HEIGHT, content_height = height, html.WIDTH, content_width = width) }) }
|
||||
if (type == FLOW) { var h = calc(item, target.offsetHeight, height)
|
||||
if (can.base.isObject(meta) && meta.layout) { meta.layout(h, width) }
|
||||
can.page.style(can, target, html.WIDTH, width), height -= h
|
||||
can.page.style(can, target, html.WIDTH, width)
|
||||
if (can.page.isDisplay(target)) { height -= h }
|
||||
} else {
|
||||
var w = calc(item, target.offsetWidth||target.style.width||_width/list.length, _width), h = height
|
||||
if (can.base.isObject(meta)) { meta.layout(h, w = _width/list.length) }
|
||||
can.page.style(can, target, html.HEIGHT, h, html.WIDTH, w), width -= w
|
||||
can.page.style(can, target, html.HEIGHT, h, html.WIDTH, w)
|
||||
if (can.page.isDisplay(target)) { width -= w }
|
||||
}
|
||||
}), can.core.List(list, function(item) { if (can.base.isArray(item)) { layout(type == FLOW? FLEX: FLOW, item, height, width) } }) }
|
||||
ui.profile && can.onmotion.hidden(can, ui.profile), ui.display && can.onmotion.hidden(can, ui.display)
|
||||
|
@ -34,7 +34,7 @@ body {
|
||||
--svg-font-size:24px; --svg-stroke-width:1; --status-font-size:12px;
|
||||
|
||||
--legend-padding:20px; --title-margin:var(--legend-padding); --river-margin:80px;
|
||||
--textarea-height:96px; --qrcode-height:320px; --iframe-height:420px;
|
||||
--textarea-height:96px; --qrcode-height:360px; --iframe-height:420px;
|
||||
--action-height:32px; --status-height:var(--action-height); --footer-height:var(--action-height); --header-height:48px;
|
||||
--project-width:230px; --river-width:var(--project-width); --input-width:120px; --button-width:60px;
|
||||
--plugin-margin:var(--plugin-padding); --button-margin:var(--button-padding); --input-margin:var(--input-padding); --action-margin:200px; --desktop-icon-size:80px;
|
||||
@ -155,7 +155,7 @@ body>div.input tr.img td:last-child>div>span { font-size:var(--action-height); }
|
||||
body>div.input tr.icon td:last-child { position:relative; }
|
||||
body>div.input tr.icon td:last-child img:first-child { position:absolute; height:28px; width:28px; left:12px; top:12px; }
|
||||
body>div.input tr.icon td:last-child input { padding-left:var(--action-height); }
|
||||
body>div.input tr.icons td:last-child img:first-child { position:absolute; height:28px; width:28px; left:12px; top:12px; }
|
||||
body>div.input tr.icons td:last-child img:first-child { position:absolute; height:28px; width:28px; left:2px; top:2px; }
|
||||
body>div.input tr.icons td:last-child input { padding-left:var(--action-height); }
|
||||
body>div.input td span.icon { margin-left:-20px; visibility:hidden; }
|
||||
body>div.input td span.icons { margin-left:-20px; visibility:hidden; }
|
||||
@ -327,7 +327,7 @@ div.toggle.project { top:20%; left:0; border-top-right-radius:var(--plugin-radiu
|
||||
div.content>div.toggle.profile { top:20%; right:0; border-top-left-radius:var(--plugin-radius); border-bottom-left-radius:var(--plugin-radius); }
|
||||
div.content>div.toggle.display { left:20%; bottom:-52px; rotate:90deg; border-top-left-radius:var(--plugin-radius); border-bottom-left-radius:var(--plugin-radius); }
|
||||
div.project:not(.toggle) { border-right:var(--box-border); width:var(--project-width); flex:0 0 var(--project-width); }
|
||||
div.profile:not(.toggle) { border-left:var(--box-border); width:50%; }
|
||||
div.profile:not(.toggle) { border-left:var(--box-border); width:50%; flex:0 0 50%; }
|
||||
div.display:not(.toggle) { border-top:var(--box-border); }
|
||||
/* output style */
|
||||
div.output.card>div.item {
|
||||
@ -471,7 +471,7 @@ body.mobile fieldset.Search>div.action>div.item.filter>span { position:absolute;
|
||||
body.mobile fieldset.Search>div.action>div.item.filter { width:100%; position:relative; }
|
||||
body.mobile fieldset.River { position:fixed; top:var(--header-height); z-index:11; }
|
||||
body.mobile fieldset.River>div.output { font-size:1.4rem; min-width:var(--project-width); }
|
||||
body.mobile fieldset.Action { margin-top:var(--header-height); }
|
||||
html:not(.login) body.mobile fieldset.Action { margin-top:var(--header-height); }
|
||||
body.mobile fieldset.Action.cmd { margin-top:0; }
|
||||
body.mobile fieldset.Action>div.output { overflow-x:hidden; }
|
||||
body.mobile fieldset.word>div.output { overflow-x:hidden; }
|
||||
|
@ -124,7 +124,7 @@ Volcanos("misc", {
|
||||
try { var socket = new WebSocket(can.base.MergeURL(url, args)); _msg = _msg || can.request()._caller() } catch {}
|
||||
can._socket = socket, socket.onclose = function() { can.misc.Log(html.WSS, cli.CLOSE, args)
|
||||
if (socket._close) { return }
|
||||
can.base.isFunc(onclose)? onclose(socket): can.core.Timer(can.base.random(3000, 100), function() {
|
||||
can.base.isFunc(onclose)? onclose(socket): can.core.Timer(can.base.random(3000, 300), function() {
|
||||
args.name = args.name||can._wss_name, can.misc.WSS(can, args, cb, onopen, onerror, onclose, _msg)
|
||||
})
|
||||
}, socket.onerror = function() { can.misc.Log(html.WSS, log.ERROR, args)
|
||||
@ -138,6 +138,7 @@ Volcanos("misc", {
|
||||
res.append = msg.append, can.core.List(msg.append, function(key) { res[key] = msg[key] }), res.result = (msg.result||[]).concat(can.core.List(arguments))
|
||||
res.Option(ice.LOG_DISABLE, msg.Option(ice.LOG_DISABLE)) != ice.TRUE && can.misc.Log(html.WSS, ice.MSG_RESULT, msg.result&&msg.result.length>0? msg.result: undefined, msg, _msg)
|
||||
res.Option(ice.LOG_TRACEID, msg.Option(ice.LOG_TRACEID))
|
||||
res.Option(ice.MSG_DEBUG, msg.Option(ice.MSG_DEBUG))
|
||||
socket.send(JSON.stringify(res))
|
||||
}, msg.detail = data.detail, msg.Copy(data)
|
||||
try { msg.Option(ice.LOG_DISABLE) != ice.TRUE && can.misc.Log(html.WSS, ice.MSG_DETAIL, msg.detail, msg, _msg)
|
||||
|
@ -255,8 +255,9 @@ Volcanos("user", {
|
||||
}), resize: html.IMG,
|
||||
}) },
|
||||
login: function(can, cb, msg) { can.misc.CookieSessid(can, ""); var socket = can.misc.WSS(can, {type: aaa.LOGIN}, function(cmd, arg) {
|
||||
can.page.ClassList.add(can, document.body.parentNode, aaa.LOGIN)
|
||||
function check() {
|
||||
if (can.misc.CookieSessid(can)) { can.page.ClassList.del(can, document.body, aaa.LOGIN)
|
||||
if (can.misc.CookieSessid(can)) { can.page.ClassList.del(can, document.body.parentNode, aaa.LOGIN)
|
||||
can.onmotion.clearFloat(can), can.onmotion.delay(can, function() { socket._close = true, socket.close() })
|
||||
return can.base.isFunc(cb) && cb(), cb = null, true
|
||||
} can.core.Timer(1000, function() { check() }), can.onimport.theme(can)
|
||||
|
@ -250,7 +250,7 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb) { var paths = can.core.Sp
|
||||
})
|
||||
} else {
|
||||
return can.onmotion.toggle(can, target, false), can.onimport.layout(can), can.user.toastFailure(can, "nothing to display")
|
||||
} return can.onmotion.toggle(can, target, true), can.onmotion.delay(can, function() { can.onimport.layout(can), can.user.toastSuccess(can) })
|
||||
} return can.onmotion.toggle(can, target, true), can.onmotion.delay(can, function() { can.onimport.layout(can), can.user.toastSuccess(can) }, 0)
|
||||
},
|
||||
toolkit: function(can, meta, cb) { can.base.isString(meta) && (meta = {index: meta})
|
||||
var key = [meta.index].concat(meta.args).join(","), sub = can.db.toolkit[key]; if (sub) { sub.select(); return }
|
||||
@ -272,7 +272,13 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb) { var paths = can.core.Sp
|
||||
var sub = can.ui.content._plugin; if (!sub) { return } if (height == sub.ConfHeight()+sub.onexport.actionHeight(sub)+sub.onexport.statusHeight(sub) && width == sub.ConfWidth()) { return }
|
||||
content._root || sub.onimport.size(sub, height, width, true), can.onlayout.layout(can, height, width)
|
||||
})
|
||||
if (can.isCmdMode()) { can.ui.zone.source._layout(), can.ui.zone[can.Option(nfs.PATH)] && can.ui.zone[can.Option(nfs.PATH)]._layout() }
|
||||
if (can.isCmdMode()) {
|
||||
can.page.style(can, can.ui.tabs.parentNode, html.WIDTH, can.ui.path.offsetWidth)
|
||||
can.page.style(can, can.ui.display, html.WIDTH, can.ui.path.offsetWidth)
|
||||
can.page.style(can, can.ui.display.parentNode, html.WIDTH, can.ui.path.offsetWidth)
|
||||
|
||||
can.ui.zone.source._layout(), can.ui.zone[can.Option(nfs.PATH)] && can.ui.zone[can.Option(nfs.PATH)]._layout()
|
||||
}
|
||||
try { can.isCmdMode() && can._msg._tab.scrollIntoView() } catch (e) {}
|
||||
},
|
||||
exts: function(can, url, cb) { var sub = can.db.toolkit[url.split(web.QS)[0]]; if (sub) { return can.base.isFunc(cb)? cb(sub): sub.select() }
|
||||
|
@ -23,7 +23,7 @@ Volcanos(chat.ONIMPORT, {_init: function(can, msg, cb) { if (can.user.mod.isPod)
|
||||
]); can.ui.current = ui.current, can.ui.complete = ui.complete, can.onkeymap._plugin(can) },
|
||||
_value: function(can) { can.onimport.__tabPath(can, true), can.db.mode == mdb.INSERT && can.onmotion.delay(can, function() { can.current.text(can.ui.current.value) }) },
|
||||
}, [""])
|
||||
Volcanos(chat.ONFIGURE, {
|
||||
Volcanos(chat.ONFIGURE, {
|
||||
source: function(can, target, zone, path) {
|
||||
var args = can.base.getValid(can.misc.SearchHash(can), [can.Option(nfs.PATH), can.Option(nfs.FILE)])
|
||||
function show(target, zone, path) { can.run(can.request({}, {_method: http.GET, dir_root: path, dir_deep: true}), [nfs.PWD], function(msg) {
|
||||
@ -84,7 +84,7 @@ Volcanos(chat.ONACTION, {list: ["创建", "编译", "源码", "计划", "流程"
|
||||
if (msg.Length() > 0 || msg.Result()) { return can.onimport.exts(can, "inner/search.js", function(sub) { can.ui.search = sub, sub.select()
|
||||
can.onmotion.delay(can, function() { can.onappend._output(sub, msg, sub.Conf(ctx.DISPLAY)) })
|
||||
}) } var toast = can.user.toastProcess(can, "重启中..."); can.onmotion.delay(can, function() { toast.close(), can.user.toastSuccess(can) }, 3000)
|
||||
})
|
||||
})
|
||||
},
|
||||
"命令": function(event, can) { can.user.input(event, can, [{name: ctx.INDEX, need: "must"}, ctx.ARGS], function(list) { can.onimport.tabview(can, "", list[0]+(list[1]? mdb.FS+list[1]: ""), ctx.INDEX) }) },
|
||||
"插件": function(event, can) { can.user.input(can.request(event, {type: "plug"}), can, [{name: ctx.INDEX, need: "must"}, ctx.ARGS], function(list, data) { var sub = can.db.toolkit[list.join(",")]; if (sub) { sub.select(); return }
|
||||
@ -101,7 +101,7 @@ Volcanos(chat.ONACTION, {list: ["创建", "编译", "源码", "计划", "流程"
|
||||
"后台": function(event, can) { var pod = can.misc.Search(can, ice.POD); can.onimport.tabview(can, "", location.origin+nfs.CHAT_PORTAL+(pod? "?pod="+pod: ""), web.SPACE) },
|
||||
"桌面": function(event, can) { can.onimport.tabview(can, "", web.CHAT_MACOS_DESKTOP, ctx.INDEX) },
|
||||
"官网": function(event, can) { can.onimport.tabview(can, "", can.misc.MergePodCmd(can, {cmd: web.WIKI_PORTAL}), web.SPACE) },
|
||||
|
||||
|
||||
insertLine: function(can, value, before) { var line = can.onaction.appendLine(can, value); before && can.ui.content.insertBefore(line, can.onaction._getLine(can, before)); return can.onaction.rerankLine(can), can.onexport.line(can, line) },
|
||||
deleteLine: function(can, line) { line = can.onaction._getLine(can, line); var next = line.nextSibling||line.previousSibling; return can.page.Remove(can, line), can.onaction.rerankLine(can), next },
|
||||
_selectLine: function(can) { can.current && can.page.Select(can, can.current.line, "td.text", function(td) { var target = can.ui.current; target.value = td.innerText
|
||||
@ -189,7 +189,7 @@ Volcanos(chat.ONKEYMAP, {
|
||||
c: shy("编译项目", function(event, can) { can.onaction.compile(event, can, code.COMPILE) }),
|
||||
v: shy("渲染界面", function(event, can) { can.onaction.show(event, can) }),
|
||||
r: shy("执行命令", function(event, can) { can.onaction.exec(event, can) }),
|
||||
|
||||
|
||||
Escape: shy("切换模式", function(event, can) { can.onkeymap._plugin(can) }),
|
||||
ArrowLeft: shy("光标左移", function(can, target) { can.onkeymap.cursorMove(target, -1) }),
|
||||
ArrowRight: shy("光标右移", function(can, target) { can.onkeymap.cursorMove(target, 1) }),
|
||||
@ -218,7 +218,7 @@ Volcanos(chat.ONKEYMAP, {
|
||||
}),
|
||||
|
||||
yy: shy("复制当前行", function(event, can, target, count) { var list = [], line = can.current.line
|
||||
for (var i = 0; i < count; i++) { list.push(can.onexport.text(can, line)), line = line.nextSibling } can.db._last_text = list; return true
|
||||
for (var i = 0; i < count; i++) { list.push(can.onexport.text(can, line)), line = line.nextSibling } can.db._last_text = list; return true
|
||||
}),
|
||||
dd: shy("剪切当前行", function(event, can, target, count) { var line = can.onaction.selectLine(can), callee = arguments.callee
|
||||
var list = []; for (var i = 0; i < count; i++) { (function() { var line = can.onaction.selectLine(can), text = can.current.text(); list.push(text)
|
||||
|
@ -14,6 +14,6 @@ App({
|
||||
this.conf.platform = res.platform
|
||||
this.conf.brand = res.brand
|
||||
this.conf.model = res.model
|
||||
console.log("app load", this.conf, res)
|
||||
this.misc.Info("app load", this.conf, res)
|
||||
},
|
||||
})
|
||||
|
@ -6,6 +6,13 @@
|
||||
"condition": {
|
||||
"miniprogram": {
|
||||
"list": [
|
||||
{
|
||||
"name": "",
|
||||
"pathName": "pages/action/action",
|
||||
"query": "index=web.chat.wx.ide",
|
||||
"launchMode": "default",
|
||||
"scene": null
|
||||
},
|
||||
{
|
||||
"name": "web.dream",
|
||||
"pathName": "pages/action/action",
|
||||
|
@ -43,16 +43,21 @@ var web = {
|
||||
}
|
||||
var aaa = {
|
||||
}
|
||||
var lex = {
|
||||
NL: "\n",
|
||||
}
|
||||
var tcp = {
|
||||
}
|
||||
var nfs = {
|
||||
DF: ice.DF, PS: ice.PS, PT: ice.PT,
|
||||
CHAT_RIVER: "/chat/river/",
|
||||
CHAT_ACTION: "/chat/action/",
|
||||
PATH: "path",
|
||||
}
|
||||
var cli = {
|
||||
}
|
||||
var log = {
|
||||
INFO: "info",
|
||||
}
|
||||
var code = {
|
||||
COMMENT: "comment", KEYWORD: "keyword",
|
||||
@ -92,6 +97,7 @@ var html = {
|
||||
module.exports = {
|
||||
kit, ice,
|
||||
ctx, mdb, web, aaa,
|
||||
lex,
|
||||
tcp, nfs, cli, log,
|
||||
code, wiki, chat, team, mall,
|
||||
http, html,
|
||||
|
@ -28,7 +28,8 @@ Volcanos("base", {
|
||||
var arg = this.Args.apply(this, [arg].concat(Array.prototype.slice.call(arguments, 1))); return url.split(ice.QS)[0]+(arg? ice.QS+arg: "")
|
||||
},
|
||||
ParseURL: function(url) { var res = this._parse(url); res.link = url, res.origin = res._origin; return res },
|
||||
ParseJSON: function(str) { var res; if (typeof str == code.OBJECT) { return str }
|
||||
ParseJSON: function(str) {
|
||||
var res; if (typeof str == code.OBJECT) { return str }
|
||||
if (str.indexOf(ice.HTTP) == 0) {
|
||||
var res = this._parse(str, {type: web.LINK, name: "", text: str})
|
||||
return res.name = res._origin.split("://").pop().split(nfs.PS)[0], res
|
||||
@ -65,4 +66,5 @@ Volcanos("base", {
|
||||
trim: function(arg) { if (this.isString(arg)) { return arg.trim() }
|
||||
if (this.isArray(arg)) { for (var i = arg.length-1; i >= 0; i--) { if (!arg[i]) { arg.pop() } else { break } } } return arg
|
||||
},
|
||||
random: function(max, min) { return min = min||0, parseInt(Math.random()*(max-min))+min },
|
||||
})
|
||||
|
@ -1,4 +1,4 @@
|
||||
const {kit, ice, ctx, mdb, web, nfs, code, chat, http, html} = require("../const.js")
|
||||
const {kit, ice, ctx, mdb, web, lex, nfs, log, code, chat, http, html} = require("../const.js")
|
||||
const {Volcanos} = require("../proto.js")
|
||||
module.exports =
|
||||
Volcanos("misc", {
|
||||
@ -57,23 +57,20 @@ Volcanos("misc", {
|
||||
for (var i = 1; i < ls.length; i += 2) { if (can.base.isIn(ls[i], [ice.POD, ice.CMD])) { args[ls[i]] = ls[i+1] } }
|
||||
return args
|
||||
},
|
||||
WSS: function(can) {
|
||||
WSS: function(can) { if (can.conf.platform == "devtools" && can.db.serve != can.conf.serve) { return }
|
||||
var url = can.base.MergeURL(can.db.serve.replace("http", "ws")+"/space/", mdb.TYPE, "weixin", mdb.NAME, "weixin", mdb.TEXT, can.base.MergeURL(nfs.PS+can.ui.route, can.db), can.conf)
|
||||
var socket = wx.connectSocket({url: url, header:{"content-type": "application/json"}})
|
||||
console.log("wss connect", url, socket)
|
||||
socket.onOpen(function(res) { console.log("wss open", res) })
|
||||
socket.onClose(function(res) { console.log("wss close", res)
|
||||
if (can._socket) { can._socket = socket = can.misc.WSS(can) }
|
||||
})
|
||||
socket.onMessage(function(res) {
|
||||
var msg = can.request(), data = can.base.Obj(res.data); msg.Copy(data), msg.detail = data.detail, console.log("wss recv", msg)
|
||||
var socket = wx.connectSocket({url: url, header:{"content-type": "application/json"}}); can.misc.Info("wss connect", url, socket)
|
||||
socket.onOpen(function(res) { can.misc.Info("wss open", res) })
|
||||
socket.onClose(function(res) { can.misc.Info("wss close", res), can._socket && can.core.Timer(can.base.random(30000, 3000), function() { can.misc.WSS(can) }) })
|
||||
socket.onMessage(function(res) { var msg = can.request(), data = can.base.Obj(res.data); msg.Copy(data), msg.detail = data.detail, can.misc.Info("wss recv", msg.detail, msg)
|
||||
switch (msg.detail[0]) {
|
||||
case "pwd": can._daemon = msg.detail[1]; break
|
||||
}
|
||||
msg.Echo("hello world")
|
||||
delete(msg._hand), console.log("wss send", msg), socket.sendSocketMessage({data: JSON.stringify(msg)})
|
||||
})
|
||||
return socket
|
||||
case "parse": can.core.Timer(30, function() { can.user.parse(can, data.detail[1]) }); break
|
||||
case "info": break
|
||||
} delete(msg._hand), delete(msg.detail), msg.Option("_handle", ice.TRUE)
|
||||
msg._target = (msg._source||[]).reverse(), msg._source = (msg._target||[]).reverse().slice(1)||[]
|
||||
can.misc.Info("wss send", msg.result, msg), socket.send({data: JSON.stringify(msg)})
|
||||
}); return can._socket = socket
|
||||
},
|
||||
request: function(can, msg, cmd, data, cb) { data.sessid = can.conf.sessid, data.appid = data.appid||can.conf.appid
|
||||
can.core.List(msg.option, function(key) { data[key] = data[key]||[msg.Option(key)] }), data.option = data.option||msg.option
|
||||
@ -84,7 +81,8 @@ Volcanos("misc", {
|
||||
can.user.info = {}, can.misc.localStorage(can, ice.MSG_SESSID, can.conf.sessid = "")
|
||||
return can.user.login(can, function() { can.misc.request(can, msg, cmd, data, cb) })
|
||||
}
|
||||
msg.Copy(res.data), console.log("request", cmd, data.cmds||data, msg)
|
||||
if (res.statusCode == 403) { msg.result = [res.data] }
|
||||
msg.Copy(res.data), can.misc.Info("request", cmd, data.cmds||data, msg)
|
||||
can.base.toLast(msg.append, mdb.TIME), can.base.toLast(msg.append, web.LINK), can.base.toLast(msg.append, ctx.ACTION)
|
||||
if (msg.append && msg.append.indexOf(ctx.ACTION) > 0) {
|
||||
msg._style = "content action"
|
||||
@ -126,4 +124,39 @@ Volcanos("misc", {
|
||||
value != undefined && wx.setStorageSync(key, value)
|
||||
return wx.getStorageSync(key)
|
||||
},
|
||||
Log: function() { var args = this._args("", arguments); console.log.apply(console, args), this._signal(args) },
|
||||
Info: function() { var args = this._args("", arguments); console.log.apply(console, args), this._signal(args) },
|
||||
Warn: function() { var args = this._args(log.WARN, arguments); console.warn.apply(console, args), this._signal(args); debugger },
|
||||
Error: function() { var args = this._args(log.ERROR, arguments); args.push(lex.NL, this._stacks().slice(1).join(lex.NL)), console.error.apply(console, args), this._signal(args); debugger },
|
||||
FileLine: function(depth, length) { var file = this.fileLine(depth+1, length||9); return file.link },
|
||||
fileLine: function(depth, length) { var list = this._stacks()
|
||||
function split(i) { if (!list[i]) { return {} }
|
||||
var ls = new RegExp("(https?://[^/]+)?([^:]+):([0-9]+):([0-9]+)").exec(list[i]); if (!ls) { return {} }
|
||||
var name = ""; list[i].lastIndexOf(lex.TB) > 0 && (name = list[i].split(lex.TB).pop())
|
||||
if (ls[0].indexOf(ice.QS) > -1) { ls[0] = ls[0].split(ice.QS)[0]+nfs.DF+ls[3]+nfs.DF+ls[4] }
|
||||
return {_path: ls[2]+":"+ls[3], name: name, link: ls[0], path: ls[2], file: ls[2].split(nfs.PS).slice(-length).join(nfs.PS), line: ls[3], cols: ls[4]}
|
||||
}
|
||||
if (depth < 0) { var current = split(-depth)
|
||||
for (var i = -depth+1; i < list.length; i++) { var pos = split(i); if (pos.path != current.path) { return pos } }
|
||||
} return split(depth)||{}
|
||||
},
|
||||
_stacks: function(n, s) { var list = ((s||(new Error())).stack||"").split(lex.NL).slice(typeof n == "undefined"? 2: n)
|
||||
for (var i = 0; i < list.length; i++) { var ls = list[i].trim().split(lex.SP)
|
||||
list[i] = ls.pop().trim(); if (list[i][0] == "(") { list[i] = list[i].slice(1, -1) }
|
||||
list[i] = " "+list[i]; if (ls.length > 1) { list[i] += " "+ls.pop() }
|
||||
list[i] = list[i].replace(/\?[^:]+/, "")
|
||||
} return list
|
||||
}, _stack: function() { return ((new Error()).stack||"").split(lex.NL).slice(2) },
|
||||
_time: function() { var now = new Date()
|
||||
var hour = now.getHours(); hour < 10 && (hour = "0"+hour)
|
||||
var minute = now.getMinutes(); minute < 10 && (minute = "0"+minute)
|
||||
var second = now.getSeconds(); second < 10 && (second = "0"+second)
|
||||
var mill = now.getMilliseconds(); mill < 10 && (mill = "00"+mill) || mill < 100 && (mill = "0"+mill)
|
||||
return [hour, minute, second].join(nfs.DF)+nfs.PT+mill
|
||||
},
|
||||
_args: function(level, arg) { var app = getApp()
|
||||
var args = [this._time(), app && app.conf.platform == "devtools"? this.FileLine(this._skip+1, 3)||"": ""].concat(level? [level]: [])
|
||||
for (var i in arg) { arg[i] != undefined && args.push(arg[i]) } return args
|
||||
},
|
||||
_signal: function(args) { this._list.push(args) }, _list: [], _skip: 2,
|
||||
})
|
||||
|
@ -3,6 +3,11 @@ const {shy, Volcanos} = require("../proto.js")
|
||||
module.exports =
|
||||
Volcanos("user", {
|
||||
agent: {
|
||||
enableDebug: function(can) {
|
||||
if (can.db.debug == ice.TRUE && can.conf.platform != "devtools") {
|
||||
wx.setEnableDebug({enableDebug: true})
|
||||
}
|
||||
},
|
||||
getLocation: function(can, cb) {
|
||||
wx.chooseLocation({success: function(res) {
|
||||
cb && cb({
|
||||
@ -14,14 +19,12 @@ Volcanos("user", {
|
||||
},
|
||||
connectWifi: function(can, ssid, password, cb, cbs) { wx.showLoading()
|
||||
wx.startWifi({success: function(res) {
|
||||
wx.connectWifi({SSID: ssid, password: password, success: function(res) { wx.hideLoading()
|
||||
console.log("wifi", res), cb && cb(res)
|
||||
}, fail: function(res) {
|
||||
console.log("wifi", res), cbs && cbs(res)
|
||||
}})
|
||||
}, fail: function(res) {
|
||||
console.log("wifi", res), cbs && cbs(res)
|
||||
}})
|
||||
wx.connectWifi({SSID: ssid, password: password, success: function(res) {
|
||||
can.core.Timer(1000, function() { wx.hideLoading()
|
||||
can.misc.Info("wifi", res), cb && cb(res)
|
||||
})
|
||||
}, fail: function(res) { can.misc.Warn("wifi", res), cbs && cbs(res) }})
|
||||
}, fail: function(res) { can.misc.Warn("wifi", res), cbs && cbs(res) }})
|
||||
},
|
||||
getClipboard: function(can, cb) {
|
||||
wx.getClipboardData({success: function(res) {
|
||||
@ -30,33 +33,37 @@ Volcanos("user", {
|
||||
},
|
||||
scanQRCode: function(can, cb) {
|
||||
wx.scanCode({success: function(res) {
|
||||
if (res.result.indexOf("WIFI:") == 0) {
|
||||
var ls = can.core.Split(res.result, ":;"), data = {}
|
||||
for (var i = 1; i < ls.length; i += 2) { data[ls[i]] = ls[i+1] }
|
||||
console.log("scan", data)
|
||||
can.user.agent.connectWifi(can, data.S, data.P, function() {
|
||||
can.user.toast(can, "success")
|
||||
})
|
||||
return
|
||||
}
|
||||
var data = can.base.ParseJSON(res.result)
|
||||
if (data.type == web.LINK && data._origin) { can.base.Copy(data, can.misc.ParseURL(can, res.result)) }
|
||||
console.log("scan", data)
|
||||
if (cb && cb(data)) { return }
|
||||
if (data.type == web.LINK && data._origin) { delete(data.type), delete(data.name), delete(data.text)
|
||||
var ls = new RegExp("(https?://[^/]+)([^?#]*)([^#]*)(.*)").exec(data._origin); delete(data._origin)
|
||||
data.serve = ls[1]; if (ls[2].indexOf("/pages/") == 0) { data.pages = ls[2] }
|
||||
}
|
||||
if (data.cmd||data.index||data.share) {
|
||||
can.user.jumps(can.base.MergeURL(data.pages||chat.PAGES_ACTION, data))
|
||||
} else if (data.pod||data.space||data.serve) {
|
||||
can.user.jumps(can.base.MergeURL(data.pages||chat.PAGES_RIVER, data))
|
||||
} else {
|
||||
can.misc.request(can, can.request(), chat.WX_LOGIN_SCAN, data)
|
||||
}
|
||||
can.misc.Info("scan", res.result)
|
||||
can.user.parse(can, res.result, cb)
|
||||
}})
|
||||
},
|
||||
}, info: {},
|
||||
scene: function(can, scene) {
|
||||
can.misc.request(can, can.request(), "/chat/wx/login/action/scene", {scene: scene}, function(msg) {
|
||||
can.misc.Info("app parse", msg.Result()), can.user.parse(can, msg.Result())
|
||||
})
|
||||
},
|
||||
parse: function(can, text, cb) {
|
||||
if (text.indexOf("WIFI:") == 0) { var data = kit.Dict(can.core.Split(text, ":;").slice(1))
|
||||
if (cb && cb(data)) { return }
|
||||
return can.user.agent.connectWifi(can, data.S, data.P, function() { can.user.toast(can, ice.SUCCESS) })
|
||||
}
|
||||
var data = can.base.ParseJSON(text)
|
||||
if (data.type == web.LINK && data._origin) { can.base.Copy(data, can.misc.ParseURL(can, text)) }
|
||||
if (cb && cb(data)) { return }
|
||||
if (data.type == web.LINK && data._origin) { delete(data.type), delete(data.name), delete(data.text)
|
||||
var ls = new RegExp("(https?://[^/]+)([^?#]*)([^#]*)(.*)").exec(data._origin); delete(data._origin)
|
||||
data.serve = ls[1]; if (ls[2].indexOf("/pages/") == 0) { data.pages = ls[2] }
|
||||
}
|
||||
can.misc.Info("app parse", data)
|
||||
if (data.cmd||data.index||data.share) {
|
||||
can.user.jumps(can.base.MergeURL(data.pages||chat.PAGES_ACTION, data))
|
||||
} else if (data.pod||data.space||data.serve) {
|
||||
can.user.jumps(can.base.MergeURL(data.pages||chat.PAGES_RIVER, data))
|
||||
} else {
|
||||
can.misc.request(can, can.request(), chat.WX_LOGIN_SCAN, data)
|
||||
}
|
||||
},
|
||||
jumps: function(url, cb) { wx.navigateTo({url: url, success: cb}) },
|
||||
title: function(text, cb) { text && wx.setNavigationBarTitle({title: text, success: cb}) },
|
||||
toast: function(can, title) { wx.showToast({title: title||""}) },
|
||||
|
@ -4,10 +4,7 @@ function shy(help, meta, list, cb) { var arg = arguments, i = 0; function next(t
|
||||
} else if (type == code.ARRAY) { if (typeof arg[i] == code.OBJECT && arg[i].length != undefined) { return arg[i++] }
|
||||
} else if (i < arg.length && (!type || type == typeof arg[i])) { return arg[i++] }
|
||||
} return cb = typeof arg[arg.length-1] == code.FUNCTION? arg[arg.length-1]: function() {}, cb.help = next(code.STRING)||"", cb.meta = next(code.OBJECT)||{}, cb.list = next(code.ARRAY)||[], cb }
|
||||
function Volcanos(name, list) {
|
||||
if (Volcanos._page) { Volcanos._page[name] = list }
|
||||
return list
|
||||
}
|
||||
function Volcanos(name, list) { if (Volcanos._page) { Volcanos._page[name] = list } return list }
|
||||
Volcanos._init = function() {
|
||||
var can = {__proto__: Volcanos._page,
|
||||
request: function(event) { event = event||{}, event = event._event||event
|
||||
@ -21,40 +18,36 @@ Volcanos._init = function() {
|
||||
}): can.core.Item(can.base.isFunc(item)? item(): item, set)
|
||||
}); return msg
|
||||
},
|
||||
run: function(event, cmds, cb) {
|
||||
wx.showLoading(); const res = wx.getSystemInfoSync()
|
||||
run: function(event, cmds, cb) { wx.showLoading(); const sys = wx.getSystemInfoSync()
|
||||
can.misc.request(can, can.request(event), can.base.MergeURL(can.onaction._apis||nfs.CHAT_ACTION, kit.Dict(
|
||||
ice.POD, can.db.pod||can.db.space, ice.MSG_THEME, res.theme, ice.MSG_DEBUG, can.db.debug,
|
||||
)), {cmds: (can.onaction._cmds||[]).concat(cmds)}, function(msg) {
|
||||
msg.Dump = function() { can.ui.setData({list: msg.Table()}) }, cb(msg), wx.hideLoading()
|
||||
ice.POD, can.db.pod||can.db.space, ice.MSG_THEME, sys.theme, ice.MSG_DEBUG, can.db.debug,
|
||||
)), {cmds: (can.onaction._cmds||[]).concat(cmds)}, function(msg) { wx.hideLoading()
|
||||
msg.Dump = function() { can.ui.setData({list: msg.Table()}) }, cb(msg)
|
||||
})
|
||||
},
|
||||
}; Volcanos._page.__proto__ = getApp(), delete(Volcanos._page)
|
||||
var page = {data: {action: can.onaction.list, list: []},
|
||||
onLoad: function(options) { can.ui = this, can.db = options, can.db.serve = can.db.serve||can.conf.serve
|
||||
can.core.Item(can.db, function(key, value) { can.db[key] = decodeURIComponent(value) })
|
||||
can.misc.Info("app show", can.ui.route, can.db), can.user.agent.enableDebug(can)
|
||||
can.user.title(can.db.title||can.db.pod||can.db.space||(can.db.serve||can.conf.serve).split("://")[1])
|
||||
console.log("app show", can.ui.route, can.db)
|
||||
if (can.db.ssid && can.db.password != "******") {
|
||||
can.user.agent.connectWifi(can, can.db.ssid, can.db.password||"", function() { can.db.password = "******"
|
||||
can.core.Timer(300, function() {
|
||||
can.ui.setData({conf: can.db}), can.user.login(can, function() { can.onaction.refresh({}, can) })
|
||||
})
|
||||
})
|
||||
function refresh() { can.ui.setData({conf: can.db}), can.user.login(can, function() {
|
||||
can.misc.WSS(can), can.core.Timer(300, function() { can.onaction.refresh({}, can) })
|
||||
}) }
|
||||
function wifi(cb) { can.db.ssid && can.db.password != "******"? can.user.agent.connectWifi(can, can.db.ssid, can.db.password||"", function() { can.db.password = "******", cb() }): cb() }
|
||||
if (can.db.scene) { var ls = can.db.scene.split(nfs.PS); can.db.scene = ls[2]
|
||||
if (ls[0] == "s") { can.db.serve = "https://"+ls[1] } if (ls[0] == "h") { can.db.serve = "http://"+ls[1] }
|
||||
if (ls[0] == "w") { can.db.serve = "http://192.168."+parseInt("0x"+ls[1][0])+"."+parseInt("0x"+ls[1][1])+":9020", can.db.ssid = ls[3], can.db.password = ls[4] }
|
||||
wifi(function() { can.user.scene(can, can.db.scene) })
|
||||
} else {
|
||||
can.ui.setData({conf: can.db}), can.user.login(can, function() { can.onaction.refresh({}, can) })
|
||||
wifi(refresh)
|
||||
}
|
||||
},
|
||||
onShow: function() { can.misc.WSS(can) },
|
||||
onReady: function() {},
|
||||
onShow: function() { }, onReady: function() {},
|
||||
onHide: function() { can._socket && can._socket.close(), delete(can._socket) },
|
||||
onUnload: function() { can._socket && can._socket.close(), delete(can._socket) },
|
||||
onReachBottom: function() {},
|
||||
onPullDownRefresh: function() { this.onLoad(can.db) },
|
||||
onReachBottom: function() {}, onPullDownRefresh: function() { this.onLoad(can.db) },
|
||||
onShareAppMessage: function() {}
|
||||
}
|
||||
can.core.ItemCB(can.onaction, function(key, cb) { page[key] = function(event) {
|
||||
can.core.CallFunc(cb, [event, can, key, event.target.dataset])
|
||||
} }), Page(page)
|
||||
}; can.core.ItemCB(can.onaction, function(key, cb) { page[key] = function(event) { can.core.CallFunc(cb, [event, can, key, event.target.dataset]) } }), Page(page)
|
||||
}
|
||||
module.exports = {shy, Volcanos}
|
||||
|
Loading…
x
Reference in New Issue
Block a user