完善
This commit is contained in:
parent
c0b3396173
commit
23deffffd1
|
@ -23,7 +23,7 @@ func index(c *gin.Context) {
|
||||||
if !helper.IsContainInArr(order, []string{"asc", "desc"}) {
|
if !helper.IsContainInArr(order, []string{"asc", "desc"}) {
|
||||||
order = "asc"
|
order = "asc"
|
||||||
}
|
}
|
||||||
title := models.Options["blogname"]
|
title := ""
|
||||||
header := ""
|
header := ""
|
||||||
postType := []interface{}{"post"}
|
postType := []interface{}{"post"}
|
||||||
where := models.SqlBuilder{{
|
where := models.SqlBuilder{{
|
||||||
|
@ -94,6 +94,9 @@ func index(c *gin.Context) {
|
||||||
page = pa
|
page = pa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if page == 1 {
|
||||||
|
title = helper.StrJoin(models.Options["blogname"], "-", models.Options["blogdescription"])
|
||||||
|
}
|
||||||
|
|
||||||
postIds, totalRaw, err := models.SimplePagination[models.WpPosts](where, "ID", "", page, pageSize, models.SqlBuilder{{"post_date", order}}, join, postType, status)
|
postIds, totalRaw, err := models.SimplePagination[models.WpPosts](where, "ID", "", page, pageSize, models.SqlBuilder{{"post_date", order}}, join, postType, status)
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -104,6 +107,9 @@ func index(c *gin.Context) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if len(postIds) < 1 && category != "" {
|
||||||
|
title = "未找到页面"
|
||||||
|
}
|
||||||
var all []uint64
|
var all []uint64
|
||||||
var allPosts []models.WpPosts
|
var allPosts []models.WpPosts
|
||||||
var needQuery []interface{}
|
var needQuery []interface{}
|
||||||
|
|
|
@ -1,10 +1,17 @@
|
||||||
{{template "layout/base" .}}
|
{{template "layout/base" .}}
|
||||||
{{define "content" }}
|
{{define "content" }}
|
||||||
|
{{if .posts}}
|
||||||
<div id="primary" class="content-area">
|
<div id="primary" class="content-area">
|
||||||
<main id="main" class="site-main">
|
<main id="main" class="site-main">
|
||||||
{{if .header}}
|
{{if .header}}
|
||||||
<header class="page-header">
|
<header class="page-header">
|
||||||
<h1 class="page-title">{{.header|unescaped}}</h1>
|
<h1 class="page-title">
|
||||||
|
{{if .search}}
|
||||||
|
{{.header}}
|
||||||
|
{{else}}
|
||||||
|
{{.header |unescaped}}
|
||||||
|
{{end}}
|
||||||
|
</h1>
|
||||||
</header>
|
</header>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{ range $k,$v:=.posts}}
|
{{ range $k,$v:=.posts}}
|
||||||
|
@ -56,4 +63,8 @@
|
||||||
{{template "layout/page" .}}
|
{{template "layout/page" .}}
|
||||||
</main><!-- .site-main -->
|
</main><!-- .site-main -->
|
||||||
</div>
|
</div>
|
||||||
|
{{else }}
|
||||||
|
{{template "layout/empty" .}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
37
templates/layout/empty.html
Normal file
37
templates/layout/empty.html
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
{{define "layout/empty"}}
|
||||||
|
<section id="primary" class="content-area">
|
||||||
|
<main id="main" class="site-main">
|
||||||
|
|
||||||
|
<section class="no-results not-found">
|
||||||
|
<header class="page-header">
|
||||||
|
<h1 class="page-title">
|
||||||
|
{{if .search}}
|
||||||
|
未找到
|
||||||
|
{{else}}
|
||||||
|
有点尴尬诶!该页无法显示。
|
||||||
|
{{end}}
|
||||||
|
</h1>
|
||||||
|
</header><!-- .page-header -->
|
||||||
|
|
||||||
|
<div class="page-content">
|
||||||
|
|
||||||
|
<p>{{if .search}}
|
||||||
|
抱歉,没有符合您搜索条件的结果。请换其它关键词再试。
|
||||||
|
{{else}}
|
||||||
|
这儿似乎什么都没有,试试搜索?
|
||||||
|
{{end}}
|
||||||
|
</p>
|
||||||
|
<form role="search" method="get" class="search-form" action="https://www.xloyy.com/">
|
||||||
|
<label>
|
||||||
|
<span class="screen-reader-text">搜索:</span>
|
||||||
|
<input type="search" class="search-field" placeholder="搜索…" value="{{.search}}" name="s">
|
||||||
|
</label>
|
||||||
|
<input type="submit" class="search-submit screen-reader-text" value="搜索">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div><!-- .page-content -->
|
||||||
|
</section><!-- .no-results -->
|
||||||
|
|
||||||
|
</main><!-- .site-main -->
|
||||||
|
</section>
|
||||||
|
{{end}}
|
Loading…
Reference in New Issue
Block a user