diff --git a/settings.yaml b/settings.yaml index 6cf9fe4..ff59093 100644 --- a/settings.yaml +++ b/settings.yaml @@ -590,6 +590,31 @@ spec: name: profile_location label: 侧边栏信息-地理位置 placeholder: '请输入个人所在地' + - $formkit: repeater + name: custom_stats + label: 侧边栏信息-统计 + help: 可最多配置3个统计项,未配置统计项时不显示。 + max: 3 + value: + - type: post + - type: category + - type: comment + children: + - $formkit: select + name: type + label: 统计项 + value: "" + options: + - value: 'post' + label: 文章数量 + - value: 'category' + label: 分类数量 + - value: 'comment' + label: 评论数量 + - value: 'upvote' + label: 点赞数量 + - value: 'visit' + label: 访问数量 - $formkit: text name: profile_theme_button label: 侧边栏信息-主题按钮 @@ -1082,4 +1107,4 @@ spec: name: inline_js_body label: "内嵌JS(body)" placeholder: 请输入 JS 代码内容 - help: '填入JS代码,无需script标签,将插入body标签尾部。' \ No newline at end of file + help: '填入JS代码,无需script标签,将插入body标签尾部。' diff --git a/templates/widget/profile.html b/templates/widget/profile.html index b8c70d6..f619ecf 100644 --- a/templates/widget/profile.html +++ b/templates/widget/profile.html @@ -15,23 +15,27 @@ </p> </div> </nav> - <nav class="level"> - <div class="level-item"> - <div> - <p class="heading">文章</p> - <p class="value" th:text="${stats.post}"></p> + <nav class="level" th:if="${!#lists.isEmpty(theme.config.sidebar.custom_stats)}"> + <div th:each="item,sindex :${theme.config.sidebar.custom_stats}" class="level-item" th:switch="${item.type}"> + <div th:case="visit"> + <p class="heading">访问</p> + <p class="value" th:text="${stats.visit}"></p> </div> - </div> - <div class="level-item has-text-centered is-marginless"> - <div> + <div th:case="upvote"> + <p class="heading">点赞</p> + <p class="value" th:text="${stats.upvote}"></p> + </div> + <div th:case="comment"> + <p class="heading">评论</p> + <p class="value" th:text="${stats.comment}"></p> + </div> + <div th:case="category"> <p class="heading">分类</p> <p class="value" th:text="${stats.category}"></p> </div> - </div> - <div class="level-item"> - <div> - <p class="heading">评论</p> - <p class="value" th:text="${stats.comment}"></p> + <div th:case="*"> + <p class="heading">文章</p> + <p class="value" th:text="${stats.post}"></p> </div> </div> </nav> @@ -52,4 +56,4 @@ </a> </div> </div> -</div> \ No newline at end of file +</div>