From eb3d613e3da7c56a2cadee0dd9f40b5892e63547 Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Wed, 7 Jan 2026 22:06:13 +0800 Subject: [PATCH] feat: Set overview as default menu for multi-node management (#11588) --- core/init/migration/helper/menu.go | 5 ++-- core/init/migration/migrate.go | 1 + core/init/migration/migrations/init.go | 41 ++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/core/init/migration/helper/menu.go b/core/init/migration/helper/menu.go index 26698fbb9..1a6cee32a 100644 --- a/core/init/migration/helper/menu.go +++ b/core/init/migration/helper/menu.go @@ -3,10 +3,11 @@ package helper import ( "encoding/json" "fmt" + "strings" + "github.com/1Panel-dev/1Panel/core/app/dto" "github.com/1Panel-dev/1Panel/core/app/model" "gorm.io/gorm" - "strings" ) func LoadMenus() string { @@ -43,7 +44,7 @@ func LoadMenus() string { Children: []dto.ShowMenu{ {ID: "118", Disabled: false, Title: "xpack.app.app", IsShow: true, Label: "XApp", Path: "/xpack/app", Sort: 100}, {ID: "112", Disabled: false, Title: "xpack.waf.name", IsShow: true, Label: "Dashboard", Path: "/xpack/waf/dashboard", Sort: 200}, - {ID: "111", Disabled: false, Title: "xpack.node.nodeManagement", IsShow: true, Label: "Node", Path: "/xpack/node", Sort: 300}, + {ID: "111", Disabled: false, Title: "xpack.node.nodeManagement", IsShow: true, Label: "NodeDashboard", Path: "/xpack/node/dashboard", Sort: 300}, {ID: "119", Disabled: false, Title: "xpack.upage", IsShow: true, Label: "Upage", Path: "/xpack/upage", Sort: 400}, {ID: "113", Disabled: false, Title: "xpack.monitor.name", IsShow: true, Label: "MonitorDashboard", Path: "/xpack/monitor/dashboard", Sort: 500}, {ID: "114", Disabled: false, Title: "xpack.tamper.tamper", IsShow: true, Label: "Tamper", Path: "/xpack/tamper", Sort: 600}, diff --git a/core/init/migration/migrate.go b/core/init/migration/migrate.go index cc21b2916..9babcc807 100644 --- a/core/init/migration/migrate.go +++ b/core/init/migration/migrate.go @@ -26,6 +26,7 @@ func Init() { migrations.AddUpgradeBackupCopies, migrations.AddScriptSync, migrations.UpdateXpackHideMenuSort, + migrations.AdjustXpackNode, }) if err := m.Migrate(); err != nil { global.LOG.Error(err) diff --git a/core/init/migration/migrations/init.go b/core/init/migration/migrations/init.go index 5117a07f6..c48bbfcdb 100644 --- a/core/init/migration/migrations/init.go +++ b/core/init/migration/migrations/init.go @@ -602,3 +602,44 @@ var UpdateXpackHideMenuSort = &gormigrate.Migration{ return tx.Model(&model.Setting{}).Where("key = ?", "HideMenu").Update("value", string(updatedJSON)).Error }, } + +var AdjustXpackNode = &gormigrate.Migration{ + ID: "20260108-adjust-xpack-node", + Migrate: func(tx *gorm.DB) error { + var menuJSON string + if err := tx.Model(&model.Setting{}).Where("key = ?", "HideMenu").Pluck("value", &menuJSON).Error; err != nil { + return err + } + if menuJSON == "" { + menuJSON = helper.LoadMenus() + } + var menus []dto.ShowMenu + if err := json.Unmarshal([]byte(menuJSON), &menus); err != nil { + return tx.Model(&model.Setting{}). + Where("key = ?", "HideMenu"). + Update("value", helper.LoadMenus()).Error + } + + for i := 0; i < len(menus); i++ { + if menus[i].Label != "Xpack-Menu" { + continue + } + for j := 0; j < len(menus[i].Children); j++ { + if menus[i].Children[j].Label == "Node" { + menus[i].Children[j].Label = "NodeDashboard" + menus[i].Children[j].Path = "/xpack/node/dashboard" + break + } + } + } + + updatedJSON, err := json.Marshal(menus) + if err != nil { + return tx.Model(&model.Setting{}). + Where("key = ?", "HideMenu"). + Update("value", helper.LoadMenus()).Error + } + + return tx.Model(&model.Setting{}).Where("key = ?", "HideMenu").Update("value", string(updatedJSON)).Error + }, +}