JLBA202505130001_关于吉林银行新建AI智能培训系统的需求_开发录音组件,完善

This commit is contained in:
田岩
2026-03-04 20:04:09 +08:00
parent d6f7847e69
commit 696a48f3d6
3 changed files with 31 additions and 23 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ ENV = 'development'
#VITE_APP_BASE_API_Url = 'https://aits.jlbank.com.cn:7001'
VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001'
VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002'
# DEV
+25 -17
View File
@@ -59,7 +59,7 @@
</view>
<!-- 第一形态两侧按钮 -->
<view class="page-box" :style="{ marginBottom: pageBoxMarginBottom }">
<view class="page-1" :class="[status, props.mode]">
<view class="page-1" :class="[status, workMode]">
<view class="btns-box">
<!-- 左侧取消按钮 -->
<image
@@ -87,7 +87,7 @@
</view>
</view>
<!-- 第二形态 -->
<view class="page-2" :class="[status, voice_to_text_status, props.mode]">
<view class="page-2" :class="[status, voice_to_text_status, workMode]">
<!-- 左侧XX -->
<view class="transVoiceIng cancel-btn" @click="closePopup()">
<text class="btn-text">取消</text>
@@ -127,14 +127,6 @@
const voice_to_text_status = ref<VoiceToTextSubStatus>('init');
const popupRef = ref(null);
const props = defineProps({
// mode控制功能模式
mode: {
type: String,
default: 'text-only',
validator: (value: string) => {
return ['voice-only', 'text-only', 'both'].includes(value);
}
},
isDisabled: {
default: false,
type: Boolean
@@ -168,8 +160,24 @@
// 最小录音间隔
type: Number,
default: 1000
},
answerMethod:{
type: String,
default: '01',
validator: (value: string) => {
/* '01': '不限制回答方式', '02': '仅文字回答', '03': '仅语音回答'*/
return ['01', '02', '03'].includes(value);
}
}
});
const workMode = computed(() => {
const modeMap = {
'01': 'both',
'02': 'text-only',
'03': 'voice-only'
};
return modeMap[props.answerMethod] || 'both';
});
const textAreaText = computed({
get() {
return allText.value + tempText.value;
@@ -184,7 +192,7 @@
(isOutStatus.value === '03' || status.value === 'voice_to_text' || status.value === 'send_over') &&
classes.push('is-translate');
// 仅语音模式,01松手后要和03操作一样
// isOutStatus.value === '01' && props.mode === 'text-only' && status.value == 'voice_to_text' && classes.push('is-translate');
// isOutStatus.value === '01' && workMode.value === 'text-only' && status.value == 'voice_to_text' && classes.push('is-translate');
voice_to_text_status.value !== '' && classes.push(voice_to_text_status.value);
return classes;
});
@@ -202,8 +210,8 @@
const recordStartTime = ref(0); // 录音开始时间戳
const pressTimer = ref<number | null>(null);
// 计算属性:判断是否仅语音/仅文字模式(简化模板逻辑)
const isVoiceOnlyMode = computed(() => props.mode === 'voice-only');
const isTextOnlyMode = computed(() => props.mode === 'text-only');
const isVoiceOnlyMode = computed(() => workMode.value === 'voice-only');
const isTextOnlyMode = computed(() => workMode.value === 'text-only');
const talkRightIcon = computed(() => {
if (isInputVisible.value) return TouchBtnImages.icKeyboardSvg();
if (inputText.value) return TouchBtnImages.iconSendSvg();
@@ -214,7 +222,7 @@
const { y: touchY, x: touchX } = touchPos;
if (touchY >= bottomAreaTopBoundary) return '01';
// 仅语音模式只能返回取消(02
if (props.mode === 'voice-only') return '02';
if (workMode.value === 'voice-only') return '02';
return touchX < horizontalSplitX ? '02' : '03';
});
// 监听按下移动
@@ -284,7 +292,7 @@
text = controlBody.txt.trim();
}
const _isOutStatus =
props.mode === 'text-only' && isOutStatus.value === '01' ? '03' : isOutStatus.value;
workMode.value === 'text-only' && isOutStatus.value === '01' ? '03' : isOutStatus.value;
// 只有模式为01的时候才发送出去
if (_isOutStatus === '01') {
emit('submitVoice', { ossKey, text, recordId: recordId.value });
@@ -341,7 +349,7 @@
const stopRecord = async (errrStatus = '') => {
clearTimeout(pressTimer.value);
if (!isRecording.value) return; // 未处于录音状态
const _isOutStatus = props.mode === 'text-only' && isOutStatus.value === '01' ? '03' : isOutStatus.value;
const _isOutStatus = workMode.value === 'text-only' && isOutStatus.value === '01' ? '03' : isOutStatus.value;
console.log('_isOutStatus', _isOutStatus);
// 拖动到转文字按钮上抬手或者仅文字模式的发送也强行算他转文字
if (_isOutStatus === '03') {
@@ -407,7 +415,7 @@
if (voiceTimer) clearTimeout(voiceTimer);
voiceTimer = setTimeout(() => {
voiceTimer = null;
if (props.mode === 'voice-only') {
if (workMode.value === 'voice-only') {
if (status.value === 'send_over') return;
status.value = 'send_over'; // 恢复成默认状态
emit('submitVoice', { ossKey: '', text: '', recordId: recordId.value });
+5 -5
View File
@@ -67,7 +67,7 @@
<view class="fixed-box font_pf" :style="{ marginBottom: popup_input_bottom }">
<view class="touch-btn-div" :class="{ show: showTouchBtn }">
<TouchBtnOnlyVoice
<!-- <TouchBtnOnlyVoice
v-if="answerMethod === '03'"
class="talk-btns"
ref="touchBtnRef"
@@ -91,9 +91,9 @@
:adjustPosition="false"
:isDisabled="false"
:answerMethod="answerMethod"
/>
/> -->
<!-- <touch-btn
<touch-btn
class="talk-btns"
ref="touchBtnRef"
@sendLoading="sendLoading"
@@ -103,7 +103,7 @@
:isLoading="touchIsDisabled"
loadingText="只能进行一条回答"
:answerMethod="answerMethod"
/> -->
/>
</view>
</view>
@@ -123,7 +123,7 @@
import Subject from '@/components/examination/subject.vue';
import CharactersSubject from '@/components/examination/characters-subject.vue';
// import TouchBtn from '@/components/examination/touchBtn.vue';
import TouchBtn from '@/pages/course/components/touchBtn.vue';
// import TouchBtn from '@/pages/course/components/touchBtn.vue';
import TouchBtnOnlyVoice from '@/pages/course/components/touchBtnOnlyVoice.vue';
import common from '@/common/common';
import { setPageCache, formatSeconds, getPageCache, setupKeyboardHeightListener } from '@/common/common';