fix: 修复SpeechGenerationModal中emotion字段的TypeScript类型错误

- 为emotion字段添加类型断言,确保e.target.value符合SpeechGenerationRequest接口的emotion联合类型要求
- 解决了'string'类型无法分配给emotion联合类型的编译错误
This commit is contained in:
imeepos 2025-07-31 16:42:34 +08:00
parent f246850cb9
commit b2c6aac3e9
1 changed files with 3 additions and 6 deletions

View File

@ -1,14 +1,12 @@
import React, { useState, useCallback, useEffect } from 'react';
import React, { useState, useCallback } from 'react';
import {
Volume2,
Play,
Download,
CheckCircle,
XCircle,
Loader2,
Settings,
Users,
Mic,
ChevronDown
} from 'lucide-react';
import { invoke } from '@tauri-apps/api/core';
@ -21,7 +19,6 @@ import {
SpeechGenerationStatus,
SpeechGenerationState,
VoiceInfo,
GetVoicesResponse
} from '../types/voiceClone';
import { SystemVoice } from '../types/systemVoice';
@ -68,7 +65,7 @@ export const SpeechGenerationModal: React.FC<SpeechGenerationModalProps> = ({
// ============= 音色选择功能 =============
const handleVoiceSelect = useCallback((voiceId: string, voiceInfo: VoiceInfo | SystemVoice, source: 'system' | 'custom') => {
const voiceName = 'voice_name' in voiceInfo ? voiceInfo.voice_name : voiceInfo.name;
const voiceName = voiceInfo.voice_name;
setSelectedVoice({
id: voiceId,
@ -292,7 +289,7 @@ export const SpeechGenerationModal: React.FC<SpeechGenerationModalProps> = ({
</label>
<select
value={speechRequest.emotion || 'calm'}
onChange={(e) => setSpeechRequest(prev => ({ ...prev, emotion: e.target.value }))}
onChange={(e) => setSpeechRequest(prev => ({ ...prev, emotion: e.target.value as 'happy' | 'sad' | 'angry' | 'fearful' | 'disgusted' | 'surprised' | 'calm' }))}
disabled={speechState.status === SpeechGenerationStatus.GENERATING}
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent disabled:opacity-50"
>