From 92bae4ce1cbab5a112d92f1cc77c2672373cc178 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Fri, 24 Jul 2026 11:07:13 +0800 Subject: [PATCH 1/2] refactor: GeneratePage Phase 3 - split Step sub-components --- .../components/Step2MaterialSelect.tsx | 297 ++------- .../components/Step4TitleSettings.tsx | 270 ++------- .../generate/components/Step5VoiceSelect.tsx | 568 +++--------------- .../material/ManualMaterialList.tsx | 84 +++ .../components/material/MaterialModeTabs.tsx | 32 + .../components/material/SmartMatchCard.tsx | 60 ++ .../components/material/SmartMatchInput.tsx | 80 +++ .../components/material/SmartMatchResults.tsx | 114 ++++ .../generate/components/title/AiTitleCard.tsx | 35 ++ .../components/title/AiTitleGenerator.tsx | 105 ++++ .../components/title/TitlePresetsGrid.tsx | 41 ++ .../components/title/TitleStylePanel.tsx | 151 +++++ .../components/voice/CloneVoiceSection.tsx | 132 ++++ .../components/voice/CustomVoicePanel.tsx | 93 +++ .../components/voice/PresetVoiceDetail.tsx | 77 +++ .../components/voice/SaveVoiceModal.tsx | 125 ++++ .../components/voice/VoiceChoiceCard.tsx | 53 ++ .../voice/VoiceRecommendSection.tsx | 100 +++ .../pages/generate/hooks/useStep2Materials.ts | 2 +- .../pages/generate/hooks/useStep5Voice.tsx | 2 +- .../pages/generate/utils/formatDuration.ts | 9 + 21 files changed, 1462 insertions(+), 968 deletions(-) create mode 100644 apps/web/src/pages/generate/components/material/ManualMaterialList.tsx create mode 100644 apps/web/src/pages/generate/components/material/MaterialModeTabs.tsx create mode 100644 apps/web/src/pages/generate/components/material/SmartMatchCard.tsx create mode 100644 apps/web/src/pages/generate/components/material/SmartMatchInput.tsx create mode 100644 apps/web/src/pages/generate/components/material/SmartMatchResults.tsx create mode 100644 apps/web/src/pages/generate/components/title/AiTitleCard.tsx create mode 100644 apps/web/src/pages/generate/components/title/AiTitleGenerator.tsx create mode 100644 apps/web/src/pages/generate/components/title/TitlePresetsGrid.tsx create mode 100644 apps/web/src/pages/generate/components/title/TitleStylePanel.tsx create mode 100644 apps/web/src/pages/generate/components/voice/CloneVoiceSection.tsx create mode 100644 apps/web/src/pages/generate/components/voice/CustomVoicePanel.tsx create mode 100644 apps/web/src/pages/generate/components/voice/PresetVoiceDetail.tsx create mode 100644 apps/web/src/pages/generate/components/voice/SaveVoiceModal.tsx create mode 100644 apps/web/src/pages/generate/components/voice/VoiceChoiceCard.tsx create mode 100644 apps/web/src/pages/generate/components/voice/VoiceRecommendSection.tsx create mode 100644 apps/web/src/pages/generate/utils/formatDuration.ts diff --git a/apps/web/src/pages/generate/components/Step2MaterialSelect.tsx b/apps/web/src/pages/generate/components/Step2MaterialSelect.tsx index 983351d2a..905c38829 100644 --- a/apps/web/src/pages/generate/components/Step2MaterialSelect.tsx +++ b/apps/web/src/pages/generate/components/Step2MaterialSelect.tsx @@ -2,11 +2,11 @@ * Step 2 素材选择组件 */ import React from "react" -import { Typography } from "antd" -import { LoadingOutlined, PlayCircleOutlined, CheckCircleFilled } from "@ant-design/icons" import { useStep2Materials } from "../hooks/useStep2Materials" - -const { Text } = Typography +import MaterialModeTabs from "./material/MaterialModeTabs" +import ManualMaterialList from "./material/ManualMaterialList" +import SmartMatchInput from "./material/SmartMatchInput" +import SmartMatchResults from "./material/SmartMatchResults" interface Step2MaterialSelectProps { materialMode: "manual" | "auto" @@ -18,58 +18,21 @@ interface Step2MaterialSelectProps { } const Step2MaterialSelect: React.FC = (props) => { - const { - libraries, - selectedLibraryId, - setSelectedLibraryId, - materials, - materialsLoading, - materialMode, - onMaterialModeChange, - selectedMaterials, - handleToggleMaterial, - smartMatchInput, - setSmartMatchInput, - smartMatching, - smartMatchedResults, - hasMatched, - smartSelectedIds, - handleSmartMatch, - handleToggleSmartSelect, - handleRefreshMatch, - handleSelectAllMatched, - handleClearSmartSelect, - smartSelectedTotalDuration, - formatDuration, - } = useStep2Materials(props) + const m = useStep2Materials(props) return (

📦 选择素材

- {/* ── 模式切换 Tab ── */} -
- - -
+ - {/* ── 视频库选择(两种模式共用) ── */}
- m.setSelectedLibraryId(e.target.value)} + > + {m.libraries.map((lib) => ( @@ -77,8 +40,7 @@ const Step2MaterialSelect: React.FC = (props) => {
- {/* ── 手动选择模式 ── */} - {materialMode === "manual" && ( + {m.materialMode === "manual" && ( <>
= (props) => { gap: 10, }} > - 已选 {selectedMaterials.length} 个素材 + 已选 {m.selectedMaterials.length} 个素材
- {/* 素材列表 */} -
- {materialsLoading ? ( - 加载素材中… - ) : materials.items.length === 0 ? ( - - 暂无素材,请先在视频库中上传 - - ) : ( -
- {materials.items.map((m) => { - const checked = selectedMaterials.includes(m.id) - return ( - - ) - })} -
- )} -
+ )} - {/* ── 自动匹配模式 ── */} - {materialMode === "auto" && ( + {m.materialMode === "auto" && (
- {/* 描述输入区 */} -
- -