增强滚动锁定功能

This commit is contained in:
jxxghp
2025-07-13 09:46:38 +08:00
parent e25caddfef
commit eb098ca775
3 changed files with 137 additions and 28 deletions

View File

@@ -164,7 +164,15 @@ const handleServiceWorkerMessage = (event: MessageEvent) => {
}
// 使用滚动锁定 composable自动监听showPluginQuickAccess的变化
useScrollLockWithWatch(showPluginQuickAccess)
useScrollLockWithWatch(showPluginQuickAccess, {
preventTouchScroll: true,
preserveScrollPosition: true,
autoRestore: true,
// 允许快速访问面板内的滚动
allowScrollSelectors: ['.plugin-quick-access'],
// 允许快速访问面板内的可滚动容器
allowScrollContainerSelectors: ['.plugin-grid'],
})
// 检查是否可以使用下拉手势
const canUsePullGesture = () => {

View File

@@ -141,7 +141,9 @@ function getPluginIcon(plugin: Plugin): string {
// 如果是网络图片则使用代理后返回
if (plugin?.plugin_icon?.startsWith('http'))
return `${import.meta.env.VITE_API_BASE_URL}system/img/1?imgurl=${encodeURIComponent(plugin?.plugin_icon)}&cache=true`
return `${import.meta.env.VITE_API_BASE_URL}system/img/1?imgurl=${encodeURIComponent(
plugin?.plugin_icon,
)}&cache=true`
return `./plugin_icon/${plugin?.plugin_icon}`
}
@@ -233,6 +235,12 @@ function handleTouchStart(event: TouchEvent) {
const target = event.target as HTMLElement
startedFromBottomArea.value = !!target.closest('.bottom-drag-area')
// 如果触摸发生在插件网格内,不处理拖拽关闭
if (target.closest('.plugin-grid')) {
startedFromBottomArea.value = false
return
}
startY.value = touch.clientY
lastY.value = touch.clientY
lastTime.value = Date.now()
@@ -253,6 +261,12 @@ function handleTouchMove(event: TouchEvent) {
// 只有从 bottom-drag-area 开始的触摸才处理上滑关闭
if (!startedFromBottomArea.value) return
// 检查当前触摸是否在插件网格内,如果是则不处理拖拽关闭
const target = event.target as HTMLElement
if (target.closest('.plugin-grid')) {
return
}
const currentY = touch.clientY
const currentTime = Date.now()
const deltaY = startY.value - currentY // 向上为正值
@@ -561,6 +575,7 @@ function handleBackdropClick(event: MouseEvent) {
flex: 1;
flex-direction: column;
gap: 16px;
max-block-size: calc(100vh - 200px); // 确保有最大高度限制
min-block-size: 0;
-webkit-overflow-scrolling: touch;
-ms-overflow-style: none; // IE/Edge
@@ -571,6 +586,7 @@ function handleBackdropClick(event: MouseEvent) {
// 隐藏滚动条
scrollbar-width: none; // Firefox
touch-action: pan-y;
will-change: scroll-position;
&::-webkit-scrollbar {
display: none; // WebKit 浏览器