mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 13:48:02 +00:00
feat: updates
This commit is contained in:
parent
47e41dea9b
commit
ebebf2a733
160 changed files with 4148 additions and 2001 deletions
|
|
@ -35,19 +35,22 @@ const initSettings: Settings = {
|
|||
},
|
||||
}
|
||||
|
||||
const settingsInLocalStorage = localStorage.getItem('settings')
|
||||
const settings = proxy<Settings>(
|
||||
merge(
|
||||
initSettings,
|
||||
settingsInLocalStorage ? JSON.parse(settingsInLocalStorage) : {}
|
||||
)
|
||||
)
|
||||
const STORAGE_KEY = 'settings'
|
||||
const statesInStorageString = localStorage.getItem(STORAGE_KEY)
|
||||
let statesInStorage = {}
|
||||
if (statesInStorageString) {
|
||||
try {
|
||||
statesInStorage = JSON.parse(statesInStorageString)
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
const settings = proxy<Settings>(merge(initSettings, statesInStorage))
|
||||
|
||||
subscribe(settings, () => {
|
||||
localStorage.setItem('settings', JSON.stringify(settings))
|
||||
})
|
||||
subscribe(settings, () => {
|
||||
window.ipcRenderer?.send(IpcChannels.SyncSettings, settings)
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(settings))
|
||||
})
|
||||
|
||||
export default settings
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue