Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
84 lines
2.7 KiB
Go
84 lines
2.7 KiB
Go
package web
|
|
|
|
import (
|
|
"strings"
|
|
"videoweb/app/service/playletser"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// More 专题详情页 SSR:专题由路由 slug 标识;历史 /more 地址会跳转到 /topic canonical。
|
|
func More(c *gin.Context) {
|
|
q := playletser.ParseRecommendQuery(routeOrQuery(c, "page", "page"))
|
|
if slug := strings.TrimSpace(c.Param("slug")); slug != "" {
|
|
if id := playletser.ParseDetailID(slug); id > 0 {
|
|
q.ThemeID = id
|
|
} else {
|
|
q.ThemeSlug = slug
|
|
}
|
|
}
|
|
if path := c.Request.URL.Path; path == "/more" || strings.HasPrefix(path, "/more/") {
|
|
redirectCanonical(c, playletser.RecommendPagePath(q))
|
|
return
|
|
}
|
|
themes := playletser.FetchThemesOrEmpty(c, 2)
|
|
themeName := ""
|
|
for _, theme := range themes {
|
|
matchesID := q.ThemeID > 0 && theme.ID == q.ThemeID
|
|
matchesSlug := strings.TrimSpace(q.ThemeSlug) != "" && strings.EqualFold(strings.TrimSpace(theme.Slug), strings.TrimSpace(q.ThemeSlug))
|
|
if !matchesID && !matchesSlug {
|
|
continue
|
|
}
|
|
themeName = strings.TrimSpace(theme.Name)
|
|
if q.ThemeID <= 0 {
|
|
q.ThemeID = theme.ID
|
|
}
|
|
if strings.TrimSpace(theme.Slug) != "" {
|
|
q.ThemeSlug = strings.TrimSpace(theme.Slug)
|
|
}
|
|
break
|
|
}
|
|
if redirectCanonical(c, playletser.RecommendPagePath(q)) {
|
|
return
|
|
}
|
|
raw := playletser.FetchRecommendListOrEmpty(c, q)
|
|
if playletser.PageOutOfRange(q.PageNum, q.PageSize, raw.TotalCount) {
|
|
NotFound(c, "页面不存在")
|
|
return
|
|
}
|
|
hasIdentifier := q.ThemeID > 0 || strings.TrimSpace(q.ThemeSlug) != ""
|
|
if emptyScopedPage(hasIdentifier, raw.TotalCount, len(raw.List)) {
|
|
NotFound(c, "专题不存在")
|
|
return
|
|
}
|
|
title := playletser.RecommendThemeTitle(themeName, raw.SeoInfo.Title, q.ThemeID)
|
|
if queryTitle := strings.TrimSpace(c.Query("title")); queryTitle != "" {
|
|
title = queryTitle
|
|
}
|
|
heading := title
|
|
if !strings.HasSuffix(heading, "介绍") {
|
|
heading += "介绍"
|
|
}
|
|
description := strings.TrimSpace(raw.SeoInfo.Description)
|
|
if description == "" {
|
|
description = "精品高分 AI 成人短剧专题,精选高人气、高评分 AI 原创短剧,每日持续更新。涵盖多种热门剧情与角色设定,为你带来高质量、高清流畅的观影体验。"
|
|
}
|
|
data := gin.H{
|
|
"title": title,
|
|
"pageKey": "topic",
|
|
"pageName": title,
|
|
"pageTitle": title,
|
|
"topicHeading": heading,
|
|
"topicDescription": description,
|
|
"pagePath": playletser.RecommendCanonicalPath(q.ThemeID, q.ThemeSlug),
|
|
"seoInfo": raw.SeoInfo,
|
|
"list": raw.List,
|
|
"itemListOffset": (q.PageNum - 1) * q.PageSize,
|
|
"pagination": playletser.BuildRecommendPagination(q, raw.TotalCount),
|
|
}
|
|
if raw.TotalCount <= 0 || len(raw.List) == 0 {
|
|
setNoIndex(data, true)
|
|
}
|
|
HTMLOK(c, "more.html", data)
|
|
}
|