mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 02:15:48 +02:00
feat(ota): show short hash
This commit is contained in:
parent
1c282a57ad
commit
3fe4d859df
6 changed files with 34 additions and 18 deletions
|
@ -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 = {
|
||||
|
|
|
@ -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'))
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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}
|
|
@ -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>
|
||||
|
|
|
@ -12,12 +12,7 @@ type RuntimeInfo struct {
|
|||
OS string `json:"os"`
|
||||
Arch string `json:"arch"`
|
||||
ExPath string `json:"ex_path"`
|
||||
}
|
||||
|
||||
type CurVersion struct {
|
||||
Version string `json:"version"`
|
||||
BuildID int `json:"build_id"`
|
||||
TotalBuild int `json:"total_build"`
|
||||
CurVersion *Info `json:"cur_version"`
|
||||
}
|
||||
|
||||
func GetRuntimeInfo() (r RuntimeInfo, err error) {
|
||||
|
@ -36,6 +31,7 @@ func GetRuntimeInfo() (r RuntimeInfo, err error) {
|
|||
OS: runtime.GOOS,
|
||||
Arch: runtime.GOARCH,
|
||||
ExPath: realPath,
|
||||
CurVersion: GetVersionInfo(),
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -11,6 +11,7 @@ type Info struct {
|
|||
Version string `json:"version"`
|
||||
BuildId int `json:"build_id"`
|
||||
TotalBuild int `json:"total_build"`
|
||||
ShortHash string `json:"short_hash"`
|
||||
}
|
||||
|
||||
var versionInfo *Info
|
||||
|
@ -21,6 +22,7 @@ func GetVersionInfo() *Info {
|
|||
Version: Version,
|
||||
BuildId: BuildId,
|
||||
TotalBuild: TotalBuild,
|
||||
ShortHash: GetShortHash(),
|
||||
}
|
||||
}
|
||||
return versionInfo
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue