Fix:修复开启性能模式后,演示插件无法正常工作的问题

This commit is contained in:
街角小林 2024-07-29 09:28:51 +08:00
parent f92146a1f4
commit fde6fc2583

View File

@ -40,6 +40,7 @@ class Demonstrate {
{ ...defaultConfig },
this.mindMap.opt.demonstrateConfig || {}
)
this.needRestorePerformanceMode = false
}
// 进入演示模式
@ -56,6 +57,8 @@ class Demonstrate {
}
_enter() {
// 如果开启了性能模式,那么需要暂停
this.pausePerformanceMode()
// 添加演示用的临时的样式
this.addTmpStyles()
// 记录演示前的画布状态
@ -97,9 +100,27 @@ class Demonstrate {
this.removeHighlightEl()
this.mindMap.command.recovery()
this.mindMap.keyCommand.recovery()
this.restorePerformanceMode()
this.mindMap.emit('exit_demonstrate')
}
// 暂停性能模式
pausePerformanceMode() {
const { openPerformance } = this.mindMap.opt
if (openPerformance) {
this.needRestorePerformanceMode = true
this.mindMap.opt.openPerformance = false
this.mindMap.renderer.forceLoadNode()
}
}
// 恢复性能模式
restorePerformanceMode() {
if (!this.needRestorePerformanceMode) return
this.mindMap.opt.openPerformance = true
this.mindMap.renderer.forceLoadNode()
}
// 添加临时的样式
addTmpStyles() {
this.tmpStyleEl = document.createElement('style')