Files
Novault-Frontend-app/walkthrough.md
2026-01-28 00:37:56 +08:00

58 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Build Fix Walkthrough - Phase 8
## 🎯 目标
修复所有 TypeScript 编译错误,确保应用可以成功构建。
## 🛠️ 修复内容
### 1. 类型定义修复 (`src/types/index.ts`)
- **HeadersInit**: 在 `api.ts` 中使用 `Record<string, string>` 替代 `HeadersInit`,解决类型兼容性问题。
- **Transaction Interface**: 添加了缺失的展示性字段UI 需要但后端返回未归一化的字段):
- `categoryName`, `categoryIcon`, `categoryColor`
- `accountName`, `accountIcon`
- `toAccountId`, `toAccountName`, `toAccountIcon`
- **BudgetPeriodType**: 扩展了周期类型,添加 `quarterly``custom`
### 2. 服务层 API 统一
为所有 Service (`account`, `transaction`, `budget`, `category`) 添加了统一的别名方法,确保与前端调用习惯一致:
- `getAll()` -> `getXxxs()`
- `getById()` -> `getXxx()`
- `create()` -> `createXxx()`
- `update()` -> `updateXxx()`
- `delete()` -> `deleteXxx()`
### 3. 组件重构
- **AccountSelector & CategorySelector**:
- 重构为支持**受控模式 (Controlled Mode)**。
- 添加了 `visible`, `onClose`, `onSelect` 等属性。
- 当传入 `visible` 属性时,组件作为纯 Modal 运作,适配 `TransferScreen``EditTransactionScreen` 的使用场景。
- **DatePickerModal**:
- 创建了基于原生 View 的自定义日期选择器,移除了对 `@react-native-community/datetimepicker` 的依赖,简化安装流程。
### 4. 页面逻辑修复
- **TransferScreen**:
- 修复 `transactionService.create` 调用缺失 `currency` 参数的问题。
- 修复 `toAccountId` 类型问题。
- **AddBudgetScreen**:
- 修正参数名 `rollover` -> `isRolling`
- 移除不支持的 `icon` 参数。
- **TransactionDetailScreen**:
- 修复 `Tag` 对象直接作为 React Child 渲染的错误 (使用 `tag.name`)。
- **EditTransactionScreen**:
- 修复 `toAccountId` 可能为 `null` 导致类型不匹配的问题。
## ✅ 验证结果
运行 `npx tsc --noEmit` 成功通过,无报错。
## 📋 下一步
- 进行真机/模拟器运行测试,验证功能逻辑。
- 开始 Phase 7 的 UI 优化或 Phase 8 的性能优化。