From 1574ce007c9a8cf699709684b147fc6ba02c849a Mon Sep 17 00:00:00 2001 From: mjsoftware <1406993111@qq.com> Date: Thu, 7 Mar 2024 20:02:55 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=9A=201.=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E8=AF=84=E8=AE=BA=E5=8A=A0=E8=BD=BD=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=EF=BC=8C=E6=94=B9=E4=B8=BA=E7=BB=84=E4=BB=B6=EF=BC=8C=E9=A1=BB?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=AF=84=E8=AE=BA=E6=8F=92=E4=BB=B6=E5=88=B0?= =?UTF-8?q?2.0.0=E5=90=AB=E9=A2=84=E5=8F=91=E5=B8=83=202.=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E6=8F=92=E4=BB=B6=E7=BB=9F=E4=B8=80=E9=85=8D=E8=89=B2?= =?UTF-8?q?=E6=96=B9=E6=A1=88=E5=88=87=E6=8D=A2=E6=96=B9=E5=BC=8F=EF=BC=8C?= =?UTF-8?q?=E7=9B=AE=E5=89=8D=E4=BD=BF=E7=94=A8=E6=90=9C=E7=B4=A2=E3=80=81?= =?UTF-8?q?=E8=AF=84=E8=AE=BA=E6=8F=92=E4=BB=B6=E8=87=AA=E5=B8=A6=E7=9A=84?= =?UTF-8?q?=E9=AB=98=E4=BA=AE=E5=92=8C=E6=9A=97=E9=BB=91=E6=96=B9=E6=A1=88?= =?UTF-8?q?=203.=E7=A7=BB=E9=99=A4=E7=99=BE=E5=BA=A6=E3=80=81=E5=A4=B4?= =?UTF-8?q?=E6=9D=A1=E6=8E=A8=E9=80=81=E8=83=BD=E5=8A=9B=EF=BC=8C=E5=BB=BA?= =?UTF-8?q?=E8=AE=AE=E4=BD=BF=E7=94=A8=E6=8F=92=E4=BB=B6=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- settings.yaml | 36 +++---- src/css/theme.less | 181 ++++++++++++++++++++-------------- src/js/common.js | 64 ++++++------ src/js/pjax.js | 8 +- src/js/utils.js | 42 ++++---- templates/common/config.html | 18 +++- templates/common/layout.html | 2 +- templates/common/scripts.html | 2 +- templates/links.html | 6 +- templates/main/article.html | 6 +- templates/moments.html | 6 +- 11 files changed, 215 insertions(+), 156 deletions(-) diff --git a/settings.yaml b/settings.yaml index 615708f..9651681 100644 --- a/settings.yaml +++ b/settings.yaml @@ -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 日志 diff --git a/src/css/theme.less b/src/css/theme.less index ddfe2aa..2ca6f6f 100644 --- a/src/css/theme.less +++ b/src/css/theme.less @@ -108,81 +108,116 @@ html { } } } -} -//組件高亮 -.color-scheme-light { - /*搜索組件配色 - 高亮*/ - //基础字体大小 - //--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 插件统一方案,使用此须在主题配置中设定变量,用来应对高亮和黑暗配色切换 + &.plugin-unified-plan { + /*todo 搜索組件*/ + //基础字体大小 + //--halo-search-widget-base-font-size: 1rem !important; + //基础元素的圆角 + //--halo-search-widget-base-border-radius: !important; + //基础字体族 + //--halo-search-widget-base-font-family: !important; + //模态层颜色 + //--halo-search-widget-color-modal-layer: var(--theme) !important; + //模态内容背景颜色 + //--halo-search-widget-color-modal-content-bg: var(--theme) !important; + //表单输入背景颜色 + //--halo-search-widget-color-form-input-bg: !important; + //表单输入文字颜色 + //--halo-search-widget-color-form-input: !important; + //表单输入占位符颜色 + //--halo-search-widget-color-form-input-placeholder: !important; + //表单分隔线颜色 + //--halo-search-widget-color-form-divider: !important; + //无结果提示颜色 + //--halo-search-widget-color-result-empty: !important; + //结果项背景颜色 + //--halo-search-widget-color-result-item-bg: !important; + //结果项悬停背景颜色 + //--halo-search-widget-color-result-item-hover-bg: !important; + //结果项标题颜色 + //--halo-search-widget-color-result-item-title: !important; + //结果项内容颜色 + //--halo-search-widget-color-result-item-content: !important; + //命令键盘项颜色 + //--halo-search-widget-color-command-kbd-item: !important; + //命令键盘边框颜色 + //--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: ; - -} \ No newline at end of file +////組件高亮,todo 使用此方案时复制统一配色方案的相关内容后修改对应值 +//.color-scheme-light { +//} +////組件暗黑,todo 使用此方案时复制统一配色方案的相关内容后修改对应值 +//.color-scheme-dark { +//} \ No newline at end of file diff --git a/src/js/common.js b/src/js/common.js index 71668ab..005487a 100644 --- a/src/js/common.js +++ b/src/js/common.js @@ -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]() diff --git a/src/js/pjax.js b/src/js/pjax.js index abddb07..b8c14cb 100644 --- a/src/js/pjax.js +++ b/src/js/pjax.js @@ -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() }) diff --git a/src/js/utils.js b/src/js/utils.js index a66fe90..d1dd5f7 100644 --- a/src/js/utils.js +++ b/src/js/utils.js @@ -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)) diff --git a/templates/common/config.html b/templates/common/config.html index 8fb70cb..51dc3fe 100644 --- a/templates/common/config.html +++ b/templates/common/config.html @@ -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'); + } + })(); \ No newline at end of file diff --git a/templates/common/layout.html b/templates/common/layout.html index a85bf80..3a757f3 100644 --- a/templates/common/layout.html +++ b/templates/common/layout.html @@ -1,5 +1,5 @@ diff --git a/templates/common/scripts.html b/templates/common/scripts.html index 3d26e25..fc9e9ce 100644 --- a/templates/common/scripts.html +++ b/templates/common/scripts.html @@ -14,7 +14,7 @@ - + diff --git a/templates/links.html b/templates/links.html index 1fe4f2b..1810b3b 100644 --- a/templates/links.html +++ b/templates/links.html @@ -49,7 +49,11 @@

评论

-
+
diff --git a/templates/main/article.html b/templates/main/article.html index a4fadf6..dd3b3dd 100644 --- a/templates/main/article.html +++ b/templates/main/article.html @@ -92,6 +92,10 @@

评论

-
+
\ No newline at end of file diff --git a/templates/moments.html b/templates/moments.html index 63938d8..a793f92 100644 --- a/templates/moments.html +++ b/templates/moments.html @@ -46,7 +46,11 @@
-
+