Skip to content

Commit e2222d7

Browse files
author
TARS
committed
chore(release): v1.0.6
- 多人 Tab 支持横向滑动 - 添加 -webkit-overflow-scrolling: touch 优化 iOS 滑动体验 - 切换 Tab 时自动滚动到可视区域 - Tab 按钮使用 flex-shrink-0 防止压缩
1 parent 95459cf commit e2222d7

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "cf-daily-tracker",
33
"private": true,
4-
"version": "1.0.5",
4+
"version": "1.0.6",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

src/App.tsx

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useEffect } from 'react';
1+
import { useState, useEffect, useRef } from 'react';
22
import { useTranslation } from 'react-i18next';
33
import { TagInput, UserCard, SubmissionList, SubmissionFilterPanel, LanguageSwitcher, ThemeSwitcher, ErrorMessage, DateRangePicker } from './components';
44
import { useUserQuery, useTheme, useSearchHistory } from './hooks';
@@ -68,13 +68,34 @@ interface UserTabsProps {
6868
}
6969

7070
function UserTabs({ users, activeIndex, onSelect }: UserTabsProps) {
71+
const containerRef = useRef<HTMLDivElement>(null);
72+
73+
// 当 activeIndex 变化时,滚动到可见区域
74+
useEffect(() => {
75+
if (containerRef.current) {
76+
const buttons = containerRef.current.querySelectorAll('button');
77+
const activeButton = buttons[activeIndex];
78+
if (activeButton) {
79+
activeButton.scrollIntoView({
80+
behavior: 'smooth',
81+
block: 'nearest',
82+
inline: 'center',
83+
});
84+
}
85+
}
86+
}, [activeIndex]);
87+
7188
return (
72-
<div className="flex gap-1 p-1 bg-gray-100 dark:bg-gray-800 rounded-xl overflow-x-auto scrollbar-hide">
89+
<div
90+
ref={containerRef}
91+
className="flex gap-1 p-1 bg-gray-100 dark:bg-gray-800 rounded-xl overflow-x-auto scrollbar-hide"
92+
style={{ WebkitOverflowScrolling: 'touch' }}
93+
>
7394
{users.map((user, index) => (
7495
<button
7596
key={user.handle}
7697
onClick={() => onSelect(index)}
77-
className={`flex items-center gap-2 px-3 sm:px-4 py-2 rounded-lg text-sm font-medium whitespace-nowrap transition-all min-w-0
98+
className={`flex items-center gap-2 px-3 sm:px-4 py-2 rounded-lg text-sm font-medium whitespace-nowrap transition-all flex-shrink-0
7899
${activeIndex === index
79100
? 'bg-white dark:bg-gray-700 text-blue-600 dark:text-blue-400 shadow-sm'
80101
: 'text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200 hover:bg-gray-200/50 dark:hover:bg-gray-700/50'
@@ -242,7 +263,7 @@ function getRatingColor(rating: number): string {
242263
}
243264

244265
// 应用版本号(与 package.json 保持一致)
245-
const APP_VERSION = '1.0.5';
266+
const APP_VERSION = '1.0.6';
246267

247268
/**
248269
* 主应用组件

0 commit comments

Comments
 (0)