Feat:插件新增销毁前生命周期函数,解决销毁思维导图时插件的一些副作用没有清除的问题
This commit is contained in:
parent
8c0c2c5bc4
commit
b35dd282ec
@ -406,6 +406,9 @@ class MindMap {
|
|||||||
destroy() {
|
destroy() {
|
||||||
// 移除插件
|
// 移除插件
|
||||||
;[...MindMap.pluginList].forEach(plugin => {
|
;[...MindMap.pluginList].forEach(plugin => {
|
||||||
|
if (this[plugin.instanceName].beforePluginDestroy) {
|
||||||
|
this[plugin.instanceName].beforePluginDestroy()
|
||||||
|
}
|
||||||
this[plugin.instanceName] = null
|
this[plugin.instanceName] = null
|
||||||
})
|
})
|
||||||
// 解绑事件
|
// 解绑事件
|
||||||
@ -414,6 +417,7 @@ class MindMap {
|
|||||||
this.svg.remove()
|
this.svg.remove()
|
||||||
// 去除给容器元素设置的背景样式
|
// 去除给容器元素设置的背景样式
|
||||||
Style.removeBackgroundStyle(this.el)
|
Style.removeBackgroundStyle(this.el)
|
||||||
|
this.el.innerHTML = ''
|
||||||
this.el = null
|
this.el = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -263,6 +263,11 @@ class NodeImgAdjust {
|
|||||||
beforePluginRemove() {
|
beforePluginRemove() {
|
||||||
this.unBindEvent()
|
this.unBindEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 插件被卸载前做的事情
|
||||||
|
beforePluginDestroy() {
|
||||||
|
this.unBindEvent()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeImgAdjust.instanceName = 'nodeImgAdjust'
|
NodeImgAdjust.instanceName = 'nodeImgAdjust'
|
||||||
|
|||||||
@ -69,6 +69,11 @@ class Painter {
|
|||||||
beforePluginRemove() {
|
beforePluginRemove() {
|
||||||
this.unBindEvent()
|
this.unBindEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 插件被卸载前做的事情
|
||||||
|
beforePluginDestroy() {
|
||||||
|
this.unBindEvent()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Painter.instanceName = 'painter'
|
Painter.instanceName = 'painter'
|
||||||
|
|||||||
@ -631,6 +631,11 @@ class RichText {
|
|||||||
this.transformAllNodesToNormalNode()
|
this.transformAllNodesToNormalNode()
|
||||||
document.head.removeChild(this.styleEl)
|
document.head.removeChild(this.styleEl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 插件被卸载前做的事情
|
||||||
|
beforePluginDestroy() {
|
||||||
|
document.head.removeChild(this.styleEl)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RichText.instanceName = 'richText'
|
RichText.instanceName = 'richText'
|
||||||
|
|||||||
@ -148,6 +148,11 @@ class TouchEvent {
|
|||||||
beforePluginRemove() {
|
beforePluginRemove() {
|
||||||
this.unBindEvent()
|
this.unBindEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 插件被卸载前做的事情
|
||||||
|
beforePluginDestroy() {
|
||||||
|
this.unBindEvent()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TouchEvent.instanceName = 'touchEvent'
|
TouchEvent.instanceName = 'touchEvent'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user