feat: 添加5套主题切换:深邃暗/纯净白/赛博朋克/莫兰迪/护眼绿
This commit is contained in:
18
ui.js
18
ui.js
@@ -282,6 +282,24 @@ saveSettingsBtn.addEventListener('click', async () => {
|
||||
}
|
||||
});
|
||||
|
||||
// ── Theme switcher ─────────────────────────────────────────────
|
||||
|
||||
function applyTheme(theme) {
|
||||
document.documentElement.dataset.theme = theme;
|
||||
localStorage.setItem('imgGen-theme', theme);
|
||||
document.querySelectorAll('.theme-btn').forEach(btn =>
|
||||
btn.classList.toggle('active', btn.dataset.theme === theme)
|
||||
);
|
||||
}
|
||||
|
||||
document.querySelectorAll('.theme-btn').forEach(btn => {
|
||||
btn.addEventListener('click', () => applyTheme(btn.dataset.theme));
|
||||
});
|
||||
|
||||
// Restore saved theme
|
||||
const savedTheme = localStorage.getItem('imgGen-theme');
|
||||
if (savedTheme) applyTheme(savedTheme);
|
||||
|
||||
// ── Start ──────────────────────────────────────────────────────
|
||||
|
||||
init();
|
||||
|
||||
Reference in New Issue
Block a user