Skip to content

Commit ffbc2f1

Browse files
committed
增加黑暗模式的关闭,fixes #17
1 parent b178f55 commit ffbc2f1

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

assets/css/main.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ header {
6666
background: var(--light-background);
6767
box-shadow: var(--box-shadow);
6868
height: 2.8rem;
69-
border-bottom: 1px solid var(--theme-text-color);
7069
}
7170
.toolbar-left {
7271
font-size: 20px;

assets/js/lanstarApp.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ let lanstar = {
8181
})
8282
},
8383
addDarkMode: function () {
84+
if(config['dark'] == '0') return false;
8485
// 根据时间
8586
let timeNow = new Date();
8687
// 获取当前小时
@@ -269,7 +270,7 @@ let lanstar = {
269270
logo: 'OωO',
270271
container: document.getElementsByClassName('OwO')[0],
271272
target: document.getElementsByClassName('owo-textarea')[0],
272-
api: _owo,
273+
api: config['owo'],
273274
position: 'down',
274275
width: '100%',
275276
maxHeight: '250px'

component/index.footer.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
<script src="https://cdn.staticfile.org/toastify-js/1.11.2/toastify.min.js"></script>
88
<script type="text/javascript" src="https://unpkg.com/mathjax@3.2.2/es5/tex-mml-chtml.js"></script>
99
<?php $this->options->jsEcho(); ?>
10-
<script>let _owo = '<?php utils::indexTheme('assets/owo/OwO.json'); ?>'</script>
10+
<script>let config = {
11+
'owo':'<?php utils::indexTheme('assets/owo/OwO.json'); ?>',
12+
'dark': '<?php echo $this->options->darkBtn;?>''
13+
}</script>
1114
<script
1215
src="<?php utils::indexTheme('assets/js/OwO.js'); ?>"></script>
1316
<script

layout/head.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<use xlink:href="#icon-daohang1"></use>
1414
</svg>
1515
</button>
16+
<?php if($this->options->darkBtn):?>
1617
<button class="float-end chose-mode-day float-right" id="night-mode" type="button">
1718
<svg class="icon" aria-hidden="true">
1819
<use xlink:href="#icon-yueliang"></use>
@@ -23,6 +24,7 @@
2324
<use xlink:href="#icon-taiyang"></use>
2425
</svg>
2526
</button>
27+
<?php endif;?>
2628
</div>
2729
</header>
2830

libs/options.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ function themeConfig($form)
9797
$logoUrl = new Typecho_Widget_Helper_Form_Element_Text('logoUrl', NULL, NULL, _t('站点 LOGO 地址'), _t('在这里填入一个图片 URL 地址, 以在头部加上一个 LOGO'));
9898
$logoUrl->setAttribute('class', 'theme-setting-content theme-setting-global');
9999
$form->addInput($logoUrl);
100+
101+
$darkBtn = new Typecho_Widget_Helper_Form_Element_Radio('darkBtn',
102+
array(1 => _t('启用'),
103+
0 => _t('关闭')),
104+
1, _t('是否开启暗黑模式'), _t('默认关闭'));
105+
$darkBtn->setAttribute('class', 'theme-setting-content theme-setting-global');
106+
$form->addInput($darkBtn);
107+
100108
$bannerBtn = new Typecho_Widget_Helper_Form_Element_Radio('bannerBtn',
101109
array(1 => _t('启用'),
102110
0 => _t('关闭')),

0 commit comments

Comments
 (0)