11import { useEffect , useRef , useState , useCallback } from 'preact/hooks'
22import { route , getCurrentUrl } from 'preact-router'
3- import { ChevronLeft , ChevronRight , X , Home , Users , Settings , FileText } from 'lucide-preact'
3+ import { ChevronLeft , ChevronRight , X , Home , Users , Settings , FileText , type LucideIcon } from 'lucide-preact'
44import {
55 tabs ,
66 activeTabId ,
@@ -48,7 +48,7 @@ const pathTitles: Record<string, string> = {
4848}
4949
5050// 路径到图标的映射
51- const pathIcons : Record < string , any > = {
51+ const pathIcons : Record < string , LucideIcon > = {
5252 '/' : Home ,
5353 '/users' : Users ,
5454 '/settings' : Settings ,
@@ -62,7 +62,7 @@ const resolveTitle = (path: string): string => {
6262 return match ? match [ 1 ] : path . split ( '/' ) . pop ( ) || '新页面'
6363}
6464
65- const resolveIcon = ( path : string ) : any => {
65+ const resolveIcon = ( path : string ) : LucideIcon => {
6666 const match = Object . entries ( pathIcons ) . find (
6767 ( [ key ] ) => path === key || path . startsWith ( `${ key } /` )
6868 )
@@ -108,7 +108,7 @@ export function TabBar() {
108108 if ( activeTab ) {
109109 activeTab . scrollIntoView ( { behavior : 'smooth' , block : 'nearest' , inline : 'center' } )
110110 }
111- } , [ activeTabId . value ] )
111+ } , [ ] )
112112
113113 // 监听路由变化,自动添加标签
114114 useEffect ( ( ) => {
@@ -130,7 +130,7 @@ export function TabBar() {
130130 useEffect ( ( ) => {
131131 checkScroll ( )
132132 scrollToActiveTab ( )
133- } , [ tabs . value , activeTabId . value , checkScroll , scrollToActiveTab ] )
133+ } , [ checkScroll , scrollToActiveTab ] )
134134
135135 // 监听容器大小变化
136136 useEffect ( ( ) => {
@@ -251,15 +251,15 @@ export function TabBar() {
251251 : 'bg-muted/50 text-muted-foreground hover:bg-muted hover:text-foreground'
252252 } `}
253253 onClick = { ( ) => handleTabClick ( tab ) }
254- onContextMenu = { ( e ) => handleContextMenu ( e as any , tab ) }
254+ onContextMenu = { ( e ) => handleContextMenu ( e as unknown as MouseEvent , tab ) }
255255 >
256256 { /* 活动指示器 */ }
257257 { activeTabId . value === tab . id && (
258258 < div class = "absolute bottom-0 left-0 right-0 h-0.5 bg-primary" />
259259 ) }
260260
261261 { /* 图标 */ }
262- { Icon && < Icon class = "h-3.5 w-3.5 shrink-0" /> }
262+ { Icon && < Icon className = "h-3.5 w-3.5 shrink-0" /> }
263263
264264 { /* 标题 */ }
265265 < span class = "truncate text-sm" > { tab . title } </ span >
@@ -272,7 +272,7 @@ export function TabBar() {
272272 ? 'opacity-100'
273273 : 'opacity-0 group-hover:opacity-100'
274274 } `}
275- onClick = { ( e ) => handleCloseTab ( e as any , tab ) }
275+ onClick = { ( e ) => handleCloseTab ( e as unknown as MouseEvent , tab ) }
276276 >
277277 < X class = "h-3 w-3" />
278278 </ button >
@@ -306,7 +306,7 @@ export function TabBar() {
306306 class = "w-full px-3 py-1.5 text-sm text-left hover:bg-accent hover:text-accent-foreground"
307307 onClick = { ( ) => {
308308 if ( contextMenu . tab ) {
309- handleCloseTab ( new MouseEvent ( 'click' ) as any , contextMenu . tab )
309+ handleCloseTab ( new MouseEvent ( 'click' ) , contextMenu . tab )
310310 }
311311 } }
312312 >
0 commit comments