initial commit

This commit is contained in:
2026-08-08 18:34:12 +08:00
commit 0d7438e368
82 changed files with 17407 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
import Store from 'electron-store'
/** 应用配置结构(对应旧 electron-store 字段,做了类型化整理) */
export interface AppConfig {
/** 本地曲库根目录http-server root */
serverPath: string
/** HTTP 文件服务端口 */
serverPort: number
/** 歌曲源 URL本地或远程播放器与传输据此取流 */
url: string
/** 播放模式order/repeat/single/shuffle */
playMode: 'order' | 'repeat' | 'single' | 'shuffle'
/** 音量 0-1 */
volume: number
/** 主题模式 */
theme: 'light' | 'dark' | 'system'
/** 主题强调色 */
accentColor: string
/** 数据版本OSS data.json 版本) */
dataVersion: string
/** 上次播放列表musicUId 数组) */
lastPlayList: string[]
/** 上次播放曲目 */
lastPlayId: string
/** 上次播放列表中的索引 */
lastPlayIndex: number
/** 上次播放进度(秒) */
lastProgress: number
/** 传输选中的歌曲 */
transMusic: string[]
/** 最近连接的手机系统 */
phoneSystem: string
}
const defaults: AppConfig = {
serverPath: '',
serverPort: 10000,
url: '',
playMode: 'order',
volume: 0.8,
theme: 'system',
accentColor: '#0A84FF',
dataVersion: '',
lastPlayList: [],
lastPlayId: '',
lastPlayIndex: 0,
lastProgress: 0,
transMusic: [],
phoneSystem: ''
}
let store: Store<AppConfig> | null = null
export function getStore(): Store<AppConfig> {
if (!store) {
store = new Store<AppConfig>({ name: 'config', defaults })
}
return store
}
export function getConfig<K extends keyof AppConfig>(key: K): AppConfig[K] {
return getStore().get(key)
}
export function setConfig<K extends keyof AppConfig>(key: K, value: AppConfig[K]): void {
getStore().set(key, value)
}