完善
This commit is contained in:
parent
fbf5b64ddf
commit
0bd59e4172
|
@ -16,32 +16,34 @@ import (
|
||||||
var PostsCache sync.Map
|
var PostsCache sync.Map
|
||||||
|
|
||||||
type IndexHandle struct {
|
type IndexHandle struct {
|
||||||
c *gin.Context
|
c *gin.Context
|
||||||
page int
|
page int
|
||||||
pageSize int
|
pageSize int
|
||||||
title string
|
title string
|
||||||
titleL string
|
titleL string
|
||||||
titleR string
|
titleR string
|
||||||
search string
|
search string
|
||||||
totalPage int
|
totalPage int
|
||||||
category string
|
category string
|
||||||
categoryType string
|
categoryType string
|
||||||
where models.SqlBuilder
|
where models.SqlBuilder
|
||||||
orderBy models.SqlBuilder
|
orderBy models.SqlBuilder
|
||||||
order string
|
order string
|
||||||
join models.SqlBuilder
|
join models.SqlBuilder
|
||||||
postType []interface{}
|
postType []interface{}
|
||||||
status []interface{}
|
status []interface{}
|
||||||
header string
|
header string
|
||||||
|
paginationStep int
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIndexHandle(ctx *gin.Context) *IndexHandle {
|
func NewIndexHandle(ctx *gin.Context) *IndexHandle {
|
||||||
return &IndexHandle{
|
return &IndexHandle{
|
||||||
c: ctx,
|
c: ctx,
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
titleL: models.Options["blogname"],
|
paginationStep: 1,
|
||||||
titleR: models.Options["blogdescription"],
|
titleL: models.Options["blogname"],
|
||||||
|
titleR: models.Options["blogdescription"],
|
||||||
where: models.SqlBuilder{
|
where: models.SqlBuilder{
|
||||||
{"post_type", "in", ""},
|
{"post_type", "in", ""},
|
||||||
{"post_status", "in", ""},
|
{"post_status", "in", ""},
|
||||||
|
@ -225,9 +227,6 @@ func index(c *gin.Context) {
|
||||||
archive, err := archives()
|
archive, err := archives()
|
||||||
categoryItems, err := categories()
|
categoryItems, err := categories()
|
||||||
q := c.Request.URL.Query().Encode()
|
q := c.Request.URL.Query().Encode()
|
||||||
if q != "" {
|
|
||||||
q = fmt.Sprintf("?%s", q)
|
|
||||||
}
|
|
||||||
c.HTML(http.StatusOK, "index.html", gin.H{
|
c.HTML(http.StatusOK, "index.html", gin.H{
|
||||||
"posts": postIds,
|
"posts": postIds,
|
||||||
"options": models.Options,
|
"options": models.Options,
|
||||||
|
@ -235,8 +234,7 @@ func index(c *gin.Context) {
|
||||||
"archives": archive,
|
"archives": archive,
|
||||||
"categories": categoryItems,
|
"categories": categoryItems,
|
||||||
"totalPage": h.getTotalPage(totalRaw),
|
"totalPage": h.getTotalPage(totalRaw),
|
||||||
"queryRaw": q,
|
"pagination": pagination(h.page, h.totalPage, h.paginationStep, c.Request.URL.Path, q),
|
||||||
"pagination": pagination(h.page, h.totalPage, 1, c.Request.URL.Path, q),
|
|
||||||
"search": h.search,
|
"search": h.search,
|
||||||
"header": h.header,
|
"header": h.header,
|
||||||
"title": h.getTitle(),
|
"title": h.getTitle(),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user