Skip to content

Commit 628fc63

Browse files
committed
feat(embedded): Helper embedded display settings
1 parent 2332252 commit 628fc63

File tree

3 files changed

+52
-49
lines changed

3 files changed

+52
-49
lines changed

frontend/src/utils/utils.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,47 +107,50 @@ export const setTitle = (title?: string) => {
107107
document.title = title || 'SQLBot'
108108
}
109109

110-
export const setCurrentColor = (currentColor: any) => {
111-
document.documentElement.style.setProperty('--ed-color-primary', currentColor)
112-
document.documentElement.style.setProperty('--van-blue', currentColor)
113-
document.documentElement.style.setProperty(
110+
export const setCurrentColor = (
111+
currentColor: any,
112+
elemet: HTMLElement = document.documentElement
113+
) => {
114+
elemet.style.setProperty('--ed-color-primary', currentColor)
115+
elemet.style.setProperty('--van-blue', currentColor)
116+
elemet.style.setProperty(
114117
'--ed-color-primary-light-5',
115118
colorFunctions
116119
.mix(new colorTree('ffffff'), new colorTree(currentColor.substr(1)), { value: 40 })
117120
.toRGB()
118121
)
119-
document.documentElement.style.setProperty(
122+
elemet.style.setProperty(
120123
'--ed-color-primary-light-3',
121124
colorFunctions
122125
.mix(new colorTree('ffffff'), new colorTree(currentColor.substr(1)), { value: 15 })
123126
.toRGB()
124127
)
125128

126-
document.documentElement.style.setProperty(
129+
elemet.style.setProperty(
127130
'--ed-color-primary-60',
128131
colorFunctions
129132
.mix(new colorTree('ffffff'), new colorTree(currentColor.substr(1)), { value: 60 })
130133
.toRGB()
131134
)
132135

133-
document.documentElement.style.setProperty(
136+
elemet.style.setProperty(
134137
'--ed-color-primary-80',
135138
colorFunctions
136139
.mix(new colorTree('ffffff'), new colorTree(currentColor.substr(1)), { value: 80 })
137140
.toRGB()
138141
)
139142

140-
document.documentElement.style.setProperty(
143+
elemet.style.setProperty(
141144
'--ed-color-primary-15-d',
142145
colorFunctions
143146
.mix(new colorTree('000000'), new colorTree(currentColor.substr(1)), { value: 15 })
144147
.toRGB()
145148
)
146-
document.documentElement.style.setProperty('--ed-color-primary-1a', `${currentColor}1a`)
147-
document.documentElement.style.setProperty('--ed-color-primary-14', `${currentColor}14`)
148-
document.documentElement.style.setProperty('--ed-color-primary-33', `${currentColor}33`)
149-
document.documentElement.style.setProperty('--ed-color-primary-99', `${currentColor}99`)
150-
document.documentElement.style.setProperty(
149+
elemet.style.setProperty('--ed-color-primary-1a', `${currentColor}1a`)
150+
elemet.style.setProperty('--ed-color-primary-14', `${currentColor}14`)
151+
elemet.style.setProperty('--ed-color-primary-33', `${currentColor}33`)
152+
elemet.style.setProperty('--ed-color-primary-99', `${currentColor}99`)
153+
elemet.style.setProperty(
151154
'--ed-color-primary-dark-2',
152155
colorFunctions
153156
.mix(new colorTree('000000'), new colorTree(currentColor.substr(1)), { value: 15 })

frontend/src/views/embedded/assistant.vue

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
<script lang="ts" setup>
2-
import { ref } from 'vue'
2+
import { ref, computed } from 'vue'
33
import icon_sidebar_outlined from '@/assets/embedded/icon_sidebar_outlined.svg'
44
import icon_new_chat_outlined from '@/assets/embedded/icon_new-chat_outlined.svg'
55
import LOGO from '@/assets/embedded/LOGO.png'
66
import disable_answer from '@/assets/embedded/disable.png'
77
import icon_close_outlined from '@/assets/svg/icon_close_outlined.svg'
88
import icon_magnify_outlined from '@/assets/svg/icon_magnify_outlined.svg'
9-
9+
import { propTypes } from '@/utils/propTypes'
10+
11+
const props = defineProps({
12+
welcomeDesc: propTypes.string.def(''),
13+
logo: propTypes.string.def(''),
14+
welcome: propTypes.string.def(''),
15+
name: propTypes.string.def(''),
16+
})
1017
const textareaVal = ref('')
18+
const basePath = import.meta.env.VITE_API_BASE_URL
19+
const baseUrl = basePath + '/system/assistant/picture/'
20+
21+
const pageLogo = computed(() => {
22+
return !props.logo ? LOGO : props.logo.startsWith('blob') ? props.logo : baseUrl + props.logo
23+
})
1124
</script>
1225

1326
<template>
@@ -16,8 +29,8 @@ const textareaVal = ref('')
1629
<el-icon size="20">
1730
<icon_sidebar_outlined></icon_sidebar_outlined>
1831
</el-icon>
19-
<img :src="LOGO" class="logo" width="30px" height="30px" alt="" />
20-
<span class="tite">{{ $t('embedded.intelligent_customer_service') }}</span>
32+
<img :src="pageLogo" class="logo" width="30px" height="30px" alt="" />
33+
<span class="title">{{ name }}</span>
2134

2235
<el-tooltip effect="dark" :content="$t('embedded.new_conversation')" placement="top">
2336
<el-icon class="new-chat" size="20">
@@ -34,10 +47,9 @@ const textareaVal = ref('')
3447
</el-icon>
3548
</div>
3649
<div class="center">
37-
<img :src="LOGO" class="logo" width="30px" height="30px" alt="" />
38-
<div class="i-am">{{ $t('embedded.i_am_sqlbot') }}</div>
39-
<div class="i-can">{{ $t('embedded.predict_data_etc') }}</div>
40-
<div class="data-query">{{ $t('embedded.intelligent_data_query') }}</div>
50+
<img :src="pageLogo" class="logo" width="30px" height="30px" alt="" />
51+
<div class="i-am">{{ welcome }}</div>
52+
<div class="i-can">{{ welcomeDesc }}</div>
4153
</div>
4254
<div class="content">
4355
<div class="textarea-send">
@@ -95,6 +107,7 @@ const textareaVal = ref('')
95107
font-weight: 500;
96108
font-size: 16px;
97109
line-height: 24px;
110+
color: var(--ed-text-color-primary);
98111
}
99112
100113
.ed-icon {
@@ -146,13 +159,11 @@ const textareaVal = ref('')
146159
147160
.i-can {
148161
margin-bottom: 4px;
149-
}
150-
151-
.data-query,
152-
.i-can {
162+
max-width: 350px;
163+
text-align: center;
153164
font-weight: 400;
154165
font-size: 14px;
155-
line-height: 22px;
166+
line-height: 24px;
156167
color: #646a73;
157168
}
158169
}

frontend/src/views/system/embedded/SetUi.vue

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import { ref, unref, reactive, nextTick } from 'vue'
44
import { type UploadUserFile, ElMessage } from 'element-plus-secondary'
55
import { useI18n } from 'vue-i18n'
66
import { request } from '@/utils/request'
7+
import { setCurrentColor } from '@/utils/utils'
78
import { useAppearanceStoreWithOut } from '@/stores/appearance'
8-
import colorFunctions from 'less/lib/less/functions/color.js'
9-
import colorTree from 'less/lib/less/tree/color.js'
109
import { cloneDeep } from 'lodash-es'
1110
1211
const appearanceStore = useAppearanceStoreWithOut()
@@ -145,26 +144,8 @@ const customColorChange = (val: any) => {
145144
}
146145
147146
const setPageCustomColor = (val: any) => {
148-
const ele = document.getElementsByClassName('ui-main')[0] as HTMLElement
149-
150-
ele.style.setProperty('--ed-color-primary', val)
151-
ele.style.setProperty('--van-blue', val)
152-
ele.style.setProperty(
153-
'--ed-color-primary-light-5',
154-
colorFunctions.mix(new colorTree('ffffff'), new colorTree(val.substr(1)), { value: 40 }).toRGB()
155-
)
156-
ele.style.setProperty(
157-
'--ed-color-primary-light-3',
158-
colorFunctions.mix(new colorTree('ffffff'), new colorTree(val.substr(1)), { value: 15 }).toRGB()
159-
)
160-
ele.style.setProperty('--ed-color-primary-1a', `${val}1a`)
161-
ele.style.setProperty('--ed-color-primary-14', `${val}14`)
162-
ele.style.setProperty('--ed-color-primary-33', `${val}33`)
163-
ele.style.setProperty('--ed-color-primary-99', `${val}99`)
164-
ele.style.setProperty(
165-
'--ed-color-primary-dark-2',
166-
colorFunctions.mix(new colorTree('000000'), new colorTree(val.substr(1)), { value: 15 }).toRGB()
167-
)
147+
const ele = document.querySelector('.ui-main') as HTMLElement
148+
setCurrentColor(val, ele)
168149
}
169150
170151
const setPageHeaderFontColor = (val: any) => {
@@ -224,6 +205,9 @@ const open = (row: any) => {
224205
// rawData = JSON.parse(row.configuration)
225206
// init()
226207
dialogVisible.value = true
208+
nextTick(() => {
209+
setPageCustomColor('#1CBA90')
210+
})
227211
}
228212
defineExpose({
229213
open,
@@ -239,7 +223,12 @@ defineExpose({
239223
>
240224
<div class="ui-main">
241225
<div class="left-preview">
242-
<assistant></assistant>
226+
<assistant
227+
:welcome-desc="sqlBotForm.welcome_desc"
228+
:welcome="sqlBotForm.welcome"
229+
:name="sqlBotForm.name"
230+
:logo="logo"
231+
></assistant>
243232
</div>
244233
<div class="right-form">
245234
<div style="display: flex; align-items: center; justify-content: space-between">

0 commit comments

Comments
 (0)