From a53d6201839688bfe259702e191f34314d06133c Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期六, 12 四月 2025 18:00:19 +0800
Subject: [PATCH] 关闭数字人

---
 src/components/chat/components/playBar/hook/useDigitalHuman.ts |   29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/src/components/chat/components/playBar/hook/useDigitalHuman.ts b/src/components/chat/components/playBar/hook/useDigitalHuman.ts
index 955c021..680fdfd 100644
--- a/src/components/chat/components/playBar/hook/useDigitalHuman.ts
+++ b/src/components/chat/components/playBar/hook/useDigitalHuman.ts
@@ -93,13 +93,34 @@
 
 	const speakContent = (content: string) => {
 		// 鎵撴柇涔嬪墠鐨勫凡鏀跺埌xxx
-		duix.break();
+		duix?.break();
 		isWaitingSpeak = false;
-		duix.speak({
+		duix?.speak({
 			content,
 		});
 	};
+	const closeOtherDigitalHuman = async () => {
+		const response = await fetch(`https://duix.guiji.ai/duix-openapi-v2/v1/distroyCallSessionsByAppId?appId=${duixConfig.appId}`, {
+			method: 'GET',
+			headers: {
+				priority: 'u=1, i',
+				sig: duixConfig.sign,
+			},
+		});
 
+		const data = await response.json();
+		// const total = data.data.totalConcurrentNumber;
+		// const user = data.data.userConcurrentNumber;
+
+		// if (total === null || total === 0) {
+		// 	return false;
+		// }
+		// if (total !== null && total === user) {
+		// 	return false;
+		// }
+
+		// return true;
+	};
 	const startDuix = () => {
 		const conversationId = duixConfig.conversationId; // duix骞冲彴浼氳瘽id
 
@@ -212,8 +233,8 @@
 		duixConfig.sign = await createSig(duixConfig.appId, duixConfig.appKey, 60 * 60 * duixConfig.expired);
 		const isUsable = await checkIsUseable();
 		if (!isUsable) {
-			ElMessage.warning('"璧勬簮鍗犵敤涓紝璇锋鏌ュ悗鍐嶈瘯~"');
-			return;
+			await closeOtherDigitalHuman();
+			// ElMessage.warning('"璧勬簮鍗犵敤涓紝璇锋鏌ュ悗鍐嶈瘯~"');
 		}
 		digitalHumanIsShow.value = true;
 

--
Gitblit v1.9.3