From d9d1c4df52f3930cf17e7a23fd97a23da69ac1a7 Mon Sep 17 00:00:00 2001 From: imeepos Date: Thu, 31 Jul 2025 16:43:43 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=B8=85=E7=90=86=E8=AF=AD?= =?UTF-8?q?=E9=9F=B3=E9=80=89=E6=8B=A9=E5=99=A8=E7=9B=B8=E5=85=B3=E7=BB=84?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除未使用的VoiceSelectorDemo组件 - 移除各组件中的冗余导入和未使用代码 - 优化VoiceCloneModal、VoiceSelector、SystemVoiceSelector组件 - 清理ModelDetail和VoiceCloneTool页面中的无用代码 影响范围: 语音克隆功能模块 类型: 代码清理和重构 --- .../src/components/SystemVoiceSelector.tsx | 6 - .../src/components/VoiceCloneModal.tsx | 1 - apps/desktop/src/components/VoiceSelector.tsx | 2 - .../src/components/VoiceSelectorDemo.tsx | 116 ------------------ apps/desktop/src/pages/ModelDetail.tsx | 2 +- .../src/pages/tools/VoiceCloneTool.tsx | 7 -- 6 files changed, 1 insertion(+), 133 deletions(-) delete mode 100644 apps/desktop/src/components/VoiceSelectorDemo.tsx diff --git a/apps/desktop/src/components/SystemVoiceSelector.tsx b/apps/desktop/src/components/SystemVoiceSelector.tsx index 48fe094..e6febb9 100644 --- a/apps/desktop/src/components/SystemVoiceSelector.tsx +++ b/apps/desktop/src/components/SystemVoiceSelector.tsx @@ -1,26 +1,20 @@ import React, { useState, useEffect, useCallback, useMemo } from 'react'; import { Search, - Filter, Volume2, CheckCircle, Loader2, RefreshCw, ChevronDown, ChevronUp, - Star, - Users, - Globe } from 'lucide-react'; import { SystemVoice, SystemVoiceType, - VoiceGender, SystemVoiceQuery, VoiceSelectorProps, VOICE_TYPE_LABELS, GENDER_LABELS, - VOICE_TYPE_COLORS, GENDER_ICONS } from '../types/systemVoice'; import { SystemVoiceService } from '../services/systemVoiceService'; diff --git a/apps/desktop/src/components/VoiceCloneModal.tsx b/apps/desktop/src/components/VoiceCloneModal.tsx index dada131..723bbe8 100644 --- a/apps/desktop/src/components/VoiceCloneModal.tsx +++ b/apps/desktop/src/components/VoiceCloneModal.tsx @@ -8,7 +8,6 @@ import { Loader2, Music, FileAudio, - X } from 'lucide-react'; import { invoke } from '@tauri-apps/api/core'; import { open } from '@tauri-apps/plugin-dialog'; diff --git a/apps/desktop/src/components/VoiceSelector.tsx b/apps/desktop/src/components/VoiceSelector.tsx index fa10b61..f07878b 100644 --- a/apps/desktop/src/components/VoiceSelector.tsx +++ b/apps/desktop/src/components/VoiceSelector.tsx @@ -8,10 +8,8 @@ import { Volume2, Users, Settings, - Filter, CheckCircle, Loader2, - X } from 'lucide-react'; import { invoke } from '@tauri-apps/api/core'; import { Modal } from './Modal'; diff --git a/apps/desktop/src/components/VoiceSelectorDemo.tsx b/apps/desktop/src/components/VoiceSelectorDemo.tsx deleted file mode 100644 index e43f51d..0000000 --- a/apps/desktop/src/components/VoiceSelectorDemo.tsx +++ /dev/null @@ -1,116 +0,0 @@ -import React, { useState } from 'react'; -import { Volume2, Settings, Users } from 'lucide-react'; -import { VoiceSelector } from './VoiceSelector'; -import { VoiceInfo } from '../types/voiceClone'; -import { SystemVoice } from '../types/systemVoice'; - -/** - * 音色选择器演示组件 - * 展示新的音色选择器的使用方法和效果 - */ -export const VoiceSelectorDemo: React.FC = () => { - const [showSelector, setShowSelector] = useState(false); - const [selectedVoice, setSelectedVoice] = useState<{ - id: string; - name: string; - source: 'system' | 'custom'; - data: VoiceInfo | SystemVoice; - } | null>(null); - - const handleVoiceSelect = (voiceId: string, voiceInfo: VoiceInfo | SystemVoice, source: 'system' | 'custom') => { - const voiceName = 'voice_name' in voiceInfo ? voiceInfo.voice_name : voiceInfo.name; - - setSelectedVoice({ - id: voiceId, - name: voiceName || voiceId, - source, - data: voiceInfo - }); - }; - - return ( -
-
-
-

音色选择器演示

- -
- {/* 当前选择的音色 */} -
- - - {selectedVoice ? ( -
-
- {selectedVoice.source === 'system' ? ( - - ) : ( - - )} -
-

{selectedVoice.name}

-

- {selectedVoice.source === 'system' ? '系统音色' : '自定义音色'} - ID: {selectedVoice.id} -

-
-
-
- ) : ( -
- 尚未选择音色 -
- )} -
- - {/* 选择音色按钮 */} -
- -
- - {/* 功能说明 */} -
-

新音色选择器特性

-
    -
  • • 🎵 统一展示系统音色和自定义音色
  • -
  • • 🔍 支持搜索和分类筛选
  • -
  • • 🎧 音色预览试听功能(开发中)
  • -
  • • 📱 响应式网格布局
  • -
  • • ⭐ 收藏常用音色
  • -
  • • 🏷️ 音色标签和描述
  • -
  • • 🎨 美观的卡片式设计
  • -
-
- - {/* 对比说明 */} -
-

相比原版的改进

-
    -
  • • ✅ 简化了主界面,只需一个按钮
  • -
  • • ✅ 无需在系统音色和自定义音色间切换
  • -
  • • ✅ 更直观的音色信息展示
  • -
  • • ✅ 更好的用户体验和交互
  • -
  • • ✅ 节省了界面空间
  • -
-
-
-
-
- - {/* 音色选择器 */} - setShowSelector(false)} - onSelect={handleVoiceSelect} - selectedVoiceId={selectedVoice?.id} - /> -
- ); -}; diff --git a/apps/desktop/src/pages/ModelDetail.tsx b/apps/desktop/src/pages/ModelDetail.tsx index 6db99a6..6337d08 100644 --- a/apps/desktop/src/pages/ModelDetail.tsx +++ b/apps/desktop/src/pages/ModelDetail.tsx @@ -52,7 +52,7 @@ const ModelDetail: React.FC = () => { const [outfitPage, setOutfitPage] = useState(1); const [outfitHasMore, setOutfitHasMore] = useState(false); const [outfitLoadingMore, setOutfitLoadingMore] = useState(false); - const [outfitTotalCount, setOutfitTotalCount] = useState(0); + const [_outfitTotalCount, setOutfitTotalCount] = useState(0); const [generatingOutfit, setGeneratingOutfit] = useState(false); const [activeTab, setActiveTab] = useState('overview'); diff --git a/apps/desktop/src/pages/tools/VoiceCloneTool.tsx b/apps/desktop/src/pages/tools/VoiceCloneTool.tsx index 2b23e98..a99ab53 100644 --- a/apps/desktop/src/pages/tools/VoiceCloneTool.tsx +++ b/apps/desktop/src/pages/tools/VoiceCloneTool.tsx @@ -14,13 +14,6 @@ import { Trash2, Star, Users, - Search, - Plus, - Play, - Pause, - Calendar, - Clock, - Filter } from 'lucide-react'; import { invoke } from '@tauri-apps/api/core'; import { open } from '@tauri-apps/plugin-dialog';