2022-07-11 11:06:41 +08:00
|
|
|
export const changeTheme = (theme: 'light' | 'dark') => {
|
|
|
|
document.body.setAttribute('class', theme)
|
|
|
|
if (!window.env?.isElectron) {
|
|
|
|
document.documentElement.style.background =
|
|
|
|
theme === 'dark' ? '#000' : '#fff'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-17 12:46:06 +08:00
|
|
|
export const changeAccentColor = (color: string) => {
|
|
|
|
document.body.setAttribute('data-accent-color', color)
|
|
|
|
}
|
|
|
|
|
2022-07-11 11:06:41 +08:00
|
|
|
const settingsInStorage = localStorage.getItem('settings')
|
|
|
|
const settings = settingsInStorage ? JSON.parse(settingsInStorage) : {}
|
2022-04-17 12:46:06 +08:00
|
|
|
|
2022-07-11 11:06:41 +08:00
|
|
|
changeTheme(settings.theme || 'dark')
|
|
|
|
changeAccentColor(settings?.accentColor || 'green')
|