From 57bf0d202140d6996829ac9375466204b3ef8d86 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Fri, 12 Sep 2025 20:57:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BF=AB=E6=8D=B7=E8=AE=BF?= =?UTF-8?q?=E9=97=AE=E7=BB=84=E4=BB=B6=E7=9A=84=E6=BB=9A=E5=8A=A8=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layouts/components/QuickAccess.vue | 129 ++++++++++++++++--------- 1 file changed, 85 insertions(+), 44 deletions(-) diff --git a/src/layouts/components/QuickAccess.vue b/src/layouts/components/QuickAccess.vue index 58098743..b599533b 100644 --- a/src/layouts/components/QuickAccess.vue +++ b/src/layouts/components/QuickAccess.vue @@ -206,6 +206,29 @@ function handleClosePluginDataDialog() { currentPlugin.value = null } +// 管理滚动状态 +function manageScrollLock() { + if (isVisible.value) { + // 使用 nextTick 确保 DOM 已经更新 + nextTick(() => { + // 先恢复之前的锁定状态,避免重复锁定 + const scrollableElement = document.querySelector('.all-plugins-grid') + if (scrollableElement) { + // 确保元素存在且可见 + if ((scrollableElement as HTMLElement).offsetHeight > 0) { + disableBodyScroll(scrollableElement as HTMLElement) + } + } + }) + } else { + // 恢复背景滚动 + const scrollableElement = document.querySelector('.all-plugins-grid') + if (scrollableElement) { + enableBodyScroll(scrollableElement as HTMLElement) + } + } +} + // 监听可见性变化,加载数据 watch( () => isVisible.value, @@ -213,18 +236,9 @@ watch( if (visible) { fetchPluginsWithPage() loadRecentPlugins() - // 禁用背景滚动,但允许面板内部滚动 - // 注意:参数是要允许滚动的目标元素,即面板本身 - const panelElement = document.querySelector('.plugin-quick-access') - if (panelElement) { - disableBodyScroll(panelElement as HTMLElement) - } + manageScrollLock() } else { - // 恢复背景滚动 - const panelElement = document.querySelector('.plugin-quick-access') - if (panelElement) { - enableBodyScroll(panelElement as HTMLElement) - } + manageScrollLock() } }, { immediate: true }, @@ -234,14 +248,15 @@ onMounted(() => { if (isVisible.value) { fetchPluginsWithPage() loadRecentPlugins() + manageScrollLock() } }) // 组件卸载时确保恢复背景滚动 onUnmounted(() => { - const panelElement = document.querySelector('.plugin-quick-access') - if (panelElement) { - enableBodyScroll(panelElement as HTMLElement) + const scrollableElement = document.querySelector('.all-plugins-grid') + if (scrollableElement) { + enableBodyScroll(scrollableElement as HTMLElement) } }) @@ -441,40 +456,41 @@ function handleBackdropClick(event: MouseEvent) {
{{ t('plugin.allPlugins') }}
-
-
- +
+
-
- -
- -
{{ plugin.plugin_name }}
+
+ +
+ +
{{ plugin.plugin_name }}
+
-
@@ -643,10 +659,34 @@ function handleBackdropClick(event: MouseEvent) { padding-inline: 0; } +.all-plugins-container { + display: flex; + overflow: hidden; + flex: 1; + flex-direction: column; + min-block-size: 0; +} + .all-plugins-grid { display: grid; gap: 4px; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); + max-block-size: 100%; + -webkit-overflow-scrolling: touch; + -ms-overflow-style: none; // IE/Edge + overflow-y: auto; + overscroll-behavior: contain; + padding-block: 8px; + padding-inline: 0; + + // 隐藏滚动条 + scrollbar-width: none; // Firefox + touch-action: pan-y; + will-change: scroll-position; + + &::-webkit-scrollbar { + display: none; // WebKit 浏览器 + } } .plugin-item { @@ -698,6 +738,7 @@ function handleBackdropClick(event: MouseEvent) { font-size: 12px; font-weight: 500; -webkit-line-clamp: 2; + line-clamp: 2; line-height: 1.2; max-block-size: 2.4em; text-align: center;