Skip to content

refactor: 重构下载器并引入镜像源#214

Merged
AnemoFlower merged 7 commits into
CylorineStudio:mainfrom
AnemoFlower:refactor/download
Jul 12, 2026
Merged

refactor: 重构下载器并引入镜像源#214
AnemoFlower merged 7 commits into
CylorineStudio:mainfrom
AnemoFlower:refactor/download

Conversation

@AnemoFlower

@AnemoFlower AnemoFlower commented Jul 7, 2026

Copy link
Copy Markdown
Member

本 PR 将 SingleFileDownloaderMultiFileDownloader 合并为统一的 FileDownloader,并添加了 DownloadSourceDownloadSourceManager 用于统一管理下载源选择策略。

closes #198

@AnemoFlower
AnemoFlower marked this pull request as draft July 7, 2026 11:00
@AnemoFlower
AnemoFlower marked this pull request as ready for review July 10, 2026 08:09
@AnemoFlower
AnemoFlower requested a review from Copilot July 10, 2026 08:09

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 轻微类型推断/声明简化

Comment thread PCL.Mac.Core/Services/Download/Source/DownloadSourceManager.swift
Comment thread PCL.Mac.Core/Services/Download/FileDownloader.swift
Comment thread PCL.Mac/App/AppDelegate.swift
Comment thread PCL.Mac/App/AppDelegate.swift
Comment thread PCL.Mac/Components/MySelect.swift Outdated
@AnemoFlower
AnemoFlower merged commit c5117de into CylorineStudio:main Jul 12, 2026
1 check passed
@AnemoFlower
AnemoFlower deleted the refactor/download branch July 12, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] 为文件下载添加镜像源

2 participants