forked from mirror/MCSManager
修改 - URL 定位器
This commit is contained in:
parent
56e20536f4
commit
815832f3e0
@ -1,13 +1,18 @@
|
||||
//标准的URL定位器
|
||||
//如果你的程序不在根目录,可以考虑更改这里,或者你有什么其他姿势。
|
||||
//保证 99% 的可用性,因为代码历史遗留问题,不能保证所有请求都能通过此 URL 定位器
|
||||
//如果你需要反向代理加入SSL,请更改此处
|
||||
|
||||
//Ws 默认协议
|
||||
MCSERVER.WS_PROTOCOL = 'ws://';
|
||||
//HTTP 默认协议
|
||||
MCSERVER.HTTP_PROTOCOL = 'http://';
|
||||
|
||||
//某些 login 页面没有 MCSERVER 全局变量,在此实例化
|
||||
if (window.MCSERVER == undefined) window.MCSERVER = {};
|
||||
|
||||
//URL定位器
|
||||
MCSERVER.URL = function (url, protocol) {
|
||||
var _protocol = protocol || 'http://';
|
||||
var _protocol = protocol || MCSERVER.HTTP_PROTOCOL;
|
||||
var hostName = window.location.host;
|
||||
var openURL = hostName + '/' + url;
|
||||
return _protocol + openURL;
|
||||
|
@ -8,7 +8,7 @@
|
||||
RES.TOKEN_NAME = TOKEN_NAME;
|
||||
RES.TOKEN = null;
|
||||
RES.getToken = function (callback) {
|
||||
// 同源策略可以防止其他域对这里发送一个Ajax请求.
|
||||
//同源策略可以防止其他域对这里发送一个Ajax请求.
|
||||
var _url = MCSERVER.URL("./token?_LoveYouMaster_Time=" + Date.parse(new Date()));
|
||||
$.get(_url, function (data, status) {
|
||||
data = JSON.parse(data);
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
window.WS.init = function (openCallback) {
|
||||
var wsURL = 'websocket/ws?' + RES.TOKEN_NAME + '=' + RES.TOKEN;
|
||||
window.WS = new WebSocket(MCSERVER.URL(wsURL, 'ws://'));
|
||||
window.WS = new WebSocket(MCSERVER.URL(wsURL, MCSERVER.WS_PROTOCOL));
|
||||
var tmp_callback = null;
|
||||
wsHeartBeatPackage(WS); //心跳包定时器开启
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user