diff options
| author | Eltrac Koalar <hi@guhub.cn> | 2022-09-22 00:28:15 +0800 |
|---|---|---|
| committer | Eltrac Koalar <hi@guhub.cn> | 2022-09-22 00:28:15 +0800 |
| commit | 88f5218c0e75d2f7c09184aabe9a884cd5671f52 (patch) | |
| tree | 0bb62d501a254d5e75e7bac24a5cad65ac5061a2 /libs | |
| parent | 08f2cf5ddba0ec7dfd2175a1077887737a0bd181 (diff) | |
:sheep: Add: 初步实现「超简洁模式」
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/Matcha.php | 25 | ||||
| -rw-r--r-- | libs/Options.php | 12 |
2 files changed, 29 insertions, 8 deletions
diff --git a/libs/Matcha.php b/libs/Matcha.php index 6b31b5b..f7aa77f 100644 --- a/libs/Matcha.php +++ b/libs/Matcha.php @@ -105,8 +105,6 @@ class Matcha echo '<script>'; echo 'siteurl="'; Utils::indexHome(); echo '";'; //站点 url 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;'; } @@ -161,9 +159,9 @@ class Matcha //必须要在本地引入的文件 array_push($local_includes, "prism/prism", - "smoothscroll/smoothscroll", "toaster/toaster" ); + if(Helper::options()->EnableExtraSimple!='able') array_push($local_includes, 'smoothscroll/smoothscroll'); if(Helper::options()->EnableAjaxComment=='able') array_push($local_includes, 'matcha.comment'); array_push($local_includes, 'matcha'); //主题核心文件在最后引入 foreach($local_includes as $value){ @@ -409,11 +407,13 @@ class Matcha } /** - * 判断是否打开夜间模式 + * 输出 body 标签的 class */ - public static function ifDark() { + public static function bodyClass() { + $class_list = array(); + + //判断夜间模式 $ifDark=false; - if(isset($_COOKIE['matchaDark'])) { if($_COOKIE['matchaDark']=='y') { $ifDark=true; @@ -432,8 +432,17 @@ class Matcha $ifDark=true; } } - - if($ifDark) echo ' class="matcha-dark"'; + if($ifDark) array_push($class_list, 'matcha-dark'); + + //是否开启「超简洁模式」 + if(Helper::options()->EnableExtraSimple=='able') array_push($class_list, 'extrasimple'); + + if(!empty($class_list)){ + $class_list = implode(' ', $class_list); + echo ' class="'.$class_list.'"'; + }else{ + return false; + } } /** diff --git a/libs/Options.php b/libs/Options.php index 43180e0..cc16028 100644 --- a/libs/Options.php +++ b/libs/Options.php @@ -28,6 +28,18 @@ function themeConfig($form) { _t('自定义主题色'), _t('只有在上一个设置项选择「自定义主题色」,这个设置才会生效,在这里写入任何 css 支持的颜色代码')); $form->addInput($themeColorCustom); + //超简洁模式 + $EnableExtraSimple = new Typecho_Widget_Helper_Form_Element_Radio('EnableExtraSimple', array( + 'able' => _t('启用'), + 'disable' => _t('停用'), + ), + 'able', + _t('是否启用「超简洁模式」'), + _t(' + 启用后开启超简洁模式,页面整体会更干净,也会一定程度上加快页面加载速度。 + ') + ); + $form->addInput($EnableExtraSimple->addRule('required', _t('此处必须设置'))); //首页摘要显示模式 $IndexDisplayMode = new Typecho_Widget_Helper_Form_Element_Radio('IndexDisplayMode', array( 'FullText' => _t('根据 more 标签截断'), |
