feat: 重构首页模板,双栏现代化布局 + 移动端适配
- 全新 Hero Banner:渐变背景,用户欢迎语 - 左侧最新文章卡片列表,含标题/摘要/作者/日期 - 右侧侧边栏:用户卡片(修复头像显示)、社区统计、快捷入口 - 完全重写 home.css,现代化样式,sticky 侧边栏 - 移动端适配:768px 单列布局,比例缩放 - 后端路由注入 PostService,获取最新 6 篇 approved 文章
This commit is contained in:
@ -23,6 +23,7 @@ type dependencies struct {
|
||||
settingsCtrl *controller.SettingsController
|
||||
messageCtrl *controller.MessageController
|
||||
postCtrl *controller.PostController
|
||||
postService *service.PostService
|
||||
spaceCtrl *controller.SpaceController
|
||||
studioCtrl *controller.StudioController
|
||||
adminPostCtrl *adminCtrl.AdminPostController
|
||||
|
||||
@ -49,7 +49,7 @@ func buildDeps(db *gorm.DB, cfg *config.Config, siteSettings *config.SiteSetting
|
||||
return &dependencies{
|
||||
authCtrl: authCtrl, authMdw: authMdw, maintenanceMdw: maintenanceMdw,
|
||||
settingsCtrl: settingsCtrl,
|
||||
messageCtrl: messageController, postCtrl: postCtrl, spaceCtrl: spaceCtrl,
|
||||
messageCtrl: messageController, postCtrl: postCtrl, postService: postService, spaceCtrl: spaceCtrl,
|
||||
studioCtrl: studioCtrl,
|
||||
adminPostCtrl: adminPostCtrl,
|
||||
adminCtrl: adminController, auditCtrl: auditController,
|
||||
|
||||
@ -22,9 +22,16 @@ func setupFrontendRoutes(r *gin.Engine, cfg *config.Config, d *dependencies) {
|
||||
})
|
||||
{
|
||||
pages.GET("/", func(c *gin.Context) {
|
||||
posts, total, err := d.postService.List("", 1, 6)
|
||||
if err != nil {
|
||||
posts = nil
|
||||
total = 0
|
||||
}
|
||||
c.HTML(http.StatusOK, "home/index.html", common.BuildPageData(c, gin.H{
|
||||
"Title": "首页",
|
||||
"ExtraCSS": "/static/css/home.css",
|
||||
"Title": "首页",
|
||||
"ExtraCSS": "/static/css/home.css",
|
||||
"Posts": posts,
|
||||
"PostCount": total,
|
||||
}))
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user