修复首页能修改背景的BUG
This commit is contained in:
parent
4e59384b56
commit
4ab8653cdb
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"card_style": "compact",
|
"card_style": "normal",
|
||||||
"search_history": [],
|
"search_history": [],
|
||||||
"theme": "dark",
|
"theme": "light",
|
||||||
"bg_image": "/upload/background/5dd4f5d3cd7b.png",
|
"bg_image": "/upload/background/5dd4f5d3cd7b.png",
|
||||||
"dark_bg_image": "/upload/background/d078c01de3be.png",
|
"dark_bg_image": "/upload/background/d078c01de3be.png",
|
||||||
"site_title": "应用导航中心",
|
"site_title": "应用导航中心",
|
||||||
|
|||||||
@ -1655,31 +1655,57 @@ body.dark-theme .secondary-filters-container::after {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 主题切换功能
|
// 主题切换功能
|
||||||
function setupThemeSwitcher() {
|
// 主题切换功能
|
||||||
const themeToggle = document.getElementById('themeToggle');
|
function setupThemeSwitcher() {
|
||||||
|
const themeToggle = document.getElementById('themeToggle');
|
||||||
|
|
||||||
themeToggle.addEventListener('click', () => {
|
themeToggle.addEventListener('click', () => {
|
||||||
// 只在明亮和暗黑之间切换
|
// 确定新主题
|
||||||
if (document.body.classList.contains('dark-theme')) {
|
const newTheme = document.body.classList.contains('dark-theme') ? 'light' : 'dark';
|
||||||
settings.theme = 'light';
|
|
||||||
document.body.classList.remove('dark-theme');
|
|
||||||
|
|
||||||
// 更新视频背景显示状态
|
// 更新界面主题
|
||||||
document.querySelectorAll('.video-bg-container.bg-light').forEach(el => el.style.display = 'block');
|
document.body.classList.remove('dark-theme', 'light-theme');
|
||||||
document.querySelectorAll('.video-bg-container.bg-dark').forEach(el => el.style.display = 'none');
|
if (newTheme === 'dark') {
|
||||||
} else {
|
document.body.classList.add('dark-theme');
|
||||||
settings.theme = 'dark';
|
// 更新视频背景显示状态
|
||||||
document.body.classList.add('dark-theme');
|
document.querySelectorAll('.video-bg-container.bg-light').forEach(el => el.style.display = 'none');
|
||||||
|
document.querySelectorAll('.video-bg-container.bg-dark').forEach(el => el.style.display = 'block');
|
||||||
|
} else {
|
||||||
|
document.body.classList.add('light-theme');
|
||||||
|
// 更新视频背景显示状态
|
||||||
|
document.querySelectorAll('.video-bg-container.bg-light').forEach(el => el.style.display = 'block');
|
||||||
|
document.querySelectorAll('.video-bg-container.bg-dark').forEach(el => el.style.display = 'none');
|
||||||
|
}
|
||||||
|
|
||||||
// 更新视频背景显示状态
|
// 更新主题按钮图标
|
||||||
document.querySelectorAll('.video-bg-container.bg-light').forEach(el => el.style.display = 'none');
|
updateThemeButtonIcon();
|
||||||
document.querySelectorAll('.video-bg-container.bg-dark').forEach(el => el.style.display = 'block');
|
|
||||||
}
|
|
||||||
|
|
||||||
updateThemeButtonIcon();
|
// 更新本地设置(仅主题)
|
||||||
saveSettings();
|
settings.theme = newTheme;
|
||||||
});
|
|
||||||
}
|
// 保存设置(不会影响后台的背景设置)
|
||||||
|
if (isLoggedIn) {
|
||||||
|
// 已登录用户只更新主题设置
|
||||||
|
fetch('/api/settings', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({ theme: newTheme })
|
||||||
|
}).catch(error => {
|
||||||
|
console.error('保存主题设置失败:', error);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 游客保存到本地(仅保存主题、卡片样式和搜索历史)
|
||||||
|
const settingsToSave = {
|
||||||
|
theme: newTheme,
|
||||||
|
card_style: settings.card_style,
|
||||||
|
search_history: settings.search_history
|
||||||
|
};
|
||||||
|
localStorage.setItem('navSettings', JSON.stringify(settingsToSave));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 简洁模式切换
|
// 简洁模式切换
|
||||||
function setupCompactToggle() {
|
function setupCompactToggle() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user