mirror of
https://github.com/Gongxh0901/kunpolibrary
synced 2025-10-09 16:45:45 +00:00
发布1.0.29,添加热更新说明文档
This commit is contained in:
@@ -118,9 +118,9 @@ export class HotUpdate {
|
||||
}
|
||||
}).then(res => {
|
||||
log(`${TAG} 检查更新结果:${JSON.stringify(res)}`);
|
||||
resolve(res);
|
||||
res.code === HotUpdateCode.Succeed ? resolve(res) : reject(res);
|
||||
}).catch(res => {
|
||||
resolve(res);
|
||||
reject(res);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -138,12 +138,10 @@ export class HotUpdate {
|
||||
if (res.skipCheck) {
|
||||
this.startUpdateTask();
|
||||
} else {
|
||||
this.checkUpdate().then((res) => {
|
||||
if (res.code === HotUpdateCode.Succeed) {
|
||||
this.startUpdateTask();
|
||||
} else {
|
||||
this._complete(res.code, res.message);
|
||||
}
|
||||
this.checkUpdate().then(res => {
|
||||
this.startUpdateTask();
|
||||
}).catch((res: ICheckUpdatePromiseResult) => {
|
||||
this._complete(res.code, res.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -299,20 +297,20 @@ export class HotUpdate {
|
||||
switch (eventCode) {
|
||||
case native.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST:
|
||||
this._am.setEventCallback(null);
|
||||
resolve({ code: HotUpdateCode.LoadManifestFailed, message: "检查更新时下载manifest文件失败", needUpdate: false, size: 0 });
|
||||
resolve({ code: HotUpdateCode.LoadManifestFailed, message: "检查更新时下载manifest文件失败", size: 0 });
|
||||
return;
|
||||
case native.EventAssetsManager.ERROR_PARSE_MANIFEST:
|
||||
this._am.setEventCallback(null);
|
||||
resolve({ code: HotUpdateCode.ParseManifestFailed, message: "检查更新时解析manifest文件失败", needUpdate: false, size: 0 });
|
||||
resolve({ code: HotUpdateCode.ParseManifestFailed, message: "检查更新时解析manifest文件失败", size: 0 });
|
||||
return;
|
||||
case native.EventAssetsManager.ALREADY_UP_TO_DATE:
|
||||
this._am.setEventCallback(null);
|
||||
resolve({ code: HotUpdateCode.LatestVersion, message: "已是最新版本", needUpdate: false, size: 0 });
|
||||
resolve({ code: HotUpdateCode.LatestVersion, message: "已是最新版本", size: 0 });
|
||||
return;
|
||||
case native.EventAssetsManager.NEW_VERSION_FOUND:
|
||||
// 发现新版本
|
||||
this._am.setEventCallback(null);
|
||||
resolve({ code: HotUpdateCode.Succeed, message: "发现新版本", needUpdate: true, size: this._am.getTotalBytes() / 1024 });
|
||||
resolve({ code: HotUpdateCode.Succeed, message: "发现新版本", size: this._am.getTotalBytes() / 1024 });
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
@@ -105,22 +105,27 @@ export class HotUpdateManager {
|
||||
public checkUpdate(): Promise<ICheckUpdatePromiseResult> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!Platform.isNativeMobile) {
|
||||
resolve({ code: HotUpdateCode.PlatformNotSupported, message: "当前平台不需要热更新" });
|
||||
reject({ code: HotUpdateCode.PlatformNotSupported, message: "当前平台不需要热更新" });
|
||||
return;
|
||||
}
|
||||
if (!this._isInitialized) {
|
||||
resolve({ code: HotUpdateCode.NotInitialized, message: "未初始化, 需要先调用init方法" });
|
||||
reject({ code: HotUpdateCode.NotInitialized, message: "未初始化, 需要先调用init方法" });
|
||||
return;
|
||||
}
|
||||
if (this._updating) {
|
||||
resolve({ code: HotUpdateCode.Updating, message: "正在更新或者正在检查更新中" });
|
||||
reject({ code: HotUpdateCode.Updating, message: "正在更新或者正在检查更新中" });
|
||||
return;
|
||||
}
|
||||
this._updating = true;
|
||||
this._hotUpdate = new HotUpdate();
|
||||
this._hotUpdate.checkUpdate().then((res) => {
|
||||
this._updating = false;
|
||||
// 有更新
|
||||
resolve(res);
|
||||
}).catch((res: ICheckUpdatePromiseResult) => {
|
||||
this._updating = false;
|
||||
// 无更新
|
||||
reject(res);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@@ -12,8 +12,6 @@ export interface IPromiseResult {
|
||||
}
|
||||
|
||||
export interface ICheckUpdatePromiseResult extends IPromiseResult {
|
||||
/** 是否需要更新 */
|
||||
needUpdate?: boolean;
|
||||
/** 需要更新的资源大小 (KB) */
|
||||
size?: number;
|
||||
}
|
Reference in New Issue
Block a user