Skip to content

Commit

Permalink
增加黑暗模式的关闭,fixes #17
Browse files Browse the repository at this point in the history
  • Loading branch information
dyedd committed Aug 8, 2022
1 parent b178f55 commit ffbc2f1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
1 change: 0 additions & 1 deletion assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ header {
background: var(--light-background);
box-shadow: var(--box-shadow);
height: 2.8rem;
border-bottom: 1px solid var(--theme-text-color);
}
.toolbar-left {
font-size: 20px;
Expand Down
3 changes: 2 additions & 1 deletion assets/js/lanstarApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ let lanstar = {
})
},
addDarkMode: function () {
if(config['dark'] == '0') return false;
// 根据时间
let timeNow = new Date();
// 获取当前小时
Expand Down Expand Up @@ -269,7 +270,7 @@ let lanstar = {
logo: 'OωO',
container: document.getElementsByClassName('OwO')[0],
target: document.getElementsByClassName('owo-textarea')[0],
api: _owo,
api: config['owo'],
position: 'down',
width: '100%',
maxHeight: '250px'
Expand Down
5 changes: 4 additions & 1 deletion component/index.footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
<script src="https://cdn.staticfile.org/toastify-js/1.11.2/toastify.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/mathjax@3.2.2/es5/tex-mml-chtml.js"></script>
<?php $this->options->jsEcho(); ?>
<script>let _owo = '<?php utils::indexTheme('assets/owo/OwO.json'); ?>'</script>
<script>let config = {
'owo':'<?php utils::indexTheme('assets/owo/OwO.json'); ?>',
'dark': '<?php echo $this->options->darkBtn;?>''
}</script>
<script
src="<?php utils::indexTheme('assets/js/OwO.js'); ?>"></script>
<script
Expand Down
2 changes: 2 additions & 0 deletions layout/head.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<use xlink:href="#icon-daohang1"></use>
</svg>
</button>
<?php if($this->options->darkBtn):?>
<button class="float-end chose-mode-day float-right" id="night-mode" type="button">
<svg class="icon" aria-hidden="true">
<use xlink:href="#icon-yueliang"></use>
Expand All @@ -23,6 +24,7 @@
<use xlink:href="#icon-taiyang"></use>
</svg>
</button>
<?php endif;?>
</div>
</header>

Expand Down
8 changes: 8 additions & 0 deletions libs/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ function themeConfig($form)
$logoUrl = new Typecho_Widget_Helper_Form_Element_Text('logoUrl', NULL, NULL, _t('站点 LOGO 地址'), _t('在这里填入一个图片 URL 地址, 以在头部加上一个 LOGO'));
$logoUrl->setAttribute('class', 'theme-setting-content theme-setting-global');
$form->addInput($logoUrl);

$darkBtn = new Typecho_Widget_Helper_Form_Element_Radio('darkBtn',
array(1 => _t('启用'),
0 => _t('关闭')),
1, _t('是否开启暗黑模式'), _t('默认关闭'));
$darkBtn->setAttribute('class', 'theme-setting-content theme-setting-global');
$form->addInput($darkBtn);

$bannerBtn = new Typecho_Widget_Helper_Form_Element_Radio('bannerBtn',
array(1 => _t('启用'),
0 => _t('关闭')),
Expand Down

0 comments on commit ffbc2f1

Please sign in to comment.