feat: 支持 UNM rust

This commit is contained in:
qier222 2022-05-01 19:53:25 +08:00
parent 4d59401549
commit 4d54060a4f
No known key found for this signature in database
GPG key ID: 9C85007ED905F14D
29 changed files with 717 additions and 231 deletions

View file

@ -1,37 +1,27 @@
import { proxy, subscribe } from 'valtio'
import { devtools } from 'valtio/utils'
import { Player } from '@/renderer/utils/player'
import {merge} from 'lodash-es'
interface Store {
uiStates: {
loginPhoneCountryCode: string
showLyricPanel: boolean
}
settings: {
showSidebar: boolean
accentColor: string
}
}
const initialState: Store = {
uiStates: {
loginPhoneCountryCode: '+86',
showLyricPanel: false,
},
settings: {
showSidebar: true,
accentColor: 'blue',
},
}
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) : {})
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')