|
@@ -8,9 +8,9 @@ import type { type_dyaw_xlfw_zxhd, type_dyaw_xlfw_zxhd_log } from '~/types';
|
|
|
import user, { UserRole } from '~/store/user';
|
|
|
import { socketSend } from '~/utils/ws';
|
|
|
import { formatOffsetSec } from '~/utils/time';
|
|
|
-import { useInterval } from '@vueuse/core'
|
|
|
|
|
|
-let offsetTime: unknown
|
|
|
+let offsetTimer: NodeJS.Timeout
|
|
|
+let offsetTime: number
|
|
|
|
|
|
const emits = defineEmits<{
|
|
|
(event: 'update-info', info: Partial<type_dyaw_xlfw_zxhd_log>, isUpdate?: boolean): void;
|
|
@@ -100,7 +100,9 @@ defineExpose({
|
|
|
if (mode === 'video')
|
|
|
await rtcInstance.client!.publish(rtcInstance.localVideoTrack!);
|
|
|
currentChatStatus = CHAT_STATUS.CHATING
|
|
|
- offsetTime = useInterval(1000, { callback: n => formatOffsetSec(n) })
|
|
|
+ offsetTimer = setInterval(() => {
|
|
|
+ offsetTime = (offsetTime as number + 1)
|
|
|
+ }, 1000)
|
|
|
break;
|
|
|
case CHAT_OPERATION.DENY:
|
|
|
emits('update-info', content.fullSendData!, true)
|
|
@@ -109,6 +111,7 @@ defineExpose({
|
|
|
break;
|
|
|
case CHAT_OPERATION.END:
|
|
|
emits('update-info', content.fullSendData!, true)
|
|
|
+ offsetTimer && clearInterval(offsetTimer)
|
|
|
isOpen = false
|
|
|
await rtcInstance.client!.leave();
|
|
|
break;
|
|
@@ -328,7 +331,9 @@ async function handleAudioChatAccept() {
|
|
|
fullSendData
|
|
|
})
|
|
|
currentChatStatus = CHAT_STATUS.CHATING
|
|
|
- offsetTime = useInterval(1000, { callback: n => formatOffsetSec(n) })
|
|
|
+ offsetTimer = setInterval(() => {
|
|
|
+ offsetTime = (offsetTime as number + 1)
|
|
|
+ }, 1000)
|
|
|
}
|
|
|
async function handleAudioChatDeny() {
|
|
|
const fullSendData = await handleInfoEdit({ dxzl_status: '4' }, '已拒接')
|
|
@@ -342,6 +347,7 @@ async function handleAudioChatDeny() {
|
|
|
}
|
|
|
async function handleAudioChatEnd() {
|
|
|
const fullSendData = await handleInfoEdit({ dxzl_status: '4' }, '已结束')
|
|
|
+ offsetTimer && clearInterval(offsetTimer)
|
|
|
await rtcInstance.client!.leave();
|
|
|
socketSend(ws2, {
|
|
|
dxzl_stu_user_id: dyaw_xlfw_zxhd!.dxz_stu_user_id,
|
|
@@ -372,6 +378,7 @@ function handleSwitchVideo() {
|
|
|
console.error(error);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
@@ -456,7 +463,7 @@ function handleSwitchVideo() {
|
|
|
<div class="text-hex-909090 flex_center flex-col space-y-2 h-16"
|
|
|
v-show="mode === 'audio' && currentChatStatus === CHAT_STATUS.CHATING">
|
|
|
<div>正在通话中</div>
|
|
|
- <div>{{ offsetTime }}</div>
|
|
|
+ <div>{{ formatOffsetSec(offsetTime) }}</div>
|
|
|
</div>
|
|
|
<!-- </div> -->
|
|
|
</div>
|
|
@@ -465,6 +472,3 @@ function handleSwitchVideo() {
|
|
|
</UseDraggable>
|
|
|
</template>
|
|
|
|
|
|
-<style scoped>
|
|
|
-
|
|
|
-</style>
|