mirror of
https://ghfast.top/https://github.com/zsjy/halo-theme-dream2.0-plus.git
synced 2025-03-16 04:19:41 +08:00
优化:
1.为组件添加暗黑模式时的默认样式 2.调整网页加载时暗黑还是高亮的判定方式 3.追加搜索组件的配色方案,但未启用
This commit is contained in:
parent
69dbfffe2e
commit
b0238605b0
@ -109,3 +109,80 @@ html {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//組件高亮
|
||||||
|
.color-scheme-light {
|
||||||
|
/*搜索組件配色 - 高亮*/
|
||||||
|
//基础字体大小
|
||||||
|
//--halo-search-widget-base-font-size: 1rem;
|
||||||
|
//基础元素的圆角
|
||||||
|
//--halo-search-widget-base-border-radius: ;
|
||||||
|
//基础字体族
|
||||||
|
//--halo-search-widget-base-font-family: ;
|
||||||
|
//模态层颜色
|
||||||
|
//--halo-search-widget-color-modal-layer: ;
|
||||||
|
//模态内容背景颜色
|
||||||
|
//--halo-search-widget-color-modal-content-bg: ;
|
||||||
|
//表单输入背景颜色
|
||||||
|
//--halo-search-widget-color-form-input-bg: ;
|
||||||
|
//表单输入文字颜色
|
||||||
|
//--halo-search-widget-color-form-input: ;
|
||||||
|
//表单输入占位符颜色
|
||||||
|
//--halo-search-widget-color-form-input-placeholder: ;
|
||||||
|
//表单分隔线颜色
|
||||||
|
//--halo-search-widget-color-form-divider: ;
|
||||||
|
//无结果提示颜色
|
||||||
|
//--halo-search-widget-color-result-empty: ;
|
||||||
|
//结果项背景颜色
|
||||||
|
//--halo-search-widget-color-result-item-bg: ;
|
||||||
|
//结果项悬停背景颜色
|
||||||
|
//--halo-search-widget-color-result-item-hover-bg: ;
|
||||||
|
//结果项标题颜色
|
||||||
|
//--halo-search-widget-color-result-item-title: ;
|
||||||
|
//结果项内容颜色
|
||||||
|
//--halo-search-widget-color-result-item-content: ;
|
||||||
|
//命令键盘项颜色
|
||||||
|
//--halo-search-widget-color-command-kbd-item: ;
|
||||||
|
//命令键盘边框颜色
|
||||||
|
//--halo-search-widget-color-command-kbd-border: ;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
//組件暗黑
|
||||||
|
.color-scheme-dark {
|
||||||
|
/*搜索組件配色 - 暗黑*/
|
||||||
|
//基础字体大小
|
||||||
|
//--halo-search-widget-base-font-size: 1rem;
|
||||||
|
//基础元素的圆角
|
||||||
|
//--halo-search-widget-base-border-radius: ;
|
||||||
|
//基础字体族
|
||||||
|
//--halo-search-widget-base-font-family: ;
|
||||||
|
//模态层颜色
|
||||||
|
//--halo-search-widget-color-modal-layer: ;
|
||||||
|
//模态内容背景颜色
|
||||||
|
//--halo-search-widget-color-modal-content-bg: ;
|
||||||
|
//表单输入背景颜色
|
||||||
|
//--halo-search-widget-color-form-input-bg: ;
|
||||||
|
//表单输入文字颜色
|
||||||
|
//--halo-search-widget-color-form-input: ;
|
||||||
|
//表单输入占位符颜色
|
||||||
|
//--halo-search-widget-color-form-input-placeholder: ;
|
||||||
|
//表单分隔线颜色
|
||||||
|
//--halo-search-widget-color-form-divider: ;
|
||||||
|
//无结果提示颜色
|
||||||
|
//--halo-search-widget-color-result-empty: ;
|
||||||
|
//结果项背景颜色
|
||||||
|
//--halo-search-widget-color-result-item-bg: ;
|
||||||
|
//结果项悬停背景颜色
|
||||||
|
//--halo-search-widget-color-result-item-hover-bg: ;
|
||||||
|
//结果项标题颜色
|
||||||
|
//--halo-search-widget-color-result-item-title: ;
|
||||||
|
//结果项内容颜色
|
||||||
|
//--halo-search-widget-color-result-item-content: ;
|
||||||
|
//命令键盘项颜色
|
||||||
|
//--halo-search-widget-color-command-kbd-item: ;
|
||||||
|
//命令键盘边框颜色
|
||||||
|
//--halo-search-widget-color-command-kbd-border: ;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -71,17 +71,11 @@ const commonContext = {
|
|||||||
let isNight = localStorage.getItem('night') || false
|
let isNight = localStorage.getItem('night') || false
|
||||||
const applyNight = (isNightValue) => {
|
const applyNight = (isNightValue) => {
|
||||||
if (isNightValue) {
|
if (isNightValue) {
|
||||||
document.documentElement.classList.add('night')
|
// 配色方案
|
||||||
// 组件配色方案
|
$('html').addClass('color-scheme-dark').removeClass('color-scheme-light').addClass('night')
|
||||||
$('html').addClass('color-scheme-dark').removeClass('color-scheme-light')
|
|
||||||
// document.documentElement.classList.add('color-scheme-dark')
|
|
||||||
// document.documentElement.classList.remove('color-scheme-light')
|
|
||||||
} else {
|
} else {
|
||||||
document.documentElement.classList.remove('night')
|
// 配色方案
|
||||||
// 组件配色方案
|
$('html').addClass('color-scheme-light').removeClass('color-scheme-dark').removeClass('night')
|
||||||
$('html').addClass('color-scheme-light').removeClass('color-scheme-dark')
|
|
||||||
// document.documentElement.classList.remove('color-scheme-dark')
|
|
||||||
// document.documentElement.classList.add('color-scheme-light')
|
|
||||||
}
|
}
|
||||||
$('.comment-section>div').each(function () {
|
$('.comment-section>div').each(function () {
|
||||||
const shadowDom = this.shadowRoot.querySelectorAll('.halo-comment-widget')[0]
|
const shadowDom = this.shadowRoot.querySelectorAll('.halo-comment-widget')[0]
|
||||||
@ -91,10 +85,14 @@ const commonContext = {
|
|||||||
localStorage.setItem('night', isNightValue)
|
localStorage.setItem('night', isNightValue)
|
||||||
isNight = isNightValue
|
isNight = isNightValue
|
||||||
}
|
}
|
||||||
|
//切换按钮
|
||||||
$('#toggle-mode').on('click', () => applyNight(isNight.toString() !== 'true'))
|
$('#toggle-mode').on('click', () => applyNight(isNight.toString() !== 'true'))
|
||||||
|
//加载后首选的配色
|
||||||
if (DreamConfig.default_theme === 'system') {
|
if (DreamConfig.default_theme === 'system') {
|
||||||
window.matchMedia('(prefers-color-scheme: dark)')
|
window.matchMedia('(prefers-color-scheme: dark)')
|
||||||
.addListener((event) => applyNight(event.matches))
|
.addListener((event) => applyNight(event.matches))
|
||||||
|
} else {
|
||||||
|
applyNight(isNight.toString() === 'true')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/* 导航条高亮 */
|
/* 导航条高亮 */
|
||||||
|
@ -126,18 +126,6 @@
|
|||||||
|
|
||||||
/** 配置主题模式 */
|
/** 配置主题模式 */
|
||||||
DreamConfig["default_theme"] = '[(${theme.config.basic_style.default_theme})]';
|
DreamConfig["default_theme"] = '[(${theme.config.basic_style.default_theme})]';
|
||||||
(function(){
|
|
||||||
let isNight = DreamConfig.default_theme === 'system'? matchMedia('(prefers-color-scheme: dark)').matches : localStorage.getItem('night') || DreamConfig.default_theme === 'night';
|
|
||||||
if (isNight.toString() === 'true') {
|
|
||||||
localStorage.setItem('night', 'true');
|
|
||||||
document.documentElement.classList.add('night');
|
|
||||||
// 组件配色方案
|
|
||||||
document.documentElement.classList.add('color-scheme-dark');
|
|
||||||
} else {
|
|
||||||
localStorage.setItem('night', 'false');
|
|
||||||
// 组件配色方案
|
|
||||||
document.documentElement.classList.add('color-scheme-light');
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
</script>
|
</script>
|
||||||
</th:block>
|
</th:block>
|
Loading…
x
Reference in New Issue
Block a user