Skip to content

Commit

Permalink
项目空间数量超过分页数量后不显示的bug修复
Browse files Browse the repository at this point in the history
  • Loading branch information
gsw945 committed Aug 9, 2023
1 parent 06e7b0a commit 5011aa9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
8 changes: 5 additions & 3 deletions controllers/ItemsetsController.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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)

Expand All @@ -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"] = ""
Expand All @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion views/home/index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</div>
<nav class="pagination-container">
{{if gt .TotalPages 1}}
{{.PageHtml}}
{{.PageHtml}}
{{end}}
<div class="clearfix"></div>
</nav>
Expand Down
4 changes: 2 additions & 2 deletions views/items/index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
</div>

<nav class="pagination-container">
{{if gt .TotalPages 1}}
{{.PageHtml}}
{{if gt .TotalPages 1}}
{{.PageHtml}}
{{end}}
<div class="clearfix"></div>
</nav>
Expand Down
5 changes: 4 additions & 1 deletion views/items/list.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@
<div class="clearfix"></div>
</div>
<nav class="pagination-container">
{{.PageHtml}}
{{if gt .TotalPages 1}}
{{.PageHtml}}
{{end}}
<div class="clearfix"></div>
</nav>
</div>
</div>
Expand Down

0 comments on commit 5011aa9

Please sign in to comment.