修复waline最近评论bug,图库返回按钮

This commit is contained in:
1152958806@qq.com 2023-09-23 02:50:58 +08:00
parent 16dcba410d
commit fedf43ddf1
6 changed files with 166 additions and 137 deletions

View File

@ -1612,6 +1612,12 @@ spec:
key: bigTitle key: bigTitle
label: 大标题 label: 大标题
value: 这里是我的相册集哦😯 value: 这里是我的相册集哦😯
- $formkit: text
name: topLink
key: topLink
if: $get(photosStyle).value == 'default'
label: 返回地址 (填写图库分组地址)
value: "/album"
- $formkit: text - $formkit: text
if: $get(photosStyle).value == 'default' if: $get(photosStyle).value == 'default'
name: detail name: detail
@ -2295,7 +2301,7 @@ spec:
name: lazyload name: lazyload
label: 评论懒加载 label: 评论懒加载
value: false value: false
help: 当评论进入浏览器的视窗时,将加载评论系统。 help: 当评论进入浏览器的视窗时,将加载评论系统。(不建议使用,定位不到评论位置)
options: options:
- label: 打开 - label: 打开
value: true value: true
@ -2376,6 +2382,7 @@ spec:
serverURL: "" serverURL: ""
walinesJs: "" walinesJs: ""
walinesCss: "" walinesCss: ""
locale: "{'placeholder': '欢迎评论', 'sofa': '来发评论吧~1'}"
children: children:
- $formkit: url - $formkit: url
name: serverURL name: serverURL
@ -2396,6 +2403,13 @@ spec:
label: Waline评论 - css label: Waline评论 - css
placeholder: 请输入css文件地址 placeholder: 请输入css文件地址
help: 主题的walines版本是最新版本(如果你使用的不是最新版本请自己引入css文件) help: 主题的walines版本是最新版本(如果你使用的不是最新版本请自己引入css文件)
- $formkit: code
name: locale
height: 200px
label: 选项
placeholder: 请输入json格式数据
help: "格式:{'placeholder': '欢迎评论', 'sofa': '来发评论吧~1'} 更多请查看文档https://waline.js.org/cookbook/customize/locale.html#%E4%BE%8B%E5%AD%90"
language: json
- $formkit: group - $formkit: group
if: ($get(use).value == 'Twikoo' || $get(use).value == 'Artalk' || $get(use).value == 'Waline' ) && $get(commentsEnable).value if: ($get(use).value == 'Twikoo' || $get(use).value == 'Artalk' || $get(use).value == 'Waline' ) && $get(commentsEnable).value
name: visitorMail name: visitorMail

View File

@ -8,6 +8,7 @@
dark: 'html[data-theme="dark"]', dark: 'html[data-theme="dark"]',
path: window.location.pathname, path: window.location.pathname,
comment: false, comment: false,
locale:GLOBAL_CONFIG.source.waline.locale
}, null)) }, null))
} }

View File

@ -72,7 +72,7 @@
}) })
saveToLocal.set('waline-newest-comments', JSON.stringify(walineArray), 10 / (60 * 24)) saveToLocal.set('waline-newest-comments', JSON.stringify(walineArray), 10 / (60 * 24))
generateHtml(walineArray) generateHtml(walineArray)
document.querySelector('#newcomm') && necommHtml(artalk) document.querySelector('#newcomm') && necommHtml(walineArray)
}).catch(e => { }).catch(e => {
const $dom = document.querySelector('#card-newest-comments .aside-list') const $dom = document.querySelector('#card-newest-comments .aside-list')
$dom.innerHTML = "无法获取评论,请确认相关配置是否正确" $dom.innerHTML = "无法获取评论,请确认相关配置是否正确"

View File

@ -184,135 +184,7 @@
<!-- icon图标 --> <!-- icon图标 -->
<link rel="stylesheet" th:href="'https://cdn.cbd.int/hao-theme-static@'+${theme.spec.version}+'/icon/iconfont.css'"> <link rel="stylesheet" th:href="'https://cdn.cbd.int/hao-theme-static@'+${theme.spec.version}+'/icon/iconfont.css'">
<!-- 声明一些公共信息 --> <th:block th:replace="~{modules/variables/site-config :: site-config}" />
<script id="site-config" th:inline="javascript">
var GLOBAL_CONFIG = {
// 页面类型 index,page,post,tag,category
htmlType: [[${ htmlType }]],
postTitle: [[${ htmlType == 'post' ? post.spec.title : htmlType == 'page' ? singlePage.spec.title : ''}]],
isPost: [[${htmlType == 'post'}]],
isHome: [[${ htmlType == 'index'}]],
copyright: undefined,
lightbox: 'fancybox',
lazyload: {enable: [[${theme.config.other.vanillaLazyload.enable}]], error: [[@{${theme.config.other.vanillaLazyload.errorImg}}]] },
isFriendLinksInFooter: [[${theme.config.footer.footer_group.enable_footer_group}]],
loadingBox: [[${theme.config.other.loadingBoxs.loadingBoxEnable}]],
loadProgressBar: [[${theme.config.other.loadingBoxs.loadProgressBar}]],
navMusicEnable:[[${theme.config.tool.nav_music.nav_musicEnable}]],
isMusic: [[${ htmlType == 'music'}]],
helloText: [[${#strings.listSplit(theme.config.sidebar.profile.helloText, ',')}]],
profileStyle: [[${theme.config.sidebar.profile.profileStyle}]],
rightMenuEnable: [[${theme.config.tool.rightMenu.rightMenuEnable}]],
source: {
links: {
linksUrl: [[${ theme.config.link.linksUrl }]],
linksNum: [[${theme.config.footer.footer_group.num}]],
},
jQuery: 'https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.6.0/jquery.min.js',
justifiedGallery: {
js: 'https://npm.elemecdn.com/flickr-justified-gallery@2.1.2/dist/fjGallery.min.js',
css: 'https://npm.elemecdn.com/flickr-justified-gallery@2.1.2/dist/fjGallery.css'
},
fancybox: {
js: 'https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/fancybox/3.5.7/jquery.fancybox.min.js',
css: 'https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/fancybox/3.5.7/jquery.fancybox.min.css'
},
comments:{
use: [[${theme.config.comments.use}]],
maxBarrage: [[${ theme.config.comments.commentBarrageConfig.maxBarrage }]],
barrageTime: [[${ theme.config.comments.commentBarrageConfig.barrageTime }]],
mailMd5: "[(${theme.config.comments.commentBarrageConfig.mailMd5})]",
lazyload: [[${theme.config.comments.lazyload}]],
textarea: [[${ theme.config.comments.use == 'Twikoo' ? 'el-textarea__inner' :
theme.config.comments.use == 'Artalk' ? 'atk-textarea' :
theme.config.comments.use == 'Waline' ? 'wl-editor' : 'appearance-none' }]]
},
twikoo:{
js:[[${not #strings.isEmpty(theme.config.comments.twikoos.js) ? theme.config.comments.twikoos.js : assets_link +'/libs/twikoo/twikoo.all.min.js' }]],
twikooUrl: "[(${theme.config.comments.twikoos.envId})]",
accessToken: "[(${theme.config.comments.twikoos.accessToken})]",
},
artalk:{
js:[[${not #strings.isEmpty(theme.config.comments.artalks.artalkJs) ? theme.config.comments.artalks.artalkJs : assets_link +'/libs/artalk/Artalk.js' }]],
css:[[${not #strings.isEmpty(theme.config.comments.artalks.artalkCss) ? theme.config.comments.artalks.artalkCss : assets_link +'/libs/artalk/Artalk.css' }]],
artalkUrl: "[(${theme.config.comments.artalks.server})]",
siteName: "[(${theme.config.comments.artalks.siteName})]",
},
waline:{
js:[[${not #strings.isEmpty(theme.config.comments.walines.walinesJs) ? theme.config.comments.walines.walinesJs : 'https://cdn.cbd.int/@waline/client@2.15.7/dist/waline.js' }]],
serverURL: "[(${theme.config.comments.walines.serverURL})]",
},
welcome:{
key:"[(${theme.config.sidebar.welcome.key})]",
locationLng: [[${theme.config.sidebar.welcome.locationLng}]],
locationLat: [[${theme.config.sidebar.welcome.locationLat}]],
},
post:{
dynamicBackground: [[${ theme.config.post.dynamicBackground }]]
},
tool:{
switch: [[${ theme.config.tool.snackbar.switch }]]
},
postAi:{
ai : [[${htmlType != 'post' || !theme.config.post.aiDescription.aiDescriptionEnable ? '' :
theme.config.post.aiDescription.mode != 'local' && !theme.config.post.aiDescription.switchBtn ? '' :
post.spec.excerpt.autoGenerate ? '本地模式需要自己填写文章摘要' :
#strings.isEmpty(post.status.excerpt) ? '请填写文章摘要' : post.status.excerpt }]],
randomNum : [[${theme.config.post.aiDescription.randomNum}]],
basicWordCount : [[${theme.config.post.aiDescription.basicWordCount}]],
btnLink : "[(${theme.config.post.aiDescription.btnLink})]",
gptName : "[(${theme.config.post.aiDescription.gptName})]",
modeName : [[${theme.config.post.aiDescription.mode}]],
switchBtn : [[${theme.config.post.aiDescription.switchBtn}]],
keys : "[(${theme.config.post.aiDescription.key})]",
Referers : "[(${theme.config.post.aiDescription.Referer})]",
},
img:{
src: [[${isLazyload ? 'data-lazy-src' : 'src' }]]
}
},
date_suffix: {
just: '刚刚',
min: '分钟前',
hour: '小时前',
day: '天前',
month: '个月前'
},
Snackbar: {
chs_to_cht: "你已切换为繁体",
cht_to_chs: "你已切换为简体",
day_to_night: "你已切换为深色模式",
night_to_day: "你已切换为浅色模式",
bgLight: "[(${theme.config.style.themeLightSkin})]",
bgDark: "[(${theme.config.style.themeDarkSkin})]",
position: "top-center",
},
translate: {
defaultEncoding:[[${theme.config.style.translate.defaultEncoding}]],
translateDelay:0,
msgToTraditionalChinese:"繁",
msgToSimplifiedChinese:"简",
rightMenuMsgToTraditionalChinese:"轉為繁體",
rightMenuMsgToSimplifiedChinese:"转为简体"
},
prism: {
enable: [[${ theme.config.code.enable }]],
enable_title: [[${ theme.config.code.enable_title }]],
enable_hr: [[${ theme.config.code.enable_hr }]],
enable_line: [[${ theme.config.code.enable_line }]],
enable_copy: [[${ theme.config.code.enable_copy }]],
enable_expander: [[${ theme.config.code.enable_expander }]],
prism_limit: Number([[${#strings.isEmpty(theme.config.code.height_limit) ? 300 : theme.config.code.height_limit}]])+30,
enable_height_limit: [[${theme.config.code.enable_height_limit}]]
},
};
</script>
</th:block> </th:block>

View File

@ -0,0 +1,132 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<th:block th:fragment="site-config">
<!-- 声明一些公共信息 -->
<script id="site-config" th:inline="javascript">
var GLOBAL_CONFIG = {
// 页面类型 index,page,post,tag,category
htmlType: [[${ htmlType }]],
postTitle: [[${ htmlType == 'post' ? post.spec.title : htmlType == 'page' ? singlePage.spec.title : ''}]],
isPost: [[${htmlType == 'post'}]],
isHome: [[${ htmlType == 'index'}]],
copyright: undefined,
lightbox: 'fancybox',
lazyload: {enable: [[${theme.config.other.vanillaLazyload.enable}]], error: [[@{${theme.config.other.vanillaLazyload.errorImg}}]] },
isFriendLinksInFooter: [[${theme.config.footer.footer_group.enable_footer_group}]],
loadingBox: [[${theme.config.other.loadingBoxs.loadingBoxEnable}]],
loadProgressBar: [[${theme.config.other.loadingBoxs.loadProgressBar}]],
navMusicEnable:[[${theme.config.tool.nav_music.nav_musicEnable}]],
isMusic: [[${ htmlType == 'music'}]],
helloText: [[${#strings.listSplit(theme.config.sidebar.profile.helloText, ',')}]],
profileStyle: [[${theme.config.sidebar.profile.profileStyle}]],
rightMenuEnable: [[${theme.config.tool.rightMenu.rightMenuEnable}]],
date_suffix: {
just: '刚刚',
min: '分钟前',
hour: '小时前',
day: '天前',
month: '个月前'
},
Snackbar: {
chs_to_cht: "你已切换为繁体",
cht_to_chs: "你已切换为简体",
day_to_night: "你已切换为深色模式",
night_to_day: "你已切换为浅色模式",
bgLight: "[(${theme.config.style.themeLightSkin})]",
bgDark: "[(${theme.config.style.themeDarkSkin})]",
position: "top-center",
},
translate: {
defaultEncoding:[[${theme.config.style.translate.defaultEncoding}]],
translateDelay:0,
msgToTraditionalChinese:"繁",
msgToSimplifiedChinese:"简",
rightMenuMsgToTraditionalChinese:"轉為繁體",
rightMenuMsgToSimplifiedChinese:"转为简体"
},
prism: {
enable: [[${ theme.config.code.enable }]],
enable_title: [[${ theme.config.code.enable_title }]],
enable_hr: [[${ theme.config.code.enable_hr }]],
enable_line: [[${ theme.config.code.enable_line }]],
enable_copy: [[${ theme.config.code.enable_copy }]],
enable_expander: [[${ theme.config.code.enable_expander }]],
prism_limit: Number([[${#strings.isEmpty(theme.config.code.height_limit) ? 300 : theme.config.code.height_limit}]])+30,
enable_height_limit: [[${theme.config.code.enable_height_limit}]]
},
source: {
links: {
linksUrl: [[${ theme.config.link.linksUrl }]],
linksNum: [[${theme.config.footer.footer_group.num}]],
},
jQuery: 'https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.6.0/jquery.min.js',
justifiedGallery: {
js: 'https://npm.elemecdn.com/flickr-justified-gallery@2.1.2/dist/fjGallery.min.js',
css: 'https://npm.elemecdn.com/flickr-justified-gallery@2.1.2/dist/fjGallery.css'
},
fancybox: {
js: 'https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/fancybox/3.5.7/jquery.fancybox.min.js',
css: 'https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/fancybox/3.5.7/jquery.fancybox.min.css'
},
comments:{
use: [[${theme.config.comments.use}]],
maxBarrage: [[${ theme.config.comments.commentBarrageConfig.maxBarrage }]],
barrageTime: [[${ theme.config.comments.commentBarrageConfig.barrageTime }]],
mailMd5: "[(${theme.config.comments.commentBarrageConfig.mailMd5})]",
lazyload: [[${theme.config.comments.lazyload}]],
textarea: [[${ theme.config.comments.use == 'Twikoo' ? 'el-textarea__inner' :
theme.config.comments.use == 'Artalk' ? 'atk-textarea' :
theme.config.comments.use == 'Waline' ? 'wl-editor' : 'appearance-none' }]]
},
welcome:{
key:"[(${theme.config.sidebar.welcome.key})]",
locationLng: [[${theme.config.sidebar.welcome.locationLng}]],
locationLat: [[${theme.config.sidebar.welcome.locationLat}]]
},
post:{
dynamicBackground: [[${ theme.config.post.dynamicBackground }]]
},
tool:{
switch: [[${ theme.config.tool.snackbar.switch }]]
},
postAi:{
ai : [[${htmlType != 'post' || !theme.config.post.aiDescription.aiDescriptionEnable ? '' :
theme.config.post.aiDescription.mode != 'local' && !theme.config.post.aiDescription.switchBtn ? '' :
post.spec.excerpt.autoGenerate ? '本地模式需要自己填写文章摘要' :
#strings.isEmpty(post.status.excerpt) ? '请填写文章摘要' : post.status.excerpt }]],
randomNum : [[${theme.config.post.aiDescription.randomNum}]],
basicWordCount : [[${theme.config.post.aiDescription.basicWordCount}]],
btnLink : "[(${theme.config.post.aiDescription.btnLink})]",
gptName : "[(${theme.config.post.aiDescription.gptName})]",
modeName : [[${theme.config.post.aiDescription.mode}]],
switchBtn : [[${theme.config.post.aiDescription.switchBtn}]],
keys : "[(${theme.config.post.aiDescription.key})]",
Referers : "[(${theme.config.post.aiDescription.Referer})]",
},
img:{
src: [[${isLazyload ? 'data-lazy-src' : 'src' }]]
},
twikoo:{
js:[[${not #strings.isEmpty(theme.config.comments.twikoos.js) ? theme.config.comments.twikoos.js : assets_link +'/libs/twikoo/twikoo.all.min.js' }]],
twikooUrl: "[(${theme.config.comments.twikoos.envId})]",
accessToken: "[(${theme.config.comments.twikoos.accessToken})]",
},
artalk:{
js:[[${not #strings.isEmpty(theme.config.comments.artalks.artalkJs) ? theme.config.comments.artalks.artalkJs : assets_link +'/libs/artalk/Artalk.js' }]],
css:[[${not #strings.isEmpty(theme.config.comments.artalks.artalkCss) ? theme.config.comments.artalks.artalkCss : assets_link +'/libs/artalk/Artalk.css' }]],
artalkUrl: "[(${theme.config.comments.artalks.server})]",
siteName: "[(${theme.config.comments.artalks.siteName})]",
},
waline:{
js:[[${not #strings.isEmpty(theme.config.comments.walines.walinesJs) ? theme.config.comments.walines.walinesJs : 'https://cdn.cbd.int/@waline/client@2.15.7/dist/waline.js' }]],
serverURL: "[(${theme.config.comments.walines.serverURL})]",
locale: [(${not #strings.isEmpty(theme.config.comments.walines.locale) ? theme.config.comments.walines.locale : {} })]
},
},
};
</script>
</th:block>
</html>

View File

@ -15,12 +15,22 @@
<th:block th:each="group : ${photoFinder.groupBy()}"> <th:block th:each="group : ${photoFinder.groupBy()}">
<th:block th:if="${#strings.equals(group.metadata.name, param.photo_group_name)}" th:with="description = ${#annotations.get(group, 'description')}, <th:block th:if="${#strings.equals(group.metadata.name, param.photo_group_name)}" th:with="description = ${#annotations.get(group, 'description')},
background = ${#annotations.get(group, 'background')}"> background = ${#annotations.get(group, 'background')}">
<th:div th:replace="~{macro/author-content :: author-content(background = ${background}, <div class="author-content author-content-item essayPage single"
smallTitle = '相册集', th:style="'background:url('+${background}+') left 28% / cover no-repeat !important;'">
bigTitle = ${group.spec.displayName}, <div class="card-content">
detail = ${description}, <div class="author-content-item-tips" text="相册集"></div>
buttonUrl = '', <span class="author-content-item-title" th:text="${group.spec.displayName}"></span>
buttonTitle = '')}" /> <div class="content-bottom">
<div class="tips" th:text="${description}"></div>
</div>
<div class="banner-button-group">
<a class="banner-button" target="_blank" th:attr="onclick='pjax.loadUrl(\''+ ${theme.config.photos.topLink} +'\')'">
<i class="haofont hao-icon-circle-arrow-right"></i>
<span class="banner-button-text" th:text="返回"></span>
</a>
</div>
</div>
</div>
</th:block> </th:block>
</th:block> </th:block>
<div id="article-container"> <div id="article-container">