refactor: 统一客户端类型定义并增强类型一致性

- 更新客户端类型以使用定义的 APIClient 类型并确保类型一致性
- 添加类型定义以导出基于路由配置的客户端类型。
This commit is contained in:
2026-01-18 03:26:26 +08:00
parent debb47a60e
commit 1d8479c063
2 changed files with 7 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import { createTanstackQueryUtils } from '@orpc/tanstack-query'
import { createIsomorphicFn } from '@tanstack/react-start'
import { getRequestHeaders } from '@tanstack/react-start/server'
import { router } from './router'
import type { APIClient } from './types'
const getORPCClient = createIsomorphicFn()
.server(() =>
@@ -18,9 +19,9 @@ const getORPCClient = createIsomorphicFn()
const link = new RPCLink({
url: `${window.location.origin}/api/rpc`,
})
return createORPCClient<RouterClient<typeof router>>(link)
return createORPCClient<APIClient>(link)
})
const client = getORPCClient()
const client: APIClient = getORPCClient()
export const orpc = createTanstackQueryUtils(client)

4
src/orpc/types.ts Normal file
View File

@@ -0,0 +1,4 @@
import type { RouterClient } from '@orpc/server'
import type { router } from './router'
export type APIClient = RouterClient<typeof router>