|
@@ -93,7 +93,7 @@
|
|
|
}).api.v1['your-entities'];
|
|
}).api.v1['your-entities'];
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
-6. **前端调用**
|
|
|
|
|
|
|
+### 7. **前端调用**
|
|
|
- 在页面组件(如`pages_users.tsx`)中:
|
|
- 在页面组件(如`pages_users.tsx`)中:
|
|
|
- 使用`InferResponseType`提取响应类型
|
|
- 使用`InferResponseType`提取响应类型
|
|
|
- 使用`InferRequestType`提取请求类型
|
|
- 使用`InferRequestType`提取请求类型
|
|
@@ -103,6 +103,41 @@
|
|
|
type CreateRequest = InferRequestType<typeof entityClient.$post>['json'];
|
|
type CreateRequest = InferRequestType<typeof entityClient.$post>['json'];
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
|
+### 8. **注册管理后台路由和菜单**
|
|
|
|
|
+ - **注册路由**:在`src/client/admin/routes.tsx`中添加路由配置:
|
|
|
|
|
+ ```typescript
|
|
|
|
|
+ import YourEntityList from './pages/YourEntityList';
|
|
|
|
|
+ import YourEntityDetail from './pages/YourEntityDetail';
|
|
|
|
|
+
|
|
|
|
|
+ export const routes = [
|
|
|
|
|
+ // ...其他路由
|
|
|
|
|
+ {
|
|
|
|
|
+ path: '/your-entities',
|
|
|
|
|
+ element: <YourEntityList />
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ path: '/your-entities/:id',
|
|
|
|
|
+ element: <YourEntityDetail />
|
|
|
|
|
+ }
|
|
|
|
|
+ ];
|
|
|
|
|
+ ```
|
|
|
|
|
+
|
|
|
|
|
+ - **注册菜单**:在`src/client/admin/menu.tsx`中添加菜单配置:
|
|
|
|
|
+ ```typescript
|
|
|
|
|
+ import { TableOutlined } from '@ant-design/icons';
|
|
|
|
|
+
|
|
|
|
|
+ export const menuItems = [
|
|
|
|
|
+ // ...其他菜单项
|
|
|
|
|
+ {
|
|
|
|
|
+ key: 'your-entities',
|
|
|
|
|
+ icon: <TableOutlined />,
|
|
|
|
|
+ label: '实体管理',
|
|
|
|
|
+ path: '/your-entities'
|
|
|
|
|
+ }
|
|
|
|
|
+ ];
|
|
|
|
|
+ ```
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
## 自定义复杂CRUD开发流程
|
|
## 自定义复杂CRUD开发流程
|
|
|
|
|
|
|
|
当实体需要复杂业务逻辑或非标准CRUD操作时,采用以下完整流程:
|
|
当实体需要复杂业务逻辑或非标准CRUD操作时,采用以下完整流程:
|
|
@@ -457,14 +492,48 @@
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
### 7. **前端调用**
|
|
### 7. **前端调用**
|
|
|
- - 在页面组件(如`pages_users.tsx`)中:
|
|
|
|
|
- - 使用`InferResponseType`提取响应类型
|
|
|
|
|
- - 使用`InferRequestType`提取请求类型
|
|
|
|
|
- - 示例:
|
|
|
|
|
- ```typescript
|
|
|
|
|
- type EntityResponse = InferResponseType<typeof entityClient.$get, 200>;
|
|
|
|
|
- type CreateRequest = InferRequestType<typeof entityClient.$post>['json'];
|
|
|
|
|
- ```
|
|
|
|
|
|
|
+ - 在页面组件(如`pages_users.tsx`)中:
|
|
|
|
|
+ - 使用`InferResponseType`提取响应类型
|
|
|
|
|
+ - 使用`InferRequestType`提取请求类型
|
|
|
|
|
+ - 示例:
|
|
|
|
|
+ ```typescript
|
|
|
|
|
+ type EntityResponse = InferResponseType<typeof entityClient.$get, 200>;
|
|
|
|
|
+ type CreateRequest = InferRequestType<typeof entityClient.$post>['json'];
|
|
|
|
|
+ ```
|
|
|
|
|
+
|
|
|
|
|
+### 8. **注册管理后台路由和菜单**
|
|
|
|
|
+ - **注册路由**:在`src/client/admin/routes.tsx`中添加路由配置:
|
|
|
|
|
+ ```typescript
|
|
|
|
|
+ import YourEntityList from './pages/YourEntityList';
|
|
|
|
|
+ import YourEntityDetail from './pages/YourEntityDetail';
|
|
|
|
|
+
|
|
|
|
|
+ export const routes = [
|
|
|
|
|
+ // ...其他路由
|
|
|
|
|
+ {
|
|
|
|
|
+ path: '/your-entities',
|
|
|
|
|
+ element: <YourEntityList />
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ path: '/your-entities/:id',
|
|
|
|
|
+ element: <YourEntityDetail />
|
|
|
|
|
+ }
|
|
|
|
|
+ ];
|
|
|
|
|
+ ```
|
|
|
|
|
+
|
|
|
|
|
+ - **注册菜单**:在`src/client/admin/menu.tsx`中添加菜单配置:
|
|
|
|
|
+ ```typescript
|
|
|
|
|
+ import { TableOutlined } from '@ant-design/icons';
|
|
|
|
|
+
|
|
|
|
|
+ export const menuItems = [
|
|
|
|
|
+ // ...其他菜单项
|
|
|
|
|
+ {
|
|
|
|
|
+ key: 'your-entities',
|
|
|
|
|
+ icon: <TableOutlined />,
|
|
|
|
|
+ label: '实体管理',
|
|
|
|
|
+ path: '/your-entities'
|
|
|
|
|
+ }
|
|
|
|
|
+ ];
|
|
|
|
|
+ ```
|
|
|
|
|
|
|
|
## 注意事项
|
|
## 注意事项
|
|
|
|
|
|