From 86039958e4bd2c95fe4bdc7bd1e3fae919aef9f6 Mon Sep 17 00:00:00 2001 From: mjsoftware <1406993111@qq.com> Date: Mon, 4 Mar 2024 13:11:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=20=E5=BB=BA?= =?UTF-8?q?=E7=AB=99=E6=97=B6=E9=97=B4=E6=94=B9=E4=B8=BA=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=EF=BC=8C=E6=94=AF=E6=8C=81=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=88=B0=E5=88=86=E9=92=9F=EF=BC=9B=20=E7=81=B0=E8=89=B2?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=AE=B5=E6=98=BE=E7=A4=BA=EF=BC=8C=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=97=B6=E9=97=B4=E7=BB=84=E4=BB=B6=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=BC=80=E5=A7=8B=E5=92=8C=E7=BB=93=E6=9D=9F=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- settings.yaml | 46 ++++++++++++++++++++++++++---------- src/css/style.less | 4 ++++ src/js/common.js | 20 ++++++++++++++-- templates/common/config.html | 6 ++++- 4 files changed, 61 insertions(+), 15 deletions(-) diff --git a/settings.yaml b/settings.yaml index 1bb2163..615708f 100644 --- a/settings.yaml +++ b/settings.yaml @@ -46,11 +46,10 @@ spec: name: record_number_ps label: 公安部备案 placeholder: 'X公网安备 XXXXXXXXXXXXXX号' - - $formkit: text + - $formkit: datetime-local name: website_time label: 建站时间 - placeholder: 'YYYY/MM/dd HH:mm:ss' - help: '按YYYY/MM/dd HH:mm:ss格式输入时间进行倒计时,非时间格式则直接显示文本。' + help: '请选择建站时间,未选择时不显示。' - $formkit: attachment name: cloud_by_logo label: '云服务提供商 Logo' @@ -1236,16 +1235,39 @@ spec: label: 黑暗模式 - value: all label: 全模式 - - $formkit: radio - name: enable_gray_mode - label: 灰色模式 - value: false + - $formkit: group + name: gray_mode_group + label: 灰色模式 help: '向英雄致敬,愿精神长存!' - options: - - value: true - label: 开启 - - value: false - label: 关闭 + value: + enable_gray_mode: false + gray_mode_start_time: + gray_mode_end_time: + children: + - $formkit: radio + name: enable_gray_mode + id: enable_gray_mode + label: 开启灰色模式 + options: + - value: true + label: 开启 + - value: custom + label: 自定义 + - value: false + label: 关闭 + - $formkit: datetime-local + name: gray_mode_start_time + id: gray_mode_start_time + if: $get(enable_gray_mode).value === 'custom' + validation: required + help: 请选择开始时间,包含开始时间。 + label: 灰色模式 - 开始时间 + - $formkit: datetime-local + name: gray_mode_end_time + if: $get(enable_gray_mode).value === 'custom' + validation: required + help: 请选择结束时间,结束时间须大于开始时间,不包含结束时间。 + label: 灰色模式 - 结束时间 - $formkit: radio name: enable_busuanzi label: 开启 busuanzi 访客统计 diff --git a/src/css/style.less b/src/css/style.less index cf35869..1c3dc78 100644 --- a/src/css/style.less +++ b/src/css/style.less @@ -21,6 +21,10 @@ -webkit-tap-highlight-color: transparent; } +.gray-mode { + filter: grayscale(1) !important; +} + body > .footer, body > .navbar, body > .section { opacity: 0; transition: opacity 0.3s ease-out, transform 0.3s ease-out; diff --git a/src/js/common.js b/src/js/common.js index 80254ea..c0d2811 100644 --- a/src/js/common.js +++ b/src/js/common.js @@ -385,8 +385,11 @@ const commonContext = { return } const websiteDate = document.getElementById('websiteDate') - if (!/^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}$/.test(DreamConfig.website_time)) { - websiteDate.innerText = DreamConfig.website_time + // if (!/^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}$/.test(DreamConfig.website_time)) { + // websiteDate.innerText = DreamConfig.website_time + // return + // } + if (DreamConfig.website_time === '') { return } const now = new Date() @@ -519,6 +522,19 @@ const commonContext = { }) $('.aside-timelife').html(htmlStr) }, + /* 灰色模式 */ + initGrayMode() { + if(DreamConfig.gray_mode === true) { + $('html').addClass('gray-mode') + } else if(DreamConfig.gray_mode === 'custom') { + var now = new Date().getTime() + var startTime = new Date(DreamConfig.gray_mode_start_time).getTime() + var endTime = new Date(DreamConfig.gray_mode_end_time).getTime() + if(now >= startTime && now <= endTime) { + $('html').addClass('gray-mode') + } + } + }, /* 初始化评论区 */ initComment() { if (!window.CommentWidget) { diff --git a/templates/common/config.html b/templates/common/config.html index 7199c47..d34f470 100644 --- a/templates/common/config.html +++ b/templates/common/config.html @@ -12,7 +12,7 @@ html { --theme: [(${theme.config.basic_style.theme_color})]; - filter: [(${theme.config.enhance.enable_gray_mode ? 'grayscale(1) !important' : 'none'})]; + /*filter: [(${theme.config.enhance.enable_gray_mode ? 'grayscale(1) !important' : 'none'})];*/ [(${theme.config.enhance.cursor_style == 'breeze' ? '--cursor-default:url(/themes/theme-dream/assets/cursor/breeze/Arrow.cur),auto;--cursor-pointer:url(/themes/theme-dream/assets/cursor/breeze/Hand.cur),pointer;--cursor-text:url(/themes/theme-dream/assets/cursor/breeze/IBeam.cur),auto;--cursor-zoom-in:url(/themes/theme-dream/assets/cursor/breeze/Cross.cur),zoom-in;' : theme.config.enhance.cursor_style == 'black_cat' ? '--cursor-default:url(/themes/theme-dream/assets/cursor/black_cat/normal.cur),auto;--cursor-pointer:url(/themes/theme-dream/assets/cursor/black_cat/ayuda.cur),pointer;--cursor-text:url(/themes/theme-dream/assets/cursor/black_cat/texto.cur),auto;--cursor-zoom-in:url(/themes/theme-dream/assets/cursor/black_cat/precision.cur),zoom-in;' : theme.config.enhance.cursor_style == 'overwatch' ? '--cursor-default:url(/themes/theme-dream/assets/cursor/overwatch/pointer.cur),auto;--cursor-pointer:url(/themes/theme-dream/assets/cursor/overwatch/link.cur),pointer;--cursor-text:url(/themes/theme-dream/assets/cursor/overwatch/text.cur),auto;--cursor-zoom-in:url(/themes/theme-dream/assets/cursor/overwatch/cross.cur),zoom-in;' @@ -72,6 +72,10 @@ const DreamConfig = {}; /** 站点名 */ DreamConfig["site_title"] = [[${site.title}]]; + /** 灰色模式 */ + DreamConfig["gray_mode"] = [[${theme.config.enhance.gray_mode_group.enable_gray_mode}]]; + DreamConfig["gray_mode_start_time"] = [[${theme.config.enhance.gray_mode_group.gray_mode_start_time}]]; + DreamConfig["gray_mode_end_time"] = [[${theme.config.enhance.gray_mode_group.gray_mode_end_time}]]; /** 配置分享方式 */ let post_share = [] for (let share of [[${theme.config.post.custom_post_share}]]) {