From bb51b4e6c5a3c1df3989c605e9482041c57e4db9 Mon Sep 17 00:00:00 2001 From: bdim404 Date: Mon, 26 Jan 2026 17:23:04 +0800 Subject: [PATCH] Add HistoryContext and integrate it into relevant components for improved job management --- qwen3-tts-frontend/src/App.tsx | 9 +- .../src/components/HistorySidebar.tsx | 6 +- .../src/components/tts/CustomVoiceForm.tsx | 5 + .../src/components/tts/VoiceCloneForm.tsx | 5 + .../src/components/tts/VoiceDesignForm.tsx | 5 + .../src/contexts/HistoryContext.tsx | 126 ++++++++++++++++++ .../src/contexts/JobContext.tsx | 11 +- qwen3-tts-frontend/src/pages/Home.tsx | 6 +- 8 files changed, 163 insertions(+), 10 deletions(-) create mode 100644 qwen3-tts-frontend/src/contexts/HistoryContext.tsx diff --git a/qwen3-tts-frontend/src/App.tsx b/qwen3-tts-frontend/src/App.tsx index 6e2a2b9..ffb27c0 100644 --- a/qwen3-tts-frontend/src/App.tsx +++ b/qwen3-tts-frontend/src/App.tsx @@ -5,6 +5,7 @@ import { ThemeProvider } from '@/contexts/ThemeContext' import { AuthProvider, useAuth } from '@/contexts/AuthContext' import { AppProvider } from '@/contexts/AppContext' import { JobProvider } from '@/contexts/JobContext' +import { HistoryProvider } from '@/contexts/HistoryContext' import ErrorBoundary from '@/components/ErrorBoundary' import LoadingScreen from '@/components/LoadingScreen' import { SuperAdminRoute } from '@/components/SuperAdminRoute' @@ -71,9 +72,11 @@ function App() { element={ - - - + + + + + } diff --git a/qwen3-tts-frontend/src/components/HistorySidebar.tsx b/qwen3-tts-frontend/src/components/HistorySidebar.tsx index cb1052c..40b89fe 100644 --- a/qwen3-tts-frontend/src/components/HistorySidebar.tsx +++ b/qwen3-tts-frontend/src/components/HistorySidebar.tsx @@ -1,5 +1,5 @@ import { useRef, useEffect } from 'react' -import { useHistory } from '@/hooks/useHistory' +import { useHistoryContext } from '@/contexts/HistoryContext' import { HistoryItem } from '@/components/HistoryItem' import { ScrollArea } from '@/components/ui/scroll-area' import { Sheet, SheetContent } from '@/components/ui/sheet' @@ -15,7 +15,7 @@ interface HistorySidebarProps { } function HistorySidebarContent({ onLoadParams }: Pick) { - const { jobs, loading, loadingMore, hasMore, loadMore, deleteJob, error, retry } = useHistory() + const { jobs, loading, loadingMore, hasMore, loadMore, deleteJob, error, retry } = useHistoryContext() const observerTarget = useRef(null) useEffect(() => { @@ -99,7 +99,7 @@ function HistorySidebarContent({ onLoadParams }: Pick -