项目空间数量超过分页数量后不显示的bug修复

pull/914/head
gsw945 2023-08-09 10:51:06 +08:00
parent 06e7b0ab70
commit 5011aa964f
4 changed files with 12 additions and 7 deletions

View File

@ -1,6 +1,8 @@
package controllers package controllers
import ( import (
"math"
"github.com/beego/beego/v2/client/orm" "github.com/beego/beego/v2/client/orm"
"github.com/beego/beego/v2/core/logs" "github.com/beego/beego/v2/core/logs"
"github.com/mindoc-org/mindoc/conf" "github.com/mindoc-org/mindoc/conf"
@ -24,7 +26,7 @@ func (c *ItemsetsController) Prepare() {
func (c *ItemsetsController) Index() { func (c *ItemsetsController) Index() {
c.Prepare() c.Prepare()
c.TplName = "items/index.tpl" c.TplName = "items/index.tpl"
pageSize := 18 pageSize := 16
pageIndex, _ := c.GetInt("page", 0) pageIndex, _ := c.GetInt("page", 0)
@ -33,7 +35,6 @@ func (c *ItemsetsController) Index() {
if err != nil && err != orm.ErrNoRows { if err != nil && err != orm.ErrNoRows {
c.ShowErrorPage(500, err.Error()) c.ShowErrorPage(500, err.Error())
} }
c.Data["TotalPages"] = pageIndex
if err == orm.ErrNoRows || len(items) <= 0 { if err == orm.ErrNoRows || len(items) <= 0 {
c.Data["Lists"] = items c.Data["Lists"] = items
c.Data["PageHtml"] = "" c.Data["PageHtml"] = ""
@ -46,7 +47,7 @@ func (c *ItemsetsController) Index() {
} else { } else {
c.Data["PageHtml"] = "" c.Data["PageHtml"] = ""
} }
c.Data["TotalPages"] = int(math.Ceil(float64(totalCount) / float64(pageSize)))
c.Data["Lists"] = items c.Data["Lists"] = items
} }
@ -85,6 +86,7 @@ func (c *ItemsetsController) List() {
} else { } else {
c.Data["PageHtml"] = "" c.Data["PageHtml"] = ""
} }
c.Data["TotalPages"] = int(math.Ceil(float64(totalCount) / float64(pageSize)))
c.Data["Lists"] = searchResult c.Data["Lists"] = searchResult
c.Data["Model"] = item c.Data["Model"] = item

View File

@ -49,7 +49,7 @@
</div> </div>
<nav class="pagination-container"> <nav class="pagination-container">
{{if gt .TotalPages 1}} {{if gt .TotalPages 1}}
{{.PageHtml}} {{.PageHtml}}
{{end}} {{end}}
<div class="clearfix"></div> <div class="clearfix"></div>
</nav> </nav>

View File

@ -42,8 +42,8 @@
</div> </div>
<nav class="pagination-container"> <nav class="pagination-container">
{{if gt .TotalPages 1}} {{if gt .TotalPages 1}}
{{.PageHtml}} {{.PageHtml}}
{{end}} {{end}}
<div class="clearfix"></div> <div class="clearfix"></div>
</nav> </nav>

View File

@ -53,7 +53,10 @@
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
<nav class="pagination-container"> <nav class="pagination-container">
{{.PageHtml}} {{if gt .TotalPages 1}}
{{.PageHtml}}
{{end}}
<div class="clearfix"></div>
</nav> </nav>
</div> </div>
</div> </div>