diff --git a/actions/detail.go b/actions/detail.go index 3477961..d8d966e 100644 --- a/actions/detail.go +++ b/actions/detail.go @@ -50,22 +50,20 @@ func Detail(c *gin.Context) { } } pw := sessions.Default(c).Get("post_password") - showComment := true + showComment := false + if post.CommentCount > 0 || post.CommentStatus == "open" { + showComment = true + } common.PasswordProjectTitle(&post) if post.PostPassword != "" && pw != post.PostPassword { common.PasswdProjectContent(&post) showComment = false } - canComment := false - if post.CommentStatus == "open" { - canComment = true - } prev, next, err := common.GetContextPost(post.Id, post.PostDate) h["title"] = fmt.Sprintf("%s-%s", post.PostTitle, models.Options["blogname"]) h["post"] = post - h["comment"] = showComment - h["canComment"] = canComment + h["showComment"] = showComment h["prev"] = prev h["next"] = next } diff --git a/templates/posts/detail.gohtml b/templates/posts/detail.gohtml index 9d9f129..f64ea12 100644 --- a/templates/posts/detail.gohtml +++ b/templates/posts/detail.gohtml @@ -40,90 +40,92 @@ -
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。
-
--
-
-
+
+
+ {{end}} + {{if eq .post.CommentStatus "open"}} + + {{else}} +评论已关闭。
+ {{end}} +