mirror of
https://github.com/zimplexing/OrionTV.git
synced 2026-02-17 14:14:46 +08:00
- Updated EpisodeSelectionModal to utilize Zustand for episode selection state. - Refactored PlayerControls to manage playback state and controls using Zustand. - Simplified SettingsModal to handle settings state with Zustand. - Introduced homeStore for managing home screen categories and content data. - Created playerStore for managing video playback and episode details. - Added settingsStore for managing API settings and modal visibility. - Updated package.json to include Zustand as a dependency. - Cleaned up code formatting and improved readability across components.
32 lines
997 B
TypeScript
32 lines
997 B
TypeScript
import { create } from 'zustand';
|
|
import { SettingsManager } from '@/services/storage';
|
|
import { api } from '@/services/api';
|
|
|
|
interface SettingsState {
|
|
apiBaseUrl: string;
|
|
isModalVisible: boolean;
|
|
loadSettings: () => Promise<void>;
|
|
setApiBaseUrl: (url: string) => void;
|
|
saveSettings: () => Promise<void>;
|
|
showModal: () => void;
|
|
hideModal: () => void;
|
|
}
|
|
|
|
export const useSettingsStore = create<SettingsState>((set, get) => ({
|
|
apiBaseUrl: '',
|
|
isModalVisible: false,
|
|
loadSettings: async () => {
|
|
const settings = await SettingsManager.get();
|
|
set({ apiBaseUrl: settings.apiBaseUrl });
|
|
api.setBaseUrl(settings.apiBaseUrl);
|
|
},
|
|
setApiBaseUrl: (url) => set({ apiBaseUrl: url }),
|
|
saveSettings: async () => {
|
|
const { apiBaseUrl } = get();
|
|
await SettingsManager.save({ apiBaseUrl });
|
|
api.setBaseUrl(apiBaseUrl);
|
|
set({ isModalVisible: false });
|
|
},
|
|
showModal: () => set({ isModalVisible: true }),
|
|
hideModal: () => set({ isModalVisible: false }),
|
|
})); |