调整:

1.调整评论加载方式,改为组件,须更新评论插件到2.0.0含预发布
2.调整插件统一配色方案切换方式,目前使用搜索、评论插件自带的高亮和暗黑方案
3.移除百度、头条推送能力,建议使用插件进行推送
This commit is contained in:
mjsoftware 2024-03-07 20:02:55 +08:00
parent b0238605b0
commit 1574ce007c
11 changed files with 215 additions and 156 deletions

View File

@ -1280,24 +1280,24 @@ spec:
label: 隐藏
- value: false
label: 关闭
- $formkit: radio
name: enable_baidu_push
label: 启用百度 URL 自动推送
value: false
options:
- value: true
label: 开启
- value: false
label: 关闭
- $formkit: radio
name: enable_toutiao_push
label: 启用头条搜索自动推送
value: false
options:
- value: true
label: 开启
- value: false
label: 关闭
# - $formkit: radio
# name: enable_baidu_push
# label: 启用百度 URL 自动推送
# value: false
# options:
# - value: true
# label: 开启
# - value: false
# label: 关闭
# - $formkit: radio
# name: enable_toutiao_push
# label: 启用头条搜索自动推送
# value: false
# options:
# - value: true
# label: 开启
# - value: false
# label: 关闭
- $formkit: radio
name: enable_debug
label: 开启 DEBUG 日志

View File

@ -108,81 +108,116 @@ html {
}
}
}
}
//組件高亮
.color-scheme-light {
/*搜索組件配色 - 高亮*/
//todo 插件统一方案,使用此须在主题配置中设定变量,用来应对高亮和黑暗配色切换
&.plugin-unified-plan {
/*todo 搜索組件*/
//基础字体大小
//--halo-search-widget-base-font-size: 1rem;
//--halo-search-widget-base-font-size: 1rem !important;
//基础元素的圆角
//--halo-search-widget-base-border-radius: ;
//--halo-search-widget-base-border-radius: !important;
//基础字体族
//--halo-search-widget-base-font-family: ;
//--halo-search-widget-base-font-family: !important;
//模态层颜色
//--halo-search-widget-color-modal-layer: ;
//--halo-search-widget-color-modal-layer: var(--theme) !important;
//模态内容背景颜色
//--halo-search-widget-color-modal-content-bg: ;
//--halo-search-widget-color-modal-content-bg: var(--theme) !important;
//表单输入背景颜色
//--halo-search-widget-color-form-input-bg: ;
//--halo-search-widget-color-form-input-bg: !important;
//表单输入文字颜色
//--halo-search-widget-color-form-input: ;
//--halo-search-widget-color-form-input: !important;
//表单输入占位符颜色
//--halo-search-widget-color-form-input-placeholder: ;
//--halo-search-widget-color-form-input-placeholder: !important;
//表单分隔线颜色
//--halo-search-widget-color-form-divider: ;
//--halo-search-widget-color-form-divider: !important;
//无结果提示颜色
//--halo-search-widget-color-result-empty: ;
//--halo-search-widget-color-result-empty: !important;
//结果项背景颜色
//--halo-search-widget-color-result-item-bg: ;
//--halo-search-widget-color-result-item-bg: !important;
//结果项悬停背景颜色
//--halo-search-widget-color-result-item-hover-bg: ;
//--halo-search-widget-color-result-item-hover-bg: !important;
//结果项标题颜色
//--halo-search-widget-color-result-item-title: ;
//--halo-search-widget-color-result-item-title: !important;
//结果项内容颜色
//--halo-search-widget-color-result-item-content: ;
//--halo-search-widget-color-result-item-content: !important;
//命令键盘项颜色
//--halo-search-widget-color-command-kbd-item: ;
//--halo-search-widget-color-command-kbd-item: !important;
//命令键盘边框颜色
//--halo-search-widget-color-command-kbd-border: ;
//--halo-search-widget-color-command-kbd-border: !important;
/*todo 评论组件*/
//基础文字颜色
//--halo-comment-widget-base-color: var(--dark-c) !important;
//基础元素的圆角
//--halo-comment-widget-base-border-radius: !important;
////基础字体大小
//--halo-comment-widget-base-font-size: !important;
////基础行高
//--halo-comment-widget-base-line-height: !important;
////基础字体族
//--halo-comment-widget-base-font-family: !important;
////头像的圆角大小
//--halo-comment-widget-component-avatar-rounded: !important;
////头像大小
//--halo-comment-widget-component-avatar-size: !important;
////表单输入背景颜色
//--halo-comment-widget-component-form-input-bg-color: !important;
////表单输入文字颜色
//--halo-comment-widget-component-form-input-color: !important;
////表单输入边框颜色
//--halo-comment-widget-component-form-input-border-color: !important;
////表单输入焦点时边框颜色
//--halo-comment-widget-component-form-input-border-color-focus: !important;
////表单输入焦点时的阴影
//--halo-comment-widget-component-form-input-box-shadow-focus: !important;
////登录按钮背景颜色
//--halo-comment-widget-component-form-button-login-bg-color: var(--theme) !important;
////登录按钮悬停背景颜色
//--halo-comment-widget-component-form-button-login-bg-color-hover: var(--theme) !important;
////登录按钮边框颜色
//--halo-comment-widget-component-form-button-login-border-color: #999 !important;
////提交按钮背景颜色
//--halo-comment-widget-component-form-button-submit-bg-color: var(--theme) !important;
////提交按钮文字颜色
//--halo-comment-widget-component-form-button-submit-color: #f7f7f7 !important;
////提交按钮边框颜色
//--halo-comment-widget-component-form-button-submit-border-color: var(--theme) !important;
////提交按钮悬停边框颜色
//--halo-comment-widget-component-form-button-submit-border-color-hover: var(--theme) !important;
////表情按钮颜色
//--halo-comment-widget-component-form-button-emoji-color: var(--theme) !important;
////评论项操作悬停背景颜色
//--halo-comment-widget-component-comment-item-action-bg-color-hover: !important;
////评论项操作颜色
//--halo-comment-widget-component-comment-item-action-color: !important;
////评论项操作悬停颜色
//--halo-comment-widget-component-comment-item-action-color-hover: !important;
////分页按钮悬停背景颜色
//--halo-comment-widget-component-pagination-button-bg-color-hover: !important;
////分页按钮活动状态背景颜色
//--halo-comment-widget-component-pagination-button-bg-color-active: !important;
////分页按钮活动状态边框颜色
//--halo-comment-widget-component-pagination-button-border-color-active: !important;
////表情选择器颜色
//--halo-comment-widget-component-emoji-picker-rgb-color: var(--theme) !important;
////表情选择器强调颜色
//--halo-comment-widget-component-emoji-picker-rgb-accent: !important;
////表情选择器背景颜色
//--halo-comment-widget-component-emoji-picker-rgb-background: !important;
////表情选择器输入颜色
//--halo-comment-widget-component-emoji-picker-rgb-input: !important;
////表情选择器边框颜色
//--halo-comment-widget-component-emoji-picker-color-border: !important;
////表情选择器悬停边框颜色
//--halo-comment-widget-component-emoji-picker-color-border-over: !important;
}
}
//組件暗黑
.color-scheme-dark {
/*搜索組件配色 - 暗黑*/
//基础字体大小
//--halo-search-widget-base-font-size: 1rem;
//基础元素的圆角
//--halo-search-widget-base-border-radius: ;
//基础字体族
//--halo-search-widget-base-font-family: ;
//模态层颜色
//--halo-search-widget-color-modal-layer: ;
//模态内容背景颜色
//--halo-search-widget-color-modal-content-bg: ;
//表单输入背景颜色
//--halo-search-widget-color-form-input-bg: ;
//表单输入文字颜色
//--halo-search-widget-color-form-input: ;
//表单输入占位符颜色
//--halo-search-widget-color-form-input-placeholder: ;
//表单分隔线颜色
//--halo-search-widget-color-form-divider: ;
//无结果提示颜色
//--halo-search-widget-color-result-empty: ;
//结果项背景颜色
//--halo-search-widget-color-result-item-bg: ;
//结果项悬停背景颜色
//--halo-search-widget-color-result-item-hover-bg: ;
//结果项标题颜色
//--halo-search-widget-color-result-item-title: ;
//结果项内容颜色
//--halo-search-widget-color-result-item-content: ;
//命令键盘项颜色
//--halo-search-widget-color-command-kbd-item: ;
//命令键盘边框颜色
//--halo-search-widget-color-command-kbd-border: ;
}
////組件高亮todo 使用此方案时复制统一配色方案的相关内容后修改对应值
//.color-scheme-light {
//}
////組件暗黑todo 使用此方案时复制统一配色方案的相关内容后修改对应值
//.color-scheme-dark {
//}

View File

@ -77,11 +77,11 @@ const commonContext = {
// 配色方案
$('html').addClass('color-scheme-light').removeClass('color-scheme-dark').removeClass('night')
}
$('.comment-section>div').each(function () {
const shadowDom = this.shadowRoot.querySelectorAll('.halo-comment-widget')[0]
$(shadowDom)[`${isNightValue ? 'add' : 'remove'}Class`]('dark')
$(shadowDom)[`${isNightValue ? 'remove' : 'add'}Class`]('light')
})
// $('.comment-section>div').each(function () {
// const shadowDom = this.shadowRoot.querySelectorAll('.halo-comment-widget')[0]
// $(shadowDom)[`${isNightValue ? 'add' : 'remove'}Class`]('dark')
// $(shadowDom)[`${isNightValue ? 'remove' : 'add'}Class`]('light')
// })
localStorage.setItem('night', isNightValue)
isNight = isNightValue
}
@ -541,26 +541,26 @@ const commonContext = {
}
}
},
/* 初始化评论区 */
initComment() {
if (!window.CommentWidget) {
return
}
$('.comment-section').each(function (index, item) {
let target = $(this).attr('data-target')
let id = $(this).attr('data-id')
CommentWidget.init(
`.comment-section[data-id='${id}'][data-target='${target}']`,
'/plugins/PluginCommentWidget/assets/static/style.css',
{
group: target === 'Moment' ? 'moment.halo.run' : 'content.halo.run',
kind: target,
name: id,
colorScheme: (localStorage.getItem('night') !== 'true' ? 'light' : 'dark')
}
)
})
},
// /* 初始化评论区 */
// initComment() {
// if (!window.CommentWidget) {
// return
// }
// $('.comment-section').each(function (index, item) {
// let target = $(this).attr('data-target')
// let id = $(this).attr('data-id')
// CommentWidget.init(
// `.comment-section[data-id='${id}'][data-target='${target}']`,
// '/plugins/PluginCommentWidget/assets/static/style.css',
// {
// group: target === 'Moment' ? 'moment.halo.run' : 'content.halo.run',
// kind: target,
// name: id,
// colorScheme: (localStorage.getItem('night') !== 'true' ? 'light' : 'dark')
// }
// )
// })
// },
/* 初始化特效,只需要初始化一次,移动端设备不初始化 */
initEffects() {
if (Utils.isMobile()) return
@ -573,11 +573,11 @@ const commonContext = {
DreamConfig.effects_universe_mode && Utils.cachedScript(`${DreamConfig.theme_base}/js/effects/universe.min.js?mew=${DreamConfig.theme_version}`)
DreamConfig.effects_circle_magic_mode && Utils.cachedScript(`${DreamConfig.theme_base}/js/effects/circleMagic.min.js?mew=${DreamConfig.theme_version}`)
},
/* 加载主动推送、统计脚本等参数 */
loadMaintain() {
DreamConfig.enable_baidu_push && Utils.baiduPush()
DreamConfig.enable_toutiao_push && Utils.toutiaoPush()
},
// /* 加载主动推送、统计脚本等参数 */
// loadMaintain() {
// DreamConfig.enable_baidu_push && Utils.baiduPush()
// DreamConfig.enable_toutiao_push && Utils.toutiaoPush()
// },
/* 显示主题版本信息 */
showThemeVersion() {
window.logger(`%c页面加载耗时${Math.round(performance.now())}ms | Theme By Dream ${DreamConfig.theme_version}`,
@ -588,8 +588,8 @@ const commonContext = {
window.commonContext = commonContext
!(function () {
const loads = ['initCarousel', 'sparkInput', 'websiteTime', 'initComment']
const omits = ['initEffects', 'loadMaintain', 'showThemeVersion']
const loads = ['initCarousel', 'sparkInput', 'websiteTime']
const omits = ['initEffects', 'showThemeVersion']
Object.keys(commonContext).forEach(
(c) => !loads.includes(c) && !omits.includes(c) && commonContext[c]()

View File

@ -171,12 +171,12 @@ $(document).on('pjax:success', async function (event, data, status, xhr, options
window.journalPjax && window.journalPjax(serialNumber)
/* 初始化文章界面 */
window.postPjax && window.postPjax(serialNumber)
/* 初始化评论 */
commonContext.initComment()
// /* 初始化评论 */
// commonContext.initComment()
/* 初始化轮播 */
commonContext.initCarousel()
/* 加载主动推送或统计脚本 */
commonContext.loadMaintain()
// /* 加载主动推送或统计脚本 */
// commonContext.loadMaintain()
window.DProgress && DProgress.done()
})

View File

@ -199,27 +199,27 @@ const Utils = {
})
})
},
/* 百度自动推送 */
baiduPush() {
let bp = document.createElement('script')
let curProtocol = window.location.protocol.split(':')[0]
if (curProtocol === 'https') {
bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'
} else {
bp.src = 'http://push.zhanzhang.baidu.com/push.js'
}
$(`script[src="${bp.src}"]`).remove()
let s = document.getElementsByTagName('script')[0]
s.parentNode.insertBefore(bp, s)
},
toutiaoPush() {
let el = document.createElement('script')
el.src = 'https://lf1-cdn-tos.bytegoofy.com/goofy/ttzz/push.js?0fbcfbb1ed642c21419d5be02d56ade7d6ee5372ca221d12ba35df110760b2a830632485602430134f60bc55ca391050b680e2741bf7233a8f1da9902314a3fa'
el.id = 'ttzz'
$(`script[src="${el.src}"]`).remove()
let s = document.getElementsByTagName('script')[0]
s.parentNode.insertBefore(el, s)
},
// /* 百度自动推送 */
// baiduPush() {
// let bp = document.createElement('script')
// let curProtocol = window.location.protocol.split(':')[0]
// if (curProtocol === 'https') {
// bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'
// } else {
// bp.src = 'http://push.zhanzhang.baidu.com/push.js'
// }
// $(`script[src="${bp.src}"]`).remove()
// let s = document.getElementsByTagName('script')[0]
// s.parentNode.insertBefore(bp, s)
// },
// toutiaoPush() {
// let el = document.createElement('script')
// el.src = 'https://lf1-cdn-tos.bytegoofy.com/goofy/ttzz/push.js?0fbcfbb1ed642c21419d5be02d56ade7d6ee5372ca221d12ba35df110760b2a830632485602430134f60bc55ca391050b680e2741bf7233a8f1da9902314a3fa'
// el.id = 'ttzz'
// $(`script[src="${el.src}"]`).remove()
// let s = document.getElementsByTagName('script')[0]
// s.parentNode.insertBefore(el, s)
// },
/* sleep */
sleep(ms = 250) {
return new Promise((resolve) => setTimeout(resolve, ms))

View File

@ -117,8 +117,8 @@
[(${theme.config.enhance.effects_snowflake_mode != 'none'?'DreamConfig["effects_snowflake_mode"] = "' + theme.config.enhance.effects_snowflake_mode + '";': ''})]
[(${theme.config.enhance.effects_universe_mode != 'none'?'DreamConfig["effects_universe_mode"] = "' + theme.config.enhance.effects_universe_mode + '";': ''})]
[(${theme.config.enhance.effects_circle_magic_mode != 'none'?'DreamConfig["effects_circle_magic_mode"] = "' + theme.config.enhance.effects_circle_magic_mode + '";': ''})]
[(${theme.config.enhance.enable_baidu_push?'DreamConfig["enable_baidu_push"] = true;': ''})]
[(${theme.config.enhance.enable_toutiao_push?'DreamConfig["enable_toutiao_push"] = true;': ''})]
// [(${theme.config.enhance.enable_baidu_push?'DreamConfig["enable_baidu_push"] = true;': ''})]
// [(${theme.config.enhance.enable_toutiao_push?'DreamConfig["enable_toutiao_push"] = true;': ''})]
[(${theme.config.post.show_img_name?'DreamConfig["show_img_name"] = true;': ''})]
[(${theme.config.basic_style.load_progress != 'none'?'DreamConfig["load_progress"] = "' + theme.config.basic_style.load_progress + '";': ''})]
[(${!#strings.isEmpty(theme.config.page_config.journals_share_image)?'DreamConfig["journals_share_image"] = "' + theme.config.page_config.journals_share_image + '";': ''})]
@ -126,6 +126,18 @@
/** 配置主题模式 */
DreamConfig["default_theme"] = '[(${theme.config.basic_style.default_theme})]';
(function(){
let isNight = DreamConfig.default_theme === 'system'? matchMedia('(prefers-color-scheme: dark)').matches : localStorage.getItem('night') || DreamConfig.default_theme === 'night';
if (isNight.toString() === 'true') {
localStorage.setItem('night', 'true');
document.documentElement.classList.add('night');
// 组件配色方案
document.documentElement.classList.add('color-scheme-dark');
} else {
localStorage.setItem('night', 'false');
// 组件配色方案
document.documentElement.classList.add('color-scheme-light');
}
})();
</script>
</th:block>

View File

@ -1,5 +1,5 @@
<html lang="zh" xmlns:th="https://www.thymeleaf.org"
th:class="${theme.config.basic_style.theme_style}"
th:class="${theme.config.basic_style.theme_style + ' plugin-unified-plan'}"
th:fragment="layout (title, canonical, content, isPost)">
<th:block th:with="contributor = ${contributorFinder.getContributor(theme.config.basic_info.metadata_name)},
enableComment = ${baseEnableComment == true && site.comment.enable && pluginFinder.available('PluginCommentWidget')}">

View File

@ -14,7 +14,7 @@
<script th:if="${isJournals}" data-pjax th:src="@{/assets/js/journals.min.js(mew=${theme.spec.version})}"></script>
</th:block>
<script th:if="${isPhotos}" data-pjax th:src="@{/assets/lib/justifiedGallery@3.8.1/jquery.justifiedGallery.min.js}"></script>
<script th:if="${enableComment}" data-pjax src="/plugins/PluginCommentWidget/assets/static/comment-widget.iife.js"></script>
<!-- <script th:if="${enableComment}" data-pjax src="/plugins/PluginCommentWidget/assets/static/comment-widget.iife.js"></script>-->
<script th:src="@{/assets/js/mew-custom.min.js(mew=${theme.spec.version})}"></script>

View File

@ -49,7 +49,11 @@
</div>
<div class="card card-content" id="comment-wrapper" th:if="${enableComment}">
<h3 class="comment-title">评论</h3>
<div class="comment-section" th:data-id="${theme.config.page_config.link_comment_id}" data-target="SinglePage"></div>
<halo:comment
group="content.halo.run"
kind="SinglePage"
th:attr="name=${theme.config.page_config.link_comment_id}"
/>
</div>
</th:block>
</th:block>

View File

@ -92,6 +92,10 @@
<div class="card card-content" id="comment-wrapper" th:if="${enableComment}">
<h3 class="comment-title">评论</h3>
<div class="comment-section" th:data-id="${post.metadata.name}" th:data-target="${type}"></div>
<halo:comment
group="content.halo.run"
th:kind="${type}"
th:attr="name=${post.metadata.name}"
/>
</div>
</th:block>

View File

@ -46,7 +46,11 @@
</div>
</div>
<div class="journal-comment" th:if="${enableComment}">
<div class="comment-section" data-target="Moment" th:data-id="${moment.metadata.name}"></div>
<halo:comment
group="moment.halo.run"
kind="Moment"
th:attr="name=${moment.metadata.name}"
/>
</div>
</div>
<th:block th:replace="~{main/pagination :: pagination (${moments}, '/moments')}"/>