mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 13:48:02 +00:00
chore: 用esbuild代替vite来打包main
This commit is contained in:
parent
b4590c3c34
commit
c4219afd3d
152 changed files with 669 additions and 747 deletions
36
src/renderer/store.ts
Normal file
36
src/renderer/store.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { RefObject } from 'react'
|
||||
import { proxy, subscribe } from 'valtio'
|
||||
import { devtools } from 'valtio/utils'
|
||||
import { player as PlayerCore } from '@/utils/player'
|
||||
|
||||
interface Store {
|
||||
uiStates: {
|
||||
loginPhoneCountryCode: string
|
||||
}
|
||||
settings: {
|
||||
showSidebar: boolean
|
||||
}
|
||||
}
|
||||
|
||||
const initialState: Store = {
|
||||
uiStates: {
|
||||
loginPhoneCountryCode: '+86',
|
||||
},
|
||||
settings: {
|
||||
showSidebar: true,
|
||||
},
|
||||
}
|
||||
|
||||
const stateInLocalStorage = localStorage.getItem('state')
|
||||
export const state = proxy<Store>(
|
||||
(stateInLocalStorage && JSON.parse(stateInLocalStorage)) || initialState
|
||||
)
|
||||
subscribe(state, () => {
|
||||
localStorage.setItem('state', JSON.stringify(state))
|
||||
})
|
||||
|
||||
export const player = proxy(PlayerCore)
|
||||
|
||||
// Devtools
|
||||
devtools(state, 'state')
|
||||
devtools(player, 'player')
|
||||
Loading…
Add table
Add a link
Reference in a new issue