perf: optimize 'side_tools' configuration item of the theme _config.yml
This commit is contained in:
parent
4ab5189cb2
commit
77892feeaa
|
@ -1,16 +1,19 @@
|
||||||
<%- js([
|
<%- js([
|
||||||
'js/utils.js',
|
'js/utils.js',
|
||||||
'js/header-shrink.js',
|
'js/header-shrink.js',
|
||||||
'js/dark-light-toggle.js',
|
|
||||||
'js/main.js'
|
'js/main.js'
|
||||||
]) %>
|
]) %>
|
||||||
|
|
||||||
<% if (theme.local_search.enable && config.search) { %>
|
<% if (theme.side_tools.enable) { %>
|
||||||
<%- js('js/local-search.js') %>
|
<%- js('js/dark-light-toggle.js') %>
|
||||||
|
|
||||||
|
<% if (theme.back2top.enable) { %>
|
||||||
|
<%- js('js/back2top.js') %>
|
||||||
|
<% } %>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
<% if (theme.back2top.enable) { %>
|
<% if (theme.local_search.enable && config.search) { %>
|
||||||
<%- js('js/back2top.js') %>
|
<%- js('js/local-search.js') %>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
<% if (is_post()) { %>
|
<% if (is_post()) { %>
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if (theme.side_tools.enable) { %>
|
<% if (theme.side_tools.enable) { %>
|
||||||
<div class="sidebar-tools-2">
|
<div class="bottom-sidebar-tools">
|
||||||
<%- partial('_partial/tools2') %>
|
<%- partial('_partial/tools2') %>
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
|
@ -15,7 +15,8 @@ hexo.extend.helper.register('export_config', function () {
|
||||||
localsearch: theme.local_search,
|
localsearch: theme.local_search,
|
||||||
codeblock: theme.codeblock,
|
codeblock: theme.codeblock,
|
||||||
toc: theme.toc,
|
toc: theme.toc,
|
||||||
back2top: theme.back2top
|
back2top: theme.back2top,
|
||||||
|
side_tools: theme.side_tools
|
||||||
};
|
};
|
||||||
if (config.search) {
|
if (config.search) {
|
||||||
exportConfig.path = config.search.path;
|
exportConfig.path = config.search.path;
|
||||||
|
|
|
@ -166,7 +166,7 @@ $page-aside-width = 258px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.sidebar-tools-2 {
|
.bottom-sidebar-tools {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: $component-interspace;
|
bottom: $component-interspace;
|
||||||
right: $component-interspace;
|
right: $component-interspace;
|
||||||
|
|
|
@ -56,7 +56,7 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||||
},
|
},
|
||||||
|
|
||||||
initModeToggleButton() {
|
initModeToggleButton() {
|
||||||
this.modeToggleButton_dom && this.modeToggleButton_dom.addEventListener('click', () => {
|
this.modeToggleButton_dom.addEventListener('click', () => {
|
||||||
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||||
this.setItemUtil('light-mode', 'dark');
|
this.setItemUtil('light-mode', 'dark');
|
||||||
} else {
|
} else {
|
||||||
|
@ -64,7 +64,6 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ILS.utils.modeToggle.initModeStatus();
|
ILS.utils.modeToggle.initModeStatus();
|
||||||
|
|
|
@ -67,12 +67,13 @@ ILS.utils = {
|
||||||
|
|
||||||
// tools
|
// tools
|
||||||
registerToolsButtonClick() {
|
registerToolsButtonClick() {
|
||||||
|
if (!CONFIG.side_tools.enable) return;
|
||||||
|
|
||||||
let isOpen = false
|
let isOpen = false;
|
||||||
this.toolsMenuButton_dom = document.querySelector('.tools-button');
|
this.toolsMenuButton_dom = document.querySelector('.tools-button');
|
||||||
this.toolsWrapperList_dom = document.querySelectorAll('.tools-wrapper li');
|
this.toolsWrapperList_dom = document.querySelectorAll('.tools-wrapper li');
|
||||||
|
|
||||||
this.toolsMenuButton_dom && this.toolsMenuButton_dom.addEventListener('click', e => {
|
this.toolsMenuButton_dom.addEventListener('click', e => {
|
||||||
isOpen = !isOpen;
|
isOpen = !isOpen;
|
||||||
|
|
||||||
const toolsMenuButtonIcon = this.toolsMenuButton_dom.querySelector('i');
|
const toolsMenuButtonIcon = this.toolsMenuButton_dom.querySelector('i');
|
||||||
|
|
Loading…
Reference in New Issue