feat: updates

This commit is contained in:
qier222 2023-03-03 03:12:27 +08:00
parent 9a52681687
commit 840a5b8e9b
No known key found for this signature in database
104 changed files with 1645 additions and 13494 deletions

View file

@ -5,12 +5,14 @@ interface PersistedUiStates {
loginPhoneCountryCode: string
loginType: 'phone' | 'email' | 'qrCode'
minimizePlayer: boolean
librarySelectedTab: 'playlists' | 'albums' | 'artists' | 'videos'
}
const initPersistedUiStates: PersistedUiStates = {
loginPhoneCountryCode: '+86',
loginType: 'qrCode',
minimizePlayer: false,
librarySelectedTab: 'albums',
}
const STORAGE_KEY = 'persistedUiStates'
@ -24,9 +26,7 @@ if (statesInStorage) {
}
}
const persistedUiStates = proxy<PersistedUiStates>(
merge(initPersistedUiStates, sates)
)
const persistedUiStates = proxy<PersistedUiStates>(merge(initPersistedUiStates, sates))
subscribe(persistedUiStates, () => {
localStorage.setItem(STORAGE_KEY, JSON.stringify(persistedUiStates))

View file

@ -1,41 +1,33 @@
import { IpcChannels } from '@/shared/IpcChannels'
import { merge } from 'lodash-es'
import { proxy, subscribe } from 'valtio'
import i18n, { getLanguage, supportedLanguages } from '../i18n/i18n'
import i18n, { getInitLanguage, SupportedLanguage, supportedLanguages } from '../i18n/i18n'
interface Settings {
accentColor: string
language: typeof supportedLanguages[number]
unm: {
enabled: boolean
sources: Array<
'migu' | 'kuwo' | 'kugou' | 'ytdl' | 'qq' | 'bilibili' | 'joox'
>
searchMode: 'order-first' | 'fast-first'
proxy: null | {
protocol: 'http' | 'https' | 'socks5'
host: string
port: number
username?: string
password?: string
}
cookies: {
qq?: string
joox?: string
language: SupportedLanguage
enableFindTrackOnYouTube: boolean
httpProxyForYouTube?: {
host: string
port: number
protocol: 'http' | 'https'
auth?: {
username: string
password: string
}
}
playAnimatedArtworkFromApple: boolean
priorityDisplayOfAlbumArtistDescriptionFromAppleMusic: boolean
displayPlaylistsFromNeteaseMusic: boolean
}
const initSettings: Settings = {
accentColor: 'blue',
language: getLanguage(),
unm: {
enabled: true,
sources: ['migu'],
searchMode: 'order-first',
proxy: null,
cookies: {},
},
accentColor: 'green',
language: getInitLanguage(),
enableFindTrackOnYouTube: false,
playAnimatedArtworkFromApple: true,
priorityDisplayOfAlbumArtistDescriptionFromAppleMusic: true,
displayPlaylistsFromNeteaseMusic: true,
}
const STORAGE_KEY = 'settings'
@ -50,15 +42,11 @@ try {
const settings = proxy<Settings>(merge(initSettings, statesInStorage))
subscribe(settings, () => {
if (
settings.language !== i18n.language &&
supportedLanguages.includes(settings.language)
) {
if (settings.language !== i18n.language && supportedLanguages.includes(settings.language)) {
i18n.changeLanguage(settings.language)
}
window.ipcRenderer?.send(IpcChannels.SyncSettings, settings)
localStorage.setItem(STORAGE_KEY, JSON.stringify(settings))
window.ipcRenderer?.send(IpcChannels.SyncSettings, JSON.parse(JSON.stringify(settings)))
})
export default settings

View file

@ -5,7 +5,6 @@ interface UIStates {
showLyricPanel: boolean
showLoginPanel: boolean
hideTopbarBackground: boolean
librarySelectedTab: 'playlists' | 'albums' | 'artists' | 'videos'
mobileShowPlayingNext: boolean
blurBackgroundImage: string | null
fullscreen: boolean
@ -17,7 +16,6 @@ const initUIStates: UIStates = {
showLyricPanel: false,
showLoginPanel: false,
hideTopbarBackground: false,
librarySelectedTab: 'playlists',
mobileShowPlayingNext: false,
blurBackgroundImage: null,
fullscreen: false,