mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-25 00:37:24 +08:00
fix(缓存): 修复歌词缓存IPC通道并接入初始化
This commit is contained in:
@@ -5,6 +5,7 @@ import { join } from 'path';
|
|||||||
import type { Language } from '../i18n/main';
|
import type { Language } from '../i18n/main';
|
||||||
import i18n from '../i18n/main';
|
import i18n from '../i18n/main';
|
||||||
import { loadLyricWindow } from './lyric';
|
import { loadLyricWindow } from './lyric';
|
||||||
|
import { initializeCacheManager } from './modules/cache';
|
||||||
import { initializeConfig } from './modules/config';
|
import { initializeConfig } from './modules/config';
|
||||||
import { initializeFileManager } from './modules/fileManager';
|
import { initializeFileManager } from './modules/fileManager';
|
||||||
import { initializeFonts } from './modules/fonts';
|
import { initializeFonts } from './modules/fonts';
|
||||||
@@ -41,6 +42,8 @@ function initialize(configStore: any) {
|
|||||||
|
|
||||||
// 初始化文件管理
|
// 初始化文件管理
|
||||||
initializeFileManager();
|
initializeFileManager();
|
||||||
|
// 初始化歌词缓存管理
|
||||||
|
initializeCacheManager();
|
||||||
// 初始化其他 API (搜索建议等)
|
// 初始化其他 API (搜索建议等)
|
||||||
initializeOtherApi();
|
initializeOtherApi();
|
||||||
// 初始化窗口管理
|
// 初始化窗口管理
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ class CacheManager {
|
|||||||
export const cacheManager = new CacheManager();
|
export const cacheManager = new CacheManager();
|
||||||
|
|
||||||
export function initializeCacheManager() {
|
export function initializeCacheManager() {
|
||||||
|
// 兼容历史通道命名
|
||||||
|
const CLEAR_LYRIC_CHANNELS = ['clear-lyric-cache', 'clear-lyrics-cache'] as const;
|
||||||
|
|
||||||
// 添加歌词缓存相关的 IPC 处理
|
// 添加歌词缓存相关的 IPC 处理
|
||||||
ipcMain.handle('cache-lyric', async (_, id: number, lyricData: any) => {
|
ipcMain.handle('cache-lyric', async (_, id: number, lyricData: any) => {
|
||||||
return await cacheManager.cacheLyric(id, lyricData);
|
return await cacheManager.cacheLyric(id, lyricData);
|
||||||
@@ -83,7 +86,9 @@ export function initializeCacheManager() {
|
|||||||
return await cacheManager.getCachedLyric(id);
|
return await cacheManager.getCachedLyric(id);
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.handle('clear-lyric-cache', async () => {
|
for (const channel of CLEAR_LYRIC_CHANNELS) {
|
||||||
return await cacheManager.clearLyricCache();
|
ipcMain.handle(channel, async () => {
|
||||||
});
|
return await cacheManager.clearLyricCache();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user