feat: 增强路由类型安全与数据预加载

- 为路由器上下文添加类型约束以确保类型安全
- 在根路由中添加查询客户端上下文类型并使用带上下文的根路由创建函数
- 启用加载器以预先获取待办事项列表数据
This commit is contained in:
2026-01-18 04:04:52 +08:00
parent 7af770adef
commit effb7f16c7
3 changed files with 16 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
import { createRouter } from '@tanstack/react-router'
import { setupRouterSsrQueryIntegration } from '@tanstack/react-router-ssr-query'
import { getContext as getQueryContext } from './integrations/tanstack-query'
import type { RouterContext } from './routes/__root'
import { routeTree } from './routeTree.gen'
export const getRouter = () => {
@@ -10,7 +11,7 @@ export const getRouter = () => {
routeTree,
context: {
...queryContext,
},
} satisfies RouterContext,
scrollRestoration: true,
defaultPreloadStaleTime: 0,