2022-07-11 11:06:41 +08:00

18 lines
568 B
TypeScript

export const changeTheme = (theme: 'light' | 'dark') => {
document.body.setAttribute('class', theme)
if (!window.env?.isElectron) {
document.documentElement.style.background =
theme === 'dark' ? '#000' : '#fff'
}
}
export const changeAccentColor = (color: string) => {
document.body.setAttribute('data-accent-color', color)
}
const settingsInStorage = localStorage.getItem('settings')
const settings = settingsInStorage ? JSON.parse(settingsInStorage) : {}
changeTheme(settings.theme || 'dark')
changeAccentColor(settings?.accentColor || 'green')