import { STATUS, } from '@consts'; import { Service } from 'egg'; // let fs = require("fs"); // const HOT_URL = 'http://zyz-hot-update.trgame.cn/version.manifest' /** * UpdateRes Service */ export default class Update extends Service { /** * 获取版本号 * @param version - 客户端版本号 */ public async getVersion(version: string) { const ctx = this.ctx; console.log('client version: ', version); return ctx.service.utils.resResult(STATUS.SUCCESS, { packageUrl: 'http://zyz-hot-update.trgame.cn/', remoteManifestUrl: 'http://zyz-hot-update.trgame.cn/project.manifest', remoteVersionUrl: 'http://zyz-hot-update.trgame.cn/version.manifest' }); } public async getUpdateUrl(env: string, curVersion: string, updateResUrl: string) { const ctx = this.ctx; if (!env || !curVersion || !updateResUrl) return ctx.service.utils.resResult(STATUS.UPDATE_INFO_ERR); const baseUrl = `${updateResUrl}/${env}/${curVersion}`; return ctx.service.utils.resResult(STATUS.SUCCESS, { packageUrl: baseUrl, remoteManifestUrl: `${baseUrl}/project.manifest`, remoteVersionUrl: `${baseUrl}/version.manifest` }); } }