Răsfoiți Sursa

✨ feat(users): 添加角色列表API支持

- 在api.ts中导出roleClient,用于访问角色相关API
- 在Users.tsx中导入roleClient并定义RoleListResponse类型,为后续角色功能开发做准备
yourname 5 luni în urmă
părinte
comite
576004a527
2 a modificat fișierele cu 7 adăugiri și 2 ștergeri
  1. 2 1
      src/client/admin/pages/Users.tsx
  2. 5 1
      src/client/api.ts

+ 2 - 1
src/client/admin/pages/Users.tsx

@@ -5,10 +5,11 @@ import {
 } from 'antd';
 import { useQuery } from '@tanstack/react-query';
 import dayjs from 'dayjs';
-import { userClient } from '@/client/api';
+import { roleClient, userClient } from '@/client/api';
 import type { InferResponseType, InferRequestType } from 'hono/client';
 
 type UserListResponse = InferResponseType<typeof userClient.$get, 200>;
+type RoleListResponse = InferResponseType<typeof roleClient.$get, 200>;
 type UserDetailResponse = InferResponseType<typeof userClient[':id']['$get'], 200>;
 type CreateUserRequest = InferRequestType<typeof userClient.$post>['json'];
 type UpdateUserRequest = InferRequestType<typeof userClient[':id']['$put']>['json'];

+ 5 - 1
src/client/api.ts

@@ -1,7 +1,7 @@
 import axios, { isAxiosError } from 'axios';
 import { hc } from 'hono/client'
 import type {
-  AuthRoutes, UserRoutes,
+  AuthRoutes, UserRoutes, RoleRoutes
 } from '@/server/api';
 
 // 创建 axios 适配器
@@ -60,3 +60,7 @@ export const authClient = hc<AuthRoutes>('/', {
 export const userClient = hc<UserRoutes>('/', {
   fetch: axiosFetch,
 }).api.v1.users;
+
+export const roleClient = hc<RoleRoutes>('/', {
+  fetch: axiosFetch,
+}).api.v1.roles;