mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 05:38:04 +00:00
feat: updates
This commit is contained in:
parent
a1b0bcf4d3
commit
884f3df41a
198 changed files with 4572 additions and 5336 deletions
|
|
@ -36,6 +36,11 @@ export const openContextMenu = ({
|
|||
dataSourceID: ContextMenu['dataSourceID']
|
||||
options?: ContextMenu['options']
|
||||
}) => {
|
||||
if (event.target === contextMenus.target) {
|
||||
closeContextMenu()
|
||||
return
|
||||
}
|
||||
|
||||
const target = event.target as HTMLElement
|
||||
contextMenus.target = ref(target)
|
||||
|
||||
|
|
@ -48,8 +53,8 @@ export const openContextMenu = ({
|
|||
}
|
||||
}
|
||||
|
||||
export const closeContextMenu = (event: MouseEvent) => {
|
||||
if (event.target === contextMenus.target) {
|
||||
export const closeContextMenu = (event?: MouseEvent) => {
|
||||
if (event?.target === contextMenus.target) {
|
||||
return
|
||||
}
|
||||
assign(contextMenus, initContextMenu)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
import { IpcChannels } from '@/shared/IpcChannels'
|
||||
import { merge } from 'lodash-es'
|
||||
import { proxy, subscribe } from 'valtio'
|
||||
import i18n, { getLanguage, supportedLanguages } from '../i18n/i18n'
|
||||
|
||||
interface Settings {
|
||||
accentColor: string
|
||||
language: typeof supportedLanguages[number]
|
||||
unm: {
|
||||
enabled: boolean
|
||||
sources: Array<
|
||||
|
|
@ -26,6 +28,7 @@ interface Settings {
|
|||
|
||||
const initSettings: Settings = {
|
||||
accentColor: 'blue',
|
||||
language: getLanguage(),
|
||||
unm: {
|
||||
enabled: true,
|
||||
sources: ['migu'],
|
||||
|
|
@ -36,19 +39,24 @@ const initSettings: Settings = {
|
|||
}
|
||||
|
||||
const STORAGE_KEY = 'settings'
|
||||
const statesInStorageString = localStorage.getItem(STORAGE_KEY)
|
||||
|
||||
let statesInStorage = {}
|
||||
if (statesInStorageString) {
|
||||
try {
|
||||
statesInStorage = JSON.parse(statesInStorageString)
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
try {
|
||||
statesInStorage = JSON.parse(localStorage.getItem(STORAGE_KEY) || '{}')
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
const settings = proxy<Settings>(merge(initSettings, statesInStorage))
|
||||
|
||||
subscribe(settings, () => {
|
||||
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))
|
||||
})
|
||||
|
|
|
|||
|
|
@ -18,7 +18,11 @@ const initUIStates: UIStates = {
|
|||
librarySelectedTab: 'playlists',
|
||||
mobileShowPlayingNext: false,
|
||||
blurBackgroundImage: null,
|
||||
fullscreen: window.ipcRenderer?.sendSync(IpcChannels.IsMaximized) || false,
|
||||
fullscreen: false,
|
||||
}
|
||||
|
||||
window.ipcRenderer
|
||||
?.invoke(IpcChannels.IsMaximized)
|
||||
.then(isMaximized => (initUIStates.fullscreen = !!isMaximized))
|
||||
|
||||
export default proxy<UIStates>(initUIStates)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue