Files
peko-ios/issues/room-more-menu-refactor-todo.md

83 lines
2.9 KiB
Markdown
Raw Permalink 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.

# 房间更多菜单重构 TODO
## 重构目标
`XPRoomMoreMenuViewController.m` 中 600 行的垃圾代码重构为清晰、可维护的架构。
## 当前问题
1. `didSelectItemAtIndexPath` 方法有 200+ 行,包含 20+ 个不同的功能
2. 巨大的 switch 语句,违反单一职责原则
3. 到处都是 if-else 处理特殊情况
4. 难以测试、难以维护、难以扩展
## 重构方案
使用策略模式 + 工厂模式,将每个功能封装成独立的 Action 类。
## TODO 清单
### ✅ 已完成
- [x] 创建 `XPRoomMoreMenuAction.h/.m` - 抽象基类
- [x] 创建 `XPRoomMoreMenuActionContext.h/.m` - 上下文类
- [x] 创建 `XPRoomMoreMenuActionFactory.h/.m` - 工厂类
- [x] 创建 `XPGiftEffectAction.h/.m` - 礼物特效 Action 类
- [x] 创建 `XPRoomSettingAction.h/.m` - 房间设置 Action 类
- [x] 创建 `XPSocialAction.h/.m` - 社交功能 Action 类
- [x] 创建 `XPPKAction.h/.m` - PK 相关功能 Action 类
- [x] 重构主控制器 `didSelectItemAtIndexPath` 方法
- [x] 集成新架构到主控制器
- [x] 更新工厂类集成PK Action
- [x] 测试新架构功能
### 🔄 进行中
- [ ] 修复编译环境问题 - UIKit 导入问题
- [ ] 修复 PIBaseModel 继承问题
- [ ] 添加新的 Action 类到 Xcode 项目
### 📋 待完成
#### 基础设施搭建 (优先级:高)
- [ ] 修复编译环境问题 - UIKit 导入问题
- [ ] 修复 PIBaseModel 继承问题
- [ ] 修复手动引用计数问题
#### 实现具体的 Action 类 (优先级:高)
- [x] `XPRoomSettingAction.h/.m` - 房间设置
- [x] `XPSocialAction.h/.m` - 社交功能
- [x] `XPPKAction.h/.m` - PK 相关功能同房PK、跨房PK、主播PK、相亲模式
- [ ] `XPRoomManagementAction.h/.m` - 房间管理
- [ ] `XPOtherAction.h/.m` - 其他功能
#### 重构主控制器 (优先级:高)
- [x] 重构 `XPRoomMoreMenuViewController.m` - 简化主逻辑
- [x] 集成工厂模式
- [x] 更新数据源创建逻辑
- [ ] 移除巨大的 switch 语句 (保留为 fallback)
- [ ] 进一步优化架构
#### 测试和优化 (优先级:中)
- [ ] 创建单元测试
- [ ] 集成测试
- [ ] 性能测试
- [ ] 代码审查
#### 文档和优化 (优先级:低)
- [ ] 编写重构文档
- [ ] 创建使用示例
- [ ] 进一步优化架构
## 当前遇到的问题
1. **编译环境问题**UIKit 导入失败,可能是预编译头文件配置问题
2. **PIBaseModel 继承问题**:找不到 PIBaseModel 接口声明
3. **手动引用计数问题**:项目使用 MRC需要调整属性修饰符
## 下一步计划
1. 解决编译环境问题
2. 完成基础设施类
3. 实现第一个具体的 Action 类
4. 在主控制器中集成测试
## 重构收益
- 代码行数:从 600 行减少到每个类 50-100 行
- 可维护性:每个类职责单一,易于理解和修改
- 可测试性:每个 Action 可以独立测试
- 可扩展性:新增功能只需添加新的 Action 类