From b5a7159dba022f815303a5b8f86c26a6be02a523 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Fri, 29 Aug 2025 16:06:33 +0800 Subject: [PATCH] perf: Page Embedding Logic Optimization --- frontend/src/stores/assistant.ts | 12 ++++++++++-- frontend/src/views/chat/index.vue | 18 +++++++++++------- frontend/src/views/embedded/page.vue | 23 ++++++++++++++++++++--- 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/frontend/src/stores/assistant.ts b/frontend/src/stores/assistant.ts index b85c5fed..d6eeb2f1 100644 --- a/frontend/src/stores/assistant.ts +++ b/frontend/src/stores/assistant.ts @@ -19,6 +19,7 @@ interface AssistantState { type: number certificate: string online: boolean + pageEmbedded?: boolean requestPromiseMap: Map } @@ -32,6 +33,7 @@ export const AssistantStore = defineStore('assistant', { type: 0, certificate: '', online: false, + pageEmbedded: false, requestPromiseMap: new Map(), } }, @@ -57,13 +59,16 @@ export const AssistantStore = defineStore('assistant', { getOnline(): boolean { return this.online }, + getPageEmbedded(): boolean { + return this.pageEmbedded || false + }, getEmbedded(): boolean { return this.assistant && this.type === 4 }, }, actions: { refreshCertificate() { - const timeout = 5000 + const timeout = 30000 return new Promise((resolve, reject) => { const timeoutId = setTimeout(() => { this.requestPromiseMap.delete(this.id) @@ -82,7 +87,7 @@ export const AssistantStore = defineStore('assistant', { }, }) const readyData = { - eventName: 'sqlbot_assistant_event', + eventName: this.pageEmbedded ? 'sqlbot_embedded_event' : 'sqlbot_assistant_event', busi: 'ready', ready: true, messageId: this.id, @@ -119,6 +124,9 @@ export const AssistantStore = defineStore('assistant', { wsCache.set(flagKey, flag) } }, + setPageEmbedded(embedded?: boolean) { + this.pageEmbedded = !!embedded + }, setOnline(online: boolean) { this.online = !!online }, diff --git a/frontend/src/views/chat/index.vue b/frontend/src/views/chat/index.vue index c92a521f..b12fccbe 100644 --- a/frontend/src/views/chat/index.vue +++ b/frontend/src/views/chat/index.vue @@ -1,6 +1,9 @@