From d3c60e18b95b50751f8088fa2d23cd8ff7f173bc Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期三, 01 七月 2026 11:05:17 +0800
Subject: [PATCH] 测试完成
---
src/components/CallButton/index.vue | 36 +++++++++++++++++++++++++++---------
1 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/src/components/CallButton/index.vue b/src/components/CallButton/index.vue
index d95fb2f..83186de 100644
--- a/src/components/CallButton/index.vue
+++ b/src/components/CallButton/index.vue
@@ -162,7 +162,10 @@
// 澶勭悊鍚勭鐘舵��
if (status.type === "registered") {
this.handleRegistered();
- } else if (status.type === "failed" || status.type === "disconnected") {
+ } else if (
+ status.type === "failed" ||
+ status.type === "disconnected"
+ ) {
this.handleDisconnected();
} else if (status.type === "connecting") {
this.handleConnecting();
@@ -172,7 +175,8 @@
// 鐩戝惉閫氳瘽鐘舵�佸彉鍖�
sipService.onCallStatusChange = (status) => {
this.callStatus = status.type;
- this.isCalling = status.type === "calling" || status.type === "connected";
+ this.isCalling =
+ status.type === "calling" || status.type === "connected";
this.updateLastActivityTime(); // 閫氳瘽鐘舵�佸彉鍖栨椂鏇存柊娲诲姩鏃堕棿
this.$emit("call-status-change", status);
@@ -180,7 +184,6 @@
// 璁剧疆瓒呮椂澶勭悊
this.setupRegistrationTimeout();
-
} catch (error) {
console.error("SIP鏈嶅姟鍒濆鍖栧け璐�:", error);
this.handleDisconnected();
@@ -272,7 +275,10 @@
}
this.reconnectCount++;
- const delay = Math.min(this.reconnectDelay * Math.pow(1.5, this.reconnectCount - 1), 30000);
+ const delay = Math.min(
+ this.reconnectDelay * Math.pow(1.5, this.reconnectCount - 1),
+ 30000
+ );
console.log(`璁″垝鍦�${delay}ms鍚庨噸杩烇紝绗�${this.reconnectCount}娆″皾璇昤);
@@ -295,12 +301,11 @@
this.cleanupSipConnection();
// 绛夊緟涓�娈垫椂闂�
- await new Promise(resolve => setTimeout(resolve, 1000));
+ await new Promise((resolve) => setTimeout(resolve, 1000));
// 閲嶆柊鍒濆鍖�
await this.CallgetList(); // 閲嶆柊鑾峰彇鍒嗘満鍙�
this.initSipService();
-
} catch (error) {
console.error("閲嶈繛澶辫触:", error);
this.isReconnecting = false;
@@ -338,7 +343,7 @@
async startCall() {
if (!this.phoneNumber) {
- this.$message.error("璇疯緭鍏ョ數璇濆彿鐮�");
+ this.$message.warning("璇疯緭鍏ョ數璇濆彿鐮�");
return;
}
@@ -357,6 +362,15 @@
} catch (error) {
console.error("鍛煎彨澶辫触1:", error);
+ if (
+ error.message.includes("Canceled") ||
+ error.message.includes("鏈敞鍐�")
+ ) {
+ console.warn("鍛煎彨鍥犻〉闈㈢寮�鎴栨湭娉ㄥ唽鑰屽彇娑堬紝涓嶉噸璇�");
+ this.callStatus = "ended";
+ this.isCalling = false;
+ return;
+ }
try {
// 灏濊瘯鍔�0鍐嶆鍛煎彨
const { canCall, reason } = sipService.canMakeCall();
@@ -371,7 +385,7 @@
} catch (error) {
this.callStatus = "ended";
this.isCalling = false;
- this.$message.error("鍛煎彨澶辫触锛岃妫�鏌ョ綉缁滄垨鍙风爜");
+ this.$message.warning("褰撳墠鍛煎彨鍗犵嚎涓紝璇风◢鍚庡啀鎷�");
}
}
},
@@ -451,7 +465,11 @@
},
},
beforeUnmount() {
- this.cleanupResources();
+ if (this.isCalling) {
+ this.endCall(); // 鍐呴儴璁剧疆浜� isManualEnd
+ }
+ // 鍏朵粬娓呯悊锛堝瀹氭椂鍣級...
+ this.cleanupResources(); // 浣嗘敞鎰忎笉瑕侀噸澶嶆竻鐞嗗畾鏃跺櫒锛屽彲浼樺寲鍒ゆ柇
},
};
</script>
--
Gitblit v1.9.3