fix: version display and comparison issues
- Remove duplicate 'v' prefix in version display - Add version string cleanup (trim spaces, remove v/V prefix) - Use custom download URL when set - Fix has_update logic for same version comparison Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"verification-platform-backend/internal/database"
|
"verification-platform-backend/internal/database"
|
||||||
"verification-platform-backend/internal/model"
|
"verification-platform-backend/internal/model"
|
||||||
"verification-platform-backend/internal/service"
|
"verification-platform-backend/internal/service"
|
||||||
@@ -92,10 +93,19 @@ func handleAppCheckUpdate(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 清理版本号:去除空格和前缀 v/V
|
||||||
|
cleanVersion := func(v string) string {
|
||||||
|
v = strings.TrimSpace(v)
|
||||||
|
v = strings.TrimPrefix(v, "v")
|
||||||
|
v = strings.TrimPrefix(v, "V")
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
clientVersionClean := cleanVersion(clientVersion)
|
||||||
|
|
||||||
// 找到客户端当前版本对应的版本记录
|
// 找到客户端当前版本对应的版本记录
|
||||||
var clientVersionRecord *model.Version
|
var clientVersionRecord *model.Version
|
||||||
for i := range allVersions {
|
for i := range allVersions {
|
||||||
if allVersions[i].Version == clientVersion {
|
if cleanVersion(allVersions[i].Version) == clientVersionClean {
|
||||||
clientVersionRecord = &allVersions[i]
|
clientVersionRecord = &allVersions[i]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -171,12 +181,18 @@ func handleAppCheckUpdate(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 确定下载地址:优先使用自定义地址
|
||||||
|
downloadURL := latestVersion.FilePath
|
||||||
|
if latestVersion.CustomDownloadURL != "" {
|
||||||
|
downloadURL = latestVersion.CustomDownloadURL
|
||||||
|
}
|
||||||
|
|
||||||
// 构建返回结果
|
// 构建返回结果
|
||||||
result := map[string]interface{}{
|
result := map[string]interface{}{
|
||||||
"has_update": true,
|
"has_update": true,
|
||||||
"current_version": clientVersion,
|
"current_version": clientVersion,
|
||||||
"latest_version": latestVersion.Version,
|
"latest_version": latestVersion.Version,
|
||||||
"download_url": latestVersion.FilePath,
|
"download_url": downloadURL,
|
||||||
"file_size": latestVersion.FileSize,
|
"file_size": latestVersion.FileSize,
|
||||||
"file_hash": latestVersion.FileHash,
|
"file_hash": latestVersion.FileHash,
|
||||||
"entry_file": latestVersion.EntryFile,
|
"entry_file": latestVersion.EntryFile,
|
||||||
|
|||||||
@@ -29,7 +29,10 @@ export function getColumns(options: ColumnOptions, t: (key: string) => string):
|
|||||||
accessorKey: 'version',
|
accessorKey: 'version',
|
||||||
header: () => t('admin.versions.columns.version'),
|
header: () => t('admin.versions.columns.version'),
|
||||||
cell: ({ row }) => {
|
cell: ({ row }) => {
|
||||||
return h('code', { class: 'text-sm bg-muted px-2 py-1 rounded' }, `v${row.original.version}`)
|
const version = row.original.version
|
||||||
|
// 如果版本号本身已经有 v 前缀,则不再添加
|
||||||
|
const displayVersion = version.startsWith('v') || version.startsWith('V') ? version : `v${version}`
|
||||||
|
return h('code', { class: 'text-sm bg-muted px-2 py-1 rounded' }, displayVersion)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user