diff --git a/assets/scripts/BaseNet.js b/assets/scripts/BaseNet.js index 4d91e87e..6f8dae2b 100644 --- a/assets/scripts/BaseNet.js +++ b/assets/scripts/BaseNet.js @@ -18,167 +18,169 @@ // game2006-z1-test-n1.cebg.games // https://game2006ap-test.kingsome.cn export var allBaseNet = { - usa: '-z1-test.cebg.games', - japan: '-z2-test.cebg.games', - singapore: '-z3-test.cebg.games', - turkey: '-z4-test.cebg.games', + usa: '-z1-test.cebg.games', + japan: '-z2-test.cebg.games', + singapore: '-z3-test.cebg.games', + turkey: '-z4-test.cebg.games', }; isDevEnv(); function isDevEnv() { - return true; + return true; } if (isDevEnv()) { - console.log('测试服'); - allBaseNet = { - usa: '-test.kingsome.cn', - japan: '-test.kingsome.cn', - singapore: '-test.kingsome.cn', - turkey: '-test-kingsome.cn', - }; + console.log('测试服'); + allBaseNet = { + usa: '-test.kingsome.cn', + japan: '-test.kingsome.cn', + singapore: '-test.kingsome.cn', + turkey: '-test-kingsome.cn', + }; } const netIdHash = (function () { - const result = {}; - for (let key in allBaseNet) { - const url = allBaseNet[key]; - const zid = extractZid(url); - result[zid] = { - name: key, - url: url, - }; - } - return result; + const result = {}; + for (let key in allBaseNet) { + const url = allBaseNet[key]; + const zid = extractZid(url); + result[zid] = { + name: key, + url: url, + }; + } + return result; })(); const functionNet = { - login: 'https://login', // ok - service: 'https://service', // ok - gamelog: 'https://gamelog', // ok - cloud: 'https://cloud', // ok - gamemail: 'https://gamemail', - notify: 'https://notify', - stat: 'https://stat', // ok - relation: 'wss://relation', //ok - //game - gameapi: 'https://game2006api', - game: 'wss://game2006', + login: 'https://login', // ok + service: 'https://service', // ok + gamelog: 'https://gamelog', // ok + cloud: 'https://cloud', // ok + gamemail: 'https://gamemail', + notify: 'https://notify', + stat: 'https://stat', // ok + relation: 'wss://relation', //ok + //game + gameapi: 'https://game2006api', + game: 'wss://game2006', }; function getCommonParam() { - let os = ''; - if (cc.sys.os == cc.sys.OS_ANDROID) { - os = 'android'; - } else if (cc.sys.os == cc.sys.OS_IOS) { - os = 'ios'; - } else { - os = cc.sys.os; - } - return ( - '_net=' + - encodeURIComponent(localStorage.getItem('currentNet')) + - '&_os=' + - encodeURIComponent(os) - ); + let os = ''; + if (cc.sys.os == cc.sys.OS_ANDROID) { + os = 'android'; + } else if (cc.sys.os == cc.sys.OS_IOS) { + os = 'ios'; + } else { + os = cc.sys.os; + } + return ( + '_net=' + + encodeURIComponent(localStorage.getItem('currentNet')) + + '&_os=' + + encodeURIComponent(os) + ); } export function getNormalApiUrl(name) { - return ( - functionNet[name] + - '-z3-test.cebg.games' + - '/webapp/index.php?' + - getCommonParam() - ); + return ( + functionNet[name] + + (isDevEnv() ? '-test.kingsome.cn' : '-z3-test.cebg.games') + + '/webapp/index.php?' + + getCommonParam() + ); } export function getExaminingUrl() { - return ( - functionNet['login'] + - '-z3-test.cebg.games' + - '/webapp/index.php?' + - getCommonParam() - ); + return ( + functionNet['login'] + + (isDevEnv() ? '-test.kingsome.cn' : '-z3-test.cebg.games') + + '/webapp/index.php?' + + getCommonParam() + ); } export function getRelationUrl() { - return ( - functionNet['relation'] + '-z3-test.cebg.games' + '/friend/websocket' - ); + return ( + functionNet['relation'] + + (isDevEnv() ? '-test.kingsome.cn' : '-z3-test.cebg.games') + + '/friend/websocket' + ); } export function getNodeUrl() { - return ( - functionNet['game'].replace('wss://', 'https://') + - localStorage.getItem('currentNet') + - '/webapp/index.php?' + - getCommonParam() - ); + return ( + functionNet['game'].replace('wss://', 'https://') + + localStorage.getItem('currentNet') + + '/webapp/index.php?' + + getCommonParam() + ); } export function extractZid(url) { - return Number(url[2]); + return Number(url[2]); } export function getZViewName(zid) { - switch (zid) { - case 1: - { - return 'USA'; - } - break; - case 2: - { - return 'Japan'; - } - break; - case 3: - { - return 'Singapore'; - } - break; - case 4: - { - return 'Turkey'; - } - break; - default: - { - return ''; - } - break; - } + switch (zid) { + case 1: + { + return 'USA'; + } + break; + case 2: + { + return 'Japan'; + } + break; + case 3: + { + return 'Singapore'; + } + break; + case 4: + { + return 'Turkey'; + } + break; + default: + { + return ''; + } + break; + } } export function getCurrentZid() { - try { - return extractZid(localStorage.getItem('currentNet')); - } catch (err) { - return 0; - } + try { + return extractZid(localStorage.getItem('currentNet')); + } catch (err) { + return 0; + } } function getZUrl(zid) { - return netIdHash[zid]['url']; + return netIdHash[zid]['url']; } function getZName(zid) { - return netIdHash[zid]['name']; + return netIdHash[zid]['name']; } export function getGameServer(teamUuid) { - if (isDevEnv()) { - return 'wss://game2006-test.kingsome.cn/websocket'; - } - const nodeId = teamUuid ? teamUuid.split('_')[0] : cc.SDKManage.NodeId; - const zid = teamUuid - ? teamUuid.split('_')[1] - : extractZid(localStorage.getItem('currentNet')); - let urls = teamUuid ? getZUrl(zid) : localStorage.getItem('currentNet'); - urls = urls.split('.'); - urls[0] += '-n' + nodeId; - return functionNet['game'] + urls.join('.') + '/websocket'; + if (isDevEnv()) { + return 'wss://game2006-test.kingsome.cn/websocket'; + } + const nodeId = teamUuid ? teamUuid.split('_')[0] : cc.SDKManage.NodeId; + const zid = teamUuid + ? teamUuid.split('_')[1] + : extractZid(localStorage.getItem('currentNet')); + let urls = teamUuid ? getZUrl(zid) : localStorage.getItem('currentNet'); + urls = urls.split('.'); + urls[0] += '-n' + nodeId; + return functionNet['game'] + urls.join('.') + '/websocket'; } // game2006 -z1-test-n1 .cebg.games