manual save(2026-01-23 10:58)

This commit is contained in:
SiteAgent Bot
2026-01-23 10:58:56 +08:00
parent b638cf80a0
commit af6d3e3222
4 changed files with 34 additions and 13 deletions

View File

@@ -1,9 +1,24 @@
import React from 'react'
import { Outlet, ScrollRestoration } from 'react-router-dom'
import React, { useEffect } from 'react'
import { Outlet, useLocation } from 'react-router-dom'
import { Header } from './Header'
import { Footer } from './Footer'
export const SiteLayout: React.FC = () => {
const location = useLocation()
useEffect(() => {
if (location.hash) {
const id = decodeURIComponent(location.hash.replace('#', ''))
const target = document.getElementById(id)
if (target) {
target.scrollIntoView({ behavior: 'smooth', block: 'start' })
return
}
}
window.scrollTo({ top: 0, left: 0, behavior: 'auto' })
}, [location.pathname, location.hash])
return (
<div className="min-h-screen bg-white text-gray-900">
<Header />
@@ -11,7 +26,6 @@ export const SiteLayout: React.FC = () => {
<Outlet />
</main>
<Footer />
<ScrollRestoration />
</div>
)
}