From de0de10b8d5e13ca1f6b9b8d886b9e291faabb06 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 8 May 2026 23:17:53 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4min=5Fversion/bas?= =?UTF-8?q?e=5Fversion=5Fid=EF=BC=8C=E5=90=8E=E7=AB=AF=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E7=A1=AE=E5=AE=9A=E5=9F=BA=E7=A1=80=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/router/admin/versions.go | 31 +++++----- backend/internal/router/app/info.go | 3 +- frontend/src/pages/admin/versions/[id].vue | 2 - frontend/src/pages/admin/versions/create.vue | 57 +------------------ .../src/pages/admin/versions/data/schema.ts | 1 - 5 files changed, 19 insertions(+), 75 deletions(-) diff --git a/backend/internal/router/admin/versions.go b/backend/internal/router/admin/versions.go index 531c840..18db600 100644 --- a/backend/internal/router/admin/versions.go +++ b/backend/internal/router/admin/versions.go @@ -226,7 +226,6 @@ func handleGetVersionByID(c *gin.Context) { "force_update": version.ForceUpdate, "update_strategy": version.UpdateStrategy, "update_method": version.UpdateMethod, - "min_version": version.MinVersion, "changelog": version.Changelog, "status": computedStatus, "base_version_id": version.BaseVersionID, @@ -246,10 +245,8 @@ type CreateVersionRequest struct { ForceUpdate bool `json:"force_update"` UpdateStrategy string `json:"update_strategy"` UpdateMethod string `json:"update_method"` - MinVersion string `json:"min_version"` Description string `json:"description"` Changelog string `json:"changelog"` - BaseVersionID *uint `json:"base_version_id"` } func handleCreateVersionGlobal(c *gin.Context) { @@ -288,11 +285,9 @@ func handleCreateVersionGlobal(c *gin.Context) { ForceUpdate: req.ForceUpdate, UpdateStrategy: req.UpdateStrategy, UpdateMethod: req.UpdateMethod, - MinVersion: req.MinVersion, Description: req.Description, Changelog: req.Changelog, Status: "active", - BaseVersionID: req.BaseVersionID, } if version.UpdateStrategy == "" { @@ -302,6 +297,18 @@ func handleCreateVersionGlobal(c *gin.Context) { version.UpdateMethod = "manual" } + if version.UpdateStrategy == "forced" { + version.ForceUpdate = true + } + + if version.UpdateMethod == "hot" { + var lastFullVersion model.Version + if err := database.DB.Where("application_id = ? AND update_method = ?", req.ApplicationID, "full"). + Order("id DESC").First(&lastFullVersion).Error; err == nil { + version.BaseVersionID = &lastFullVersion.ID + } + } + if err := database.DB.Create(&version).Error; err != nil { response.Error(c, 500, "创建版本失败") return @@ -325,13 +332,10 @@ func handleCreateVersionGlobal(c *gin.Context) { type UpdateVersionRequest struct { Version string `json:"version"` - ForceUpdate bool `json:"force_update"` UpdateStrategy string `json:"update_strategy"` UpdateMethod string `json:"update_method"` - MinVersion string `json:"min_version"` Description string `json:"description"` Changelog string `json:"changelog"` - Status string `json:"status"` } func handleUpdateVersionGlobal(c *gin.Context) { @@ -381,22 +385,21 @@ func handleUpdateVersionGlobal(c *gin.Context) { } if req.UpdateStrategy != "" { updates["update_strategy"] = req.UpdateStrategy + if req.UpdateStrategy == "forced" { + updates["force_update"] = true + } else { + updates["force_update"] = false + } } if req.UpdateMethod != "" { updates["update_method"] = req.UpdateMethod } - if req.MinVersion != "" { - updates["min_version"] = req.MinVersion - } if req.Description != "" { updates["description"] = req.Description } if req.Changelog != "" { updates["changelog"] = req.Changelog } - if req.Status != "" { - updates["status"] = req.Status - } log.Printf("[DEBUG] Updates map: %+v\n", updates) diff --git a/backend/internal/router/app/info.go b/backend/internal/router/app/info.go index 29ef125..8492636 100644 --- a/backend/internal/router/app/info.go +++ b/backend/internal/router/app/info.go @@ -78,7 +78,7 @@ func handleAppCheckUpdate(c *gin.Context) { } hasUpdate := clientVersion != latestVersion.Version - if latestVersion.ForceUpdate { + if latestVersion.UpdateStrategy == "forced" { hasUpdate = true } @@ -104,7 +104,6 @@ func handleAppCheckUpdate(c *gin.Context) { "update_notes": latestVersion.Description, "update_strategy": latestVersion.UpdateStrategy, "update_method": latestVersion.UpdateMethod, - "min_version": latestVersion.MinVersion, "changelog": latestVersion.Changelog, "files": files, }) diff --git a/frontend/src/pages/admin/versions/[id].vue b/frontend/src/pages/admin/versions/[id].vue index 7c0da35..15154f7 100644 --- a/frontend/src/pages/admin/versions/[id].vue +++ b/frontend/src/pages/admin/versions/[id].vue @@ -47,7 +47,6 @@ const formData = ref({ update_method: 'manual' as 'manual' | 'hot' | 'full', changelog: '', entry_file: '', - base_version_id: '', file: null as File | null, }) @@ -96,7 +95,6 @@ async function fetchVersion() { formData.value.description = ver.description || '' formData.value.update_strategy = ver.update_strategy || 'optional' formData.value.update_method = ver.update_method || 'manual' - formData.value.base_version_id = ver.base_version_id ? String(ver.base_version_id) : '' formData.value.changelog = ver.changelog || '' formData.value.entry_file = ver.entry_file || '' } diff --git a/frontend/src/pages/admin/versions/create.vue b/frontend/src/pages/admin/versions/create.vue index b8282ed..e2bd20d 100644 --- a/frontend/src/pages/admin/versions/create.vue +++ b/frontend/src/pages/admin/versions/create.vue @@ -1,6 +1,6 @@