YesPlayMusic/packages/web/states/persistedUiStates.ts

20 lines
487 B
TypeScript
Raw Normal View History

2022-07-11 11:06:41 +08:00
import { proxy, subscribe } from 'valtio'
interface PersistedUiStates {
loginPhoneCountryCode: string
loginType: 'phone' | 'email' | 'qrCode'
}
const initPersistedUiStates: PersistedUiStates = {
loginPhoneCountryCode: '+86',
loginType: 'qrCode',
}
const persistedUiStates = proxy<PersistedUiStates>(initPersistedUiStates)
subscribe(persistedUiStates, () => {
localStorage.setItem('persistedUiStates', JSON.stringify(persistedUiStates))
})
export default persistedUiStates