forked from x/ContextOS
fix web.wss
This commit is contained in:
parent
76fc9443f9
commit
9855142dfe
@ -120,6 +120,8 @@ var Index = &ctx.Context{Name: "chat", Help: "会议中心",
|
||||
return
|
||||
case "rename":
|
||||
m.Cmd("aaa.auth", "username", m.Option("username"), "data", "nickname", arg[1])
|
||||
|
||||
case "weixin":
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -642,6 +642,14 @@ var page = Page({check: true,
|
||||
})
|
||||
page.river.Pane.Show(), page.pane = page.action, page.plugin = kit.Selector(page.action, "fieldset")[0]
|
||||
page.action.Pane.Layout(ctx.Search("layout")? ctx.Search("layout"): kit.device.isMobile? "办公": "工作")
|
||||
page.socket = page.WSS()
|
||||
|
||||
function conn() {
|
||||
page.socket = page.WSS(null, function() {
|
||||
page.socket.close()
|
||||
}, function() {
|
||||
setTimeout(conn, 1000)
|
||||
})
|
||||
}
|
||||
conn()
|
||||
},
|
||||
})
|
||||
|
@ -204,7 +204,7 @@ ctx = context = {
|
||||
xhr.setRequestHeader("Accept", "application/json")
|
||||
xhr.send(args.join("&"))
|
||||
},
|
||||
WSS: function(cb) {
|
||||
WSS: function(cb, onerror, onclose) {
|
||||
var s = new WebSocket(location.protocol.replace("http", "ws")+"//"+location.host+"/wss")
|
||||
s.onopen = function(event) {
|
||||
kit.Log(event)
|
||||
@ -225,9 +225,11 @@ ctx = context = {
|
||||
}
|
||||
s.onerror = function(event) {
|
||||
kit.Log(event)
|
||||
typeof onerror == "function" && onerror(event)
|
||||
}
|
||||
s.onclose = function(event) {
|
||||
kit.Log(event)
|
||||
typeof onclose == "function" && onclose(event)
|
||||
}
|
||||
return s
|
||||
},
|
||||
|
@ -142,10 +142,10 @@ function Page(page) {
|
||||
}
|
||||
|
||||
if (page.check) {
|
||||
false && kit.device.isWeiXin? page.login.Pane.Run(["weixin"], function(msg) {
|
||||
kit.device.isWeiXin? page.login.Pane.Run(["weixin"], function(msg) {
|
||||
page.Include([
|
||||
"https://res.wx.qq.com/open/js/jweixin-1.4.0.js",
|
||||
"/static/librarys/weixin.js",
|
||||
// "/static/librarys/weixin.js",
|
||||
], function(event) {
|
||||
wx.error(function(res){})
|
||||
wx.ready(function(){
|
||||
@ -437,7 +437,7 @@ function Page(page) {
|
||||
}
|
||||
return typeof page[args[0]] == "function" && kit._call(page[args[0]], args.slice(1))
|
||||
},
|
||||
WSS: function(cb) {
|
||||
WSS: function(cb, onerror, onclose) {
|
||||
return ctx.WSS(cb || (function(m) {
|
||||
if (m.detail) {
|
||||
page.action.Pane.Core(event, m, ["_cmd", m.detail], function(msg) {
|
||||
@ -446,7 +446,7 @@ function Page(page) {
|
||||
} else {
|
||||
page.ontoast(m.result.join(""))
|
||||
}
|
||||
}))
|
||||
}), onerror, onclose)
|
||||
},
|
||||
|
||||
initToast: function() {},
|
||||
@ -464,6 +464,10 @@ function Page(page) {
|
||||
})
|
||||
}]}, {type: "br"},
|
||||
])
|
||||
|
||||
if (kit.device.isWeiXin) {
|
||||
kit.AppendChild(output, [])
|
||||
}
|
||||
return {
|
||||
Login: function(username, password, cb) {
|
||||
field.Pane.Run([username, password], function(msg) {cb(msg.result && msg.result[0] || "")})
|
||||
|
Loading…
x
Reference in New Issue
Block a user