feat(download): 快速下载资源#3240
Conversation
审阅者指南(Reviewer's Guide)为搜索结果卡片中的兼容资源文件实现可配置的快捷下载流程:在卡片 UI 中接入新的操作按钮,将兼容性/最新文件选择逻辑集中处理,并在游戏管理配置和本地化中暴露相关行为设置。 资源卡片快捷下载时序图sequenceDiagram
actor User
participant MyCompItem
participant ModComp
participant ModInstanceList
participant ModLoader
User->>MyCompItem: BtnDownload_Click
MyCompItem->>ModComp: QuickDownload(project)
activate ModComp
ModComp->>ModComp: CompFilesGet(project.Id, project.FromCurseForge)
ModComp->>ModComp: files.Where(f => f.Available)
ModComp-->>User: HintService.Hint(Loading)
ModComp->>Config: read QuickDownloadBehavior
alt behavior == 0
ModComp->>ModMain: MyMsgBoxSelect(options)
ModMain-->>ModComp: choice
end
alt behavior == 1 (current instance)
ModComp->>ModInstanceList: McMcInstanceSelected
ModComp->>ModComp: QuickDownloadToInstance(project, files, instance)
ModComp->>ModComp: IsInstanceSuitableForFile(instance, file, ResolveLoaders(file, project))
ModComp->>ModComp: PickLatestFile(compatible)
ModComp->>ModComp: StartQuickDownload(file, target)
else behavior == 2 (pick instance)
ModComp->>ModComp: QuickDownloadPickInstance(project, files)
ModComp->>ModInstanceList: mcInstanceListLoader / mcInstanceList
ModComp->>ModMain: MyMsgBoxSelect(options)
ModMain-->>ModComp: selected instance
ModComp->>ModComp: QuickDownloadToInstance(project, files, instance)
ModComp->>ModComp: StartQuickDownload(file, target)
else behavior == 3 (pick folder)
ModComp->>SystemDialogs: SelectFolder()
SystemDialogs-->>ModComp: saveFolder
ModComp->>ModComp: QuickDownloadToFolder(project, files)
ModComp->>ModComp: PickLatestFile(files)
ModComp->>ModComp: StartQuickDownload(file, target)
end
ModComp->>ModLoader: new LoaderDownload(...)
ModLoader-->>ModComp: loader
ModComp->>ModLoader: loader.Start(1)
ModComp-->>User: HintService.Hint(DownloadStarted)
deactivate ModComp
文件级变更(File-Level Changes)
与关联 issue 的对照评估(Assessment against linked issues)
可能相关的 issue(Possibly linked issues)
提示与命令(Tips and commands)与 Sourcery 交互(Interacting with Sourcery)
自定义你的体验(Customizing Your Experience)访问你的 仪表盘 以:
获取帮助(Getting Help)Original review guide in EnglishReviewer's GuideImplements a configurable quick-download workflow for compatible resource files from search result cards, wiring a new action button into the card UI, centralizing compatibility/latest-file selection logic, and exposing behavior settings in the game management configuration and localization. Sequence diagram for quick download from resource cardsequenceDiagram
actor User
participant MyCompItem
participant ModComp
participant ModInstanceList
participant ModLoader
User->>MyCompItem: BtnDownload_Click
MyCompItem->>ModComp: QuickDownload(project)
activate ModComp
ModComp->>ModComp: CompFilesGet(project.Id, project.FromCurseForge)
ModComp->>ModComp: files.Where(f => f.Available)
ModComp-->>User: HintService.Hint(Loading)
ModComp->>Config: read QuickDownloadBehavior
alt behavior == 0
ModComp->>ModMain: MyMsgBoxSelect(options)
ModMain-->>ModComp: choice
end
alt behavior == 1 (current instance)
ModComp->>ModInstanceList: McMcInstanceSelected
ModComp->>ModComp: QuickDownloadToInstance(project, files, instance)
ModComp->>ModComp: IsInstanceSuitableForFile(instance, file, ResolveLoaders(file, project))
ModComp->>ModComp: PickLatestFile(compatible)
ModComp->>ModComp: StartQuickDownload(file, target)
else behavior == 2 (pick instance)
ModComp->>ModComp: QuickDownloadPickInstance(project, files)
ModComp->>ModInstanceList: mcInstanceListLoader / mcInstanceList
ModComp->>ModMain: MyMsgBoxSelect(options)
ModMain-->>ModComp: selected instance
ModComp->>ModComp: QuickDownloadToInstance(project, files, instance)
ModComp->>ModComp: StartQuickDownload(file, target)
else behavior == 3 (pick folder)
ModComp->>SystemDialogs: SelectFolder()
SystemDialogs-->>ModComp: saveFolder
ModComp->>ModComp: QuickDownloadToFolder(project, files)
ModComp->>ModComp: PickLatestFile(files)
ModComp->>ModComp: StartQuickDownload(file, target)
end
ModComp->>ModLoader: new LoaderDownload(...)
ModLoader-->>ModComp: loader
ModComp->>ModLoader: loader.Start(1)
ModComp-->>User: HintService.Hint(DownloadStarted)
deactivate ModComp
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - 我在这里给出了一些整体层面的反馈:
- 在
QuickDownloadPickInstance中,IsInstanceSuitableForFile可能会对每个实例重复调用Load(),同时你也可能在其他地方加载实例;建议考虑在前面统一加载实例,或者缓存加载结果,以避免在每次兼容性检查时重复加载。 IsInstanceSuitableForFile中的兼容性逻辑似乎与详细下载流程 (Save_Click/isVersionSuitable) 中的现有逻辑相似;将这部分逻辑提取到一个共享的辅助方法中,可以减少重复代码,也能降低两个流程随时间产生差异的风险。PickLatestFile方法接收一个可选的compatFilter参数,但在这个 PR 中从未使用;为了保持 API 一致性,要么移除该参数以简化接口,要么在当前预先过滤兼容文件的地方开始使用它。
供 AI 代理使用的提示
Please address the comments from this code review:
## Overall Comments
- In `QuickDownloadPickInstance`, `IsInstanceSuitableForFile` may call `Load()` on each instance repeatedly while you also potentially load instances elsewhere; consider ensuring instances are loaded once up front or caching the result to avoid repeated loading on every compatibility check.
- The compatibility logic in `IsInstanceSuitableForFile` appears to mirror existing logic from the detailed download flow (`Save_Click`/`isVersionSuitable`); extracting this into a shared helper would reduce duplication and the risk of the two paths diverging over time.
- The `PickLatestFile` method accepts an optional `compatFilter` parameter that is never used in this PR; either remove the parameter for simplicity or start using it where you currently pre-filter compatible files to keep the API coherent.帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English
Hey - I've left some high level feedback:
- In
QuickDownloadPickInstance,IsInstanceSuitableForFilemay callLoad()on each instance repeatedly while you also potentially load instances elsewhere; consider ensuring instances are loaded once up front or caching the result to avoid repeated loading on every compatibility check. - The compatibility logic in
IsInstanceSuitableForFileappears to mirror existing logic from the detailed download flow (Save_Click/isVersionSuitable); extracting this into a shared helper would reduce duplication and the risk of the two paths diverging over time. - The
PickLatestFilemethod accepts an optionalcompatFilterparameter that is never used in this PR; either remove the parameter for simplicity or start using it where you currently pre-filter compatible files to keep the API coherent.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `QuickDownloadPickInstance`, `IsInstanceSuitableForFile` may call `Load()` on each instance repeatedly while you also potentially load instances elsewhere; consider ensuring instances are loaded once up front or caching the result to avoid repeated loading on every compatibility check.
- The compatibility logic in `IsInstanceSuitableForFile` appears to mirror existing logic from the detailed download flow (`Save_Click`/`isVersionSuitable`); extracting this into a shared helper would reduce duplication and the risk of the two paths diverging over time.
- The `PickLatestFile` method accepts an optional `compatFilter` parameter that is never used in this PR; either remove the parameter for simplicity or start using it where you currently pre-filter compatible files to keep the API coherent.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2866ce5dbf
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3f93102d18
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Co-authored-by: ChilovenBustiangle <116699482+Chiloven945@users.noreply.github.com>
Co-authored-by: ChilovenBustiangle <116699482+Chiloven945@users.noreply.github.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b86b6dd128
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
This PR closes #3221.
本 PR 在模组存档、数据包等页面的卡片信息右侧添加一个快捷下载按钮,允许通过点击此按钮快速下载资源。
Summary by Sourcery
为组件搜索结果卡片新增可配置的快速下载支持,包括实例/文件夹目标选择以及基于兼容性的集中式文件选取。
New Features:
Enhancements:
Original summary in English
Summary by Sourcery
Add configurable quick-download support for component search result cards, including instance/folder targeting and centralized compatibility-based file selection.
New Features:
Enhancements:
新功能:
增强改进:
Original summary in English
Summary by Sourcery
为组件搜索结果卡片新增可配置的快速下载支持,包括实例/文件夹目标选择以及基于兼容性的集中式文件选取。
New Features:
Enhancements:
Original summary in English
Summary by Sourcery
Add configurable quick-download support for component search result cards, including instance/folder targeting and centralized compatibility-based file selection.
New Features:
Enhancements: