From 4b1c84b47a1bc3efac902b792fb46b4e95151b4a Mon Sep 17 00:00:00 2001 From: WEBXOSS Date: Sun, 5 Mar 2017 14:13:40 +0800 Subject: [PATCH] splite backend --- RoomManager.js | 21 ++++++++++++++++++++- index.html | 5 ++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/RoomManager.js b/RoomManager.js index 519ca82..e9ad05d 100644 --- a/RoomManager.js +++ b/RoomManager.js @@ -86,7 +86,15 @@ if (location.search === '?local=true') { console.log = function () { window._lastLog = arguments; }; - var url = getProxy() || location.host; + var host = getProxy(); + if (!host) { + if (/:\d*$/.test(location.host)) { + host = location.host.replace(/:\d*$/, ':2015'); + } else { + host = location.host + ':2015' + } + } + var url = location.protocol + '//' + host socket = io(url,{ reconnection: false, reconnectionDelay: 3000, @@ -101,6 +109,17 @@ var chatManager = new ChatManager(socket); /* 代理 */ function getProxy () { + var proxy = localStorage.getItem('proxy'); + // 兼容旧版 + var updateMap = { + 'cloudflare.webxoss.com': 'cloudflare.webxoss.com:2015', + 'incapsula.webxoss.com': 'incapsula.webxoss.com:2015', + 'shanghai.webxoss.com:10086': '', + }; + if (proxy in updateMap) { + proxy = updateMap[proxy]; + localStorage.setItem('proxy', proxy) + } return localStorage.getItem('proxy') || ''; } $('span-set-proxy').onclick = function () { diff --git a/index.html b/index.html index d9b60e0..efcc415 100644 --- a/index.html +++ b/index.html @@ -189,9 +189,8 @@