Files
web_hgtv_h5/app/api/web/search.go
T
谢宇宁andClaude Opus 5.5 3639d2184a Initial commit
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 14:47:17 +07:00

46 lines
1.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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)
}