From 2cd1e4f857af3159a894712641cbd3840add0df3 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期四, 03 四月 2025 16:06:19 +0800
Subject: [PATCH] cancelRecording

---
 src/components/amis/AMISRenderer.vue |   40 +++++++++++++++++++++++++++++++---------
 1 files changed, 31 insertions(+), 9 deletions(-)

diff --git a/src/components/amis/AMISRenderer.vue b/src/components/amis/AMISRenderer.vue
index ff4199b..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,6 +28,10 @@
 		type: Object,
 		default: () => ({}),
 	},
+	context: {
+		type: Object,
+		default: () => ({}),
+	},
 	props: {
 		type: Object,
 		default: () => ({}),
@@ -37,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();
@@ -67,9 +92,6 @@
 	});
 }
 
-const context = reactive({
-	siteName: 'AMIS DEMO',
-});
 const current = router.currentRoute.value;
 
 const location = {
@@ -86,9 +108,9 @@
 const updateProps = () => {
 	amisInstance.value?.updateProps({
 		data: {
-			...props.locals,
+			// ...props.locals,
 		},
-		context: context,
+		context: props.context,
 		...props.props,
 	});
 };
@@ -127,9 +149,9 @@
 		props.schema,
 		{
 			data: {
-				...props.locals,
+				// ...props.locals,
 			},
-			context: context,
+			context: props.context,
 			location: location,
 
 			// todo 涓嬪彂 location 瀵硅薄
@@ -142,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