mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 13:48:02 +00:00
feat: monorepo
This commit is contained in:
parent
4d54060a4f
commit
42089d4996
200 changed files with 1530 additions and 1521 deletions
|
|
@ -1,40 +0,0 @@
|
|||
import { proxy, subscribe } from 'valtio'
|
||||
import { devtools } from 'valtio/utils'
|
||||
import { Player } from '@/renderer/utils/player'
|
||||
import { merge } from 'lodash-es'
|
||||
import { IpcChannels } from '@/shared/IpcChannels'
|
||||
import { Store, initialState } from '@/shared/store'
|
||||
|
||||
const stateInLocalStorage = localStorage.getItem('state')
|
||||
export const state = proxy<Store>(
|
||||
merge(initialState, [
|
||||
stateInLocalStorage ? JSON.parse(stateInLocalStorage) : {},
|
||||
{
|
||||
uiStates: {
|
||||
showLyricPanel: false,
|
||||
},
|
||||
},
|
||||
])
|
||||
)
|
||||
subscribe(state, () => {
|
||||
localStorage.setItem('state', JSON.stringify(state))
|
||||
})
|
||||
subscribe(state.settings, () => {
|
||||
window.ipcRenderer?.send(IpcChannels.SyncSettings, { ...state.settings })
|
||||
})
|
||||
|
||||
// player
|
||||
const playerInLocalStorage = localStorage.getItem('player')
|
||||
export const player = proxy(new Player())
|
||||
player.init((playerInLocalStorage && JSON.parse(playerInLocalStorage)) || {})
|
||||
subscribe(player, () => {
|
||||
localStorage.setItem('player', JSON.stringify(player))
|
||||
})
|
||||
|
||||
if (import.meta.env.DEV) {
|
||||
;(window as any).player = player
|
||||
}
|
||||
|
||||
// Devtools
|
||||
devtools(state, 'state')
|
||||
devtools(player, 'player')
|
||||
Loading…
Add table
Add a link
Reference in a new issue