fix(core): 修复pages容器卸载会导致该容器下事件代理失效
This commit is contained in:
@@ -13,7 +13,7 @@ const {
|
|||||||
|
|
||||||
class PagesManager extends Component {
|
class PagesManager extends Component {
|
||||||
#tabs_ = null;
|
#tabs_ = null;
|
||||||
#$welcomePage_ = null;
|
#welcomePage_ = null;
|
||||||
#$editorContainer_ = null;
|
#$editorContainer_ = null;
|
||||||
#$tabsContainer_ = null;
|
#$tabsContainer_ = null;
|
||||||
#pagesRegistry_ = new Registry();
|
#pagesRegistry_ = new Registry();
|
||||||
@@ -47,8 +47,8 @@ class PagesManager extends Component {
|
|||||||
this.mountOn($parentContainer);
|
this.mountOn($parentContainer);
|
||||||
let PageType = this.#typesRegistry_.getItem('#welcome');
|
let PageType = this.#typesRegistry_.getItem('#welcome');
|
||||||
if (PageType) {
|
if (PageType) {
|
||||||
this.#$welcomePage_ = (new PageType()).getContent();
|
this.#welcomePage_ = new PageType();
|
||||||
$content.replaceWith(this.#$welcomePage_);
|
this.#showWelcomePage_();
|
||||||
}
|
}
|
||||||
this.#addEventsListener_();
|
this.#addEventsListener_();
|
||||||
}
|
}
|
||||||
@@ -84,11 +84,10 @@ class PagesManager extends Component {
|
|||||||
let page = new PageType();
|
let page = new PageType();
|
||||||
this.#pagesRegistry_.register(id, page);
|
this.#pagesRegistry_.register(id, page);
|
||||||
page.setTab($(tabEl));
|
page.setTab($(tabEl));
|
||||||
if (this.#$welcomePage_) {
|
if (this.#welcomePage_
|
||||||
if (this.#pagesRegistry_.length() && this.#page_ === 'welcome') {
|
&& this.#pagesRegistry_.length()
|
||||||
this.#$welcomePage_.replaceWith(this.getContent());
|
&& this.#page_ === 'welcome') {
|
||||||
this.#page_ = 'editor';
|
this.#hideWelcomePage_();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
page.init();
|
page.init();
|
||||||
});
|
});
|
||||||
@@ -103,15 +102,31 @@ class PagesManager extends Component {
|
|||||||
}
|
}
|
||||||
page.dispose();
|
page.dispose();
|
||||||
this.#pagesRegistry_.unregister(id);
|
this.#pagesRegistry_.unregister(id);
|
||||||
if (this.#$welcomePage_) {
|
if (this.#welcomePage_
|
||||||
if (!this.#pagesRegistry_.length() && this.#page_ !== 'welcome') {
|
&& !this.#pagesRegistry_.length()
|
||||||
this.getContent().replaceWith(this.#$welcomePage_);
|
&& this.#page_ !== 'welcome') {
|
||||||
this.#page_ = 'welcome';
|
this.#showWelcomePage_();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#showWelcomePage_() {
|
||||||
|
const $parent = this.getContent().parent();
|
||||||
|
this.getContent().detach();
|
||||||
|
$parent.append(this.#welcomePage_.getContent());
|
||||||
|
this.#welcomePage_.onMounted();
|
||||||
|
this.#page_ = 'welcome';
|
||||||
|
}
|
||||||
|
|
||||||
|
#hideWelcomePage_() {
|
||||||
|
const $page = this.#welcomePage_.getContent();
|
||||||
|
const $parent = $page.parent();
|
||||||
|
$page.detach();
|
||||||
|
this.#welcomePage_.onUnmounted();
|
||||||
|
$parent.append(this.getContent());
|
||||||
|
this.#page_ = 'editor';
|
||||||
|
}
|
||||||
|
|
||||||
resize() {
|
resize() {
|
||||||
super.resize();
|
super.resize();
|
||||||
const page = this.getActive();
|
const page = this.getActive();
|
||||||
@@ -177,6 +192,11 @@ class PagesManager extends Component {
|
|||||||
this.remove(id);
|
this.remove(id);
|
||||||
}
|
}
|
||||||
this.#tabs_.dispose();
|
this.#tabs_.dispose();
|
||||||
|
this.#welcomePage_ && this.#welcomePage_.dispose();
|
||||||
|
this.#tabs_ = null;
|
||||||
|
this.#welcomePage_ = null;
|
||||||
|
this.#$tabsContainer_ = null;
|
||||||
|
this.#$editorContainer_ = null;
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user