diff --git a/src/layout/components/main/index.scss b/src/layout/components/main/index.scss index 93df3b64..00a44a12 100644 --- a/src/layout/components/main/index.scss +++ b/src/layout/components/main/index.scss @@ -255,7 +255,10 @@ width: 12.8rem; height: 100%; background: #fff; - transition: left 0.3s ease; + transition: left 0.5s ease; + } + .drawer-drag-bg { + background: #F2F8FF; } .drawer-drag-area { height: calc(100% - 6rem); diff --git a/src/layout/components/main/index.vue b/src/layout/components/main/index.vue index 59010699..220442a2 100644 --- a/src/layout/components/main/index.vue +++ b/src/layout/components/main/index.vue @@ -17,11 +17,11 @@
-
已选组件
-
+
已选组件({{ diy_data.length }})
+
-
  • +
  • {{ item.name }} @@ -186,6 +186,14 @@ const props = defineProps({ const diy_data = ref(props.diyData); const page_data = ref(props.header); const footer_nav = ref(props.footer); +const drawer_visiable = ref(false); +watch(diy_data, (val) => { + if (val.length > 0) { + drawer_visiable.value = true; + } else { + drawer_visiable.value = false; + } +}) // 监听 watch( () => props.diyData, @@ -513,12 +521,16 @@ const set_show_tabs = (index: number) => { } }); }; +// 中间区域的滚动效果 const scrollTop = ref(null); const activeCard = ref(null); +// 左边已选组件的滚动效果 +const left_scrollTop = ref(null); +const left_activeCard = ref(null); // 滚动到指定位置 const scroll = () => { nextTick(() => { - // 获取当前选中的内容 + // 获取当前选中的内容 --中间区域的滚动效果 activeCard.value = document.querySelector('.plug-in-table.plug-in-border'); if (activeCard.value) { // 获取选中内容的位置 @@ -528,6 +540,16 @@ const scroll = () => { scrollTop.value.scrollTo({ top: scrollY - 200, behavior: 'smooth' }); } } + // 左边已选组件的滚动效果 + left_activeCard.value = document.querySelector('.drawer-drag-bg'); + if (left_activeCard.value) { + // 获取选中内容的位置 + const left_scrollY = left_activeCard.value.offsetTop; + if (left_scrollTop.value) { + // 选中的滚动到指定位置 + left_scrollTop.value.scrollTo({ top: left_scrollY - 200, behavior: 'smooth' }); + } + } }); }; //#endregion @@ -604,4 +626,4 @@ const float_bottom_change = (val: { bottom: string; location: string }, id: stri overflow: hidden; } } - + \ No newline at end of file