解决录音ui卡住的bug

This commit is contained in:
田岩
2025-12-02 11:09:54 +08:00
parent 04711aa242
commit c12914c0a1
+21 -6
View File
@@ -56,7 +56,7 @@
</view>
<view class="tips-box">松开发送</view>
<view class="btns-box">
<view :class="['close-btn', isOut ? 'is-out' : '']" id="circleBox">
<view :class="['close-btn', isOut ? 'is-out' : '']" id="circleBox" @click="closePopup()">
取消
<image class="btn-box" v-if="!isOut" src="@/static/images/course/close.png" mode=""></image>
<image class="btn-box" v-else src="@/static/images/course/close-active.png" mode=""></image>
@@ -73,6 +73,7 @@
<script setup>
import { ref, computed, onMounted, nextTick, watch, reactive } from 'vue';
import common from '@/common/common';
import { onHide } from '@dcloudio/uni-app';
import permission from '@/common/permission.js';
import { getPhoneEnvBool } from '@/common/common.js';
import { initRecord } from '@/composables/useExamSubject.js';
@@ -138,6 +139,7 @@
}
if (props.isDisabled) return;
// 开始录音
isClickOut.value = false
console.log('开始录音', recordingStatus.value);
if (recordingStatus.value !== 'not_started') return;
touchY.value = obj.changedTouches[0].pageY;
@@ -173,11 +175,17 @@
}
nextTick(() => (recordingStatus.value = 'not_started'));
};
const closePopup = () => {
console.log('点击关闭');
isClickOut.value = true
stopRecord(false)
}
onMounted(async () => {
// #ifdef APP-PLUS
recorderManager.onStop(function (res) {
console.log('录音文件临时位置', res.tempFilePath, isOut.value);
if (isOut.value) return; // 被划掉的语音
console.log('录音文件临时位置', res.tempFilePath, isOut.value, isClickOut.value);
if (isOut.value || isClickOut.value) return; // 被划掉的语音
const endTime = Date.now();
const recordDuration = endTime - startTime;
console.log('说话时长', recordDuration);
@@ -193,6 +201,7 @@
emit('submit', 'voice', res.tempFilePath);
});
recorderManager.onError(function (err) {
isClickOut.value = false
console.log('录音错误', err);
});
recorderManager.onStart(function (res) {
@@ -201,14 +210,19 @@
if (recordingStatus.value !== 'preparing') {
stopRecord();
}
startTime = Date.now();
isClickOut.value = false
recordingStatus.value = 'in_recording';
});
// #endif
});
onHide(() => {
closePopup()
console.log('onHide');
})
const touchY = ref(0);
const windowInfo = uni.getWindowInfo();
// 安全区域信息
@@ -218,6 +232,7 @@
const btnHeight = (windowInfo.screenWidth / 750) * 234;
return touchY.value < safeArea.bottom - btnHeight;
});
const isClickOut = ref(false);
const activeNum = ref(1);
const handleMove = (obj) => {