mirror of
https://github.com/dream-pep/koring-launcher.git
synced 2026-09-12 05:45:18 +08:00
fix(updater): 为跑步者beta通道添加稳定版更新探测
修复electron-updater的semver版本判断逻辑错误,当跑步者beta通道无可用更新时,自动探测最新稳定版,检查完成后恢复原通道配置。
This commit is contained in:
+36
-1
@@ -482,7 +482,15 @@ class UpdateService {
|
||||
this.suppressErrors = false;
|
||||
// 复核 electron-updater 的纯 semver 判定(v1.2.5-17 误判 v1.2.5-beta.16 为新版本)
|
||||
this.correctAvailability();
|
||||
return this.buildPayload();
|
||||
const githubResult = this.buildPayload();
|
||||
// runner(跑步)beta 无更新 → 探测最新正式版:
|
||||
// 构建号比当前 beta 大(如 beta.24 → 正式 1.2.6-25)也算更新,只是 GitHub beta 频道
|
||||
// 不返回正式版、且纯 semver 认为 beta.N > N,需切 stable 通道再查一次
|
||||
if (githubResult.state === 'not-available' && this.channelKey === 'runner') {
|
||||
const probe = await this.probeLatestStable();
|
||||
if (probe === 'available') return this.buildPayload();
|
||||
}
|
||||
return githubResult;
|
||||
} catch (err) {
|
||||
log.warn(`[updater] GitHub 官方更新源不可用: ${String((err as Error)?.message ?? err)}`);
|
||||
}
|
||||
@@ -522,6 +530,33 @@ class UpdateService {
|
||||
return this.buildPayload();
|
||||
}
|
||||
|
||||
/**
|
||||
* runner(跑步)beta 无更新时的"最新正式版"探测:
|
||||
* 临时切 stable 通道(allowPrerelease=false / channel=latest,天然开启 allowDowngrade,
|
||||
* 使 semver 判定接受"看似更低"的正式版),再查一次;命中后按项目版本序复核
|
||||
* (构建号更大 → available;否则还原为无更新)。结束后恢复通道配置。
|
||||
*/
|
||||
private async probeLatestStable(): Promise<'available' | 'not-available' | 'failed'> {
|
||||
try {
|
||||
autoUpdater.allowPrerelease = false;
|
||||
autoUpdater.channel = 'latest';
|
||||
this.state = 'checking';
|
||||
this.emit();
|
||||
log.info('[updater] runner beta 无更新,探测最新正式版...');
|
||||
await autoUpdater.checkForUpdates();
|
||||
// 项目版本序复核:构建号大于当前才算更新(beta.24 → 正式 25 是更新;25 → 26 是更新)
|
||||
this.correctAvailability();
|
||||
const probeResult = this.buildPayload();
|
||||
return probeResult.state === 'available' ? 'available' : 'not-available';
|
||||
} catch (e) {
|
||||
log.warn(`[updater] 正式版探测失败: ${String((e as Error)?.message ?? e)}`);
|
||||
return 'failed';
|
||||
} finally {
|
||||
// 还原 runner 通道配置(allowPrerelease=true / channel=beta)
|
||||
this.applyChannel();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过加速源发现最新 release tag:
|
||||
* 1) /releases/latest 页面 HTML 中提取 tag(多数下载型加速源可代理该页面;
|
||||
|
||||
Reference in New Issue
Block a user