From 7b8946bec46e037beb6873dba985eb9f05b81335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=97=E8=A7=92=E5=B0=8F=E6=9E=97?= <1013335014@qq.com> Date: Thu, 21 Dec 2023 12:09:10 +0800 Subject: [PATCH] =?UTF-8?q?Demo=EF=BC=9A=E6=98=BE=E7=A4=BA=E5=92=8C?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=BB=9A=E5=8A=A8=E6=9D=A1=E6=97=B6=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E8=BF=9B=E8=A1=8C=E6=BB=9A=E5=8A=A8=E6=9D=A1=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E6=B3=A8=E5=86=8C=E5=92=8C=E7=A7=BB=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/pages/Edit/components/Edit.vue | 21 ++++++++++++++++++++- web/src/pages/Edit/components/Scrollbar.vue | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/web/src/pages/Edit/components/Edit.vue b/web/src/pages/Edit/components/Edit.vue index a61031a4..c260c11a 100644 --- a/web/src/pages/Edit/components/Edit.vue +++ b/web/src/pages/Edit/components/Edit.vue @@ -94,7 +94,6 @@ MindMap.usePlugin(MiniMap) .usePlugin(TouchEvent) .usePlugin(SearchPlugin) .usePlugin(Painter) - .usePlugin(ScrollbarPlugin) .usePlugin(Formula) // .usePlugin(Cooperate)// 协同插件 @@ -145,6 +144,7 @@ export default { ...mapState({ isZenMode: state => state.localConfig.isZenMode, openNodeRichText: state => state.localConfig.openNodeRichText, + isShowScrollbar: state => state.localConfig.isShowScrollbar, useLeftKeySelectionRightKeyDrag: state => state.localConfig.useLeftKeySelectionRightKeyDrag, isShowScrollbar: state => state.localConfig.isShowScrollbar @@ -157,6 +157,13 @@ export default { } else { this.removeRichTextPlugin() } + }, + isShowScrollbar() { + if (this.isShowScrollbar) { + this.addScrollbarPlugin() + } else { + this.removeScrollbarPlugin() + } } }, mounted() { @@ -378,6 +385,7 @@ export default { // } }) if (this.openNodeRichText) this.addRichTextPlugin() + if (this.isShowScrollbar) this.addScrollbarPlugin() this.mindMap.keyCommand.addShortcut('Control+s', () => { this.manualSave() }) @@ -525,6 +533,17 @@ export default { this.mindMap.removePlugin(RichText) }, + // 加载滚动条插件 + addScrollbarPlugin() { + if (!this.mindMap) return + this.mindMap.addPlugin(ScrollbarPlugin) + }, + + // 移除滚动条插件 + removeScrollbarPlugin() { + this.mindMap.removePlugin(ScrollbarPlugin) + }, + // 测试动态插入节点 testDynamicCreateNodes() { // return diff --git a/web/src/pages/Edit/components/Scrollbar.vue b/web/src/pages/Edit/components/Scrollbar.vue index 14fe3c43..1aa28dd6 100644 --- a/web/src/pages/Edit/components/Scrollbar.vue +++ b/web/src/pages/Edit/components/Scrollbar.vue @@ -61,6 +61,7 @@ export default { methods: { // 向插件传递滚动条宽高数据 setScrollBarWrapSize() { + if (!this.mindMap.scrollbar) return const { width } = this.$refs.horizontalScrollbarRef.getBoundingClientRect()