From 4d50c2ea56095ae788fa9f11e69cb17fb81031f1 Mon Sep 17 00:00:00 2001 From: Eltrac Koalar Date: Sat, 27 Aug 2022 01:32:20 +0800 Subject: =?UTF-8?q?:last=5Fquarter=5Fmoon:=20Add:=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=88=87=E6=8D=A2=E5=A4=9C=E9=97=B4=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 同时添加了夜间模式相关的设置项 --- libs/Matcha.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'libs/Matcha.php') diff --git a/libs/Matcha.php b/libs/Matcha.php index 56a3d01..ff0f374 100644 --- a/libs/Matcha.php +++ b/libs/Matcha.php @@ -104,6 +104,9 @@ class Matcha echo 'pjaxCallback=function(){'.Helper::options()->pjaxCallback.'};'; echo 'AjaxCommentEnabled="'.Helper::options()->EnableAjaxComment.'";'; echo 'RandomLinks="'.Helper::options()->EnableRandomLinks.'";'; + if(Helper::options()->DarkMode=='default' || Helper::options()->DarkMode=='dark'){ + echo 'allowDarkMode=true;'; + } echo ''; } @@ -387,4 +390,26 @@ class Matcha } return $stat; } + + /** + * 判断是否打开夜间模式 + */ + public static function ifDark() { + $ifDark=false; + + if($_COOKIE['matchaDark']=='y') { + $ifDark=true; + } + elseif(Helper::options()->DarkMode=='default' && date('H')>18 && date('H')<7 && $_COOKIE['matchaDark']=='n') { + $ifDark=true; + } + elseif(Helper::options()->DarkMode=='dark' && !$_COOKIE['matchaDark']=='n'){ + $ifDark=true; + } + elseif(Helper::options()->DarkMode=='always') { + $ifDark=true; + } + + if($ifDark) echo ' class="matcha-dark"'; + } } \ No newline at end of file -- cgit v1.2.3