diff --git a/backend/internal/router/app/info.go b/backend/internal/router/app/info.go index cd03ab0..081b8b6 100644 --- a/backend/internal/router/app/info.go +++ b/backend/internal/router/app/info.go @@ -87,12 +87,6 @@ func handleAppCheckUpdate(c *gin.Context) { return } - // 客户端必须提供版本号 - if clientVersion == "" { - response.Error(c, 400, "请提供客户端版本号") - return - } - // 清理版本号:去除空格和前缀 v/V cleanVersion := func(v string) string { v = strings.TrimSpace(v) @@ -100,6 +94,47 @@ func handleAppCheckUpdate(c *gin.Context) { v = strings.TrimPrefix(v, "V") return v } + + // 如果没有传入版本号,直接返回最新版本 + if clientVersion == "" { + 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 + if latestVersion.CustomDownloadURL != "" { + downloadURL = latestVersion.CustomDownloadURL + } + + response.Success(c, gin.H{ + "has_update": true, + "latest_version": latestVersion.Version, + "download_url": downloadURL, + "file_size": latestVersion.FileSize, + "file_hash": latestVersion.FileHash, + "entry_file": latestVersion.EntryFile, + "update_notes": latestVersion.Description, + "update_strategy": latestVersion.UpdateStrategy, + "update_type": latestVersion.UpdateType, + "update_method": latestVersion.UpdateMethod, + "changelog": latestVersion.Changelog, + "files": files, + }) + return + } + clientVersionClean := cleanVersion(clientVersion) // 找到客户端当前版本对应的版本记录