From 641cac182b4f06973ab1a9a849233dcbf8806368 Mon Sep 17 00:00:00 2001 From: fuzhufang Date: Tue, 19 Aug 2025 17:06:51 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E5=BD=93=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E7=AE=A1=E7=90=86=20=E6=96=B0=E5=A2=9E=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8C=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E8=AE=BE=E7=BD=AE=E7=BB=84=E4=BB=B6=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=EF=BC=8C=E5=AF=BC=E8=87=B4=E5=9F=BA=E4=BA=8E=E8=BF=99?= =?UTF-8?q?=E4=B8=AA=E7=9B=AE=E5=BD=95=E4=B8=8B=E6=96=B0=E5=BB=BA=E7=9A=84?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E9=A1=B5=E9=9D=A2=E6=B2=A1=E6=9C=89=E5=B7=A6?= =?UTF-8?q?=E8=BE=B9=E7=9A=84=E5=AF=BC=E8=88=AA=E6=A0=8F=E3=80=82=E7=94=B1?= =?UTF-8?q?=E4=BA=8E=E7=9B=AE=E5=89=8D=E6=96=B0=E5=A2=9E=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E5=B9=B6=E6=B2=A1=E6=9C=89=E8=AE=BE=E7=BD=AE=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=EF=BC=8C=E6=89=80=E4=BB=A5=E7=BB=99=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E9=BB=98=E8=AE=A4=E7=BB=84=E4=BB=B6=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=EF=BC=9ALayout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/go.mod | 2 +- server/internal/admin/logic/menu.go | 9 +++++---- web/src/views/system/menu/index.vue | 6 ++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/server/go.mod b/server/go.mod index 7d9e21f..c6daa5e 100644 --- a/server/go.mod +++ b/server/go.mod @@ -7,6 +7,7 @@ toolchain go1.24.0 require ( github.com/goflyfox/gtoken/v2 v2.0.1 github.com/gogf/gf/contrib/drivers/mysql/v2 v2.9.0 + github.com/gogf/gf/contrib/nosql/redis/v2 v2.9.0 github.com/gogf/gf/v2 v2.9.0 github.com/mojocn/base64Captcha v1.3.8 github.com/xuri/excelize/v2 v2.9.1 @@ -23,7 +24,6 @@ require ( github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-sql-driver/mysql v1.7.1 // indirect - github.com/gogf/gf/contrib/nosql/redis/v2 v2.9.0 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/websocket v1.5.3 // indirect diff --git a/server/internal/admin/logic/menu.go b/server/internal/admin/logic/menu.go index f84a9c2..e11fa29 100644 --- a/server/internal/admin/logic/menu.go +++ b/server/internal/admin/logic/menu.go @@ -3,9 +3,6 @@ package logic import ( "context" "errors" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/util/gconv" v1 "gmanager/api/admin/v1" "gmanager/internal/admin/consts" "gmanager/internal/admin/dao" @@ -13,6 +10,10 @@ import ( "gmanager/internal/admin/model/entity" input2 "gmanager/internal/admin/model/input" "gmanager/internal/library/gftoken" + + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/util/gconv" ) // Menu 菜单 @@ -215,7 +216,7 @@ func (s *menu) Save(ctx context.Context, in *v1.MenuSaveReq) error { } } // 组件路径唯一性校验 - if model.Type != consts.MenuTypeButton && model.Component != "" { + if model.Type != consts.MenuTypeButton && model.Type != consts.MenuTypeCatalog && model.Component != "" { componentCount, err := dao.Menu.Ctx(ctx).Where(dao.Menu.Columns().Component, model.Component).WhereNot(dao.Menu.Columns().Id, in.Id).Count() if err != nil { return gerror.Wrap(err, "检查组件路径唯一性失败") diff --git a/web/src/views/system/menu/index.vue b/web/src/views/system/menu/index.vue index 4bcf2cb..633e86c 100644 --- a/web/src/views/system/menu/index.vue +++ b/web/src/views/system/menu/index.vue @@ -469,6 +469,12 @@ function handleSubmit() { menuFormRef.value.validate((isValid: boolean) => { if (isValid) { const menuId = formData.value.id; + if (formData.value.type === MenuTypeEnum.CATALOG) { + // 如果是目录,在没有设置组件路径情况下,默认值是:Layout + if (formData.value.component == undefined || formData.value.component == "") { + formData.value.component = "Layout"; + } + } if (menuId) { //修改时父级菜单不能为当前菜单 if (formData.value.parentId == menuId) { -- Gitee