refactor(client): 合并 orpc.ts 和 query-client.ts 为单文件,遵循 ORPC 官方模式

This commit is contained in:
2026-03-05 11:05:53 +08:00
parent 0cd8b57d24
commit 02bdfffe79
5 changed files with 34 additions and 36 deletions

View File

@@ -54,8 +54,7 @@ bun test -t "pattern" # Run tests matching pattern
```
src/
├── client/ # Client-side code
── orpc.ts # ORPC isomorphic client (internal)
│ └── query-client.ts # TanStack Query utils (used by components)
── orpc.ts # ORPC client + TanStack Query utils (single entry point)
├── components/ # React components
├── routes/ # TanStack Router file routes
│ ├── __root.tsx # Root layout
@@ -126,7 +125,7 @@ export const router = os.router({ feature })
### 4. Use in Components
```typescript
import { useSuspenseQuery, useMutation } from '@tanstack/react-query'
import { orpc } from '@/client/query-client'
import { orpc } from '@/client/orpc'
const { data } = useSuspenseQuery(orpc.feature.list.queryOptions())
const mutation = useMutation(orpc.feature.create.mutationOptions())