refactor: 重构下载器并引入镜像源#214
Merged
Merged
Conversation
AnemoFlower
marked this pull request as draft
July 7, 2026 11:00
There was a problem hiding this comment.
Pull request overview
该 PR 将原有的 SingleFileDownloader / MultiFileDownloader 统一重构为新的 FileDownloader,并引入 DownloadSource / DownloadSourceManager 来集中管理“官方源/镜像源”的候选 URL 生成与选择策略,同时在 App 与设置页中接入下载源策略配置。
Changes:
- 合并下载器实现为
FileDownloader,并将多文件下载与并发控制整合进同一套 API。 - 新增下载源抽象(官方/镜像)与策略管理器,并在版本清单、ModLoader 版本列表等请求中接入。
- 新增启动器设置页用于切换下载源策略,同时更新若干调用方与测试用例以适配新下载器。
Reviewed changes
Copilot reviewed 31 out of 33 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| PCL.Mac/Views/Settings/SettingsSidebar.swift | 设置侧边栏新增“启动器”入口 |
| PCL.Mac/Views/Settings/LauncherSettingsPage.swift | 新增启动器设置页:下载源策略选择 |
| PCL.Mac/Views/Launch/LaunchPage.swift | 控件预览页补充 MySelect/MyTextField 示例 |
| PCL.Mac/Views/Download/MinecraftInstallOptionsPage.swift | ModLoader 版本列表 URL 改由 DownloadSourceManager 决定 |
| PCL.Mac/ViewModels/ResourceInstallViewModel.swift | 资源下载从 SingleFileDownloader 迁移到 FileDownloader |
| PCL.Mac/Task/MinecraftLaunchTask.swift | Authlib Injector 下载迁移到 FileDownloader |
| PCL.Mac/Managers/UpdateManager.swift | 更新包下载迁移到 FileDownloader |
| PCL.Mac/Managers/EasyTierManager.swift | EasyTier 组件下载迁移到 FileDownloader |
| PCL.Mac/Extensions/Localizable.swift | 为 DownloadSourcePolicy 提供展示文本(description) |
| PCL.Mac/Components/MyTextField.swift | TextField 样式调整(padding/border/高度等) |
| PCL.Mac/Components/MySelect.swift | 新增下拉选择组件 MySelect |
| PCL.Mac/App/LauncherConfig.swift | 配置新增 downloadSourcePolicy 持久化 |
| PCL.Mac/App/AppRouter.swift | 增加 launcherSettings 路由并设为 settings 默认子路由 |
| PCL.Mac/App/AppDelegate.swift | 启动时初始化 DownloadSourceManager 并刷新地区信息;新增外观设置行 |
| PCL.Mac.Tests/DownloadTests.swift | 测试迁移到 FileDownloader API(单/多文件下载) |
| PCL.Mac.Core/Utils/Errors.swift | DownloadError 改为 LocalizedError 并提供 errorDescription |
| PCL.Mac.Core/Utils/Download/SingleFileDownloader.swift | 删除:旧单文件下载器 |
| PCL.Mac.Core/Utils/Download/MultiFileDownloader.swift | 删除:旧多文件下载器 |
| PCL.Mac.Core/Utils/ConcurrentProgressHandler.swift | 标注 @mainactor,补充 initial 初始化能力,调整实现细节 |
| PCL.Mac.Core/Task/ModpackImportTask.swift | 多文件下载迁移到 FileDownloader,并适配新的进度处理器调用方式 |
| PCL.Mac.Core/Task/MinecraftInstallTask.swift | 相关下载迁移到 FileDownloader;并发/进度处理调用调整 |
| PCL.Mac.Core/Task/JavaInstallTask.swift | 多文件下载迁移到 FileDownloader |
| PCL.Mac.Core/Services/ForgeInstallService.swift | 安装器与依赖下载迁移到 FileDownloader;参数解析改动 |
| PCL.Mac.Core/Services/Download/Source/DownloadSourceManager.swift | 新增:下载源策略与候选排序管理 |
| PCL.Mac.Core/Services/Download/Source/DownloadSource.swift | 新增:下载源协议、官方/镜像源实现与 URL 匹配辅助 |
| PCL.Mac.Core/Services/Download/FileDownloader.swift | 新增:统一下载器(单文件/批量下载、候选源与重试) |
| PCL.Mac.Core/Services/Download/DownloadSpeedManager.swift | 新增:下载速度统计管理器 |
| PCL.Mac.Core/Services/Download/DownloadItem.swift | 新增:DownloadItem 结构体(及遗留 ReplaceMethod 枚举) |
| PCL.Mac.Core/Services/Download/DownloadDelegate.swift | DownloadDelegate 公有化并新增 async start 包装;增强错误日志 |
| PCL.Mac.Core/Services/CurseForgeAPIClient.swift | semaphore.signal 改为 defer,避免异常路径泄漏信号量 |
| PCL.Mac.Core/Models/VersionManifest.swift | 版本清单 URL 改由 DownloadSourceManager 选择 |
| PCL.Mac.Core/Models/CurseForge/CurseForgeMod.swift | CurseForge 资源字段改为可选并自定义解码以容错 |
| PCL.Mac.Core/Extensions/Compatibility.swift | 轻微类型推断/声明简化 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
本 PR 将
SingleFileDownloader与MultiFileDownloader合并为统一的FileDownloader,并添加了DownloadSource和DownloadSourceManager用于统一管理下载源选择策略。closes #198