From 2e322e2606acc1b0106639c90bf171c86f89e9c1 Mon Sep 17 00:00:00 2001 From: mh-swift Date: Mon, 29 Jul 2024 13:54:06 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor(captcha):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/internal/library/captcha/captcha.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/internal/library/captcha/captcha.go b/server/internal/library/captcha/captcha.go index cdcccdc..3ee3863 100644 --- a/server/internal/library/captcha/captcha.go +++ b/server/internal/library/captcha/captcha.go @@ -7,12 +7,16 @@ package captcha import ( "context" + "image/color" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/text/gstr" "github.com/mojocn/base64Captcha" - "image/color" ) +// store 验证码存储方式 +var store = base64Captcha.DefaultMemStore + // Generate 生成验证码 func Generate(ctx context.Context) (id string, base64 string) { // 字符 @@ -47,7 +51,7 @@ func Generate(ctx context.Context) (id string, base64 string) { Fonts: []string{"chromohv.ttf"}, } - c := base64Captcha.NewCaptcha(driver.ConvertFonts(), base64Captcha.DefaultMemStore) + c := base64Captcha.NewCaptcha(driver.ConvertFonts(), store) id, base64, _, err := c.Generate() if err != nil { g.Log().Errorf(ctx, "captcha.Generate err:%+v", err) @@ -60,6 +64,5 @@ func Verify(id, answer string) bool { if id == "" || answer == "" { return false } - c := base64Captcha.NewCaptcha(new(base64Captcha.DriverString), base64Captcha.DefaultMemStore) - return c.Verify(id, gstr.ToLower(answer), true) + return store.Verify(id, gstr.ToLower(answer), true) } From 7eb32efa92a62e49bee973ee791d3270e832af01 Mon Sep 17 00:00:00 2001 From: mh-swift Date: Mon, 29 Jul 2024 17:48:12 +0800 Subject: [PATCH 2/3] =?UTF-8?q?refactor(admin):=20=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=E7=A1=AC=E7=BC=96=E7=A0=81=EF=BC=8C=E7=AE=80=E5=8C=96=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/internal/controller/admin/common/site.go | 15 ++++++++------- server/internal/logic/admin/member.go | 12 +----------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/server/internal/controller/admin/common/site.go b/server/internal/controller/admin/common/site.go index 379c82c..7b5c2f9 100644 --- a/server/internal/controller/admin/common/site.go +++ b/server/internal/controller/admin/common/site.go @@ -7,18 +7,19 @@ package common import ( "context" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" - "github.com/gogf/gf/v2/text/gstr" - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/util/gmode" "hotgo/api/admin/common" "hotgo/internal/consts" "hotgo/internal/library/captcha" "hotgo/internal/library/token" "hotgo/internal/service" "hotgo/utility/validate" + + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/gconv" + "github.com/gogf/gf/v2/util/gmode" ) var Site = cSite{} @@ -102,7 +103,7 @@ func (c *cSite) AccountLogin(ctx context.Context, req *common.AccountLoginReq) ( return } - if !req.IsLock && login.CaptchaSwitch == 1 { + if !req.IsLock && login.CaptchaSwitch == consts.StatusEnabled { // 校验 验证码 if !captcha.Verify(req.Cid, req.Code) { err = gerror.New("验证码错误") diff --git a/server/internal/logic/admin/member.go b/server/internal/logic/admin/member.go index 1104bc3..b7132c8 100644 --- a/server/internal/logic/admin/member.go +++ b/server/internal/logic/admin/member.go @@ -629,17 +629,7 @@ func (s *sAdminMember) List(ctx context.Context, in *adminin.MemberListInp) (lis mod = mod.WhereBetween(cols.CreatedAt, gtime.New(in.CreatedAt[0]), gtime.New(in.CreatedAt[1])) } - totalCount, err = mod.Count() - if err != nil { - err = gerror.Wrap(err, "获取用户数据行失败!") - return - } - - if totalCount == 0 { - return - } - - if err = mod.Hook(hook.MemberInfo).Page(in.Page, in.PerPage).OrderDesc(cols.Id).Scan(&list); err != nil { + if err = mod.Hook(hook.MemberInfo).Page(in.Page, in.PerPage).OrderDesc(cols.Id).ScanAndCount(&list, &totalCount, true); err != nil { err = gerror.Wrap(err, "获取用户列表失败!") return } From 06fed9025fb1141b54883d8d2e2d64363666dae6 Mon Sep 17 00:00:00 2001 From: mh-swift Date: Mon, 29 Jul 2024 17:48:49 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E9=83=A8=E9=97=A8=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E6=97=A0=E5=88=86=E9=A1=B5=EF=BC=8C=E5=8E=BB?= =?UTF-8?q?=E9=99=A4=E8=A1=A8=E6=A0=BC=E5=88=86=E9=A1=B5=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/views/org/dept/dept.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/web/src/views/org/dept/dept.vue b/web/src/views/org/dept/dept.vue index f77a05a..0175f14 100644 --- a/web/src/views/org/dept/dept.vue +++ b/web/src/views/org/dept/dept.vue @@ -21,6 +21,7 @@ ref="actionRef" openChecked :columns="columns" + :pagination="false" :request="loadDataTable" :row-key="(row) => row.id" :actionColumn="actionColumn"