From 5d06e1a82dc7984d7e8d0ad610fff3236eaec5a2 Mon Sep 17 00:00:00 2001 From: "xinxin.wu" Date: Fri, 28 Jul 2023 15:03:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E7=AE=A1=E7=90=86=E6=8F=92=E4=BB=B6=E6=AD=A5?= =?UTF-8?q?=E9=AA=A4=E5=B7=A6=E4=BE=A7=E6=BB=9A=E5=8A=A8=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{useHiddenButton.ts => useExpandStyle.ts} | 30 ++--- .../pluginManager/components/pluginTable.vue | 111 +++++++++++++----- .../pluginManager/components/tableExpand.vue | 52 ++++++++ 3 files changed, 144 insertions(+), 49 deletions(-) rename frontend/src/hooks/{useHiddenButton.ts => useExpandStyle.ts} (75%) create mode 100644 frontend/src/views/setting/system/pluginManager/components/tableExpand.vue diff --git a/frontend/src/hooks/useHiddenButton.ts b/frontend/src/hooks/useExpandStyle.ts similarity index 75% rename from frontend/src/hooks/useHiddenButton.ts rename to frontend/src/hooks/useExpandStyle.ts index 2b922cc393..b7a90a8d31 100644 --- a/frontend/src/hooks/useHiddenButton.ts +++ b/frontend/src/hooks/useExpandStyle.ts @@ -1,18 +1,9 @@ -import { nextTick, reactive } from 'vue'; -// 自定义展开行:如果当前行下边无内容,隐藏表格折叠按钮 -const useButtonStyle = (wrapperName?: string, className?: string[]) => { +import { nextTick, reactive, onMounted, onUnmounted } from 'vue'; +// 自定义展开行:表格的高度计算和展开折叠图标颜色控制 +const useExpandStyle = (wrapperName?: string, className?: string[]) => { const cssHeight = reactive({ height: '460px', }); - // 隐藏按钮以及图标 - const hiddenButton = () => { - nextTick(() => { - const emptyBtns = document.querySelectorAll('.empty-button'); - emptyBtns.forEach((node) => { - (node.parentNode as HTMLElement).style.display = 'none'; - }); - }); - }; // 设置折叠展开后图标的颜色 const expandOrcollapseStyle = () => { nextTick(() => { @@ -31,7 +22,6 @@ const useButtonStyle = (wrapperName?: string, className?: string[]) => { const pageContent = document.querySelector(boxElement); return pageContent ? pageContent.getBoundingClientRect().height : 0; }; - // 计算每一个元素的高度 const getDomHeightWithMargin = (selector: string) => { const dom = document.querySelector(selector) as HTMLElement; @@ -40,7 +30,6 @@ const useButtonStyle = (wrapperName?: string, className?: string[]) => { const marginBottom = parseFloat(computedStyle.marginBottom); return dom ? dom.getBoundingClientRect().height + marginTop + marginBottom : 460; }; - // 计算最后的高度 const countHeight = () => { const contentHeight = getPageContentHeight(wrapperName as string); @@ -50,16 +39,21 @@ const useButtonStyle = (wrapperName?: string, className?: string[]) => { }, 0) || 0; return `${contentHeight - excludeTotalHeight - 70}px`; }; - window.onresize = () => { + const onResize = () => { cssHeight.height = countHeight(); }; + window.addEventListener('resize', onResize); + onMounted(() => { + onResize(); + }); + onUnmounted(() => { + window.removeEventListener('resize', onResize); + }); return { - hiddenButton, expandOrcollapseStyle, - countHeight, cssHeight, }; }; -export default useButtonStyle; +export default useExpandStyle; diff --git a/frontend/src/views/setting/system/pluginManager/components/pluginTable.vue b/frontend/src/views/setting/system/pluginManager/components/pluginTable.vue index 52fcde8309..0bec6cb774 100644 --- a/frontend/src/views/setting/system/pluginManager/components/pluginTable.vue +++ b/frontend/src/views/setting/system/pluginManager/components/pluginTable.vue @@ -108,15 +108,6 @@ - - - @@ -131,7 +122,7 @@