目前对方可以接收到通话申请了(接电话有通话中判断错误导致重复send-to-user路由的问题)
This commit is contained in:
@@ -13,6 +13,17 @@
|
||||
<!-- 录音状态指示器 -->
|
||||
<RecordingIndicator />
|
||||
|
||||
<!-- 视频通话组件(移动到此处) -->
|
||||
<VideoCallComponent
|
||||
v-if="showVideoCall"
|
||||
:caller-info="callerInfo"
|
||||
:call-type="callType"
|
||||
:is-incoming="isIncoming"
|
||||
@accept-call="handleAcceptCall"
|
||||
@reject-call="handleRejectCall"
|
||||
@end-call="handleEndCall"
|
||||
/>
|
||||
|
||||
<!-- 主聊天容器 -->
|
||||
<div class="flex-1 max-w-7xl mx-auto bg-white/90 backdrop-blur-sm rounded-2xl shadow-2xl overflow-hidden flex z-10">
|
||||
<!-- 侧边导航 -->
|
||||
@@ -39,7 +50,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, onUnmounted, provide } from 'vue';
|
||||
import {onMounted, onUnmounted, ref, watch} from 'vue';
|
||||
import { useUserStore } from '@/stores/user';
|
||||
import { useChatStore } from '@/stores/chat';
|
||||
import { useThemeStore } from '@/stores/theme';
|
||||
@@ -55,6 +66,7 @@ import MediaPreview from '@/components/MediaPreview.vue';
|
||||
import FriendsManagement from '@/components/FriendsManagement.vue';
|
||||
import GroupsManagement from '@/components/GroupsManagement.vue';
|
||||
import MomentsView from '@/components/MomentsView.vue';
|
||||
import VideoCallComponent from '@/components/VideoCallComponent.vue';
|
||||
|
||||
const userStore = useUserStore();
|
||||
const chatStore = useChatStore();
|
||||
@@ -62,23 +74,62 @@ const themeStore = useThemeStore();
|
||||
|
||||
const currentNav = ref('chat');
|
||||
|
||||
// 视频通话相关状态
|
||||
const showVideoCall = ref(false);
|
||||
const callType = ref('video');
|
||||
const isIncoming = ref(false);
|
||||
const callerInfo = ref(null);
|
||||
|
||||
// 初始化WebSocket连接
|
||||
const { connectWebSocket, disconnectWebSocket } = useWebSocket();
|
||||
|
||||
// 初始化录音功能
|
||||
const { isRecording } = useRecording();
|
||||
|
||||
// 提供录音状态给子组件
|
||||
provide('isRecording', isRecording);
|
||||
|
||||
// 处理导航切换
|
||||
const handleNavChange = (nav) => {
|
||||
currentNav.value = nav;
|
||||
};
|
||||
|
||||
// 检查用户会话
|
||||
userStore.checkSession();
|
||||
// 监听通话状态变化
|
||||
watch(() => chatStore.callStatus, (status) => {
|
||||
showVideoCall.value = status !== 'idle';
|
||||
});
|
||||
|
||||
// 监听来电
|
||||
watch(() => chatStore.incomingCall, (call) => {
|
||||
if (call) {
|
||||
isIncoming.value = true;
|
||||
callerInfo.value = chatStore.friends.find(f => f.id === call.callerId);
|
||||
callType.value = call.callType;
|
||||
} else {
|
||||
isIncoming.value = false;
|
||||
}
|
||||
});
|
||||
|
||||
// 监听当前通话
|
||||
watch(() => chatStore.currentCall, (call) => {
|
||||
if (call) {
|
||||
callerInfo.value = chatStore.friends.find(f => f.id === call.peerId);
|
||||
callType.value = call.callType;
|
||||
isIncoming.value = false;
|
||||
}
|
||||
});
|
||||
|
||||
// 处理接听通话
|
||||
const handleAcceptCall = () => {
|
||||
chatStore.acceptCall();
|
||||
};
|
||||
|
||||
// 处理拒绝通话
|
||||
const handleRejectCall = () => {
|
||||
chatStore.rejectCall();
|
||||
};
|
||||
|
||||
// 处理结束通话
|
||||
const handleEndCall = () => {
|
||||
chatStore.endCall();
|
||||
};
|
||||
// 加载主题
|
||||
themeStore.loadTheme();
|
||||
|
||||
@@ -130,4 +181,4 @@ onUnmounted(() => {
|
||||
.animate-float-slow {
|
||||
animation: float-slow 18s infinite ease-in-out;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
Reference in New Issue
Block a user