feat: updates

This commit is contained in:
qier222 2022-06-25 13:47:07 +08:00
parent f340a90117
commit cec4c5909d
No known key found for this signature in database
GPG key ID: 9C85007ED905F14D
50 changed files with 1304 additions and 207 deletions

View file

@ -0,0 +1,20 @@
import { useLayoutEffect } from 'react'
import scrollPositions from '@/web/store/scrollPositions'
import { throttle } from 'lodash-es'
const ScrollRestoration = () => {
useLayoutEffect(() => {
const main = document.querySelector('main')
const handleScroll = throttle(() => {
scrollPositions.set(window.location.pathname, main?.scrollTop ?? 0)
}, 100)
main?.addEventListener('scroll', handleScroll)
return () => {
main?.removeEventListener('scroll', handleScroll)
}
}, [])
return <></>
}
export default ScrollRestoration