splite backend

This commit is contained in:
WEBXOSS 2017-03-05 14:13:40 +08:00
parent 5bd921d1ee
commit 4b1c84b47a
2 changed files with 22 additions and 4 deletions

View file

@ -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 () {

View file

@ -189,9 +189,8 @@
<select id="select-proxy">
<option id="proxy-noproxy" value="">不使用代理</option>
<option id="proxy-hongkong" value="hongkong.webxoss.com:8080">HongKong</option>
<option id="proxy-cloudflare" value="cloudflare.webxoss.com">CloudFlare</option>
<option id="proxy-incapsula" value="incapsula.webxoss.com">Incapsula</option>
<option id="proxy-shanghai" value="shanghai.webxoss.com:10086">ShangHai</option>
<option id="proxy-cloudflare" value="cloudflare.webxoss.com:2015">CloudFlare</option>
<option id="proxy-incapsula" value="incapsula.webxoss.com:2015">Incapsula</option>
<option id="proxy-provide" value="provide">提供代理服务器...</option>
</select>
<button id="proxy-button-ok">确定</button>