fix: agent_version 为空 & 恢复批量卸载

- 后端上报时若 agent_version 为空则不覆盖已有版本(防止旧Agent清空版本号)
- 安装/升级后写入版本号 v0.1.0(而非 installed/latest)
- DB 存量 online 主机 agent_version 补填 v0.1.0
- 前端恢复批量卸载 Agent 按钮
This commit is contained in:
attacker committed 2026-06-19 01:51:16 +00:00
1 parent 502674d73a
commit 4dd3e3238d
3 files changed
+43 -11

No files matched your search

@@ -171,10 +171,10 @@ func (h *AgentInstallHandler) InstallAgent(c *gin.Context) {
installed := contains(verifyOut, "active") || contains(verifyOut, "running")
if installed {
// 更新服务器 Agent 状态
// 更新服务器 Agent 状态(版本号:安装成功后由 Agent 下一次上报自动更新)
h.db.Model(&server).Updates(map[string]interface{}{
"agent_status": "online",
"agent_version": "installed",
"agent_version": "v0.1.0",
"last_check_at": time.Now(),
})
}
@@ -224,7 +224,7 @@ func (h *AgentInstallHandler) installOne(server models.Server, serverURL, token
if installed {
h.db.Model(&server).Updates(map[string]interface{}{
"agent_status": "online",
"agent_version": "installed",
"agent_version": "v0.1.0",
"last_check_at": time.Now(),
})
}
@@ -433,7 +433,7 @@ func (h *AgentInstallHandler) BatchUpgradeAgent(c *gin.Context) {
// 更新版本号
h.db.Model(&server).Updates(map[string]interface{}{
"agent_version": "latest",
"agent_version": "v0.1.0",
"last_check_at": time.Now(),
})
log.Printf("[BatchUpgrade] %s Agent 升级成功", server.Hostname)