简单美化了一下footer、header的样式
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
const themeToggle = document.querySelector('.theme-toggle');
|
||||
const html = document.documentElement;
|
||||
|
||||
function updateLogoColor(theme) {
|
||||
const logoText = document.querySelector('#logo-text-cn');
|
||||
if (logoText) {
|
||||
logoText.setAttribute('fill', theme === 'dark' ? '#ffffff' : '#000000');
|
||||
}
|
||||
}
|
||||
|
||||
function getPreferredTheme() {
|
||||
const savedTheme = localStorage.getItem('theme');
|
||||
if (savedTheme) {
|
||||
@@ -14,6 +21,7 @@ function getPreferredTheme() {
|
||||
function setTheme(theme) {
|
||||
html.setAttribute('data-theme', theme);
|
||||
localStorage.setItem('theme', theme);
|
||||
updateLogoColor(theme);
|
||||
}
|
||||
|
||||
const initialTheme = getPreferredTheme();
|
||||
@@ -33,3 +41,7 @@ window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e)
|
||||
setTheme(newTheme);
|
||||
}
|
||||
});
|
||||
|
||||
window.addEventListener('load', () => {
|
||||
updateLogoColor(html.getAttribute('data-theme') || getPreferredTheme());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user