feat: add frontend app routing

This commit is contained in:
hailin
2026-06-30 18:47:35 +08:00
parent 333dc76f18
commit c80c286227
7 changed files with 77 additions and 5 deletions

View File

@@ -1,5 +1,30 @@
import { App } from './App'
import * as React from 'react'
import { DesignSystemPreview } from '@/features/design-system/DesignSystemPreview'
function getRoute() {
return window.location.hash.replace(/^#/, '') || '/tickets'
}
export function Router() {
return <App />
const [route, setRoute] = React.useState(getRoute)
React.useEffect(() => {
const handleHashChange = () => setRoute(getRoute())
window.addEventListener('hashchange', handleHashChange)
return () => window.removeEventListener('hashchange', handleHashChange)
}, [])
if (route === '/design-system') {
return <DesignSystemPreview />
}
return (
<main className="min-h-screen bg-background p-6 text-foreground">
<div className="mx-auto max-w-6xl">
<p className="text-sm text-muted-foreground">Route</p>
<h1 className="mt-2 text-xl font-semibold">{route}</h1>
</div>
</main>
)
}