mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-17 06:00:20 +02:00
fix all imports for new structure
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { ipcMain } from 'electron';
|
||||
|
||||
import { store } from '../settings/index';
|
||||
import { store } from '../settings';
|
||||
import {
|
||||
getLyricsBySongId as getGenius,
|
||||
query as queryGenius,
|
||||
@@ -17,6 +17,8 @@ import {
|
||||
getSearchResults as searchNetease,
|
||||
} from './netease';
|
||||
|
||||
import { Song } from '/@/shared/types/domain-types';
|
||||
|
||||
export enum LyricSource {
|
||||
GENIUS = 'Genius',
|
||||
LRCLIB = 'lrclib.net',
|
||||
@@ -94,10 +96,10 @@ const MAX_CACHED_ITEMS = 10;
|
||||
|
||||
const lyricCache = new Map<string, CachedLyrics>();
|
||||
|
||||
const getRemoteLyrics = async (song: any) => {
|
||||
const getRemoteLyrics = async (song: Song) => {
|
||||
const sources = store.get('lyrics', []) as LyricSource[];
|
||||
|
||||
const cached = lyricCache.get(song.id);
|
||||
const cached = lyricCache.get(song.id.toString());
|
||||
|
||||
if (cached) {
|
||||
for (const source of sources) {
|
||||
@@ -106,16 +108,16 @@ const getRemoteLyrics = async (song: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
let lyricsFromSource = null;
|
||||
let lyricsFromSource: InternetProviderLyricResponse | null = null;
|
||||
|
||||
for (const source of sources) {
|
||||
const params = {
|
||||
album: song.album || song.name,
|
||||
artist: song.artistName,
|
||||
artist: song.artists[0].name,
|
||||
duration: song.duration / 1000.0,
|
||||
name: song.name,
|
||||
};
|
||||
const response = await FETCHERS[source](params);
|
||||
const response = await FETCHERS[source](params as unknown as LyricSearchQuery);
|
||||
|
||||
if (response) {
|
||||
const newResult = cached
|
||||
@@ -127,10 +129,12 @@ const getRemoteLyrics = async (song: any) => {
|
||||
|
||||
if (lyricCache.size === MAX_CACHED_ITEMS && cached === undefined) {
|
||||
const toRemove = lyricCache.keys().next().value;
|
||||
lyricCache.delete(toRemove);
|
||||
if (toRemove) {
|
||||
lyricCache.delete(toRemove);
|
||||
}
|
||||
}
|
||||
|
||||
lyricCache.set(song.id, newResult);
|
||||
lyricCache.set(song.id.toString(), newResult);
|
||||
|
||||
lyricsFromSource = response;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user