The search query
Maximum number of results to return (default: 10)
Promise resolving to search results
export async function searchComickManga(
query: string,
limit: number = 10,
): Promise<ComickManga[]> {
// Check cache first
const cacheKey = `search:${query.toLowerCase()}:${limit}`;
const cached = comickCache[cacheKey];
if (cached && Date.now() - cached.timestamp < CACHE_EXPIRY) {
console.log(`🎯 Comick cache hit for "${query}"`);
return cached.data;
}
try {
console.log(`🔍 Searching Comick for: "${query}" (limit: ${limit})`);
// Use IPC to call the main process instead of direct fetch to avoid CORS issues
const data = (await window.electronAPI.comick.search(
query,
limit,
)) as ComickManga[];
// Cache the results
comickCache[cacheKey] = {
data: data || [],
timestamp: Date.now(),
};
console.log(
`📦 Comick search found ${data?.length || 0} results for "${query}"`,
);
return data || [];
} catch (error) {
console.error(`❌ Comick search failed for "${query}":`, error);
return [];
}
}
Search for manga on Comick API.