feat: implement library.rs, types.ts, api.ts, and extract CSS
- library.rs: full video library management (1948 lines, 10 tests) folder scanning, progress tracking, playlists, subtitle integration, background duration scanning - types.ts: all TypeScript interfaces for Tauri command responses - api.ts: typed wrappers for all 26 Tauri invoke commands - 6 CSS files extracted from Python HTML into src/styles/
This commit is contained in:
92
src/api.ts
Normal file
92
src/api.ts
Normal file
@@ -0,0 +1,92 @@
|
||||
import { invoke } from '@tauri-apps/api/core';
|
||||
import type {
|
||||
LibraryInfo,
|
||||
OkResponse,
|
||||
PrefsResponse,
|
||||
RecentsResponse,
|
||||
NoteResponse,
|
||||
VideoMetaResponse,
|
||||
SubtitleResponse,
|
||||
AvailableSubsResponse,
|
||||
EmbeddedSubsResponse,
|
||||
} from './types';
|
||||
|
||||
export const api = {
|
||||
selectFolder: () =>
|
||||
invoke<LibraryInfo>('select_folder'),
|
||||
|
||||
openFolderPath: (folder: string) =>
|
||||
invoke<LibraryInfo>('open_folder_path', { folder }),
|
||||
|
||||
getRecents: () =>
|
||||
invoke<RecentsResponse>('get_recents'),
|
||||
|
||||
removeRecent: (path: string) =>
|
||||
invoke<OkResponse>('remove_recent', { path }),
|
||||
|
||||
getLibrary: () =>
|
||||
invoke<LibraryInfo>('get_library'),
|
||||
|
||||
setCurrent: (index: number, timecode: number = 0) =>
|
||||
invoke<OkResponse>('set_current', { index, timecode }),
|
||||
|
||||
tickProgress: (index: number, currentTime: number, duration: number | null, playing: boolean) =>
|
||||
invoke<OkResponse>('tick_progress', { index, current_time: currentTime, duration, playing }),
|
||||
|
||||
setFolderVolume: (volume: number) =>
|
||||
invoke<OkResponse>('set_folder_volume', { volume }),
|
||||
|
||||
setFolderAutoplay: (enabled: boolean) =>
|
||||
invoke<OkResponse>('set_folder_autoplay', { enabled }),
|
||||
|
||||
setFolderRate: (rate: number) =>
|
||||
invoke<OkResponse>('set_folder_rate', { rate }),
|
||||
|
||||
setOrder: (fids: string[]) =>
|
||||
invoke<OkResponse>('set_order', { fids }),
|
||||
|
||||
startDurationScan: () =>
|
||||
invoke<OkResponse>('start_duration_scan'),
|
||||
|
||||
getPrefs: () =>
|
||||
invoke<PrefsResponse>('get_prefs'),
|
||||
|
||||
setPrefs: (patch: Record<string, unknown>) =>
|
||||
invoke<OkResponse>('set_prefs', { patch }),
|
||||
|
||||
setAlwaysOnTop: (enabled: boolean) =>
|
||||
invoke<OkResponse>('set_always_on_top', { enabled }),
|
||||
|
||||
saveWindowState: () =>
|
||||
invoke<OkResponse>('save_window_state'),
|
||||
|
||||
getNote: (fid: string) =>
|
||||
invoke<NoteResponse>('get_note', { fid }),
|
||||
|
||||
setNote: (fid: string, note: string) =>
|
||||
invoke<OkResponse>('set_note', { fid, note }),
|
||||
|
||||
getCurrentVideoMeta: () =>
|
||||
invoke<VideoMetaResponse>('get_current_video_meta'),
|
||||
|
||||
getCurrentSubtitle: () =>
|
||||
invoke<SubtitleResponse>('get_current_subtitle'),
|
||||
|
||||
getEmbeddedSubtitles: () =>
|
||||
invoke<EmbeddedSubsResponse>('get_embedded_subtitles'),
|
||||
|
||||
extractEmbeddedSubtitle: (trackIndex: number) =>
|
||||
invoke<SubtitleResponse>('extract_embedded_subtitle', { track_index: trackIndex }),
|
||||
|
||||
getAvailableSubtitles: () =>
|
||||
invoke<AvailableSubsResponse>('get_available_subtitles'),
|
||||
|
||||
loadSidecarSubtitle: (filePath: string) =>
|
||||
invoke<SubtitleResponse>('load_sidecar_subtitle', { file_path: filePath }),
|
||||
|
||||
chooseSubtitleFile: () =>
|
||||
invoke<SubtitleResponse>('choose_subtitle_file'),
|
||||
|
||||
resetWatchProgress: () =>
|
||||
invoke<OkResponse>('reset_watch_progress'),
|
||||
};
|
||||
Reference in New Issue
Block a user