修改一个神奇的bug

This commit is contained in:
田岩
2025-12-12 20:55:13 +08:00
parent d740d679f3
commit 1dbec4e38a
+74 -24
View File
@@ -28,9 +28,28 @@
</view>
</template>
<script setup>
import { ref, reactive, onMounted, onUnmounted, computed, getCurrentInstance, nextTick } from 'vue';
import { onShow, onLoad, onUnload, onBackPress, onReady } from '@dcloudio/uni-app';
import { ProtocolCodec, MessageType, CompressionType, ControlCommand } from './js/ProtocolCodec';
import {
ref,
reactive,
onMounted,
onUnmounted,
computed,
getCurrentInstance,
nextTick
} from 'vue';
import {
onShow,
onLoad,
onUnload,
onBackPress,
onReady
} from '@dcloudio/uni-app';
import {
ProtocolCodec,
MessageType,
CompressionType,
ControlCommand
} from './js/ProtocolCodec';
import common from '@/common/common';
import talkMicrophone from './components/talk-microphone.vue';
import talkSpeaker from './components/talk-speaker.vue';
@@ -40,18 +59,23 @@
const talkSpeakerRef = ref(null);
const talkCameraRef = ref(null);
const { initConnection, close, send, isRecording } = useWebSocket();
const {
initConnection,
close,
send,
isRecording
} = useWebSocket();
const isVideo = ref(false);
const isVideoStyle = computed(() => dataInfo.traInterTyp === '03');
const dataInfo = reactive({
isPreview: '', // 是否是预览
traId: '',
chaId: '',
traType: '',
traInterTyp: '',
execId: '',
sceneDesc: '',
isPreview: '', // 是否是预览
traInterTypDesc: '', // 类型的文字提示,例如 语音通话
ossAddr: '', //用户头像
chaName: '' //用户名称
@@ -86,20 +110,19 @@
if (type <= 2) {
nextTick(() => {
setTimeout(() => {
if(dataInfo.execId) {
if (dataInfo.execId) {
common.redirectTo(
'/pages/sparring/result?isOver=1&traId=' +
dataInfo.traId +
'&execId=' +
dataInfo.execId +
'&type=' +
dataInfo.traType +
'&isPreview=' +dataInfo.isPreview
dataInfo.traId +
'&execId=' +
dataInfo.execId +
'&type=' +
dataInfo.traType +
'&isPreview=' + dataInfo.isPreview
);
} else {
common.navigateBack()
}
}, 300);
});
}
@@ -157,7 +180,10 @@
frameSize: 1024,
gain: 1.0,
// 音频数据的帧接口回调,直接转码后接入到websocket的发送函数
onFrameRecorded: ({ isLastFrame, frameBuffer }) => send(ProtocolCodec.pack(MessageType.AUDIO_DATA, frameBuffer))
onFrameRecorded: ({
isLastFrame,
frameBuffer
}) => send(ProtocolCodec.pack(MessageType.AUDIO_DATA, frameBuffer))
});
};
const playOver = (id) => {
@@ -199,7 +225,9 @@
// onError({code:1001}); //处理逻辑和报错一样,直接调用报错方法
} else if (error?.code === 1011) {
// 服务器错误
onError({ code: 1011 }); //处理逻辑和报错一样,直接调用报错方法
onError({
code: 1011
}); //处理逻辑和报错一样,直接调用报错方法
} else if (error?.code === 1000) {
// 用户主动挂断
} else if (error?.code === 4001) {
@@ -212,11 +240,13 @@
dataInfo.chaId = e.chaId ?? '';
dataInfo.traType = '02'; // 陪练类型 01-练习 02-考试
dataInfo.traInterTyp = e.traInterTyp ?? '02'; // 陪练交互类型 01 对话 02 语音 03 视频
// dataInfo.traInterType = '02'; // 陪练交互类型 01 对话 02 语音 03 视频
//#ifdef APP-PLUS
// 只有app才能打开摄像头
isVideo.value = dataInfo.traInterTyp === '03';
//#endif
dataInfo.isPreview = e.isPreview || ''; // 是否是预览
console.log('isVideo.value', isVideo.value);
dataInfo.isPreview = e.isPreview ?? '0'; // 是否是预览
const pageData = common.getPageCache('tipMsgsceneDesc');
dataInfo.ossAddr = pageData.ossAddr;
dataInfo.chaName = pageData.chaName;
@@ -224,7 +254,13 @@
});
onMounted(() => {
initConnection({
authParams: Object.assign({}, dataInfo),
authParams: {
'traType': dataInfo.traType,
'traInterTyp': dataInfo.traInterTyp,
'traId': dataInfo.traId,
'chaId': dataInfo.chaId,
'preview': true,
},
onStartRecord: onStartRecord,
playPcmCallback: (res) => talkSpeakerRef.value.playPCM(res),
setPlayNumber: (id) => talkSpeakerRef.value.setPlayNumber(id),
@@ -250,17 +286,17 @@
<style scoped lang="scss">
.isVideo {
// background-color: red;
.role-info {
display: none;
}
&.show-box {
background: linear-gradient(
120deg,
rgba(51, 51, 51, 0.2) 0%,
rgba(102, 102, 102, 0.2) 50%,
rgba(51, 51, 51, 0.2) 100%
);
background: linear-gradient(120deg,
rgba(51, 51, 51, 0.2) 0%,
rgba(102, 102, 102, 0.2) 50%,
rgba(51, 51, 51, 0.2) 100%);
backdrop-filter: blur(0px);
}
}
@@ -273,6 +309,7 @@
font-size: 38rpx;
margin: 0 auto;
}
.role-name {
margin-bottom: 26rpx;
// position: relative;
@@ -286,24 +323,30 @@
.title-tip {
padding-right: 20rpx;
position: relative;
&::after {
content: '';
position: absolute;
animation: loading 2.5s infinite;
}
@keyframes loading {
0% {
content: '';
}
25% {
content: '.';
}
50% {
content: '..';
}
75% {
content: '...';
}
100% {
content: '';
}
@@ -323,8 +366,10 @@
font-size: 28rpx;
color: #ffffff;
}
.switch {
transform: scale(0.7) rotate(180deg);
:deep(.uni-switch-input) {
&.uni-switch-input-checked {
border-color: #9eacbf !important;
@@ -337,10 +382,12 @@
width: 20px;
height: 20px;
}
&:before {
background-color: #62a1ff !important;
border-color: #62a1ff !important;
}
&:not(.uni-switch-input-checked) {
background-color: #62a1ff !important;
border-color: #62a1ff !important;
@@ -348,10 +395,12 @@
}
}
}
.fl1-div-1 {
min-height: 120rpx;
max-height: 240rpx;
}
.show-box {
background: linear-gradient(120deg, #333333cc 0%, #666666cc 50%, #333333cc 100%);
backdrop-filter: blur(10px);
@@ -402,6 +451,7 @@
border-radius: 16rpx;
opacity: 0;
transition: opacity 0.5s ease;
&.show {
opacity: 1;
}
@@ -419,4 +469,4 @@
margin-bottom: 112rpx;
flex-shrink: 0;
}
</style>
</style>