mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-30 10:42:09 +08:00
+15
-2
@@ -61,15 +61,22 @@ const LogPage = () => {
|
||||
[filterLogs, isDescending],
|
||||
)
|
||||
|
||||
const scrollRef = useRef({ isNearBottom: true, length: 0 })
|
||||
const virtuosoRef = useRef<VirtualListHandle>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (!isDescending && filteredLogs.length > 0) {
|
||||
if (
|
||||
!isDescending &&
|
||||
filteredLogs.length > scrollRef.current.length &&
|
||||
scrollRef.current.isNearBottom
|
||||
) {
|
||||
virtuosoRef.current?.scrollToIndex(filteredLogs.length - 1, {
|
||||
behavior: 'smooth',
|
||||
})
|
||||
}
|
||||
}, [filteredLogs.length, isDescending])
|
||||
|
||||
scrollRef.current.length = filteredLogs.length
|
||||
}, [isDescending, filteredLogs.length])
|
||||
|
||||
const handleLogLevelChange = (newLevel: LogFilter) => {
|
||||
setClashLog((pre) => ({ ...pre!, logFilter: newLevel }))
|
||||
@@ -188,6 +195,12 @@ const LogPage = () => {
|
||||
renderItem={(i) => (
|
||||
<LogItem value={filteredLogs[i]} searchState={searchState} />
|
||||
)}
|
||||
onScroll={(event) => {
|
||||
const element = event.currentTarget as HTMLDivElement
|
||||
scrollRef.current.isNearBottom =
|
||||
element.scrollHeight - element.scrollTop - element.clientHeight <=
|
||||
20
|
||||
}}
|
||||
style={{ flex: 1 }}
|
||||
/>
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user