From 75f6afcddcf8e20813f1aeb403c5edd755cc897e Mon Sep 17 00:00:00 2001 From: xing Date: Mon, 19 Sep 2022 21:31:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=A1=B5=E8=AF=84=E8=AE=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- actions/detail.go | 12 ++- templates/posts/detail.gohtml | 160 +++++++++++++++++----------------- templates/posts/index.gohtml | 12 +-- 3 files changed, 93 insertions(+), 91 deletions(-) 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 @@ -
+ {{ if .showComment}} +
+ {{ if gt .post.CommentCount 0}} +

《{{.post.PostTitle}}》上有{{.post.CommentCount}}条评论

+
    +
  1. +
    + -
      -
    1. - +
    2. +
    + {{end}} + {{if eq .post.CommentStatus "open"}} +
    +

    发表回复 + + + +

    +
    +

    + 您的电子邮箱地址不会被公开。 + +

    +

    + +

    +

    + +

    + +

    +

    + +

    + + + +

    +
    +
    + {{else}} +

    评论已关闭。

    + {{end}} +
+ {{end}} - - -
-

您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar

-
- -
- 回复 -
- - - - - {{if .canComment}} -
-

发表回复 - - - -

-
-

- 您的电子邮箱地址不会被公开。 - -

-

- -

-

- -

- -

-

- -

- - - -

-
-
- {{end}} -