Files
index/src/router/useRoute.ts
T
xiaozhou233 9ce0c5704a refactor: 重构路由、统一 MorePage 样式并清理冗余
- 新增零依赖路由器 (src/router):路由表 + useSyncExternalStore hook + Link 组件

- 抽出 HomePage,document.title 改由路由表驱动

- MorePage 改用 Tailwind 并复用 Header/Footer,移除 more.css

- 清理未使用依赖 (clsx/tailwind-merge/cva/tw-animate-css)、utils.ts、空 icons 目录、未用的 shadcn 主题变量及重复背景图
2026-10-05 19:10:47 +08:00

9 lines
341 B
TypeScript

import { useSyncExternalStore } from "react";
import { getPath, subscribe } from "./history";
import { matchRoute, type RouteDefinition } from "./routes";
export function useRoute(): { path: string; route: RouteDefinition } {
const path = useSyncExternalStore(subscribe, getPath, () => "/");
return { path, route: matchRoute(path) };
}