2026年3月14日14:37:06
This commit is contained in:
@@ -40,6 +40,13 @@ description: Soul 创业派对管理端开发规范。在 soul-admin/ 下编辑
|
||||
- **命名**:组件 PascalCase;文件与组件名一致(如 `WithdrawalsPage.tsx`);接口/类型用 PascalCase 或小驼峰按习惯。
|
||||
- **类型**:请求响应用 TypeScript 接口定义(如 `interface Withdrawal { ... }`),可用 `get<WithdrawalsRes>(...)` 泛型。
|
||||
|
||||
### 3.1 TypeScript 严格类型(可选→必填、API 映射)
|
||||
|
||||
- **可选字段赋给必填**:从 `T | undefined` 赋给 `T` 时,用 `?? defaultValue` 兜底,如 `t.appId ?? ''`、`t.pagePath ?? ''`
|
||||
- **接口与 API 对齐**:若 API 返回某字段而接口未声明,在接口中补 `field?: Type`(如 `isPinned?: boolean`)
|
||||
- **API 映射兜底**:`data.map(p => ({ id: p.token ?? p.personId ?? '', label: p.label ?? '', ... }))`,避免 `undefined` 流入 state
|
||||
- **setState 传参**:`useState<string | null>` 的 setter 不接受 `undefined`,传 `value ?? null` 而非裸 `value`
|
||||
|
||||
---
|
||||
|
||||
## 4. 列表页标准(必守)
|
||||
|
||||
Reference in New Issue
Block a user