830c908712
- orpc.ts: 改为纯 createTanstackQueryUtils,不再依赖 experimental_ API - 抽出 src/client/queries/todo.ts 的 useInvalidateTodos,避免 query key 散落页面 - shutdown: setTimeout 内 db.$client.end() 失败也走 process.exit - 删除 db/index.ts 未被使用的 DB 类型导出 - 删除 env.ts 未被消费的 VITE_APP_TITLE,根 title 改为 package.json name - 清理 routes/index.tsx 的 JSX 区段注释、compose.yaml 注释掉的端口块、robots.txt URL 注释
72 lines
1.8 KiB
TypeScript
72 lines
1.8 KiB
TypeScript
import { TanStackDevtools } from '@tanstack/react-devtools'
|
|
import type { QueryClient } from '@tanstack/react-query'
|
|
import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools'
|
|
import { createRootRouteWithContext, HeadContent, Scripts } from '@tanstack/react-router'
|
|
import { TanStackRouterDevtoolsPanel } from '@tanstack/react-router-devtools'
|
|
import type { ReactNode } from 'react'
|
|
import { name } from '@/../package.json'
|
|
import { ErrorComponent } from '@/components/Error'
|
|
import { NotFoundComponent } from '@/components/NotFound'
|
|
import appCss from '@/styles.css?url'
|
|
|
|
export interface RouterContext {
|
|
queryClient: QueryClient
|
|
}
|
|
|
|
export const Route = createRootRouteWithContext<RouterContext>()({
|
|
head: () => ({
|
|
meta: [
|
|
{
|
|
charSet: 'utf-8',
|
|
},
|
|
{
|
|
name: 'viewport',
|
|
content: 'width=device-width, initial-scale=1',
|
|
},
|
|
{
|
|
title: name,
|
|
},
|
|
],
|
|
links: [
|
|
{
|
|
rel: 'stylesheet',
|
|
href: appCss,
|
|
},
|
|
],
|
|
}),
|
|
shellComponent: RootDocument,
|
|
errorComponent: ErrorComponent,
|
|
notFoundComponent: NotFoundComponent,
|
|
})
|
|
|
|
function RootDocument({ children }: Readonly<{ children: ReactNode }>) {
|
|
return (
|
|
<html lang="zh-Hans">
|
|
<head>
|
|
<HeadContent />
|
|
</head>
|
|
<body>
|
|
{children}
|
|
{import.meta.env.DEV && (
|
|
<TanStackDevtools
|
|
config={{
|
|
position: 'bottom-right',
|
|
}}
|
|
plugins={[
|
|
{
|
|
name: 'TanStack Router',
|
|
render: <TanStackRouterDevtoolsPanel />,
|
|
},
|
|
{
|
|
name: 'TanStack Query',
|
|
render: <ReactQueryDevtoolsPanel />,
|
|
},
|
|
]}
|
|
/>
|
|
)}
|
|
<Scripts />
|
|
</body>
|
|
</html>
|
|
)
|
|
}
|