Jacky 20 часов назад
Родитель
Сommit
3fe4d859df

+ 8 - 0
app/src/api/upgrade.ts

@@ -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 = {

+ 3 - 2
app/src/lib/http/error.ts

@@ -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
app/src/version.json

@@ -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}

+ 12 - 3
app/src/views/system/Upgrade.vue

@@ -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>

+ 8 - 12
internal/version/info.go

@@ -9,15 +9,10 @@ import (
 )
 
 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"`
+	OS         string `json:"os"`
+	Arch       string `json:"arch"`
+	ExPath     string `json:"ex_path"`
+	CurVersion *Info  `json:"cur_version"`
 }
 
 func GetRuntimeInfo() (r RuntimeInfo, err error) {
@@ -33,9 +28,10 @@ func GetRuntimeInfo() (r RuntimeInfo, err error) {
 	}
 
 	r = RuntimeInfo{
-		OS:     runtime.GOOS,
-		Arch:   runtime.GOARCH,
-		ExPath: realPath,
+		OS:         runtime.GOOS,
+		Arch:       runtime.GOARCH,
+		ExPath:     realPath,
+		CurVersion: GetVersionInfo(),
 	}
 
 	return

+ 2 - 0
internal/version/version.go

@@ -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