From 5011aa964f045a128c0dc1969cc5eccf16a5ac0f Mon Sep 17 00:00:00 2001 From: gsw945 Date: Wed, 9 Aug 2023 10:51:06 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=A9=BA=E9=97=B4=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E8=B6=85=E8=BF=87=E5=88=86=E9=A1=B5=E6=95=B0=E9=87=8F?= =?UTF-8?q?=E5=90=8E=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84bug=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/ItemsetsController.go | 8 +++++--- views/home/index.tpl | 2 +- views/items/index.tpl | 4 ++-- views/items/list.tpl | 5 ++++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/controllers/ItemsetsController.go b/controllers/ItemsetsController.go index ef129111..e9625d49 100644 --- a/controllers/ItemsetsController.go +++ b/controllers/ItemsetsController.go @@ -1,6 +1,8 @@ package controllers import ( + "math" + "github.com/beego/beego/v2/client/orm" "github.com/beego/beego/v2/core/logs" "github.com/mindoc-org/mindoc/conf" @@ -24,7 +26,7 @@ func (c *ItemsetsController) Prepare() { func (c *ItemsetsController) Index() { c.Prepare() c.TplName = "items/index.tpl" - pageSize := 18 + pageSize := 16 pageIndex, _ := c.GetInt("page", 0) @@ -33,7 +35,6 @@ func (c *ItemsetsController) Index() { if err != nil && err != orm.ErrNoRows { c.ShowErrorPage(500, err.Error()) } - c.Data["TotalPages"] = pageIndex if err == orm.ErrNoRows || len(items) <= 0 { c.Data["Lists"] = items c.Data["PageHtml"] = "" @@ -46,7 +47,7 @@ func (c *ItemsetsController) Index() { } else { c.Data["PageHtml"] = "" } - + c.Data["TotalPages"] = int(math.Ceil(float64(totalCount) / float64(pageSize))) c.Data["Lists"] = items } @@ -85,6 +86,7 @@ func (c *ItemsetsController) List() { } else { c.Data["PageHtml"] = "" } + c.Data["TotalPages"] = int(math.Ceil(float64(totalCount) / float64(pageSize))) c.Data["Lists"] = searchResult c.Data["Model"] = item diff --git a/views/home/index.tpl b/views/home/index.tpl index 982b6d7a..65c9a81f 100644 --- a/views/home/index.tpl +++ b/views/home/index.tpl @@ -49,7 +49,7 @@ diff --git a/views/items/index.tpl b/views/items/index.tpl index 60e8674c..c6c4a8a2 100644 --- a/views/items/index.tpl +++ b/views/items/index.tpl @@ -42,8 +42,8 @@ diff --git a/views/items/list.tpl b/views/items/list.tpl index d187d1e9..6cab49aa 100644 --- a/views/items/list.tpl +++ b/views/items/list.tpl @@ -53,7 +53,10 @@