Skip to content

fix: 实例版本比较可能会返回错误的结果#207

Open
AnemoFlower wants to merge 9 commits into
CylorineStudio:mainfrom
AnemoFlower:refactor/minecraft-version-comparing
Open

fix: 实例版本比较可能会返回错误的结果#207
AnemoFlower wants to merge 9 commits into
CylorineStudio:mainfrom
AnemoFlower:refactor/minecraft-version-comparing

Conversation

@AnemoFlower

@AnemoFlower AnemoFlower commented Jun 12, 2026

Copy link
Copy Markdown
Member

closes #206

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 以重构 MinecraftVersion 的比较逻辑为核心,同时将版本清单(VersionManifest)的加载与缓存逻辑集中到 VersionManifest.load/VersionManifest.shared,并移除 CoreState 作为全局状态容器,从而让版本信息在 Core 与 App 两侧的使用更统一。

Changes:

  • 重写 MinecraftVersion 的比较逻辑:优先按清单 releaseTime 比较,缺失时回退到字符串 numeric 比较。
  • 新增 VersionManifest.sharedVersionManifest.load(...),并用 versionMap 加速 version(for:) 查找;同步替换多处对 CoreState.versionManifest 的引用。
  • 实例加载链路异步化(MinecraftInstanceLoader.loadasync,仓库加载相应改为 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 新增 sharedversionMapload(...) 集中加载/缓存逻辑。
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())。

Comment thread PCL.Mac/ViewModels/MinecraftDownloadPageViewModel.swift
Comment thread PCL.Mac/ViewModels/MinecraftDownloadPageViewModel.swift Outdated
Comment thread PCL.Mac/ViewModels/ResourceInstallViewModel.swift Outdated
Comment thread PCL.Mac/ViewModels/ResourceInstallViewModel.swift Outdated
Comment thread PCL.Mac/Models/ProjectListItemModel.swift Outdated

/// https://zh.minecraft.wiki/w/Version_manifest.json#JSON格式
public struct VersionManifest: Decodable, Equatable {
public static var shared: VersionManifest!
Comment thread PCL.Mac.Core/Models/VersionManifest.swift
Comment thread PCL.Mac.Core/Minecraft/MinecraftVersion.swift
Comment thread PCL.Mac.Core/Minecraft/MinecraftVersion.swift
Comment thread PCL.Mac.Core/Task/MinecraftInstallTask.swift
@AnemoFlower AnemoFlower changed the title refactor: MinecraftVersion 比较逻辑 fix: 实例版本比较可能会返回错误的结果 Jun 12, 2026
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.

[Bug] 实例所需 Java 架构判断错误

2 participants