Skip to content

Commit 814dbc3

Browse files
style: Page Embedding Style Optimization
1 parent 7c84845 commit 814dbc3

File tree

2 files changed

+46
-20
lines changed

2 files changed

+46
-20
lines changed

frontend/src/embedded.ts

Lines changed: 0 additions & 17 deletions
This file was deleted.

frontend/src/views/embedded/page.vue

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,39 @@
11
<template>
22
<div class="sqlbot--embedded-page">
3-
<chat-component v-if="!loading" ref="chatRef" />
3+
<chat-component
4+
v-if="!loading"
5+
ref="chatRef"
6+
:welcome="customSet.welcome"
7+
:welcome-desc="customSet.welcome_desc"
8+
:logo-assistant="logo"
9+
/>
410
</div>
511
</template>
612
<script setup lang="ts">
713
import ChatComponent from '@/views/chat/index.vue'
8-
import { onBeforeMount, onBeforeUnmount, ref } from 'vue'
14+
import { nextTick, onBeforeMount, onBeforeUnmount, reactive, ref } from 'vue'
915
import { useRoute } from 'vue-router'
1016
import { assistantApi } from '@/api/assistant'
1117
import { useAssistantStore } from '@/stores/assistant'
18+
import { useI18n } from 'vue-i18n'
19+
import { request } from '@/utils/request'
20+
import { setCurrentColor } from '@/utils/utils'
1221
22+
const { t } = useI18n()
1323
const chatRef = ref()
1424
const assistantStore = useAssistantStore()
1525
const route = useRoute()
1626
const assistantName = ref('')
17-
27+
const customSet = reactive({
28+
name: '',
29+
welcome: t('embedded.i_am_sqlbot'),
30+
welcome_desc: t('embedded.data_analysis_now'),
31+
theme: '#1CBA90',
32+
header_font_color: '#1F2329',
33+
}) as { [key: string]: any }
34+
const logo = ref()
35+
const basePath = import.meta.env.VITE_API_BASE_URL
36+
const baseUrl = basePath + '/system/assistant/picture/'
1837
const validator = ref({
1938
id: '',
2039
valid: false,
@@ -73,6 +92,11 @@ const registerReady = (assistantId: any) => {
7392
window.parent.postMessage(readyData, '*')
7493
}
7594
95+
const setPageCustomColor = (val: any) => {
96+
const ele = document.querySelector('.sqlbot--embedded-page') as HTMLElement
97+
setCurrentColor(val, ele)
98+
}
99+
76100
onBeforeMount(async () => {
77101
const assistantId = route.query.id
78102
if (!assistantId) {
@@ -111,6 +135,25 @@ onBeforeMount(async () => {
111135
loading.value = false
112136
113137
registerReady(assistantId)
138+
139+
request.get(`/system/assistant/${assistantId}`).then((res) => {
140+
if (res?.configuration) {
141+
const rawData = JSON.parse(res?.configuration)
142+
if (rawData.logo) {
143+
logo.value = baseUrl + rawData.logo
144+
}
145+
146+
for (const key in customSet) {
147+
if (Object.prototype.hasOwnProperty.call(customSet, key) && rawData[key]) {
148+
customSet[key] = rawData[key]
149+
}
150+
}
151+
152+
nextTick(() => {
153+
setPageCustomColor(customSet.theme)
154+
})
155+
}
156+
})
114157
})
115158
116159
onBeforeUnmount(() => {

0 commit comments

Comments
 (0)