调整热更新跳过检查逻辑

This commit is contained in:
gongxh 2025-04-19 15:10:54 +08:00
parent be4e48e8a0
commit a927aa428b
2 changed files with 23 additions and 18 deletions

View File

@ -25,8 +25,6 @@ export interface IManifestResult extends IPromiseResult {
export enum HotUpdateCode { export enum HotUpdateCode {
/** 成功 */ /** 成功 */
Succeed = 0, Succeed = 0,
/** 出错了 */
Error = -1,
/** 平台不支持 不需要热更新 */ /** 平台不支持 不需要热更新 */
PlatformNotSupported = -1000, PlatformNotSupported = -1000,
/** 未初始化 */ /** 未初始化 */
@ -146,8 +144,6 @@ export class HotUpdate {
} else { } else {
this._complete(res.code, res.message); this._complete(res.code, res.message);
} }
}).catch((err) => {
this._complete(HotUpdateCode.Error, JSON.stringify(err));
}); });
} }
} }

View File

@ -34,7 +34,7 @@ export class HotUpdateManager {
/** 是否正在更新 或者 正在检查更新 */ /** 是否正在更新 或者 正在检查更新 */
private _updating: boolean = false; private _updating: boolean = false;
/** 更新实例 只有更新的时候初始化 检查更新不赋值 */ /** 更新实例 */
private _hotUpdate: HotUpdate = null; private _hotUpdate: HotUpdate = null;
/** /**
@ -117,12 +117,10 @@ export class HotUpdateManager {
return; return;
} }
this._updating = true; this._updating = true;
new HotUpdate().checkUpdate().then((res) => { this._hotUpdate = new HotUpdate();
this._hotUpdate.checkUpdate().then((res) => {
this._updating = false; this._updating = false;
resolve(res); resolve(res);
}).catch((err) => {
this._updating = false;
resolve({ code: HotUpdateCode.Error, message: JSON.stringify(err) });
}); });
}); });
} }
@ -147,15 +145,26 @@ export class HotUpdateManager {
return; return;
} }
this._updating = true; this._updating = true;
this._hotUpdate = new HotUpdate(); if (res.skipCheck && this._hotUpdate) {
this._hotUpdate.startUpdate({ this._hotUpdate.startUpdate({
skipCheck: res.skipCheck, skipCheck: res.skipCheck,
progress: res.progress, progress: res.progress,
complete: (code: HotUpdateCode, message: string) => { complete: (code: HotUpdateCode, message: string) => {
this._updating = false; this._updating = false;
res.complete(code, message); res.complete(code, message);
} }
}); });
} else {
this._hotUpdate = new HotUpdate();
this._hotUpdate.startUpdate({
skipCheck: false,
progress: res.progress,
complete: (code: HotUpdateCode, message: string) => {
this._updating = false;
res.complete(code, message);
}
});
}
} }
/** 重试失败的资源 */ /** 重试失败的资源 */