fix all imports for new structure

This commit is contained in:
jeffvli
2025-05-20 19:23:36 -07:00
parent 249eaf89f8
commit 930165d006
291 changed files with 2056 additions and 1894 deletions
+12 -8
View File
@@ -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;
+31 -31
View File
@@ -13,37 +13,6 @@ const LYRICS_URL = 'https://music.163.com/api/song/lyric';
// Adapted from https://github.com/NyaomiDEV/Sunamu/blob/master/src/main/lyricproviders/netease.ts
export interface Album {
artist: Artist;
copyrightId: number;
id: number;
mark: number;
name: string;
picId: number;
publishTime: number;
size: number;
status: number;
transNames?: string[];
}
export interface Artist {
albumSize: number;
alias: any[];
fansGroup: null;
id: number;
img1v1: number;
img1v1Url: string;
name: string;
picId: number;
picUrl: null;
trans: null;
}
export interface NetEaseResponse {
code: number;
result: Result;
}
export interface Result {
hasMore: boolean;
songCount: number;
@@ -68,6 +37,37 @@ export interface Song {
transNames?: string[];
}
interface Album {
artist: Artist;
copyrightId: number;
id: number;
mark: number;
name: string;
picId: number;
publishTime: number;
size: number;
status: number;
transNames?: string[];
}
interface Artist {
albumSize: number;
alias: any[];
fansGroup: null;
id: number;
img1v1: number;
img1v1Url: string;
name: string;
picId: number;
picUrl: null;
trans: null;
}
interface NetEaseResponse {
code: number;
result: Result;
}
export async function getLyricsBySongId(songId: string): Promise<null | string> {
let result: AxiosResponse<any, any>;
try {
+1 -1
View File
@@ -3,7 +3,7 @@ import Fuse from 'fuse.js';
import {
InternetProviderLyricSearchResponse,
LyricSearchQuery,
} from '../../../../renderer/api/types';
} from '/@/shared/types/domain-types';
export const orderSearchResults = (args: {
params: LyricSearchQuery;
+2 -1
View File
@@ -330,7 +330,8 @@ ipcMain.on('player-set-queue', async (_event, current?: string, next?: string, p
if (current) {
try {
await getMpvInstance()?.load(current, 'replace');
} catch (error) {
} catch (error: any | NodeMpvError) {
mpvLog({ action: `Failed to load current song` }, error);
await getMpvInstance()?.play();
}
@@ -1,4 +1,3 @@
/* eslint-disable promise/always-return */
import { BrowserWindow, globalShortcut, systemPreferences } from 'electron';
import { isMacOS } from '../../../utils';
+15 -6
View File
@@ -7,16 +7,25 @@ import { join } from 'path';
import { WebSocket, WebSocketServer, Server as WsServer } from 'ws';
import { deflate, gzip } from 'zlib';
import { getMainWindow } from '../../..';
import { isLinux } from '../../../utils';
import manifest from './manifest.json';
import { getMainWindow } from '/@/main/index';
import { isLinux } from '/@/main/utils';
import { QueueSong } from '/@/shared/types/domain-types';
import { ClientEvent, ServerEvent } from '/@/shared/types/remote-types';
import { PlayerRepeat, PlayerStatus, SongState } from '/@/shared/types/types';
let mprisPlayer: any | undefined;
if (isLinux()) {
mprisPlayer = require('../../linux/mpris').mprisPlayer;
async function initMpris() {
if (isLinux()) {
const mpris = await import('../../linux/mpris');
mprisPlayer = mpris.mprisPlayer;
}
}
initMpris();
interface MimeType {
css: string;
html: string;
@@ -630,8 +639,8 @@ if (mprisPlayer) {
mprisPlayer.on('loopStatus', (event: string) => {
const repeat = event === 'Playlist' ? 'all' : event === 'Track' ? 'one' : 'none';
currentState.repeat = repeat;
broadcast({ data: repeat, event: 'repeat' });
currentState.repeat = repeat as PlayerRepeat;
broadcast({ data: repeat, event: 'repeat' } as ServerEvent);
});
mprisPlayer.on('shuffle', (shuffle: boolean) => {
+1 -1
View File
@@ -1,4 +1,4 @@
import type { TitleTheme } from '/@/renderer/types';
import type { TitleTheme } from '/@/shared/types/types';
import { ipcMain, nativeTheme, safeStorage } from 'electron';
import Store from 'electron-store';
+1 -2
View File
@@ -1,3 +1,2 @@
import './core';
// require(`./${process.platform}`)
import(`./${process.platform}`);
+3 -4
View File
@@ -1,10 +1,9 @@
import { ipcMain } from 'electron';
import Player from 'mpris-service';
import { PlayerRepeat, PlayerStatus } from '../../../renderer/types';
import { getMainWindow } from '../../main';
import { QueueSong } from '/@/renderer/api/types';
import { getMainWindow } from '/@/main/index';
import { QueueSong } from '/@/shared/types/domain-types';
import { PlayerRepeat, PlayerStatus } from '/@/shared/types/types';
const mprisPlayer = Player({
identity: 'Feishin',
-3
View File
@@ -1,3 +0,0 @@
// Dummy file to satisfy the build system
export {};