Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
33 lines
791 B
Go
33 lines
791 B
Go
package web
|
||
|
||
import (
|
||
"strings"
|
||
"videoweb/app/service/playletser"
|
||
|
||
"github.com/gin-gonic/gin"
|
||
)
|
||
|
||
// Detail 详情页 SSR:GET /api/app/playlet/detail;seoInfo 直接注入模板。
|
||
func Detail(c *gin.Context) {
|
||
key := strings.TrimSpace(c.Param("slug"))
|
||
if key == "" {
|
||
NotFound(c, "未找到该短剧")
|
||
return
|
||
}
|
||
raw := playletser.FetchDetailOrNilByKey(c, key)
|
||
if raw == nil {
|
||
NotFound(c, "未找到该短剧")
|
||
return
|
||
}
|
||
// 有 slug 使用 slug,否则保留 ID 路由。
|
||
if redirectCanonical(c, playletser.DetailPath(raw.Slug, raw.ID)) {
|
||
return
|
||
}
|
||
HTMLOK(c, "detail.html", gin.H{
|
||
"title": raw.Title,
|
||
"detail": raw,
|
||
"seoInfo": raw.SeoInfo,
|
||
"episodeRanges": playletser.BuildEpisodeRanges(raw.PlayletChapterInfo, raw.TotalEpisode, 30),
|
||
})
|
||
}
|