feat(37): 接口跳转逻辑

This commit is contained in:
luying
2023-04-06 15:47:49 +08:00
parent 08d5ebedeb
commit 4a32270297
3 changed files with 11 additions and 2 deletions

View File

@@ -54,10 +54,12 @@ module.exports = () => {
let envToHost = ctx.app.config.envToHost||new Map();
let sidToHost = new Map<string, string>();
let servers = await ServerlistModel.getAllServerList();
for(let { id, env } of servers) {
for(let { id, env, isMain } of servers) {
let webHost = envToHost.get(env);
sidToHost.set(id.toString(), webHost);
if(isMain) sidToHost.set('main', webHost);
}
if(!sidToHost.has('main') && servers.length > 0) sidToHost.set('main', envToHost.get(servers[0].env));
ctx.app.config.sidToHost = sidToHost;
}
@@ -69,7 +71,8 @@ module.exports = () => {
'/cb/refundioscallback',
'/cb/sendgiftcode',
'/cb/getrolebyserver',
'/cb/getserverinfo'
'/cb/getserverinfo',
'/cb/getrolebyuid',
];
for(let str of urls) {
if(url && url.startsWith(str)) {
@@ -91,5 +94,7 @@ module.exports = () => {
case '/cb/getrolebyserver':
case '/cb/getserverinfo':
return ctx.query.server_id.toString();
case '/cb/getrolebyuid':
return 'main';
}
}