refactor: 重构 Mod Loader 合并安装提交部分 - #3498
Open
Pigeon0v0 wants to merge 3 commits into
Open
Conversation
Contributor
审阅者指南重构实例安装和下载安装流程中的模组加载器选择逻辑,使用强类型枚举来表示主加载器,并集中管理互斥加载器的清理逻辑,从而改进与 OptiFine 和 LiteLoader 的兼容性检查的正确性。 SelectModLoader 互斥逻辑流程图flowchart TD
A[SelectModLoader ModLoaderType loaderName] --> B{loaderName == Forge}
B -->|yes| B1[keep selectedForge]
B -->|no| B2[clear selectedForge]
A --> C{loaderName == NeoForge}
C -->|yes| C1[keep selectedNeoForge, selectedNeoForgeVersion]
C -->|no| C2[clear selectedNeoForge, selectedNeoForgeVersion]
A --> D{loaderName == Cleanroom}
D -->|yes| D1[keep selectedCleanroom, selectedCleanroomVersion]
D -->|no| D2[clear selectedCleanroom, selectedCleanroomVersion]
A --> E{loaderName == Fabric}
E -->|yes| E1[keep Fabric components]
E -->|no| E2[clear selectedFabric, selectedFabricApi, selectedOptiFabric, autoSelectedFabricApi, autoSelectedOptiFabric]
A --> F{loaderName == LegacyFabric}
F -->|yes| F1[keep LegacyFabric components]
F -->|no| F2[clear selectedLegacyFabric, selectedLegacyFabricApi, autoSelectedLegacyFabricApi]
A --> G{loaderName == LabyMod}
G -->|yes| G1[keep LabyMod components]
G -->|no| G2[clear selectedLabyModChannel, selectedLabyModCommitRef, selectedLabyModVersion]
A --> H[set selectedLoaderName = loaderName]
H --> I[set selectedAPIName = null]
文件级变更
技巧与命令与 Sourcery 交互
自定义你的体验在你的 dashboard 中可以:
获取帮助Original review guide in EnglishReviewer's GuideRefactors Mod Loader selection in instance and download install flows to use a strongly-typed enum for the main loader and centralizes mutually-exclusive loader clearing logic, improving correctness of compatibility checks with OptiFine and LiteLoader. Flow diagram for SelectModLoader mutual-exclusion logicflowchart TD
A[SelectModLoader ModLoaderType loaderName] --> B{loaderName == Forge}
B -->|yes| B1[keep selectedForge]
B -->|no| B2[clear selectedForge]
A --> C{loaderName == NeoForge}
C -->|yes| C1[keep selectedNeoForge, selectedNeoForgeVersion]
C -->|no| C2[clear selectedNeoForge, selectedNeoForgeVersion]
A --> D{loaderName == Cleanroom}
D -->|yes| D1[keep selectedCleanroom, selectedCleanroomVersion]
D -->|no| D2[clear selectedCleanroom, selectedCleanroomVersion]
A --> E{loaderName == Fabric}
E -->|yes| E1[keep Fabric components]
E -->|no| E2[clear selectedFabric, selectedFabricApi, selectedOptiFabric, autoSelectedFabricApi, autoSelectedOptiFabric]
A --> F{loaderName == LegacyFabric}
F -->|yes| F1[keep LegacyFabric components]
F -->|no| F2[clear selectedLegacyFabric, selectedLegacyFabricApi, autoSelectedLegacyFabricApi]
A --> G{loaderName == LabyMod}
G -->|yes| G1[keep LabyMod components]
G -->|no| G2[clear selectedLabyModChannel, selectedLabyModCommitRef, selectedLabyModVersion]
A --> H[set selectedLoaderName = loaderName]
H --> I[set selectedAPIName = null]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey - 我留下了一些总体反馈:
- PageInstanceInstall 中新增的 SelectModLoader 辅助函数很好地集中处理了互斥逻辑;建议在 PageDownloadInstall 中也引入一个类似的辅助函数,以保持两个流程中加载器选择/清除行为的一致性。
- 既然 selectedLoaderName 现在保存的是 ModLoaderType 枚举值,可以考虑重命名(例如改为 selectedLoaderType),以更好地体现它的用途,并避免与之前基于字符串的旧用法混淆。
- SelectModLoader 当前使用了一长串 if 语句;将其改为 switch 表达式或基于表驱动的方式,可能会让以后新增加载器类型时的维护更轻松。
给 AI 代理的提示
Please address the comments from this code review:
## Overall Comments
- PageInstanceInstall 中新增的 SelectModLoader 辅助函数很好地集中处理了互斥逻辑;建议在 PageDownloadInstall 中也引入一个类似的辅助函数,以保持两个流程中加载器选择/清除行为的一致性。
- 既然 selectedLoaderName 现在保存的是 ModLoaderType 枚举值,可以考虑重命名(例如改为 selectedLoaderType),以更好地体现它的用途,并避免与之前基于字符串的旧用法混淆。
- SelectModLoader 当前使用了一长串 if 语句;将其改为 switch 表达式或基于表驱动的方式,可能会让以后新增加载器类型时的维护更轻松。帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的代码审查。
Original comment in English
Hey - I've left some high level feedback:
- The new SelectModLoader helper in PageInstanceInstall centralizes mutual‑exclusion logic nicely; consider introducing a similar helper in PageDownloadInstall to keep loader selection/clearing behavior consistent between the two flows.
- Now that selectedLoaderName holds a ModLoaderType enum, you might want to rename it (e.g., selectedLoaderType) to better reflect its purpose and avoid confusion with the legacy string-based usage.
- SelectModLoader currently uses a long chain of if statements; converting this to a switch expression or table-driven approach could make future additions of new loader types easier to maintain.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new SelectModLoader helper in PageInstanceInstall centralizes mutual‑exclusion logic nicely; consider introducing a similar helper in PageDownloadInstall to keep loader selection/clearing behavior consistent between the two flows.
- Now that selectedLoaderName holds a ModLoaderType enum, you might want to rename it (e.g., selectedLoaderType) to better reflect its purpose and avoid confusion with the legacy string-based usage.
- SelectModLoader currently uses a long chain of if statements; converting this to a switch expression or table-driven approach could make future additions of new loader types easier to maintain.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
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.
Summary by Sourcery
在安装流程中重构模组加载器的选择逻辑,引入专用枚举并集中处理互斥的加载器。
增强内容:
ModLoaderType枚举,用于表示在实例安装过程中使用的主要、互斥的模组加载器。ModLoaderType跟踪所选的主要模组加载器,而不是使用原始字符串。Original summary in English
Summary by Sourcery
Refactor mod loader selection in the install flows to use a dedicated enum and centralize mutually exclusive loader handling.
Enhancements: