From ff56fe3e682da95cf69b0db1760cf056f88e064f Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Sun, 6 Aug 2023 22:37:13 +0800 Subject: [PATCH] =?UTF-8?q?Demo:=E6=89=A9=E5=B1=95=E5=A4=A7=E7=BA=B2?= =?UTF-8?q?=E5=8A=9F=E8=83=BD,=E6=94=AF=E6=8C=81=E6=8B=96=E6=8B=BD,?= =?UTF-8?q?=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/pages/Edit/components/Outline.vue | 209 ++++++++++++++---- web/src/pages/Edit/components/OutlineEdit.vue | 15 +- .../pages/Edit/components/OutlineSidebar.vue | 18 +- web/src/pages/Edit/components/Sidebar.vue | 6 +- 4 files changed, 195 insertions(+), 53 deletions(-) diff --git a/web/src/pages/Edit/components/Outline.vue b/web/src/pages/Edit/components/Outline.vue index 0b24cb43..ca7e119c 100644 --- a/web/src/pages/Edit/components/Outline.vue +++ b/web/src/pages/Edit/components/Outline.vue @@ -1,22 +1,32 @@ @@ -35,7 +35,6 @@ export default { isOutlineEdit(val) { if (val) { this.$nextTick(() => { - this.$refs.outline.refresh() document.body.appendChild(this.$refs.outlineEditContainer) }) } @@ -46,6 +45,16 @@ export default { onClose() { this.setIsOutlineEdit(false) + }, + + onScrollTo(y) { + let container = this.$refs.outlineEditContainer + let height = container.offsetHeight + let top = container.scrollTop + y += 50 + if (y > top + height) { + container.scrollTo(0, y - height / 2) + } } } } @@ -63,7 +72,6 @@ export default { justify-content: center; background-color: #fff; overflow-y: auto; - padding: 50px 0; .closeBtn { position: absolute; @@ -80,6 +88,7 @@ export default { width: 1000px; height: max-content; overflow: hidden; + padding: 50px 0; /deep/ .customNode { .nodeEdit { diff --git a/web/src/pages/Edit/components/OutlineSidebar.vue b/web/src/pages/Edit/components/OutlineSidebar.vue index 1414d702..bf482657 100644 --- a/web/src/pages/Edit/components/OutlineSidebar.vue +++ b/web/src/pages/Edit/components/OutlineSidebar.vue @@ -3,7 +3,11 @@
- + @@ -37,10 +41,20 @@ export default { } }, methods: { - ...mapMutations(['setIsOutlineEdit']), + ...mapMutations(['setIsOutlineEdit', 'setActiveSidebar']), onChangeToOutlineEdit() { + this.setActiveSidebar('') this.setIsOutlineEdit(true) + }, + + onScrollTo(y) { + let container = this.$refs.sidebar.getEl() + let height = container.offsetHeight + let top = container.scrollTop + if (y > top + height) { + container.scrollTo(0, y - height / 2) + } } } } diff --git a/web/src/pages/Edit/components/Sidebar.vue b/web/src/pages/Edit/components/Sidebar.vue index d82b5153..377a93c0 100644 --- a/web/src/pages/Edit/components/Sidebar.vue +++ b/web/src/pages/Edit/components/Sidebar.vue @@ -9,7 +9,7 @@
{{ title }}
-
+
@@ -59,6 +59,10 @@ export default { close() { this.show = false this.setActiveSidebar('') + }, + + getEl() { + return this.$refs.sidebarContent } } }