feat: 语音的问题修复
This commit is contained in:
39
scripts/regression-chat-input-area-voice.mjs
Normal file
39
scripts/regression-chat-input-area-voice.mjs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import { dirname, resolve } from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
|
const scriptDir = dirname(fileURLToPath(import.meta.url));
|
||||||
|
const componentPath = resolve(
|
||||||
|
scriptDir,
|
||||||
|
"../src/pages/ChatMain/ChatInputArea/index.vue"
|
||||||
|
);
|
||||||
|
const source = readFileSync(componentPath, "utf8");
|
||||||
|
|
||||||
|
const handlerMatch = source.match(
|
||||||
|
/const\s+handleVoiceTouchEndFromContainer\s*=\s*\(\)\s*=>\s*{([\s\S]*?)\n};/
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
handlerMatch,
|
||||||
|
"ChatInputArea should define handleVoiceTouchEndFromContainer"
|
||||||
|
);
|
||||||
|
|
||||||
|
const handlerBody = handlerMatch[1];
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
!/speechProvider\s*!==\s*["']app["']/.test(handlerBody),
|
||||||
|
"container touchend must not ignore WeChat recordings because the pressed button can unmount while RecordingWaveBtn is shown"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
/hasActiveVoiceRecognition\(\)/.test(handlerBody),
|
||||||
|
"container touchend should only stop when a voice recognition session is active"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
/stopActiveVoiceRecognition\(\{\s*shouldSend:\s*true\s*\}\)/s.test(
|
||||||
|
handlerBody
|
||||||
|
),
|
||||||
|
"container touchend should stop the active recognition and send recognized text"
|
||||||
|
);
|
||||||
@@ -185,6 +185,7 @@ let appStopFallbackTimer = null;
|
|||||||
let hasSentAppRecognition = false;
|
let hasSentAppRecognition = false;
|
||||||
|
|
||||||
const resetUI = () => {
|
const resetUI = () => {
|
||||||
|
isVoicePressing.value = false;
|
||||||
isRecording.value = false;
|
isRecording.value = false;
|
||||||
visibleWaveBtn.value = false;
|
visibleWaveBtn.value = false;
|
||||||
try {
|
try {
|
||||||
@@ -418,7 +419,6 @@ const handleVoiceTouchEnd = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleVoiceTouchEndFromContainer = () => {
|
const handleVoiceTouchEndFromContainer = () => {
|
||||||
if (speechProvider !== "app") return;
|
|
||||||
if (!hasActiveVoiceRecognition()) return;
|
if (!hasActiveVoiceRecognition()) return;
|
||||||
stopActiveVoiceRecognition({ shouldSend: true });
|
stopActiveVoiceRecognition({ shouldSend: true });
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user