From 674d33632eb7f327e6e4991b74e35867b239a007 Mon Sep 17 00:00:00 2001 From: shinya Date: Tue, 26 Aug 2025 01:23:43 +0800 Subject: [PATCH] feat: scroll to top when changing group --- src/app/live/page.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/app/live/page.tsx b/src/app/live/page.tsx index 6c8d0a5..3412a13 100644 --- a/src/app/live/page.tsx +++ b/src/app/live/page.tsx @@ -209,6 +209,7 @@ function LivePageClient() { // 分组标签滚动相关 const groupContainerRef = useRef(null); const groupButtonRefs = useRef<(HTMLButtonElement | null)[]>([]); + const channelListRef = useRef(null); // ----------------------------------------------------------------------------- // 工具函数(Utils) @@ -459,6 +460,14 @@ function LivePageClient() { setSelectedGroup(group); const filtered = currentChannels.filter(channel => channel.group === group); setFilteredChannels(filtered); + + // 滚动到频道列表顶端 + if (channelListRef.current) { + channelListRef.current.scrollTo({ + top: 0, + behavior: 'smooth' + }); + } }; // 初始化 @@ -1111,7 +1120,7 @@ function LivePageClient() { {/* 频道列表 */} -
+
{filteredChannels.length > 0 ? ( filteredChannels.map(channel => { const isActive = channel.id === currentChannel?.id;