fix: 简化检测更新 API 返回数据,移除 files 字段

- 移除 ZIP 包内文件列表的返回,客户端只需要补丁包/完整包信息
- 返回数据更简洁:download_url, file_size, file_hash, patch_url 等

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-03 03:47:21 +08:00
parent 0d60037e4e
commit 8b887f432b
+9 -30
View File
@@ -99,21 +99,15 @@ func handleAppCheckUpdate(c *gin.Context) {
if clientVersion == "" { if clientVersion == "" {
latestVersion := &allVersions[0] latestVersion := &allVersions[0]
// 构建文件列表
files := make([]map[string]interface{}, len(latestVersion.Files))
for i, f := range latestVersion.Files {
files[i] = map[string]interface{}{
"file_path": f.FilePath,
"file_name": f.FileName,
"file_size": f.FileSize,
"file_hash": f.FileHash,
"file_type": f.FileType,
"is_required": f.IsRequired,
}
}
// 确定下载地址:优先使用自定义地址 // 确定下载地址:优先使用自定义地址
downloadURL := latestVersion.FilePath downloadURL := latestVersion.FilePath
downloadSize := latestVersion.FileSize
downloadHash := latestVersion.FileHash
if latestVersion.FullPackagePath != "" {
downloadURL = latestVersion.FullPackagePath
downloadSize = latestVersion.FullPackageSize
downloadHash = latestVersion.FullPackageHash
}
if latestVersion.CustomDownloadURL != "" { if latestVersion.CustomDownloadURL != "" {
downloadURL = latestVersion.CustomDownloadURL downloadURL = latestVersion.CustomDownloadURL
} }
@@ -122,15 +116,14 @@ func handleAppCheckUpdate(c *gin.Context) {
"has_update": true, "has_update": true,
"latest_version": latestVersion.Version, "latest_version": latestVersion.Version,
"download_url": downloadURL, "download_url": downloadURL,
"file_size": latestVersion.FileSize, "file_size": downloadSize,
"file_hash": latestVersion.FileHash, "file_hash": downloadHash,
"entry_file": latestVersion.EntryFile, "entry_file": latestVersion.EntryFile,
"update_notes": latestVersion.Description, "update_notes": latestVersion.Description,
"update_strategy": latestVersion.UpdateStrategy, "update_strategy": latestVersion.UpdateStrategy,
"update_type": latestVersion.UpdateType, "update_type": latestVersion.UpdateType,
"update_method": latestVersion.UpdateMethod, "update_method": latestVersion.UpdateMethod,
"changelog": latestVersion.Changelog, "changelog": latestVersion.Changelog,
"files": files,
}) })
return return
} }
@@ -203,19 +196,6 @@ func handleAppCheckUpdate(c *gin.Context) {
} }
} }
// 构建文件列表
files := make([]map[string]interface{}, len(latestVersion.Files))
for i, f := range latestVersion.Files {
files[i] = map[string]interface{}{
"file_path": f.FilePath,
"file_name": f.FileName,
"file_size": f.FileSize,
"file_hash": f.FileHash,
"file_type": f.FileType,
"is_required": f.IsRequired,
}
}
// 确定下载地址 // 确定下载地址
var downloadURL string var downloadURL string
var downloadSize int64 var downloadSize int64
@@ -285,7 +265,6 @@ func handleAppCheckUpdate(c *gin.Context) {
"update_type": latestVersion.UpdateType, "update_type": latestVersion.UpdateType,
"update_method": latestVersion.UpdateMethod, "update_method": latestVersion.UpdateMethod,
"changelog": latestVersion.Changelog, "changelog": latestVersion.Changelog,
"files": files,
} }
// 如果是补丁更新,添加补丁信息 // 如果是补丁更新,添加补丁信息