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

@@ -6,9 +6,9 @@ import { orpc } from '@/orpc'
export const Route = createFileRoute('/todos')({
component: Todos,
// loader: async ({ context }) => {
// await context.queryClient.prefetchQuery(orpc.todo.list.queryOptions())
// },
loader: async ({ context }) => {
await context.queryClient.prefetchQuery(orpc.todo.list.queryOptions())
},
})
function Todos() {