feat: 语音的问题修复

This commit is contained in:
2026-05-27 12:03:17 +08:00
parent 98d380edd8
commit c9f93cfa7f
2 changed files with 40 additions and 1 deletions

View 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"
);

View File

@@ -185,6 +185,7 @@ let appStopFallbackTimer = null;
let hasSentAppRecognition = false;
const resetUI = () => {
isVoicePressing.value = false;
isRecording.value = false;
visibleWaveBtn.value = false;
try {
@@ -418,7 +419,6 @@ const handleVoiceTouchEnd = () => {
};
const handleVoiceTouchEndFromContainer = () => {
if (speechProvider !== "app") return;
if (!hasActiveVoiceRecognition()) return;
stopActiveVoiceRecognition({ shouldSend: true });
};