Commit d993b940 by 李伟康

feat(chat): 添加语音输入功能到聊天界面

- 在输入组件中集成 VoiceInput 组件并正确渲染
- 修复 VoiceInput 组件的显示逻辑,添加条件渲染判断
- 更新 VoiceInputContext 的依赖数组以包含 setShowVoiceInput
- 确保语音输入状态变化时正确同步到消息上下文
1 parent 09f67a3a
...@@ -4,15 +4,11 @@ import { useFileOperation } from '../../hooks' ...@@ -4,15 +4,11 @@ import { useFileOperation } from '../../hooks'
import TextInput from './text-input' import TextInput from './text-input'
import Opration from '../operation' import Opration from '../operation'
import MultipleLineOperation from './multiple-line-operation' import MultipleLineOperation from './multiple-line-operation'
import VoiceInput from '../voice-input'
import s from './wrapper.module.scss' import s from './wrapper.module.scss'
const InputWrapper: FC = () => { const InputWrapper: FC = () => {
const { isDragActive } = useFileOperation() const { isDragActive } = useFileOperation()
return ( return (
// <div
// className={cn(
// 'relative z-10 rounded-xl border border-components-chat-input-border bg-[#fff] pb-[9px] shadow-md',
// isDragActive && 'border border-dashed border-components-option-card-option-selected-border',
// )}>
<div <div
className={cn( className={cn(
s['input-wrapper'], s['input-wrapper'],
...@@ -23,7 +19,7 @@ const InputWrapper: FC = () => { ...@@ -23,7 +19,7 @@ const InputWrapper: FC = () => {
<TextInput> <TextInput>
<Opration /> <Opration />
</TextInput> </TextInput>
{/* <VoiceInput /> */} <VoiceInput />
</div> </div>
<MultipleLineOperation /> <MultipleLineOperation />
</div> </div>
......
...@@ -13,7 +13,7 @@ const Voice: FC = () => { ...@@ -13,7 +13,7 @@ const Voice: FC = () => {
setQuery(text) setQuery(text)
requestAnimationFrame(handleTextareaResize) requestAnimationFrame(handleTextareaResize)
}, []) }, [])
// if (!showVoiceInput) return null if (!showVoiceInput) return null
setQuery('') setQuery('')
return <VoiceInput onCancel={() => setShowVoiceInput(false)} onConverted={onConverted} /> return <VoiceInput onCancel={() => setShowVoiceInput(false)} onConverted={onConverted} />
} }
......
...@@ -25,7 +25,7 @@ export const VoiceInputProvider = ({ children }: { children: ReactNode }) => { ...@@ -25,7 +25,7 @@ export const VoiceInputProvider = ({ children }: { children: ReactNode }) => {
showVoiceInput, showVoiceInput,
setShowVoiceInput, setShowVoiceInput,
}), }),
[showVoiceInput], [showVoiceInput, setShowVoiceInput],
) )
useEffect(() => postMessage({ isRecording: showVoiceInput }), [showVoiceInput]) useEffect(() => postMessage({ isRecording: showVoiceInput }), [showVoiceInput])
return <VoiceInputContext.Provider value={value}>{children}</VoiceInputContext.Provider> return <VoiceInputContext.Provider value={value}>{children}</VoiceInputContext.Provider>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!