From 09f3c2c9fc0c68da2de507d68da764029d8a4499 Mon Sep 17 00:00:00 2001 From: sight <1453017105@qq.com> Date: Sun, 28 May 2023 20:02:54 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20laydate=20=E8=BE=85?= =?UTF-8?q?=E5=8A=A9=E8=89=B2=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/laydate.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/modules/laydate.js b/src/modules/laydate.js index 6c431bd5..30f9f4cc 100644 --- a/src/modules/laydate.js +++ b/src/modules/laydate.js @@ -657,17 +657,30 @@ }); options.showBottom && elem.appendChild(divFooter); - //生成自定义主题 + // 生成自定义主题 var style = lay.elem('style'); var styleText = []; var colorTheme; + var isPrimaryColor = true; lay.each(options.theme, function (index, theme) { - if(/^#/.test(theme)){ + // 主色 + if(isPrimaryColor && /^#/.test(theme)){ colorTheme = true; + isPrimaryColor = false; styleText.push([ - '#{{id}} .layui-laydate-header{background-color:{{theme}};}' - ,'#{{id}} li.layui-this,#{{id}} td.layui-this>div{background-color:{{theme}} !important;}' - ,options.theme.indexOf('circle') !== -1 ? '' : '#{{id}} .layui-this{background-color:{{theme}} !important;}' + '#{{id}} .layui-laydate-header{background-color:{{theme}};}', + '#{{id}} li.layui-this,#{{id}} td.layui-this>div{background-color:{{theme}} !important;}', + options.theme.indexOf('circle') !== -1 ? '' : '#{{id}} .layui-this{background-color:{{theme}} !important;}', + '#{{id}} .laydate-day-now{color:{{theme}} !important;}', + '#{{id}} .laydate-day-now:after{border-color:{{theme}} !important;}', + ].join('').replace(/{{id}}/g, that.elemID).replace(/{{theme}}/g, theme)); + return; + } + // 第二个自定义颜色作为辅色 + if(!isPrimaryColor && /^#/.test(theme)){ + styleText.push([ + '#{{id}} .laydate-selected>div{background-color:{{theme}} !important;}', + '#{{id}} .laydate-selected:hover>div{background-color:{{theme}} !important;}', ].join('').replace(/{{id}}/g, that.elemID).replace(/{{theme}}/g, theme)); } }); From b4b25c4a525607957efb3cf20983970303c60dc1 Mon Sep 17 00:00:00 2001 From: sight <1453017105@qq.com> Date: Sun, 28 May 2023 22:57:56 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=8D=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E9=80=97=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/laydate.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/laydate.js b/src/modules/laydate.js index 30f9f4cc..0725bfb2 100644 --- a/src/modules/laydate.js +++ b/src/modules/laydate.js @@ -672,7 +672,7 @@ '#{{id}} li.layui-this,#{{id}} td.layui-this>div{background-color:{{theme}} !important;}', options.theme.indexOf('circle') !== -1 ? '' : '#{{id}} .layui-this{background-color:{{theme}} !important;}', '#{{id}} .laydate-day-now{color:{{theme}} !important;}', - '#{{id}} .laydate-day-now:after{border-color:{{theme}} !important;}', + '#{{id}} .laydate-day-now:after{border-color:{{theme}} !important;}' ].join('').replace(/{{id}}/g, that.elemID).replace(/{{theme}}/g, theme)); return; } @@ -680,7 +680,7 @@ if(!isPrimaryColor && /^#/.test(theme)){ styleText.push([ '#{{id}} .laydate-selected>div{background-color:{{theme}} !important;}', - '#{{id}} .laydate-selected:hover>div{background-color:{{theme}} !important;}', + '#{{id}} .laydate-selected:hover>div{background-color:{{theme}} !important;}' ].join('').replace(/{{id}}/g, that.elemID).replace(/{{theme}}/g, theme)); } });