Merged
Conversation
回来了回来了(
There was a problem hiding this comment.
Pull request overview
本 PR 在下载/安装链路中新增“安装选项”页面与 Mod Loader 安装能力,使启动器可以在创建实例时选择 Fabric / Forge,并支持加载 Modded(inheritsFrom)实例清单。
Changes:
- 新增 Minecraft 安装选项页与对应 ViewModel,提供实例命名与 Fabric/Forge 版本选择后再开始安装
- Core 安装任务扩展:引入 ModLoader 抽象、Fabric Profile 合并、Forge 安装器执行与清单合并/修正
- 重构部分 UI 组件(MyTextField/MyList/MyCard 等)与实例管理对象(InstanceViewModel → InstanceManager 单例)
Reviewed changes
Copilot reviewed 39 out of 41 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| PCL.Mac/Views/MessageBoxView.swift | 适配新的 MyList / MyTextField API |
| PCL.Mac/Views/Launch/LaunchSidebar.swift | EnvironmentObject 改为 InstanceManager |
| PCL.Mac/Views/Launch/LaunchPage.swift | 适配 MyList 新初始化方式 |
| PCL.Mac/Views/Launch/InstanceSettings/InstanceConfigPage.swift | JVM 内存输入改为 Binding 文本输入并同步配置 |
| PCL.Mac/Views/Launch/InstanceList/InstanceListSidebar.swift | EnvironmentObject 改为 InstanceManager |
| PCL.Mac/Views/Launch/InstanceList/InstanceListPage.swift | EnvironmentObject 改为 InstanceManager;错误实例展示条件优化 |
| PCL.Mac/Views/Download/MinecraftInstallOptionsPage.swift | 新增:安装选项页(命名 + Fabric/Forge 选择 + 开始下载) |
| PCL.Mac/Views/Download/MinecraftDownloadPage.swift | 点击版本后跳转到安装选项页 |
| PCL.Mac/ViewModels/MinecraftInstallOptionsViewModel.swift | 新增:安装选项状态与实例名校验逻辑 |
| PCL.Mac/ViewModels/InstanceManager.swift | InstanceViewModel 重命名并改为 shared 单例注入 |
| PCL.Mac/Extensions/Frontend.swift | SubTaskState 图标映射调整 |
| PCL.Mac/Extensions/Environments.swift | 新增:MyCard 相关环境值(index/禁用动画) |
| PCL.Mac/Components/MyTip.swift | 新增:提示条组件 |
| PCL.Mac/Components/MyTextField.swift | 改为 Binding 驱动,移除旧的立即提交/数值解析构造器 |
| PCL.Mac/Components/MyListItem.swift | 选中样式细节调整 |
| PCL.Mac/Components/MyList.swift | onSelect 支持取消选择;改为 LazyVStack |
| PCL.Mac/Components/MyExtraTextButton.swift | 新增:底部“开始下载”胶囊按钮组件 |
| PCL.Mac/Components/MyCard.swift | 支持禁用出现/悬停动画与初始折叠状态参数 |
| PCL.Mac/Assets.xcassets/VersionIcons/Forge.imageset/Forge.png | 新增 Forge 图标资源 |
| PCL.Mac/Assets.xcassets/VersionIcons/Forge.imageset/Contents.json | 新增 Forge 图标资源描述 |
| PCL.Mac/Assets.xcassets/VersionIcons/Fabric.imageset/Fabric.png | 新增 Fabric 图标资源 |
| PCL.Mac/Assets.xcassets/VersionIcons/Fabric.imageset/Contents.json | 新增 Fabric 图标资源描述 |
| PCL.Mac/App/AppWindow.swift | 注入 InstanceManager.shared 替代旧 ViewModel |
| PCL.Mac/App/AppRouter.swift | 新增路由 minecraftInstallOptions(version:) 并接入页面 |
| PCL.Mac.xcodeproj/project.pbxproj | 工程设置调整(移除 GCSupportsGameMode) |
| PCL.Mac.Core/Utils/Utils.swift | 新增:通用字符串模板替换工具 |
| PCL.Mac.Core/Utils/MavenCoordinateUtils.swift | 支持 @packaging,生成非 jar 的下载路径 |
| PCL.Mac.Core/Utils/JarUtils.swift | 新增:从 jar manifest 读取 Main-Class |
| PCL.Mac.Core/Utils/Errors.swift | 新增 MinecraftError.incomplete 用于未完成安装实例 |
| PCL.Mac.Core/Utils/ConcurrentProgressHandler.swift | 新增:并发子任务进度聚合器 |
| PCL.Mac.Core/Task/MyTask.swift | 增加 failureHandler 并在失败时回调 |
| PCL.Mac.Core/Task/MinecraftInstallTask.swift | 安装任务扩展:.incomplete 标记、Fabric/Forge 安装、并发进度计算等 |
| PCL.Mac.Core/Services/MicrosoftAuthService.swift | 错误日志补充 statusCode |
| PCL.Mac.Core/Services/ForgeInstallService.swift | 新增:Forge 安装器下载/依赖处理/processor 执行 |
| PCL.Mac.Core/Models/VersionManifest.swift | Version 增加 Hashable 以支持路由存储 |
| PCL.Mac.Core/Models/ForgeInstallProfile.swift | 新增:Forge install_profile.json 模型 |
| PCL.Mac.Core/Models/ClientManifest.swift | 支持 modded 清单 merge、parent 清单加载、非标准字段等 |
| PCL.Mac.Core/Minecraft/ModLoader.swift | 新增:ModLoader 枚举(fabric/forge) |
| PCL.Mac.Core/Minecraft/MinecraftRepository.swift | 遇到 incomplete 实例时自动删除处理 |
| PCL.Mac.Core/Minecraft/MinecraftInstance.swift | 支持 .incomplete 与 modded 清单加载/版本回退逻辑 |
| PCL.Mac.Core/Minecraft/Launch/MinecraftLauncher.swift | version_name 取实例目录名;替换参数逻辑复用 Utils.replace |
Comments suppressed due to low confidence (2)
PCL.Mac.Core/Task/MinecraftInstallTask.swift:45
- 安装任务里新增的
__pre子任务与“下载客户端 JSON 文件”都使用了ordinal == 0。在MyTask的实现中,同一ordinal的子任务会并发执行,因此这里可能出现目录尚未创建就开始下载/写入 JSON 的竞态,导致安装不稳定。建议把__pre放到更小的独立 ordinal(例如把后续任务整体 +1),或把目录创建逻辑合并到下载前的同一个子任务中。
var subTasks: [SubTask] = [
.init(0, "__pre", display: false) { _, model in
try FileManager.default.createDirectory(at: model.runningDirectory, withIntermediateDirectories: true)
FileManager.default.createFile(atPath: model.runningDirectory.appending(path: ".incomplete").path, contents: nil)
},
.init(0, "下载客户端 JSON 文件") { task, model in
guard let versionManifest = CoreState.versionManifest else {
err("CoreState.versionManifest 为空")
throw TaskError.unknownError
}
PCL.Mac.Core/Minecraft/Launch/MinecraftLauncher.swift:37
MinecraftLauncher初始化时直接读取manifest.assetIndex.id。结合ClientManifest目前对assetIndex使用decodeIfPresent的实现,这里在遇到缺少assetIndex的非标准清单时会直接触发运行时崩溃。建议在这里guard let assetIndex = manifest.assetIndex else { throw ... }并给出可理解的错误信息,或在加载清单阶段就阻止这种实例进入可启动状态。
"auth_player_name": options.profile.name,
"version_name": options.runningDirectory.lastPathComponent,
"game_directory": runningDirectory.path,
"assets_root": librariesURL.deletingLastPathComponent().appending(path: "assets").path,
"assets_index_name": manifest.assetIndex.id,
"auth_uuid": UUIDUtils.string(of: options.profile.id, withHyphens: false),
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 添加了 Mod Loader 安装功能,支持加载 Modded 实例与安装 Fabric/Forge/
NeoForge。closes #62