🎈 perf(热更新): 添加白名单热更新地址

This commit is contained in:
luying
2022-11-23 11:38:22 +08:00
parent 6981b4c3e3
commit f1c6a658da
11 changed files with 33 additions and 209 deletions

View File

@@ -1,6 +1,7 @@
import { Controller } from 'egg';
import { RegionModel } from '@db/Region';
import { STATUS } from '@consts';
import { checkWhiteList } from 'app/pubUtils/sysUtil';
export default class UpdateController extends Controller {
public async getversion() {
@@ -15,12 +16,13 @@ export default class UpdateController extends Controller {
const env = this.app.config.realEnv;
const curRegion = await RegionModel.findRegionByEnv(env);
const { curVersion, updateResUrl, addressType: originAddressType } = curRegion;
const { curVersion, whitelistVersion, updateResUrl, addressType: originAddressType } = curRegion;
if(originAddressType != addressType) {
return ctx.body = ctx.service.utils.resResult(STATUS.ADDRESS_ERR);
}
let isWhiteList = await checkWhiteList(ctx.app.config.realEnv, ctx.clientIp, ctx.uid);
ctx.body = await ctx.service.update.getUpdateUrl(env, curVersion, updateResUrl);
ctx.body = await ctx.service.update.getUpdateUrl(env, isWhiteList? whitelistVersion: curVersion, updateResUrl);
}
}