@ives_xxz/framework 1.1.6 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -77,20 +77,51 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
77
77
  if (this.isUpdate) {
78
78
  return;
79
79
  }
80
- FWLog.debug('checkHotUpdate2', this.assetMgr.getState() === jsb.AssetsManager.State.UNINITED);
81
80
  if (this.assetMgr.getState() === jsb.AssetsManager.State.UNINITED) {
82
81
  this.assetMgr.loadLocalManifest(this.localManifest.nativeUrl);
83
82
  }
83
+
84
84
  FWLog.debug('checkHotUpdate3', this.assetMgr.getLocalManifest());
85
+
85
86
  FWLog.debug('checkHotUpdate4', this.assetMgr.getLocalManifest().isLoaded());
87
+
86
88
  if (!this.assetMgr.getLocalManifest() || !this.assetMgr.getLocalManifest().isLoaded()) {
87
- return;
89
+ FWLog.debug('本地manifest未加载,尝试重新加载');
90
+ this.reloadLocalManifest();
91
+
92
+ // 如果仍然无法加载,则返回
93
+ if (!this.assetMgr.getLocalManifest() || !this.assetMgr.getLocalManifest().isLoaded()) {
94
+ FWLog.error('无法加载本地manifest文件');
95
+ return;
96
+ }
88
97
  }
98
+
99
+
89
100
  this.assetMgr.setEventCallback(this.checkEventHandle.bind(this));
90
101
  this.assetMgr.checkUpdate();
91
102
  this.isUpdate = true;
92
103
  }
93
104
 
105
+ private reloadLocalManifest() {
106
+ try {
107
+ const updatedManifestPath = `${this.storePath}/project.manifest`;
108
+ if (jsb.fileUtils.isFileExist(updatedManifestPath)) {
109
+ this.assetMgr.loadLocalManifest(updatedManifestPath);
110
+
111
+ if (this.assetMgr.getLocalManifest() && this.assetMgr.getLocalManifest().isLoaded()) {
112
+ FWLog.debug('本地manifest重新加载成功');
113
+ this.localManifest = this.assetMgr.getLocalManifest();
114
+ } else {
115
+ FWLog.error('本地manifest重新加载失败');
116
+ }
117
+ } else {
118
+ FWLog.error('更新后的manifest文件不存在:', updatedManifestPath);
119
+ }
120
+ } catch (error) {
121
+ FWLog.error('重新加载本地manifest时出错:', error);
122
+ }
123
+ }
124
+
94
125
  private checkEventHandle(event: any) {
95
126
  const code = event.getEventCode();
96
127
  FWLog.debug('checkEvent getEventCode -> ', code);
@@ -181,6 +212,16 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
181
212
  failed = true;
182
213
  break;
183
214
  case jsb.EventAssetsManager.UPDATE_FINISHED:
215
+ if (event.getPercent() > 0) {
216
+ downloadedFiles = event.getDownloadedFiles();
217
+ totalFiles = event.getTotalFiles();
218
+ downloadedBytes = event.getDownloadedBytes();
219
+ totalBytes = event.getTotalBytes();
220
+ convertDownloadedBytes = this.convertBytes(downloadedBytes);
221
+ convertTotalBytes = this.convertBytes(totalBytes);
222
+ percent = event.getPercent();
223
+ FWLog.debug('正在更新完成 -> ', '下载文件数量:', downloadedFiles, ',下载文件总数量:', totalFiles, ',已下载大小:', convertDownloadedBytes, ',下载总大小:', convertTotalBytes);
224
+ }
184
225
  str = 'UPDATE_FINISHED';
185
226
  needRestart = true;
186
227
  break;
@@ -220,14 +261,17 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
220
261
  if (needRestart) {
221
262
  FWLog.debug('热更新中结果 needRestart -> ', needRestart);
222
263
  FWLog.debug('下载完成');
223
- this.assetMgr.setEventCallback(null!);
224
- var searchPaths = jsb.fileUtils.getSearchPaths();
225
- var newPaths = this.assetMgr.getLocalManifest().getSearchPaths();
264
+ const searchPaths = jsb.fileUtils.getSearchPaths();
265
+ const newPaths = this.assetMgr.getLocalManifest().getSearchPaths();
226
266
  Array.prototype.unshift.apply(searchPaths, newPaths);
227
267
  jsb.fileUtils.setSearchPaths(searchPaths);
228
268
  this.isRetry = false;
229
269
  this.isUpdate = false;
230
- this.assetMgr = null;
270
+
271
+
272
+ this.reloadLocalManifest();
273
+
274
+ this.assetMgr.setEventCallback(null!);
231
275
  this.listener.completedHandle?.(this.newVersion);
232
276
 
233
277
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ives_xxz/framework",
3
- "version": "1.1.6",
3
+ "version": "1.1.8",
4
4
  "description": "cocoscreator 2.x mvc framework",
5
5
  "main": "index.js",
6
6
  "keywords": [