From 94afdf5495fecf4e0d05920dafaef575892057a3 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Wed, 2 Jul 2025 17:41:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=A0=B7=E5=BC=8F=E5=92=8C?= =?UTF-8?q?=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/composables/useRecentPlugins.ts | 4 +- src/layouts/components/DefaultLayout.vue | 34 +++++++----- src/layouts/components/QuickAccess.vue | 69 +++++------------------- 3 files changed, 36 insertions(+), 71 deletions(-) diff --git a/src/composables/useRecentPlugins.ts b/src/composables/useRecentPlugins.ts index 072bd5f3..94c7b71c 100644 --- a/src/composables/useRecentPlugins.ts +++ b/src/composables/useRecentPlugins.ts @@ -1,7 +1,7 @@ import type { Plugin } from '@/api/types' const RECENT_PLUGINS_KEY = 'moviepilot_recent_plugins' -const MAX_RECENT_PLUGINS = 5 +const MAX_RECENT_PLUGINS = 3 interface RecentPlugin { id: string @@ -21,7 +21,7 @@ function pluginToRecentPlugin(plugin: Plugin): RecentPlugin { plugin_icon: plugin.plugin_icon, has_page: plugin.has_page || false, state: plugin.state || false, - plugin_id: plugin.plugin_id || '', + plugin_id: plugin.id || '', access_time: Date.now(), } } diff --git a/src/layouts/components/DefaultLayout.vue b/src/layouts/components/DefaultLayout.vue index 5bfbe149..f9117554 100644 --- a/src/layouts/components/DefaultLayout.vue +++ b/src/layouts/components/DefaultLayout.vue @@ -120,6 +120,9 @@ function handleUnreadMessage(count: number) { function handleTouchStart(event: TouchEvent) { if (!appMode || !display.mdAndDown.value) return + // 如果插件快速访问面板已显示,不处理下拉手势 + if (showPluginQuickAccess.value) return + const touch = event.touches[0] startY.value = touch.clientY @@ -135,6 +138,9 @@ function handleTouchStart(event: TouchEvent) { function handleTouchMove(event: TouchEvent) { if (!appMode || !display.mdAndDown.value) return + // 如果插件快速访问面板已显示,不处理下拉手势 + if (showPluginQuickAccess.value) return + const touch = event.touches[0] const deltaY = touch.clientY - startY.value @@ -173,6 +179,9 @@ function handleTouchMove(event: TouchEvent) { function handleTouchEnd() { if (!appMode || !display.mdAndDown.value) return + // 如果插件快速访问面板已显示,不处理下拉手势 + if (showPluginQuickAccess.value) return + if (isPulling.value && pullDistance.value > 120) { // 增加触发阈值到120px // 触发插件快速访问 @@ -199,31 +208,31 @@ function handlePluginClick() { showPluginQuickAccess.value = false } -// 阻止滚动的函数 -function preventScroll(e: TouchEvent) { - e.preventDefault() -} +// 保存页面滚动位置 +let scrollPosition = 0 // 监听插件快速访问的显示状态,控制背景滚动 watch(showPluginQuickAccess, visible => { if (visible) { - // 显示时锁定背景滚动 - 使用更强的锁定方式 + // 保存当前滚动位置 + scrollPosition = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0 + + // 显示时锁定背景滚动 document.body.style.overflow = 'hidden' document.body.style.position = 'fixed' + document.body.style.top = `-${scrollPosition}px` document.body.style.width = '100%' - document.body.style.height = '100%' document.documentElement.style.overflow = 'hidden' - // 禁用触摸滚动 - document.addEventListener('touchmove', preventScroll, { passive: false }) } else { // 隐藏时恢复滚动 document.body.style.overflow = '' document.body.style.position = '' + document.body.style.top = '' document.body.style.width = '' - document.body.style.height = '' document.documentElement.style.overflow = '' - // 恢复触摸滚动 - document.removeEventListener('touchmove', preventScroll) + + // 恢复滚动位置 + window.scrollTo(0, scrollPosition) } }) @@ -251,10 +260,9 @@ onMounted(() => { // 恢复body滚动样式 document.body.style.overflow = '' document.body.style.position = '' + document.body.style.top = '' document.body.style.width = '' - document.body.style.height = '' document.documentElement.style.overflow = '' - document.removeEventListener('touchmove', preventScroll) if (appMode && display.mdAndDown.value) { document.removeEventListener('touchstart', handleTouchStart) document.removeEventListener('touchmove', handleTouchMove) diff --git a/src/layouts/components/QuickAccess.vue b/src/layouts/components/QuickAccess.vue index 3dca4bb7..f73a1bdc 100644 --- a/src/layouts/components/QuickAccess.vue +++ b/src/layouts/components/QuickAccess.vue @@ -5,6 +5,7 @@ import noImage from '@images/logos/plugin.png' import { useI18n } from 'vue-i18n' import { useRecentPlugins } from '@/composables/useRecentPlugins' import PluginDataDialog from '@/components/dialog/PluginDataDialog.vue' +import { VCard } from 'vuetify/components' // 国际化 const { t } = useI18n() @@ -52,7 +53,7 @@ const currentPlugin = ref(null) // 计算显示状态 const isVisible = computed(() => { - return props.visible // 只基于visible属性显示,不考虑pullDistance + return props.visible }) // 处理插件图标加载错误 @@ -66,7 +67,7 @@ const componentTransform = computed(() => { if (props.visible) { baseTransform = 'translateY(0)' } else { - baseTransform = 'translateY(-100%)' // 完全隐藏在顶部 + baseTransform = 'translateY(-100%)' } // 如果正在拖动关闭,添加拖动偏移 @@ -79,7 +80,7 @@ const componentTransform = computed(() => { // 计算组件透明度(包含拖动透明度变化) const componentOpacity = computed(() => { - let baseOpacity = props.visible ? 1 : 0 // 只基于visible属性决定透明度 + let baseOpacity = props.visible ? 1 : 0 // 如果正在拖动关闭,根据拖动距离调整透明度 if (isDraggingToClose.value) { @@ -194,7 +195,8 @@ function handleBackdropClick(event: MouseEvent) {