@@ -0,0 +1,32 @@
|
||||
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),
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user