diff --git a/index.html b/index.html
index 8388c4b..b3a8335 100644
--- a/index.html
+++ b/index.html
@@ -4,7 +4,7 @@
-
Vite + Vue
+ 奶酪-即时通讯-demo
diff --git a/src/components/ChatHeader.vue b/src/components/ChatHeader.vue
index 6769a34..da267eb 100644
--- a/src/components/ChatHeader.vue
+++ b/src/components/ChatHeader.vue
@@ -19,6 +19,9 @@
{{ isFriendOnline ? '在线' : '离线' }}
+
+ {{ callStatusText }}
+
@@ -64,62 +67,49 @@
-
-
-
\ No newline at end of file
diff --git a/src/components/VideoCallComponent.vue b/src/components/VideoCallComponent.vue
index 91234d3..bac42dc 100644
--- a/src/components/VideoCallComponent.vue
+++ b/src/components/VideoCallComponent.vue
@@ -22,7 +22,7 @@
{{ callerInfo.name }}
-
{{ callStatus }} {{ formattedDuration }}
+
{{ connectionText }}
@@ -120,12 +120,18 @@
-
-
+
+
+ 对方忙线中
+
+
+
+
+
@@ -205,7 +211,6 @@ const isCameraOn = ref(props.callType === 'video');
const isSpeakerOn = ref(true);
const hasLocalVideo = ref(false);
const hasRemoteVideo = ref(false);
-const connectionText = ref('正在连接...');
const callDuration = ref(0);
const callTimer = ref(null);
const isCameraWorking = ref(true);
@@ -223,6 +228,35 @@ const localVideo = ref(null);
const remoteVideo = ref(null);
const remoteVideoPreview = ref(null);
+// 获取当前通话状态
+const callStatus = computed(() => {
+ return chatStore.callError;
+});
+
+// 连接状态文本
+const connectionText = computed(() => {
+ // 优先使用 chatStore 中的详细状态
+ if (chatStore.callConnectionStatus) {
+ return chatStore.callConnectionStatus;
+ }
+
+ // 处理忙线状态
+ if (chatStore.callError === 'busy') {
+ return '对方忙线中';
+ }
+
+ // 默认状态显示
+ if (props.isIncoming && !isOngoing.value) {
+ return '来电中...';
+ }
+
+ if (isOngoing.value) {
+ return `通话中 ${formattedDuration.value}`;
+ }
+
+ return '正在连接...';
+});
+
// 通话计时器
const startCallTimer = () => {
if (callTimer.value) clearInterval(callTimer.value);
@@ -248,14 +282,6 @@ const containerStyle = computed(() => {
};
});
-// 通话状态
-const callStatus = computed(() => {
- if (props.isIncoming && !isOngoing.value) {
- return '来电中...';
- }
- return '通话中';
-});
-
// 初始化媒体设备
const initializeMedia = async () => {
try {
@@ -267,13 +293,11 @@ const initializeMedia = async () => {
// 获取本地媒体流
await webrtc.getLocalMedia(constraints);
- connectionText.value = '已连接';
startCallTimer();
} catch (error) {
console.error('无法访问媒体设备:', error);
isCameraOn.value = false;
isCameraWorking.value = false;
- connectionText.value = '连接失败';
}
};
@@ -331,7 +355,6 @@ const endCall = () => {
isVisible.value = false;
emit('end-call');
- chatStore.endCall();
};
// 接听通话
@@ -345,7 +368,6 @@ const acceptCall = () => {
const rejectCall = () => {
isVisible.value = false;
emit('reject-call');
- chatStore.rejectCall();
};
// 拖拽功能
@@ -478,7 +500,6 @@ onUnmounted(() => {
+
\ No newline at end of file