mirror of
https://github.com/atdunbg/Nekosonic-Music.git
synced 2026-06-21 16:48:48 +08:00
- 重构皮肤系统:提取 skins.ts 管理预设皮肤,CSS 变量由 JS 动态设置 - 提取公共 color.ts 工具函数(hexToRgba/toHex),消除重复定义 - 修复 seek 时暂停状态丢失的 bug(后端 audio_paused 状态保留) - 本地音乐页面:循环排序切换、三点菜单、打开所在文件夹 - 本地音乐文件夹管理:支持启用/禁用切换,兼容旧数据迁移 - 新增 show_item_in_folder 命令(Windows/macOS/Linux 跨平台) - 外观一体化:有壁纸时 TitleBar/Sidebar 透明,PlayerBar 统一透明度+backdrop-blur - 进度条外层直角、内层填充圆角 - 滚动条默认透明,悬停时显示 - 移除 PageHeader 粘性栏 - 内存优化:keep-alive TTL 5min、pageCache TTL 30min/上限30条、colorCache 上限200 - recentLocal 防抖写入、播放器 tick interval 500ms
37 lines
928 B
TypeScript
37 lines
928 B
TypeScript
const cache = new Map<string, { data: any; ts: number }>();
|
|
const TTL = 30 * 60 * 1000;
|
|
const MAX_ENTRIES = 30;
|
|
|
|
export function pageCacheGet(key: string): any | null {
|
|
const entry = cache.get(key);
|
|
if (!entry) return null;
|
|
if (Date.now() - entry.ts > TTL) {
|
|
cache.delete(key);
|
|
return null;
|
|
}
|
|
return entry.data;
|
|
}
|
|
|
|
export function pageCacheSet(key: string, data: any) {
|
|
if (cache.size >= MAX_ENTRIES && !cache.has(key)) {
|
|
// 淘汰最旧的条目
|
|
const firstKey = cache.keys().next().value;
|
|
if (firstKey !== undefined) cache.delete(firstKey);
|
|
}
|
|
cache.set(key, { data, ts: Date.now() });
|
|
}
|
|
|
|
export function pageCacheDelete(key: string) {
|
|
cache.delete(key);
|
|
}
|
|
|
|
export function pageCacheInvalidate(key: string) {
|
|
cache.delete(key);
|
|
}
|
|
|
|
export function pageCacheIsStale(key: string): boolean {
|
|
const entry = cache.get(key);
|
|
if (!entry) return true;
|
|
return Date.now() - entry.ts > TTL;
|
|
}
|