mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-18 06:07:48 +00:00
feat: updates
This commit is contained in:
parent
47e41dea9b
commit
ebebf2a733
160 changed files with 4148 additions and 2001 deletions
|
|
@ -1,19 +1,35 @@
|
|||
import { merge } from 'lodash-es'
|
||||
import { proxy, subscribe } from 'valtio'
|
||||
|
||||
interface PersistedUiStates {
|
||||
loginPhoneCountryCode: string
|
||||
loginType: 'phone' | 'email' | 'qrCode'
|
||||
minimizePlayer: boolean
|
||||
}
|
||||
|
||||
const initPersistedUiStates: PersistedUiStates = {
|
||||
loginPhoneCountryCode: '+86',
|
||||
loginType: 'qrCode',
|
||||
minimizePlayer: false,
|
||||
}
|
||||
|
||||
const persistedUiStates = proxy<PersistedUiStates>(initPersistedUiStates)
|
||||
const STORAGE_KEY = 'persistedUiStates'
|
||||
const statesInStorage = localStorage.getItem(STORAGE_KEY)
|
||||
let sates = {}
|
||||
if (statesInStorage) {
|
||||
try {
|
||||
sates = JSON.parse(statesInStorage)
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
const persistedUiStates = proxy<PersistedUiStates>(
|
||||
merge(initPersistedUiStates, sates)
|
||||
)
|
||||
|
||||
subscribe(persistedUiStates, () => {
|
||||
localStorage.setItem('persistedUiStates', JSON.stringify(persistedUiStates))
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(persistedUiStates))
|
||||
})
|
||||
|
||||
export default persistedUiStates
|
||||
|
|
|
|||
|
|
@ -35,19 +35,22 @@ const initSettings: Settings = {
|
|||
},
|
||||
}
|
||||
|
||||
const settingsInLocalStorage = localStorage.getItem('settings')
|
||||
const settings = proxy<Settings>(
|
||||
merge(
|
||||
initSettings,
|
||||
settingsInLocalStorage ? JSON.parse(settingsInLocalStorage) : {}
|
||||
)
|
||||
)
|
||||
const STORAGE_KEY = 'settings'
|
||||
const statesInStorageString = localStorage.getItem(STORAGE_KEY)
|
||||
let statesInStorage = {}
|
||||
if (statesInStorageString) {
|
||||
try {
|
||||
statesInStorage = JSON.parse(statesInStorageString)
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
const settings = proxy<Settings>(merge(initSettings, statesInStorage))
|
||||
|
||||
subscribe(settings, () => {
|
||||
localStorage.setItem('settings', JSON.stringify(settings))
|
||||
})
|
||||
subscribe(settings, () => {
|
||||
window.ipcRenderer?.send(IpcChannels.SyncSettings, settings)
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify(settings))
|
||||
})
|
||||
|
||||
export default settings
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { IpcChannels } from '@/shared/IpcChannels'
|
||||
import { proxy } from 'valtio'
|
||||
|
||||
interface UIStates {
|
||||
|
|
@ -6,6 +7,8 @@ interface UIStates {
|
|||
hideTopbarBackground: boolean
|
||||
librarySelectedTab: 'playlists' | 'albums' | 'artists' | 'videos'
|
||||
mobileShowPlayingNext: boolean
|
||||
blurBackgroundImage: string | null
|
||||
fullscreen: boolean
|
||||
}
|
||||
|
||||
const initUIStates: UIStates = {
|
||||
|
|
@ -14,6 +17,8 @@ const initUIStates: UIStates = {
|
|||
hideTopbarBackground: false,
|
||||
librarySelectedTab: 'playlists',
|
||||
mobileShowPlayingNext: false,
|
||||
blurBackgroundImage: null,
|
||||
fullscreen: window.ipcRenderer?.sendSync(IpcChannels.IsMaximized) || false,
|
||||
}
|
||||
|
||||
export default proxy<UIStates>(initUIStates)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue