feat: implement proxy mode setting for video playback with retry, none, and always options

This commit is contained in:
kuekhaoyang
2026-01-25 14:40:38 +08:00
parent f4b16bac2d
commit 2aa90a4d4f
8 changed files with 141 additions and 39 deletions
+14 -1
View File
@@ -1,5 +1,5 @@
import { useState, useEffect } from 'react';
import { settingsStore, getDefaultSources, type SortOption, type SearchDisplayMode } from '@/lib/store/settings-store';
import { settingsStore, getDefaultSources, type SortOption, type SearchDisplayMode, type ProxyMode } from '@/lib/store/settings-store';
import type { VideoSource, SourceSubscription } from '@/lib/types';
import {
type ImportResult,
@@ -27,6 +27,7 @@ export function useSettingsPage() {
const [realtimeLatency, setRealtimeLatency] = useState(false);
const [searchDisplayMode, setSearchDisplayMode] = useState<SearchDisplayMode>('normal');
const [fullscreenType, setFullscreenType] = useState<'native' | 'window'>('native');
const [proxyMode, setProxyMode] = useState<ProxyMode>('retry');
useEffect(() => {
const settings = settingsStore.getSettings();
@@ -38,6 +39,7 @@ export function useSettingsPage() {
setRealtimeLatency(settings.realtimeLatency);
setSearchDisplayMode(settings.searchDisplayMode);
setFullscreenType(settings.fullscreenType);
setProxyMode(settings.proxyMode);
// Fetch env password status
fetch('/api/config')
@@ -290,6 +292,15 @@ export function useSettingsPage() {
});
};
const handleProxyModeChange = (mode: ProxyMode) => {
setProxyMode(mode);
const currentSettings = settingsStore.getSettings();
settingsStore.saveSettings({
...currentSettings,
proxyMode: mode,
});
};
const handleRestoreDefaults = () => {
const defaults = getDefaultSources();
handleSourcesChange(defaults);
@@ -342,5 +353,7 @@ export function useSettingsPage() {
handleSearchDisplayModeChange,
fullscreenType,
handleFullscreenTypeChange,
proxyMode,
handleProxyModeChange,
};
}
+4
View File
@@ -55,6 +55,8 @@ export default function SettingsPage() {
handleRealtimeLatencyChange,
handleSearchDisplayModeChange,
handleFullscreenTypeChange,
proxyMode,
handleProxyModeChange,
} = useSettingsPage();
return (
@@ -67,6 +69,8 @@ export default function SettingsPage() {
<PlayerSettings
fullscreenType={fullscreenType}
onFullscreenTypeChange={handleFullscreenTypeChange}
proxyMode={proxyMode}
onProxyModeChange={handleProxyModeChange}
/>
{/* Password Settings */}