From e625ef0c507c90ce56468f291cc7bf79247162ee Mon Sep 17 00:00:00 2001 From: Linkon <116425752+Linkon-lcw@users.noreply.github.com> Date: Sun, 18 Jan 2026 21:43:42 +0800 Subject: [PATCH] =?UTF-8?q?feat(Home=E7=BB=84=E4=BB=B6):=20=E4=B8=BA?= =?UTF-8?q?=E5=BF=AB=E9=80=9F=E5=AF=BC=E8=88=AA=E6=B7=BB=E5=8A=A0=E8=A7=A6?= =?UTF-8?q?=E6=91=B8=E4=BA=8B=E4=BB=B6=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加触摸事件处理函数以实现移动端快速导航功能,包括触摸开始、移动和结束事件。同时禁用浏览器默认触摸处理以防止页面滚动冲突。 --- src/renderer/src/components/Home.tsx | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/renderer/src/components/Home.tsx b/src/renderer/src/components/Home.tsx index efd1ef6..b9ba7c8 100644 --- a/src/renderer/src/components/Home.tsx +++ b/src/renderer/src/components/Home.tsx @@ -454,6 +454,26 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => { document.removeEventListener('mouseup', onGlobalMouseUp) } + // 触摸事件处理 + const onNavTouchStart = (e: React.TouchEvent) => { + isNavDragging.current = true + if (e.touches[0]) { + handleNavAction(e.touches[0].clientY) + } + } + + const onNavTouchMove = (e: React.TouchEvent) => { + if (isNavDragging.current && e.touches[0]) { + handleNavAction(e.touches[0].clientY) + // 防止触摸滑动时触发页面滚动 + if (e.cancelable) e.preventDefault() + } + } + + const onNavTouchEnd = () => { + isNavDragging.current = false + } + // 渲染快速导航 const renderQuickNav = () => { if (groupedStudents.length <= 1 || sortType === 'score' || (sortType === 'alphabet' && searchKeyword)) return null @@ -462,6 +482,9 @@ export const Home: React.FC<{ canEdit: boolean }> = ({ canEdit }) => {
= ({ canEdit }) => { maxHeight: '80vh', border: '1px solid var(--ss-border-color)', cursor: 'pointer', - userSelect: 'none' + userSelect: 'none', + touchAction: 'none' // 关键:禁用浏览器的默认触摸处理 }} > {groupedStudents.map((group) => (