forked from miao-moe/QZMusic_PC
feat: Implement features and continuously optimize the proxy service
- Settings page UI - Persist settings data - Proxy server fixes & optimizations: - Fixed download latency caused by Range Seek - Improved cache stability - Implemented a dual-threading model to ensure smooth playback - Optimized styles for the homepage TopBar and SideBar - Added theme switching functionality - Added theme color customization feature
This commit is contained in:
@@ -4,8 +4,9 @@ import { fileURLToPath } from 'node:url'
|
||||
import path from 'node:path'
|
||||
import fs from 'node:fs'
|
||||
import { MpvController } from './mpvController'
|
||||
import { startProxyServer, cleanupCache } from './proxyServer'
|
||||
import { startProxyServer, cleanupCache, getCacheDir, getCacheSize, setPersistCache, clearCacheNow } from './proxyServer'
|
||||
import { PluginSystem } from '../src/main/pluginSystem.ts'
|
||||
import { loadSettings, saveSettings, getSetting, AppSettings } from './settingsStore'
|
||||
// @ts-ignore
|
||||
const require = createRequire(import.meta.url)
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
@@ -91,6 +92,55 @@ ipcMain.handle(
|
||||
}
|
||||
)
|
||||
|
||||
// Cache IPC Handlers
|
||||
ipcMain.handle('cache:getInfo', () => {
|
||||
const settings = loadSettings();
|
||||
return {
|
||||
path: getCacheDir(),
|
||||
size: getCacheSize(),
|
||||
persistCache: settings.persistCache
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.handle('cache:setPersist', (_, persist: boolean) => {
|
||||
setPersistCache(persist)
|
||||
saveSettings({ persistCache: persist })
|
||||
})
|
||||
|
||||
ipcMain.handle('cache:openFolder', () => {
|
||||
const dir = getCacheDir()
|
||||
require('electron').shell.openPath(dir)
|
||||
})
|
||||
|
||||
ipcMain.handle('cache:clear', () => {
|
||||
clearCacheNow()
|
||||
})
|
||||
|
||||
// Settings IPC Handlers
|
||||
ipcMain.handle('settings:getAll', () => {
|
||||
return loadSettings()
|
||||
})
|
||||
|
||||
ipcMain.handle('settings:set', (_, settings: Partial<AppSettings>) => {
|
||||
return saveSettings(settings)
|
||||
})
|
||||
|
||||
ipcMain.handle('settings:getTheme', () => {
|
||||
return getSetting('theme')
|
||||
})
|
||||
|
||||
ipcMain.handle('settings:setTheme', (_, theme: 'dark' | 'light') => {
|
||||
saveSettings({ theme })
|
||||
})
|
||||
|
||||
ipcMain.handle('settings:getAccentColor', () => {
|
||||
return getSetting('accentColor')
|
||||
})
|
||||
|
||||
ipcMain.handle('settings:setAccentColor', (_, color: string) => {
|
||||
saveSettings({ accentColor: color })
|
||||
})
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit()
|
||||
|
||||
Reference in New Issue
Block a user