From 7485678a97e852f03f74bf23b2c09bc7c78a44e6 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Sun, 27 Jul 2025 15:24:26 +0800 Subject: [PATCH] perf: Assistant dynamic load --- frontend/src/i18n/zh-CN.json | 3 +- frontend/src/views/system/embedded/index.vue | 33 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/frontend/src/i18n/zh-CN.json b/frontend/src/i18n/zh-CN.json index a68fe338..75c246bc 100644 --- a/frontend/src/i18n/zh-CN.json +++ b/frontend/src/i18n/zh-CN.json @@ -31,7 +31,8 @@ "re_upload": "重新上传", "not_exceed_50mb": "支持 XLS、XLSX、CSV 格式,文件大小不超过 50MB", "reset_password": "重置密码", - "password_reset_successful": "重置密码成功" + "password_reset_successful": "重置密码成功", + "or": "或者" }, "dashboard": { "add_success": "添加成功", diff --git a/frontend/src/views/system/embedded/index.vue b/frontend/src/views/system/embedded/index.vue index 20a3369d..bee5e1c1 100644 --- a/frontend/src/views/system/embedded/index.vue +++ b/frontend/src/views/system/embedded/index.vue @@ -353,6 +353,7 @@ const btnSelect = ref('d') const dialogVisible = ref(false) const scriptElement = ref('') +const jsCodeElement = ref('') const handleEmbedded = (row: any) => { dialogVisible.value = true const { origin, pathname } = window.location @@ -363,6 +364,25 @@ const handleEmbedded = (row: any) => { src="${origin + pathname}assistant.js?id=${row.id}"k-*g-#/scriptk-*` .replaceAll('g-#', '<') .replaceAll('k-*', '>') + + jsCodeElement.value = `(function(){ + const script = document.createElement('script'); + script.defer = true; + script.async = true; + script.src = "${origin + pathname}assistant.js?id=${row.id}"; + script.id = "sqlbot-assistant-float-script-${row.id}"; + document.head.appendChild(script); + })()` +} +const copyJsCode = () => { + navigator.clipboard + .writeText(jsCodeElement.value) + .then(function () { + ElMessage.success(t('embedded.copy_successful')) + }) + .catch(function () { + ElMessage.error(t('embedded.copy_successful')) + }) } const copyCode = () => { navigator.clipboard @@ -774,6 +794,19 @@ const saveHandler = () => { {{ scriptElement }} + +
+
+ {{ $t('common.or') }} + + + +
+ +
+ {{ jsCodeElement }} +
+