perf: Optimize embedded compatibility for multi-domain verification

This commit is contained in:
fit2cloud-chenyw
2025-11-26 13:29:26 +08:00
committed by fit2cloud-chenyw
parent e881b3ef47
commit 0e418d2ee8
7 changed files with 29 additions and 9 deletions
+8
View File
@@ -21,6 +21,7 @@ interface AssistantState {
online: boolean
pageEmbedded?: boolean
history: boolean
hostOrigin: string
requestPromiseMap: Map<string, PendingRequest>
}
@@ -36,6 +37,7 @@ export const AssistantStore = defineStore('assistant', {
online: false,
pageEmbedded: false,
history: true,
hostOrigin: '',
requestPromiseMap: new Map<string, PendingRequest>(),
}
},
@@ -70,6 +72,9 @@ export const AssistantStore = defineStore('assistant', {
getEmbedded(): boolean {
return this.assistant && this.type === 4
},
getHostOrigin(): string {
return this.hostOrigin
},
},
actions: {
refreshCertificate<T>() {
@@ -138,6 +143,9 @@ export const AssistantStore = defineStore('assistant', {
setHistory(history: boolean) {
this.history = history ?? true
},
setHostOrigin(origin: string) {
this.hostOrigin = origin
},
async setChat() {
if (!this.assistant) {
return null
+6
View File
@@ -100,6 +100,9 @@ class HttpService {
if (!assistantStore.getType || assistantStore.getType === 2) {
config.headers['X-SQLBOT-ASSISTANT-ONLINE'] = assistantStore.getOnline
}
if (assistantStore.getHostOrigin) {
config.headers['X-SQLBOT-HOST-ORIGIN'] = assistantStore.getHostOrigin
}
}
const locale = getLocale()
if (locale) {
@@ -302,6 +305,9 @@ class HttpService {
encodeURIComponent(assistantStore.getCertificate)
)
}
if (assistantStore.getHostOrigin) {
heads['X-SQLBOT-HOST-ORIGIN'] = assistantStore.getHostOrigin
}
if (!assistantStore.getType || assistantStore.getType === 2) {
heads['X-SQLBOT-ASSISTANT-ONLINE'] = assistantStore.getOnline
}
+3
View File
@@ -76,6 +76,9 @@ const communicationCb = async (event: any) => {
assistantStore.setCertificate(certificate)
assistantStore.resolveCertificate(certificate)
}
if (event.data?.hostOrigin) {
assistantStore.setHostOrigin(event.data?.hostOrigin)
}
if (event.data?.busi == 'setOnline') {
setFormatOnline(event.data.online)
}
+3
View File
@@ -66,6 +66,9 @@ const communicationCb = async (event: any) => {
assistantStore.setCertificate(certificate)
assistantStore.resolveCertificate(certificate)
}
if (event.data?.hostOrigin) {
assistantStore.setHostOrigin(event.data?.hostOrigin)
}
if (event.data?.busi == 'setOnline') {
setFormatOnline(event.data.online)
}