mirror of
https://github.com/zimplexing/OrionTV.git
synced 2026-05-13 02:57:30 +08:00
refactor: update storage management to use centralized storage configuration and improve README documentation
This commit is contained in:
@@ -73,18 +73,18 @@ const usePlayerStore = create<PlayerState>((set, get) => ({
|
||||
|
||||
set({
|
||||
isLoading: true,
|
||||
currentEpisodeIndex: episodeIndex,
|
||||
initialPosition: position || 0,
|
||||
episodes: episodes.map((ep, index) => ({
|
||||
url: ep,
|
||||
title: `第 ${index + 1} 集`,
|
||||
})),
|
||||
});
|
||||
|
||||
try {
|
||||
const playRecord = await PlayRecordManager.get(detail.source, detail.id.toString());
|
||||
set({
|
||||
isLoading: false,
|
||||
currentEpisodeIndex: episodeIndex,
|
||||
initialPosition: position || 0,
|
||||
episodes: episodes.map((ep, index) => ({
|
||||
url: ep,
|
||||
title: `第 ${index + 1} 集`,
|
||||
})),
|
||||
introEndTime: playRecord?.introEndTime,
|
||||
outroStartTime: playRecord?.outroStartTime,
|
||||
});
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { create } from 'zustand';
|
||||
import { SettingsManager } from '@/services/storage';
|
||||
import { api, ServerConfig } from '@/services/api';
|
||||
import { create } from "zustand";
|
||||
import { SettingsManager } from "@/services/storage";
|
||||
import { api, ServerConfig } from "@/services/api";
|
||||
import { storageConfig } from "@/services/storageConfig";
|
||||
// import useHomeStore from './homeStore';
|
||||
|
||||
|
||||
interface SettingsState {
|
||||
apiBaseUrl: string;
|
||||
m3uUrl: string;
|
||||
@@ -22,14 +22,14 @@ interface SettingsState {
|
||||
setM3uUrl: (url: string) => void;
|
||||
setRemoteInputEnabled: (enabled: boolean) => void;
|
||||
saveSettings: () => Promise<void>;
|
||||
setVideoSource: (config: { enabledAll: boolean; sources: {[key: string]: boolean} }) => void;
|
||||
setVideoSource: (config: { enabledAll: boolean; sources: { [key: string]: boolean } }) => void;
|
||||
showModal: () => void;
|
||||
hideModal: () => void;
|
||||
}
|
||||
|
||||
export const useSettingsStore = create<SettingsState>((set, get) => ({
|
||||
apiBaseUrl: '',
|
||||
m3uUrl: '',
|
||||
apiBaseUrl: "",
|
||||
m3uUrl: "",
|
||||
liveStreamSources: [],
|
||||
remoteInputEnabled: false,
|
||||
isModalVisible: false,
|
||||
@@ -55,6 +55,9 @@ export const useSettingsStore = create<SettingsState>((set, get) => ({
|
||||
fetchServerConfig: async () => {
|
||||
try {
|
||||
const config = await api.getServerConfig();
|
||||
if (config) {
|
||||
storageConfig.setStorageType(config.StorageType);
|
||||
}
|
||||
set({ serverConfig: config });
|
||||
} catch (error) {
|
||||
console.info("Failed to fetch server config:", error);
|
||||
@@ -66,7 +69,7 @@ export const useSettingsStore = create<SettingsState>((set, get) => ({
|
||||
setVideoSource: (config) => set({ videoSource: config }),
|
||||
saveSettings: async () => {
|
||||
const { apiBaseUrl, m3uUrl, remoteInputEnabled, videoSource } = get();
|
||||
await SettingsManager.save({
|
||||
await SettingsManager.save({
|
||||
apiBaseUrl,
|
||||
m3uUrl,
|
||||
remoteInputEnabled,
|
||||
@@ -78,4 +81,4 @@ export const useSettingsStore = create<SettingsState>((set, get) => ({
|
||||
},
|
||||
showModal: () => set({ isModalVisible: true }),
|
||||
hideModal: () => set({ isModalVisible: false }),
|
||||
}));
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user