From b9d28bd6af15026741099c25a6e72fe947ad3772 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期四, 10 四月 2025 17:31:50 +0800
Subject: [PATCH] 修改数字人对话

---
 src/components/amis/AMISRenderer.vue |   28 ++++++++++++++++++++++++----
 1 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/src/components/amis/AMISRenderer.vue b/src/components/amis/AMISRenderer.vue
index c49e02c..fc4a5a2 100644
--- a/src/components/amis/AMISRenderer.vue
+++ b/src/components/amis/AMISRenderer.vue
@@ -12,6 +12,8 @@
 import { NO_AUTH_API_LIST } from '/@/api/ai/chat';
 import { LOGIN_URL, TEL_LOGIN_URL } from '/@/api/ai/user';
 import { Local } from '/@/utils/storage';
+import { isSharePage } from '/@/stores/chatRoom';
+
 const amisRootRef = ref<HTMLDivElement>(null);
 
 const props = defineProps({
@@ -26,7 +28,7 @@
 		type: Object,
 		default: () => ({}),
 	},
-	context:{
+	context: {
 		type: Object,
 		default: () => ({}),
 	},
@@ -41,8 +43,27 @@
 });
 
 const emit = defineEmits(['ready']);
-
+function insertScript(src, callback) {
+	const script = document.createElement('script');
+	script.setAttribute('type', 'text/javascript');
+	script.setAttribute('src', src);
+	script.async = true;
+	script.onload = () => callback();
+	script.onerror = () => callback(new Error(`Failed to load ${src}`));
+	document.head.appendChild(script);
+}
 function loadScript(callback) {
+	if (!window.eventList.amisSdkJsPromise) {
+		window.eventList.amisSdkJsPromise = new Promise((resolve, reject) => {
+			insertScript('/static/amis/sdk/sdk.js', (error) => {
+				if (error) {
+					reject(error);
+					return;
+				}
+				resolve();
+			});
+		});
+	}
 	window.eventList.amisSdkJsPromise
 		.then(() => {
 			callback();
@@ -70,7 +91,6 @@
 		});
 	});
 }
-
 
 const current = router.currentRoute.value;
 
@@ -144,7 +164,7 @@
 				// api.context 涓寘鍚彂閫佽姹傚墠鐨勪笂涓嬫枃淇℃伅
 				// 鑾峰彇鏈湴鐨� token
 				const accessSession = Local.get(accessSessionKey);
-				if (!NO_AUTH_API_LIST.includes(api.url)) {
+				if (!NO_AUTH_API_LIST.includes(api.url) && !isSharePage.value) {
 					if (accessSession) {
 						// 灏� token 娣诲姞鍒拌姹傛姤鏂囧ご涓�
 						api.headers['hswatersession'] = accessSession;

--
Gitblit v1.9.3