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
0b4baa3eff
commit
222fb02355
77 changed files with 654 additions and 551 deletions
18
packages/web/states/player.ts
Normal file
18
packages/web/states/player.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { Player } from '@/web/utils/player'
|
||||
import { proxy, subscribe } from 'valtio'
|
||||
|
||||
const playerInLocalStorage = localStorage.getItem('player')
|
||||
const player = proxy(new Player())
|
||||
|
||||
player.init((playerInLocalStorage && JSON.parse(playerInLocalStorage)) || {})
|
||||
|
||||
subscribe(player, () => {
|
||||
localStorage.setItem('player', JSON.stringify(player))
|
||||
})
|
||||
|
||||
if (import.meta.env.DEV) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-extra-semi
|
||||
;(window as any).player = player
|
||||
}
|
||||
|
||||
export default player
|
||||
Loading…
Add table
Add a link
Reference in a new issue