Files
page-agent/packages/website/src/router.tsx
T

53 lines
1.3 KiB
TypeScript
Raw Normal View History

2026-02-27 19:46:44 +08:00
import { Suspense, useLayoutEffect } from 'react'
import { Route, Switch, useLocation } from 'wouter'
2025-09-29 16:33:15 +08:00
2026-02-27 19:46:44 +08:00
import Footer from './components/Footer'
import Header from './components/Header'
2026-02-27 20:42:24 +08:00
import HomePage from './pages/Home'
2026-01-19 19:10:00 +08:00
import DocsPages from './pages/docs/index'
2025-09-29 16:33:15 +08:00
function ScrollToTop() {
const [pathname] = useLocation()
useLayoutEffect(() => {
window.scrollTo(0, 0)
}, [pathname])
return null
}
2025-09-29 16:33:15 +08:00
export default function Router() {
return (
2026-02-27 20:42:24 +08:00
<div className="flex min-h-screen flex-col">
2026-02-27 19:46:44 +08:00
<Header />
<Suspense>
<ScrollToTop />
<Switch>
<Route path="/">
<main
id="main-content"
2026-02-27 20:42:24 +08:00
className="flex-1 bg-linear-to-br from-blue-50 to-purple-50 dark:from-gray-900 dark:to-gray-800"
2026-02-27 19:46:44 +08:00
>
2026-02-27 20:42:24 +08:00
<HomePage />
2026-02-27 19:46:44 +08:00
</main>
</Route>
2025-09-29 16:33:15 +08:00
2026-02-27 19:46:44 +08:00
<Route path="/docs" nest>
2026-02-27 20:42:24 +08:00
<div className="flex-1 bg-white dark:bg-gray-900">
2026-02-27 19:46:44 +08:00
<DocsPages />
</div>
</Route>
2025-09-29 16:33:15 +08:00
2026-02-27 19:46:44 +08:00
<Route>
2026-02-27 20:42:24 +08:00
<div className="flex-1 bg-white dark:bg-gray-900 flex items-center justify-center">
2026-02-27 19:46:44 +08:00
<div className="text-center">
<h1 className="text-4xl font-bold mb-4 text-gray-900 dark:text-white">404</h1>
<p className="text-xl text-gray-600 dark:text-gray-300">Page not found</p>
</div>
2026-01-16 15:05:09 +08:00
</div>
2026-02-27 19:46:44 +08:00
</Route>
</Switch>
</Suspense>
<Footer />
2026-02-27 20:42:24 +08:00
</div>
2025-09-29 16:33:15 +08:00
)
}