refactor(lyrics): co-locate lyrics feature into features/lyrics (LyricsPane + hooks + cache + lrclib/lyricsplus/netease providers; lyricsStore stays global)

This commit is contained in:
Psychotoxical
2026-06-30 19:21:21 +02:00
parent d9dfdf66e9
commit e0d6623bf1
11 changed files with 31 additions and 16 deletions
@@ -1,10 +1,10 @@
import React, { memo, useCallback, useEffect, useRef, useState } from 'react';
import { usePlayerStore } from '@/features/playback/store/playerStore';
import { useAuthStore } from '@/store/authStore';
import { useLyrics, type WordLyricsLine } from '@/hooks/useLyrics';
import { useWordLyricsSync } from '@/hooks/useWordLyricsSync';
import { useLyrics, type WordLyricsLine } from '@/features/lyrics';
import { useWordLyricsSync } from '@/features/lyrics';
import { getPlaybackProgressSnapshot, subscribePlaybackProgress } from '@/features/playback/store/playbackProgress';
import type { LrcLine } from '@/api/lrclib';
import type { LrcLine } from '@/features/lyrics';
import type { Track } from '@/lib/media/trackTypes';
import { EaseScroller, targetForFraction } from '@/utils/ui/easeScroll';
@@ -2,12 +2,12 @@ import { getPlaybackProgressSnapshot, subscribePlaybackProgress } from '@/featur
import { useEffect, useRef, useCallback } from 'react';
import { useShallow } from 'zustand/react/shallow';
import { usePlayerStore } from '@/features/playback/store/playerStore';
import type { LrcLine } from '../api/lrclib';
import { useLyrics, type WordLyricsLine } from '../hooks/useLyrics';
import { useAuthStore } from '../store/authStore';
import type { LrcLine } from '@/features/lyrics/api/lrclib';
import { useLyrics, type WordLyricsLine } from '@/features/lyrics/hooks/useLyrics';
import { useAuthStore } from '@/store/authStore';
import { useTranslation } from 'react-i18next';
import type { Track } from '@/lib/media/trackTypes';
import { EaseScroller, targetForFraction } from '../utils/ui/easeScroll';
import { EaseScroller, targetForFraction } from '@/utils/ui/easeScroll';
import OverlayScrollArea from '@/ui/OverlayScrollArea';
interface Props {
@@ -4,13 +4,13 @@ import type { Track } from '@/lib/media/trackTypes';
import { useEffect, useState } from 'react';
import { useShallow } from 'zustand/react/shallow';
import { invoke } from '@tauri-apps/api/core';
import { fetchLyrics, parseLrc, LrcLine } from '../api/lrclib';
import { fetchNeteaselyrics } from '../api/netease';
import { fetchLyricsPlus, hasWordSync } from '../api/lyricsplus';
import { useAuthStore } from '../store/authStore';
import { fetchLyrics, parseLrc, LrcLine } from '@/features/lyrics/api/lrclib';
import { fetchNeteaselyrics } from '@/features/lyrics/api/netease';
import { fetchLyricsPlus, hasWordSync } from '@/features/lyrics/api/lyricsplus';
import { useAuthStore } from '@/store/authStore';
import { useOfflineStore } from '@/features/offline';
import { useHotCacheStore } from '@/features/playback/store/hotCacheStore';
import { getCachedLyrics, putCachedLyrics, lyricsCacheKey } from '../utils/cache/lyricsPersistentCache';
import { getCachedLyrics, putCachedLyrics, lyricsCacheKey } from '@/features/lyrics/utils/lyricsPersistentCache';
export type LyricsSource = 'server' | 'lrclib' | 'netease' | 'embedded' | 'lyricsplus';
/**
@@ -1,7 +1,7 @@
import { useEffect, useRef } from 'react';
import { getPlaybackProgressSnapshot, subscribePlaybackProgress } from '@/features/playback/store/playbackProgress';
import type { Track } from '@/lib/media/trackTypes';
import type { WordLyricsLine } from './useLyrics';
import type { WordLyricsLine } from '@/features/lyrics/hooks/useLyrics';
interface Args {
enabled: boolean;
+15
View File
@@ -0,0 +1,15 @@
/**
* Lyrics feature — the LyricsPane UI, the lyrics fetch/sync hooks, the
* persistent lyrics cache, and the per-provider lyrics API clients (lrclib,
* lyricsplus/YouLyPlus, netease). Consumed cross-feature by the queue panel,
* the now-playing mobile view, and the fullscreen Apple-style lyrics view.
*
* Stays OUT (global / authStore-family, consumed beyond this feature): the
* `lyricsStore` open/settings state (read by the keyboard-shortcut registry +
* app boot) and `authLyricsSettingsActions` (authStore action module). The
* subsonic 'server' lyrics provider stays in `lib/api/subsonicLyrics`.
*/
export { default as LyricsPane } from './components/LyricsPane';
export { useLyrics, type WordLyricsLine, type LyricsSource } from './hooks/useLyrics';
export { useWordLyricsSync } from './hooks/useWordLyricsSync';
export type { LrcLine } from './api/lrclib';
@@ -12,7 +12,7 @@
* - notFound entries: 7 days. Lets the user / server admin add lyrics
* later without an indefinite negative cache.
*/
import type { CachedLyrics } from '../../hooks/useLyrics';
import type { CachedLyrics } from '@/features/lyrics/hooks/useLyrics';
const DB_NAME = 'psysonic-lyrics-cache';
const STORE_NAME = 'lyrics';
@@ -22,7 +22,7 @@ import {
getQueueResolverVersion,
subscribeQueueResolver,
} from '@/features/playback/store/queueTrackResolver';
import LyricsPane from '@/components/LyricsPane';
import { LyricsPane } from '@/features/lyrics';
import { usePlaybackDelayPress } from '@/hooks/usePlaybackDelayPress';
import PlaybackDelayModal from '@/features/playback/components/PlaybackDelayModal';
import PlaybackScheduleBadge from '@/features/playback/components/PlaybackScheduleBadge';
+1 -1
View File
@@ -18,7 +18,7 @@ import { copyTextToClipboard } from '@/utils/server/serverMagicString';
import { showToast } from '@/utils/ui/toast';
import { useThemeStore } from '@/store/themeStore';
import { useLyricsStore } from '@/store/lyricsStore';
import LyricsPane from '@/components/LyricsPane';
import { LyricsPane } from '@/features/lyrics';
import { NowPlayingInfo } from '@/features/nowPlaying';
import { useLuckyMixStore } from '@/features/randomMix';
import { useQueueToolbarStore } from '@/store/queueToolbarStore';