mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-09 09:46:55 +08:00
perf: Optimize embedded compatibility for multi-domain verification
This commit is contained in:
committed by
fit2cloud-chenyw
parent
e881b3ef47
commit
0e418d2ee8
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user