- Add GoManager service for downloading and managing Go versions - Implement Go version detection and installation - Add GoManager Vue component with version selection UI - Update main process to handle Go-related IPC calls - Add Jest testing configuration and GoManager unit tests - Update service store to include Go management - Add routing for Go manager page - Include Kiro specs and steering documentation
6.4 KiB
6.4 KiB
Implementation Plan: Go Version Management
Overview
本实现计划将 Go 版本管理功能集成到 PHPer 开发环境管理器中。实现将遵循现有的 NodeManager 和 PythonManager 架构模式,确保代码一致性和可维护性。所有代码将使用 TypeScript 编写,与项目现有技术栈保持一致。
Tasks
-
1. 创建 Go 管理器后端服务
-
1.1 创建 GoManager.ts 服务类
- 创建
electron/services/GoManager.ts文件 - 定义核心接口和类型(GoVersion, AvailableGoVersion, GoInfo)
- 实现基础类结构和 ConfigStore 集成
- Requirements: 1.1, 4.1, 6.1
- 创建
-
1.2 为核心结构编写单元测试
- 测试基础类初始化和配置集成
- Requirements: 1.1, 4.1, 6.1
-
-
2. 实现版本获取和管理功能
-
2.1 实现 golang.org API 集成
- 从
https://golang.org/dl/?mode=json获取版本列表 - 解析 API 响应并提取 Windows 64位版本
- 实现缓存机制(5分钟缓存)
- 添加备用版本列表
- Requirements: 1.1
- 从
-
2.2 为 API 集成编写属性测试
- Property 1: API Version Fetching Consistency
- Validates: Requirements 1.1
-
2.3 实现已安装版本检测
- 扫描本地 Go 安装目录
- 验证安装完整性(go.exe, gofmt.exe 等)
- 检测当前活动版本
- 获取版本详细信息
- Requirements: 4.1, 4.2, 4.5, 5.1, 5.2
-
2.4 为版本检测编写属性测试
- Property 9: Version Information Completeness
- Validates: Requirements 4.2, 4.3
-
-
3. 实现下载和安装功能
-
3.1 实现文件下载管理器
- 支持 HTTPS 下载和进度跟踪
- 实现 SHA256 校验和验证
- 处理下载中断和重试
- 集成到现有的下载进度系统
- Requirements: 1.2, 1.3
-
3.2 为下载功能编写属性测试
- Property 2: Download URL Construction
- Property 3: Download Progress Reporting
- Validates: Requirements 1.2, 1.3
-
3.3 实现 Go 版本安装逻辑
- ZIP 文件解压到目标目录
- 安装后验证和完整性检查
- 重复安装检测和防护
- 清理临时文件
- Requirements: 1.4, 1.5, 5.1, 5.2, 5.3, 5.4
-
3.4 为安装功能编写属性测试
- Property 4: Installation Validation Completeness
- Property 5: Duplicate Installation Prevention
- Validates: Requirements 1.4, 1.5, 5.1, 5.2, 5.3, 5.4
-
-
4. 实现环境变量管理
-
4.1 实现环境变量更新逻辑
- 使用 PowerShell 脚本更新用户环境变量
- 设置 GOROOT、GOPATH 和 PATH
- 清理旧版本的路径配置
- Requirements: 3.1, 6.1, 6.2, 6.3, 6.4
-
4.2 为环境变量管理编写属性测试
- Property 7: Active Version Environment Management
- Property 14: GOPATH Default Configuration
- Validates: Requirements 3.1, 6.1, 6.2, 6.3, 6.4
-
4.3 实现版本切换和验证
- 版本激活和环境变量更新
- 切换后的功能验证
- 系统级 Go 命令验证
- Requirements: 3.2, 3.3, 3.4
-
4.4 为版本切换编写属性测试
- Property 11: Environment Variable Validation
- Validates: Requirements 3.2, 3.4
-
-
5. 实现卸载和清理功能
-
5.1 实现版本卸载逻辑
- 文件系统清理和目录删除
- 活动版本的环境变量清理
- 配置状态更新
- Requirements: 2.2, 2.3, 2.4, 2.5
-
5.2 为卸载功能编写属性测试
- Property 6: File System Cleanup on Uninstall
- Property 8: Version State Consistency
- Validates: Requirements 2.2, 2.4
-
-
6. 实现错误处理和用户反馈
- 6.1 实现综合错误处理系统
- 网络错误、磁盘空间、权限检查
- 描述性错误消息和解决建议
- 成功操作的详细反馈
- Requirements: 8.1, 8.2, 8.3, 8.4, 8.5
- 6.1 实现综合错误处理系统
-
7. 实现 IPC 通信层
-
7.1 在主进程中注册 Go 管理 IPC 处理器
- 在
electron/main.ts中添加 Go 相关的 IPC 处理函数 - 注册 go:getVersions, go:getAvailableVersions, go:install, go:uninstall, go:setActive 等
- 集成 GoManager 实例
- Requirements: 所有后端功能
- 在
-
7.2 更新预加载脚本
- 在
electron/preload.ts中暴露 Go 管理 API - 添加 go 对象到 electronAPI
- 确保类型安全的 IPC 通信
- Requirements: 所有后端功能
- 在
-
-
8. 实现前端 Vue 组件
-
8.1 创建 GoManager.vue 组件
- 创建
src/views/GoManager.vue文件 - 设置组件模板和基本布局(参考 NodeManager.vue 和 PythonManager.vue)
- 实现 KeepAlive 缓存支持
- 添加响应式数据管理
- Requirements: 7.1, 7.5
- 创建
-
8.2 实现版本列表显示功能
- 已安装版本的卡片式展示
- 版本信息显示(版本号、路径、状态)
- 活动版本的视觉标识
- 空状态处理和友好提示
- Requirements: 4.1, 4.2, 4.3, 4.4
-
8.3 实现版本操作界面
- 安装新版本对话框
- 可用版本列表和选择
- 卸载确认对话框
- 版本切换操作按钮
- Requirements: 1.1, 2.1, 3.2
-
8.4 实现下载进度和状态反馈
- 下载进度条和状态显示
- 操作加载状态和按钮禁用
- 成功/错误消息提示
- 集成到现有的下载进度监听系统
- Requirements: 1.3, 8.4, 8.5
-
-
9. 集成到主应用程序
-
9.1 添加 Go 管理页面路由
- 在
src/router/index.ts中添加 Go 管理路由 - 路径:
/go, 名称:go, 组件:GoManager.vue - 添加页面标题元数据
- Requirements: 7.1
- 在
-
9.2 更新应用程序导航
- 在主导航中添加 Go 管理入口
- 添加 Go 相关的图标
- 确保视觉一致性
- Requirements: 7.2, 7.3, 7.4
-
-
10. 检查点 - 完整功能验证
- 确保所有功能正常工作
- 验证用户体验和界面一致性
- 询问用户是否有问题或需要调整
Notes
- 后端 GoManager 服务已完全实现,包含所有核心功能和错误处理
- 属性测试已实现,覆盖所有关键正确性属性
- 需要完成 IPC 通信层、前端组件和应用集成
- 每个任务都引用了具体的需求条目以确保可追溯性
- 所有代码将使用 TypeScript 编写,与项目技术栈保持一致
- 实现将遵循现有的 NodeManager 和 PythonManager 架构模式