feat(donate):增加打赏开关总控制以及文章和页面独立控制 (#66)

增加打赏开关总控制以及文章和页面独立控制
This commit is contained in:
mjking 2023-12-01 17:18:46 +08:00 committed by GitHub
parent f5c5481955
commit 7c7b5e98bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 43 additions and 7 deletions

View File

@ -69,6 +69,18 @@ spec:
label: 关闭
- value: ""
label: 跟随默认配置
- $formkit: radio
name: enable_donate
label: 开启文章打赏
value: ""
help: '当前配置将覆盖主题中的默认配置。'
options:
- value: "true"
label: 开启
- value: "false"
label: 关闭
- value: ""
label: 跟随默认配置
---
@ -122,4 +134,16 @@ spec:
- value: "false"
label: 关闭
- value: ""
label: 跟随默认配置
label: 跟随默认配置
- $formkit: radio
name: enable_donate
label: 开启文章打赏
value: ""
help: '当前配置将覆盖主题中的默认配置。'
options:
- value: "true"
label: 开启
- value: "false"
label: 关闭
- value: ""
label: 跟随默认配置

View File

@ -502,6 +502,16 @@ spec:
label: 默认开启
- value: false
label: 默认关闭
- $formkit: radio
name: enable_post_donate
label: 开启文章打赏
value: true
help: '如果文章或页面元数据配置了enable_donate项则当前配置将被覆盖。'
options:
- value: true
label: 默认开启
- value: false
label: 默认关闭
- $formkit: attachment
name: donate_alipay
label: 支付宝捐赠二维码

View File

@ -1,5 +1,5 @@
<th:block xmlns:th="https://www.thymeleaf.org"
th:with="donate=${!#strings.isEmpty(theme.config.post.donate_alipay) || !#strings.isEmpty(theme.config.post.donate_wechat)}">
th:with="donate=${enableDonate && (!#strings.isEmpty(theme.config.post.donate_alipay) || !#strings.isEmpty(theme.config.post.donate_wechat))}">
<div th:if="${donate || type == 'Post'}" class="admire">
<div class="admire-content">
<button th:if="${donate}" class="donate">
@ -22,4 +22,4 @@
</div>
<span>如果觉得文章对你有用,请随意赞赏</span>
</div>
</th:block>
</th:block>

View File

@ -3,5 +3,6 @@
th:insert="~{common/layout :: layout (title = ${singlePage.spec.title + ' - ' + site.title}, canonical = ${singlePage.status.permalink}, content = ~{main/article :: article (${singlePage}, 'SinglePage')}, isPost = true)}"
th:with="enableKatex = ${!#strings.isEmpty(singlePage.metadata.annotations.get('enable_katex'))? singlePage.metadata.annotations.get('enable_katex') : theme.config.post.enable_katex},
enableShare = ${!#strings.isEmpty(singlePage.metadata.annotations.get('enable_share'))? singlePage.metadata.annotations.get('enable_share') : theme.config.post.enable_post_share},
enableCopyright = ${!#strings.isEmpty(singlePage.metadata.annotations.get('enable_copyright'))? singlePage.metadata.annotations.get('enable_copyright') : theme.config.post.enable_copyright}">
</th:block>
enableCopyright = ${!#strings.isEmpty(singlePage.metadata.annotations.get('enable_copyright'))? singlePage.metadata.annotations.get('enable_copyright') : theme.config.post.enable_copyright},
enableDonate = ${!#strings.isEmpty(singlePage.metadata.annotations.get('enable_donate'))? singlePage.metadata.annotations.get('enable_donate') : theme.config.post.enable_post_donate}">
</th:block>

View File

@ -3,5 +3,6 @@
th:insert="~{common/layout :: layout (title = ${post.spec.title + ' - ' + site.title}, canonical = ${post.status.permalink}, content = ~{main/article :: article (${post}, 'Post')}, isPost = true)}"
th:with="enableKatex = ${!#strings.isEmpty(post.metadata.annotations.get('enable_katex'))? post.metadata.annotations.get('enable_katex') : theme.config.post.enable_katex},
enableShare = ${!#strings.isEmpty(post.metadata.annotations.get('enable_share'))? post.metadata.annotations.get('enable_share') : theme.config.post.enable_post_share},
enableCopyright = ${!#strings.isEmpty(post.metadata.annotations.get('enable_copyright'))? post.metadata.annotations.get('enable_copyright') : theme.config.post.enable_copyright}">
</th:block>
enableCopyright = ${!#strings.isEmpty(post.metadata.annotations.get('enable_copyright'))? post.metadata.annotations.get('enable_copyright') : theme.config.post.enable_copyright},
enableDonate = ${!#strings.isEmpty(post.metadata.annotations.get('enable_donate'))? post.metadata.annotations.get('enable_donate') : theme.config.post.enable_post_donate}">
</th:block>