46 lines
1.5 KiB
Go
46 lines
1.5 KiB
Go
package web
|
||
|
||
import (
|
||
"videoweb/app/service/playletser"
|
||
|
||
"github.com/gin-gonic/gin"
|
||
)
|
||
|
||
// Search 搜索页 SSR:GET /api/app/playlet/search,列表直接用接口字段渲染。
|
||
func Search(c *gin.Context) {
|
||
q := playletser.ParseSearchQuery(routeOrQuery(c, "keyword", "q"), routeOrQuery(c, "page", "page"))
|
||
if redirectCanonical(c, playletser.SearchCanonicalPath(q)) {
|
||
return
|
||
}
|
||
var raw *playletser.PlayletVideoResp
|
||
if q.Keyword != "" {
|
||
raw = playletser.FetchSearchOrEmpty(c, q)
|
||
} else {
|
||
raw = &playletser.PlayletVideoResp{PageNum: q.PageNum, PageSize: q.PageSize}
|
||
}
|
||
emptyTitle := "请输入关键词搜索"
|
||
emptyDesc := "在上方输入剧名、题材或标签开始搜索"
|
||
if q.Keyword != "" {
|
||
emptyTitle = "未找到相关短剧"
|
||
emptyDesc = "换个关键词试试,或返回首页看看热门内容"
|
||
}
|
||
pageTitle := "搜索短剧"
|
||
description := "在黄果短剧搜索短剧名称、标签与关键词,快速找到想看的剧集。"
|
||
if q.Keyword != "" {
|
||
pageTitle = "搜索:" + q.Keyword
|
||
description = "在黄果短剧搜索「" + q.Keyword + "」相关短剧结果,快速找到想看的剧集。"
|
||
}
|
||
data := gin.H{
|
||
"title": pageTitle,
|
||
"description": description,
|
||
"query": q.Keyword,
|
||
"list": raw.List,
|
||
"totalCount": raw.TotalCount,
|
||
"pagination": playletser.BuildSearchPagination(q, raw.TotalCount),
|
||
"emptyTitle": emptyTitle,
|
||
"emptyDesc": emptyDesc,
|
||
}
|
||
setNoIndex(data, true)
|
||
HTMLOK(c, "search.html", data)
|
||
}
|