fix(更新检测): 版本比较改真实比大小——线上版本不高于本机一律不提示更新;本机高于线上时明确提示无需更新(灰度/回滚/漏发版场景不再被引导降级)
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
import { computed, ref } from 'vue'
|
||||
import { getPywebviewApi } from '@/shared/bridges/pywebview'
|
||||
import { compareVersions, normVersion } from '@/shared/utils/version-compare'
|
||||
import {
|
||||
normalizeUpdateProgress,
|
||||
type UpdateProgress,
|
||||
@@ -32,10 +33,6 @@ function bindProgressListener() {
|
||||
})
|
||||
}
|
||||
|
||||
function normVersion(value: unknown): string {
|
||||
return String(value ?? '').trim().replace(/^[vV]/, '')
|
||||
}
|
||||
|
||||
async function fetchJson(url: string): Promise<Record<string, unknown>> {
|
||||
const resp = await window.fetch(url, { credentials: 'same-origin' })
|
||||
if (!resp.ok) throw new Error(`HTTP ${resp.status}`)
|
||||
@@ -116,11 +113,16 @@ export function useVersionUpdate() {
|
||||
: `线上最新版本 v${latest.version},暂无下载地址`
|
||||
return
|
||||
}
|
||||
hasUpdate.value = local !== latest.version
|
||||
// 只有线上版本严格高于本机版本才算"有更新":本机领先(灰度/回滚/漏发版)
|
||||
// 时不能反过来提示更新,否则会把用户往低版本上引导。
|
||||
const diff = compareVersions(latest.version, local)
|
||||
hasUpdate.value = diff > 0
|
||||
canDownload.value = hasUpdate.value && Boolean(latest.fileUrl)
|
||||
hint.value = hasUpdate.value
|
||||
? `发现新版本 v${latest.version}${latest.fileUrl ? '' : ',暂无下载地址'}`
|
||||
: `已是最新版本 v${local}`
|
||||
: diff < 0
|
||||
? `当前版本 v${local} 高于线上发布版本 v${latest.version},无需更新`
|
||||
: `已是最新版本 v${local}`
|
||||
} catch {
|
||||
hasUpdate.value = false
|
||||
canDownload.value = false
|
||||
|
||||
Reference in New Issue
Block a user