feat(ota): show short hash

This commit is contained in:
Jacky 2025-05-03 08:13:58 +08:00
parent 1c282a57ad
commit 3fe4d859df
No known key found for this signature in database
GPG key ID: 215C21B10DF38B4D
6 changed files with 34 additions and 18 deletions

View file

@ -7,6 +7,14 @@ export interface RuntimeInfo {
ex_path: string
body: string
published_at: string
cur_version: Info
}
interface Info {
version: string
build_id: number
total_build: number
short_hash: string
}
const upgrade = {

View file

@ -32,12 +32,13 @@ export function handleApiError(err: CosyError, dedupe: MessageDedupe) {
if (!errors[err.scope]) {
try {
// Dynamic import error files
import(/* @vite-ignore */ `@/constants/errors/${err.scope}.ts`)
import(`@/constants/errors/${err.scope}.ts`)
.then(error => {
registerError(err.scope!, error.default)
displayErrorMessage(err, dedupe)
})
.catch(() => {
.catch(err => {
console.error(err)
dedupe.error($gettext(err?.message ?? 'Server error'))
})
}

View file

@ -1 +1 @@
{"version":"2.0.0-rc.6","build_id":1,"total_build":417}
{"version":"2.0.0-rc.6","build_id":2,"total_build":418}

View file

@ -137,6 +137,15 @@ async function performUpgrade() {
}, 2000)
}
}
const performUpgradeBtnText = computed(() => {
if (channel.value === 'dev')
return $gettext('Install')
else if (isLatestVer.value)
return $gettext('Reinstall')
else
return $gettext('Upgrade')
})
</script>
<template>
@ -162,7 +171,7 @@ async function performUpgrade() {
</AModal>
<div class="upgrade-container">
<p>{{ $gettext('You can check Nginx UI upgrade at this page.') }}</p>
<h3>{{ $gettext('Current Version') }}: v{{ version.version }}</h3>
<h3>{{ $gettext('Current Version') }}: v{{ version.version }} <span class="short-hash">({{ data?.cur_version?.short_hash }})</span></h3>
<template v-if="getReleaseError">
<AAlert
type="error"
@ -200,7 +209,7 @@ async function performUpgrade() {
</AFormItem>
<template v-if="!loading">
<AAlert
v-if="isLatestVer"
v-if="isLatestVer && channel !== 'dev'"
type="success"
:message="$gettext('You are using the latest version')"
banner
@ -226,7 +235,7 @@ async function performUpgrade() {
ghost
@click="performUpgrade"
>
{{ isLatestVer ? $gettext('Reinstall') : $gettext('Upgrade') }}
{{ performUpgradeBtnText }}
</AButton>
</ASpace>
</div>