Commit 86790086 authored by 水玉婷's avatar 水玉婷
Browse files

feat: 添加env环境变量

parent 9e1b9591
......@@ -4,9 +4,14 @@
<button
class="voice-btn"
:class="{ 'recording': isRecording, 'disabled': disabled }"
@click="toggleRecording"
@mousedown="startRecording"
@mouseup="stopRecording"
@mouseleave="stopRecording"
@touchstart="startRecording"
@touchend="stopRecording"
@touchcancel="stopRecording"
:disabled="disabled"
:title="isRecording ? '停止录音' : '开始说话'"
:title="isRecording ? '松开停止' : '按住说话'"
>
<!-- 语音图标始终显示 -->
<span class="voice-icon">
......@@ -48,6 +53,8 @@ const props = withDefaults(defineProps<Props>(), {
const emit = defineEmits<{
audio: [audioUrl: string, audioBlob: Blob]
error: [error: string]
recordingStart: []
recordingStop: []
}>()
// 响应式数据
......@@ -128,7 +135,7 @@ const showPermissionGuide = () => {
// 开始录音
const startRecording = async () => {
if (props.disabled) return
if (props.disabled || isRecording.value) return
// 检查权限
const hasPermission = await checkMicrophonePermission();
......@@ -180,6 +187,9 @@ const startRecording = async () => {
isRecording.value = true;
showStatusMessage('正在录音...');
// 通知父组件开始录音
emit('recordingStart');
if (props.debug) {
console.log('开始录音,MediaRecorder状态:', mediaRecorder.value.state);
}
......@@ -202,6 +212,8 @@ const startRecording = async () => {
// 停止录音
const stopRecording = () => {
if (!isRecording.value) return
if (mediaRecorder.value && mediaRecorder.value.state === 'recording') {
mediaRecorder.value.stop();
isRecording.value = false;
......@@ -212,6 +224,9 @@ const stopRecording = () => {
audioStream.value = null;
}
// 通知父组件停止录音
emit('recordingStop');
if (props.debug) {
console.log('停止录音,MediaRecorder状态:', mediaRecorder.value.state);
}
......@@ -281,15 +296,6 @@ const sendRecordedAudio = async () => {
}
}
// 切换录音状态
const toggleRecording = () => {
if (isRecording.value) {
stopRecording();
} else {
startRecording();
}
}
// 组件卸载时清理资源
onUnmounted(() => {
if (isRecording.value) {
......
Supports Markdown
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