From a313d2b6c11b75234d7ad7e9d0963ca17ada5930 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期四, 16 一月 2025 18:07:58 +0800 Subject: [PATCH] Merge branch 'test' of http://47.103.154.90:83/r/WI/Web.V1.0 into test --- 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