@ives_xxz/framework 1.1.7 → 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,24 +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
|
-
|
|
89
|
+
FWLog.debug('本地manifest未加载,尝试重新加载');
|
|
90
|
+
this.reloadLocalManifest();
|
|
91
|
+
|
|
92
|
+
// 如果仍然无法加载,则返回
|
|
88
93
|
if (!this.assetMgr.getLocalManifest() || !this.assetMgr.getLocalManifest().isLoaded()) {
|
|
89
|
-
FWLog.error('
|
|
94
|
+
FWLog.error('无法加载本地manifest文件');
|
|
90
95
|
return;
|
|
91
96
|
}
|
|
92
97
|
}
|
|
98
|
+
|
|
99
|
+
|
|
93
100
|
this.assetMgr.setEventCallback(this.checkEventHandle.bind(this));
|
|
94
101
|
this.assetMgr.checkUpdate();
|
|
95
102
|
this.isUpdate = true;
|
|
96
103
|
}
|
|
97
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
|
+
|
|
98
125
|
private checkEventHandle(event: any) {
|
|
99
126
|
const code = event.getEventCode();
|
|
100
127
|
FWLog.debug('checkEvent getEventCode -> ', code);
|
|
@@ -234,14 +261,17 @@ export default class FWHotUpdateManager extends FWManager implements FW.HotUpdat
|
|
|
234
261
|
if (needRestart) {
|
|
235
262
|
FWLog.debug('热更新中结果 needRestart -> ', needRestart);
|
|
236
263
|
FWLog.debug('下载完成');
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
var newPaths = this.assetMgr.getLocalManifest().getSearchPaths();
|
|
264
|
+
const searchPaths = jsb.fileUtils.getSearchPaths();
|
|
265
|
+
const newPaths = this.assetMgr.getLocalManifest().getSearchPaths();
|
|
240
266
|
Array.prototype.unshift.apply(searchPaths, newPaths);
|
|
241
267
|
jsb.fileUtils.setSearchPaths(searchPaths);
|
|
242
268
|
this.isRetry = false;
|
|
243
269
|
this.isUpdate = false;
|
|
244
|
-
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
this.reloadLocalManifest();
|
|
273
|
+
|
|
274
|
+
this.assetMgr.setEventCallback(null!);
|
|
245
275
|
this.listener.completedHandle?.(this.newVersion);
|
|
246
276
|
|
|
247
277
|
}
|