fix: 实例版本比较可能会返回错误的结果#207
Open
AnemoFlower wants to merge 9 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
本 PR 以重构 MinecraftVersion 的比较逻辑为核心,同时将版本清单(VersionManifest)的加载与缓存逻辑集中到 VersionManifest.load/VersionManifest.shared,并移除 CoreState 作为全局状态容器,从而让版本信息在 Core 与 App 两侧的使用更统一。
Changes:
- 重写
MinecraftVersion的比较逻辑:优先按清单releaseTime比较,缺失时回退到字符串 numeric 比较。 - 新增
VersionManifest.shared与VersionManifest.load(...),并用versionMap加速version(for:)查找;同步替换多处对CoreState.versionManifest的引用。 - 实例加载链路异步化(
MinecraftInstanceLoader.load→async,仓库加载相应改为await),并在InstanceManager启动加载前确保版本清单可用。
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| PCL.Mac/Views/Download/MinecraftDownloadPage.swift | 移除页面 onAppear 触发的刷新逻辑(依赖 ViewModel/全局清单状态)。 |
| PCL.Mac/ViewModels/ResourceInstallViewModel.swift | 使用 VersionManifest.shared 判断版本类型以筛选资源适配版本。 |
| PCL.Mac/ViewModels/MinecraftDownloadPageViewModel.swift | 引入 @MainActor 与基于 VersionManifest.load/shared 的加载与状态更新。 |
| PCL.Mac/Models/ProjectListItemModel.swift | 使用 VersionManifest.shared 生成游戏版本支持描述与“最新版本”判断。 |
| PCL.Mac/App/AppDelegate.swift | 启动时从缓存恢复版本清单到 VersionManifest.shared,并异步拉取最新清单。 |
| PCL.Mac.Core/Task/MinecraftInstallTask.swift | 安装任务从 VersionManifest.shared 获取版本清单。 |
| PCL.Mac.Core/Services/MinecraftInstanceLoader.swift | 实例加载改为 async,并增强版本探测回退逻辑。 |
| PCL.Mac.Core/Models/VersionManifest.swift | 新增 shared、versionMap 与 load(...) 集中加载/缓存逻辑。 |
| PCL.Mac.Core/Models/CoreState.swift | 删除 CoreState 全局状态容器。 |
| PCL.Mac.Core/Minecraft/MinecraftVersion.swift | 移除 index,改为按 releaseTime/numeric 字符串比较实现 Comparable。 |
| PCL.Mac.Core/Minecraft/MinecraftRepository.swift | 并发加载实例时适配 await MinecraftInstanceLoader.load(...)。 |
| PCL.Mac.Core/Managers/InstanceManager.swift | 在后台加载仓库前确保版本清单已加载(必要时调用 VersionManifest.load())。 |
|
|
||
| /// https://zh.minecraft.wiki/w/Version_manifest.json#JSON格式 | ||
| public struct VersionManifest: Decodable, Equatable { | ||
| public static var shared: VersionManifest! |
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.
closes #206