package web import ( "videoweb/app/service/playletser" "videoweb/app/service/videoser" "github.com/gin-gonic/gin" ) // Index 首页 SSR:拉取 GET /api/app/playlet/home,按接口字段注入模板。 // 接口文档:http://172.104.181.99:25319/swagger/index.html#/app短剧相关接口/get_api_app_playlet_home // 继续观看:GET /api/app/playlet/history/list?pageNum=1&pageSize=6 // 热播榜:短剧 hot/rank/list;剧集 video/all/list sortType=最热 func Index(c *gin.Context) { raw := playletser.FetchHomeOrEmpty(c) title := "黄果短剧" if raw != nil && raw.SeoInfo.Title != "" { title = raw.SeoInfo.Title } history := playletser.FetchHistoryListOrEmpty(c, playletser.HistoryListQuery{PageNum: 1, PageSize: 6}) continueWatch := history.List if len(continueWatch) > 6 { continueWatch = continueWatch[:6] } hotPlaylets := playletser.FetchHotRankListOrEmpty(c, playletser.HotRankQuery{ PageNum: 1, PageSize: 10, RankType: 1, }).List if len(hotPlaylets) > 10 { hotPlaylets = hotPlaylets[:10] } hotVideos := videoser.FetchVideoAllListOrEmpty(c, videoser.SeriesListQuery{ PageNum: 1, PageSize: 10, SortType: videoser.SortHeat, MediaType: videoser.MediaAll, }).List if len(hotVideos) > 10 { hotVideos = hotVideos[:10] } HTMLOK(c, "index.html", gin.H{ "title": title, "navActive": "home", "seoInfo": raw.SeoInfo, "announcements": raw.Announcements, "advitise": raw.Advitise, "homeBannerData": playletser.ActiveHomeBanners(raw.HomeBannerData), "homeConfigData": playletser.ActiveHomeConfigs(raw.HomeConfigData), // GET /api/app/playlet/tag/options → list(已上架标签) "tagOptions": playletser.FetchTagOptionsOrEmpty(c), "continueWatch": continueWatch, "hotRankPlaylets": hotPlaylets, "hotRankVideos": hotVideos, }) }