From 1598da861acd5d6bb90ae1b8f69871f33a0dc46e Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Sun, 26 Jul 2026 16:17:24 +0800 Subject: [PATCH] =?UTF-8?q?refactor(voice-materials):=20=E6=B7=B1=E5=8C=96?= =?UTF-8?q?=E6=8B=86=E5=88=86=20UI=20=E7=BB=84=E4=BB=B6=EF=BC=88603?= =?UTF-8?q?=E2=86=92338=E8=A1=8C,=20-44%=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase 4: 继续拆 5 个 UI 组件 - Toolbar — 搜索 + 性别筛选 + 视图切换 - TagFilterBar — 标签筛选药丸条 - BatchBar — 批量操作栏(全选/打标签/删除) - EmptyState — 加载/空状态 - TtsModal — AI 配音 TTS 合成弹窗 更新 smoke test 新增模块 import --- .../voice-materials/VoiceMaterialLibrary.tsx | 388 +++--------------- .../voice-materials/components/BatchBar.tsx | 94 +++++ .../voice-materials/components/EmptyState.tsx | 52 +++ .../components/TagFilterBar.tsx | 45 ++ .../voice-materials/components/Toolbar.tsx | 76 ++++ .../voice-materials/components/TtsModal.tsx | 171 ++++++++ .../test/pages/voice-materials/smoke.test.tsx | 5 + 7 files changed, 502 insertions(+), 329 deletions(-) mode change 100755 => 100644 apps/web/src/pages/voice-materials/VoiceMaterialLibrary.tsx create mode 100644 apps/web/src/pages/voice-materials/components/BatchBar.tsx create mode 100644 apps/web/src/pages/voice-materials/components/EmptyState.tsx create mode 100644 apps/web/src/pages/voice-materials/components/TagFilterBar.tsx create mode 100644 apps/web/src/pages/voice-materials/components/Toolbar.tsx create mode 100644 apps/web/src/pages/voice-materials/components/TtsModal.tsx diff --git a/apps/web/src/pages/voice-materials/VoiceMaterialLibrary.tsx b/apps/web/src/pages/voice-materials/VoiceMaterialLibrary.tsx old mode 100755 new mode 100644 index 8d481899f..2e0416579 --- a/apps/web/src/pages/voice-materials/VoiceMaterialLibrary.tsx +++ b/apps/web/src/pages/voice-materials/VoiceMaterialLibrary.tsx @@ -9,21 +9,8 @@ * - 删除素材 */ import React from "react" -import { - AudioOutlined, - SearchOutlined, - PlusOutlined, - DeleteOutlined, - UploadOutlined, - UnorderedListOutlined, - AppstoreOutlined, - CheckOutlined, - TagsOutlined, - RobotOutlined, - LoadingOutlined, -} from "@ant-design/icons" -import { Button, Input, Select, Modal } from "@/components/ui" -import { Popover, Popconfirm } from "antd" +import { AudioOutlined, PlusOutlined, RobotOutlined } from "@ant-design/icons" +import { Button, Modal } from "@/components/ui" import PageHead from "@/components/layout/PageHead" import { useVoiceMaterials } from "./hooks/useVoiceMaterials" import { useAudioPlayer } from "./hooks/useAudioPlayer" @@ -32,6 +19,11 @@ import { useTtsSynthesize } from "./hooks/useTtsSynthesize" import MaterialForm from "./components/MaterialForm" import VoiceMaterialCard from "./components/VoiceMaterialCard" import VoiceMaterialRow from "./components/VoiceMaterialRow" +import Toolbar from "./components/Toolbar" +import TagFilterBar from "./components/TagFilterBar" +import BatchBar from "./components/BatchBar" +import EmptyState from "./components/EmptyState" +import TtsModal from "./components/TtsModal" import "./voice-materials.css" /* ============================================================ @@ -137,7 +129,7 @@ const VoiceMaterialLibrary: React.FC = () => { }) } - /* ── 渲染 ─────────────────────────────────────────────── */ + const hasFilter = !!searchText || filterGender !== "all" || filterTagId !== "all" const pageActions = (
@@ -164,155 +156,47 @@ const VoiceMaterialLibrary: React.FC = () => { /> {/* 工具栏:搜索 + 筛选 + 视图切换 */} -
-
- } - value={searchText} - onChange={(e) => setSearchText(e.target.value)} - allowClear - style={{ width: 240 }} - /> - ) => - setBatchCustomTag(e.target.value) - } - onKeyDown={(e: React.KeyboardEvent) => { - if (e.key === "Enter" && batchCustomTag.trim()) { - handleBatchCustomTag(batchCustomTag.trim()) - setBatchCustomTag("") - } - }} - /> -
- {tags.map((tag) => ( - - ))} -
- } - title="批量打标签" - trigger="click" - > - - - - - -
- + )} + {/* 加载/空状态 */} + setUploadOpen(true)} + /> + {/* 内容区 — 卡片视图 */} {!isLoading && filtered.length > 0 && viewMode === "card" && (
@@ -374,31 +258,6 @@ const VoiceMaterialLibrary: React.FC = () => {
)} - {/* 空状态 */} - {!isLoading && filtered.length === 0 && ( -
-
- -
-

暂无配音素材

-

- {searchText || filterGender !== "all" || filterTagId !== "all" - ? "未找到匹配的素材,试试调整筛选条件" - : "上传音频文件,开始管理配音素材"} -

- {!searchText && filterGender === "all" && filterTagId === "all" && ( - - )} -
- )} - {/* 上传弹窗 */} { width={560} destroyOnClose > -
- {/* 文本输入 */} -
- -