Commit cfaf6ee6 authored by StyleZhang's avatar StyleZhang

fix ui

parent 826c1a59
...@@ -594,7 +594,7 @@ const Chat: FC<IChatProps> = ({ ...@@ -594,7 +594,7 @@ const Chat: FC<IChatProps> = ({
)} )}
</div> </div>
{ {
voiceInputShow && <VoiceInput onConverted={() => setVoiceInputShow(false)} /> voiceInputShow && <VoiceInput onCancel={() => setVoiceInputShow(false)} onConverted={() => setVoiceInputShow(false)} />
} }
</div> </div>
</div> </div>
......
...@@ -8,9 +8,11 @@ import { Loading02, XClose } from '@/app/components/base/icons/src/vender/line/g ...@@ -8,9 +8,11 @@ import { Loading02, XClose } from '@/app/components/base/icons/src/vender/line/g
type VoiceInputTypes = { type VoiceInputTypes = {
onConverted: (text: string) => void onConverted: (text: string) => void
onCancel: () => void
} }
const VoiceInput = ({ const VoiceInput = ({
onCancel,
onConverted, onConverted,
}: VoiceInputTypes) => { }: VoiceInputTypes) => {
const { t } = useTranslation() const { t } = useTranslation()
...@@ -36,14 +38,14 @@ const VoiceInput = ({ ...@@ -36,14 +38,14 @@ const VoiceInput = ({
let v = dataArray[i * gap] let v = dataArray[i * gap]
if (v < 128) if (v < 128)
v = 128 v = 128
if (v > 188) if (v > 178)
v = 188 v = 178
const y = (v - 118) / 70 * canvas.height const y = (v - 128) / 50 * canvas.height
ctx.moveTo(x, 16) ctx.moveTo(x, 16)
ctx.roundRect(x, 16 - y, 2, y, [1, 1, 0, 0]) ctx.roundRect(x, 16 - y, 2, y, [1, 1, 0, 0])
ctx.fill() ctx.fill()
x += 4 x += 3
} }
ctx.closePath() ctx.closePath()
}, []) }, [])
...@@ -74,9 +76,6 @@ const VoiceInput = ({ ...@@ -74,9 +76,6 @@ const VoiceInput = ({
if (canvasRef.current && ctxRef.current) if (canvasRef.current && ctxRef.current)
drawRecord() drawRecord()
} }
const handleStopConvert = () => {
handleStartRecord()
}
const initCanvas = () => { const initCanvas = () => {
const dpr = window.devicePixelRatio || 1 const dpr = window.devicePixelRatio || 1
...@@ -138,7 +137,7 @@ const VoiceInput = ({ ...@@ -138,7 +137,7 @@ const VoiceInput = ({
startConvert && ( startConvert && (
<div <div
className='flex justify-center items-center mr-1 w-8 h-8 hover:bg-primary-100 rounded-lg cursor-pointer' className='flex justify-center items-center mr-1 w-8 h-8 hover:bg-primary-100 rounded-lg cursor-pointer'
onClick={handleStopConvert} onClick={onCancel}
> >
<XClose className='w-4 h-4 text-gray-500' /> <XClose className='w-4 h-4 text-gray-500' />
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment