Files
AlgerMusicPlayer/src/main/modules/otherApi.ts
2026-02-10 09:06:25 +08:00

29 lines
801 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import axios from 'axios';
import { ipcMain } from 'electron';
/**
* 初始化其他杂项 API如搜索建议等
*/
export function initializeOtherApi() {
// 搜索建议
ipcMain.handle('get-search-suggestions', async (_, keyword: string) => {
if (!keyword || !keyword.trim()) {
return [];
}
try {
console.log(`[Main Process Proxy] Forwarding suggestion request for: ${keyword}`);
const response = await axios.get('http://msearchcdn.kugou.com/new/app/i/search.php', {
params: {
cmd: 302,
keyword: keyword
},
timeout: 5000
});
return response.data;
} catch (error: any) {
console.error('[Main Process Proxy] Failed to fetch search suggestions:', error.message);
return [];
}
});
}