Commit 719f746f authored by limingzhe's avatar limingzhe

fix: 过早退出报错

parent df45aa85
......@@ -5,6 +5,7 @@ export abstract class middleLayerBase extends cc.Component {
abstract reWriteAir(): void;
isShowWaiting = false;
isDestroy = false;
hideWaitingLetters(){
this.isShowWaiting = false;
......@@ -186,10 +187,23 @@ export abstract class middleLayerBase extends cc.Component {
}
cc.assetManager.loadBundle(bondleUrl, { version: version }, async (err, bundle) => {
if (this.isDestroy) {
// 已退出
return;
}
bundle.loadScene(sceneName, null, null, (err, scene) => {
if (this.isDestroy) {
// 已退出
return;
}
this.courseOpenTimeStamp = Date.now();
cc.director.runScene(scene, null, () => {
if (this.isDestroy) {
// 已退出
return;
}
console.log('sceneName = ' + sceneName);
const canvas = cc.find('Canvas');
const middleLayer = cc.find('middleLayer');
......@@ -290,6 +304,10 @@ export abstract class middleLayerBase extends cc.Component {
}
this.callNetworkApiGet(api, {}, (datastr) => {
if (this.isDestroy) {
// 已退出
return;
}
const data = JSON.parse(datastr);
if (data.rows && data.rows.length > 0) {
this.courses = data.rows;
......@@ -315,7 +333,10 @@ export abstract class middleLayerBase extends cc.Component {
let sceneName, version, bondleUrl = "";
const templateBaseUrl = `${this.DOMAIN}h5template/${this.courseItem.template_name}/v${this.courseItem.last_version}`;
this.getConfigInfo(templateBaseUrl, (conf) => {
if (this.isDestroy) {
// 已退出
return;
}
if (cc.sys.os == cc.sys.OS_IOS) {
sceneName = conf.ios.sceneName;
version = conf.ios.version;
......@@ -458,4 +479,8 @@ export abstract class middleLayerBase extends cc.Component {
});
}
protected onDestroy(): void {
this.isDestroy = true;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment