我是一个什么都不会的小白~,在使用halo时摸索的结果做一个记录~持续更新~

当前登录账号的信息

th:with="currentUser = ${contributorFinder.getContributor(#authentication.name)}" 是一个 Thymeleaf 标签

该变量的值是通过当前登录用户名(#authentication.name)从 contributorFinder 获取的用户信息。

<div th:with="currentUser = ${contributorFinder.getContributor(#authentication.name)}">
    <!-- 打印当前用户对象的所有字段 -->
    <p th:text="${currentUser}"></p>
</div>

在模板中定义一个局部变量 currentUser

使用 th:text="${currentUser} 打印所有

  • ${currentUser.name}当前登录用户名

  • ${currentUser.displayName}当前登录用户显示名称

  • ${currentUser.avatar}当前登录用户头像

  • ${currentUser.bio}当前登录用户描述

  • ${currentUser.permalink} 当前所属用户组

  • ${currentUser.metadata.name}

  • ${currentUser.metadata.generateName}

  • ${currentUser.metadata.labels}

  • ${currentUser.metadata.annotations['rbac.authorization.halo.run/role-names']}

  • ${currentUser.metadata.annotations['halo.run/last-avatar-attachment-name']}

  • ${currentUser.metadata.annotations['halo.run/avatar-attachment-name']}

  • ${currentUser.metadata.annotations['halo.run/email-to-verify']} 当前用户验证过的邮箱地址

  • ${currentUser.metadata.version}

  • ${currentUser.metadata.creationTimestamp} 当前用户注册时间

  • ${currentUser.metadata.deletionTimestamp}

  • ${currentUser.metadata.finalizers}

ContributorVo
(
  name=admin, 
  displayName=帅比, 
  avatar=/upload/b65064be-9ef1-4c69-8bc5-5a5d04c9c42f.png, 
  bio=人生就是这个态度, 
  permalink=/authors/admin, 
  metadata=Metadata
    (
      name=admin, 
      generateName=null, 
      labels=null, 
      annotations=
        {
          rbac.authorization.halo.run/role-names=["super-role"], 
          halo.run/last-avatar-attachment-name=b96706d5-5e03-4d38-8661-693c7f9d432b, 
          halo.run/avatar-attachment-name=b96706d5-5e03-4d38-8661-693c7f9d432b, 
          halo.run/email-to-verify=sky@5ee.net
        }, 
      version=9, 
      creationTimestamp=2024-12-02T14:41:15.791378542Z, 
      deletionTimestamp=null, 
      finalizers=[user-protection]
    )
)

瞬间界面

  • ${moment.owner.name} "admin"

  • ${moment.owner.avatar} "/upload/b65064be-9ef1-4c69-8bc5-5a5d04c9c42f.png"

  • ${moment.owner.bio} "人生就是这个态度"

  • ${moment.owner.displayName} "帅比"

格式

${moment(瞬间).metadata .name } "moment-dyiPo"

MomentVo(
  metadata = Metadata(
    name = "moment-dyiPo",
    generateName = "moment-",
    labels = null,
    annotations = null,
    version = 22,
    creationTimestamp = "2024-12-10T10:45:06.185097230Z",
    deletionTimestamp = null,
    finalizers = [
      "moment-search-protection",
      "moment-protection"
    ]
  ),
  spec = Moment.MomentSpec(
    content = Moment.MomentContent(
      raw = "<p style=\"\">人生就像一本书,每一页都写满了不同的故事。我们既是作者也是读者,一边书写着自己的命运,一边品味着他人的经历。<br><a class=\"tag\" href=\"?tag=%E4%BA%BA%E7%94%9F\" data-pjax=\"\">人生</a> </p><p style=\"\"></p>",
      html = "<p style=\"\">人生就像一本书,每一页都写满了不同的故事。我们既是作者也是读者,一边书写着自己的命运,一边品味着他人的经历。<br><a class=\"tag\" href=\"?tag=%E4%BA%BA%E7%94%9F\" data-pjax=\"\">人生</a> </p><p style=\"\"></p>",
      medium = [
        Moment.MomentMedia(
          type = "PHOTO",
          url = "/upload/5DE52EF9B1222C50CB369DF013D311BD.gif",
          originType = "image/gif"
        ),
        Moment.MomentMedia(
          type = "PHOTO",
          url = "/upload/5B7DA4BC67D4D07EAAB08511E817D963.gif",
          originType = "image/gif"
        ),
        Moment.MomentMedia(
          type = "PHOTO",
          url = "/upload/6AB4DE54E5C3B89184CCFE538E0B054A.gif",
          originType = "image/gif"
        )
      ]
    ),
    releaseTime = "2024-12-10T10:45:05.180Z",
    visible = "PUBLIC",
    owner = "admin",
    tags = [
      "人生"
    ],
    approved = true,
    approvedTime = "2024-12-10T10:45:06.185097230Z"
  ),
  owner = ContributorVo(
    name = "admin",
    avatar = "/upload/b65064be-9ef1-4c69-8bc5-5a5d04c9c42f.png",
    bio = "人生就是这个态度",
    displayName = "帅比"
  ),
  stats = Stats(
    upvote = 1,
    totalComment = 1,
    approvedComment = 1
  )
)