44 <el-icon size =" 20" @click =" openHistory" >
55 <icon _sidebar_outlined ></icon _sidebar_outlined >
66 </el-icon >
7- <img :src =" LOGO" class =" logo" width =" 30px" height =" 30px" alt =" " />
8- <span class =" tite " >{{ assistantName || $t('embedded.intelligent_customer_service') }}</span >
7+ <img :src =" logo || LOGO" class =" logo" width =" 30px" height =" 30px" alt =" " />
8+ <span class =" title " >{{ customSet.name || $t('embedded.intelligent_customer_service') }}</span >
99
1010 <el-tooltip effect =" dark" :content =" $t('embedded.new_conversation')" placement =" top" >
1111 <el-icon class =" new-chat" size =" 20" @click =" createChat" >
1414 </el-tooltip >
1515 </div >
1616 <div class =" sqlbot-chat-container" >
17- <chat-component v-if =" !loading" ref =" chatRef" />
17+ <chat-component
18+ v-if =" !loading"
19+ ref =" chatRef"
20+ :welcome =" customSet.welcome"
21+ :welcome-desc =" customSet.welcome_desc"
22+ :logo-assistant =" logo"
23+ />
1824 </div >
1925 <div class =" drawer-assistant" @click =" openHistory" ></div >
2026 </div >
2127</template >
2228<script setup lang="ts">
23- import { onBeforeMount , onBeforeUnmount , ref , onMounted } from ' vue'
29+ import { onBeforeMount , nextTick , onBeforeUnmount , ref , onMounted , reactive } from ' vue'
2430import ChatComponent from ' @/views/chat/index.vue'
31+ import { request } from ' @/utils/request'
2532import LOGO from ' @/assets/embedded/LOGO.png'
2633import icon_sidebar_outlined from ' @/assets/embedded/icon_sidebar_outlined.svg'
2734import icon_new_chat_outlined from ' @/assets/svg/icon_new_chat_outlined.svg'
2835import { useRoute } from ' vue-router'
2936import { assistantApi } from ' @/api/assistant'
3037import { useAssistantStore } from ' @/stores/assistant'
38+ import { setCurrentColor } from ' @/utils/utils'
3139
3240const assistantStore = useAssistantStore ()
3341const route = useRoute ()
34- const assistantName = ref (' ' )
3542const chatRef = ref ()
3643
3744const createChat = () => {
@@ -92,19 +99,51 @@ onMounted(() => {
9299 } `
93100 document .querySelector (' head' )?.appendChild (style )
94101})
102+ const customSet = reactive ({
103+ name: ' ' ,
104+ welcome: ' ' ,
105+ welcome_desc: ' ' ,
106+ theme: ' #1CBA90' ,
107+ header_font_color: ' #1F2329' ,
108+ }) as { [key : string ]: any }
109+ const logo = ref ()
110+ const basePath = import .meta .env .VITE_API_BASE_URL
111+ const baseUrl = basePath + ' /system/assistant/picture/'
112+ const setPageCustomColor = (val : any ) => {
113+ const ele = document .querySelector (' .sqlbot-assistant-container' ) as HTMLElement
114+ setCurrentColor (val , ele )
115+ }
116+
117+ const setPageHeaderFontColor = (val : any ) => {
118+ const ele = document .querySelector (' .sqlbot-assistant-container' ) as HTMLElement
119+ ele .style .setProperty (' --ed-text-color-primary' , val )
120+ }
95121onBeforeMount (async () => {
96122 const assistantId = route .query .id
97123 if (! assistantId ) {
98124 ElMessage .error (' Miss assistant id, please check assistant url' )
99125 return
100126 }
127+ request .get (` /system/assistant/info/${assistantId } ` ).then ((res ) => {
128+ if (res ?.configuration ) {
129+ const rawData = JSON .parse (res ?.configuration )
130+ logo .value = baseUrl + rawData .logo
131+
132+ for (const key in customSet ) {
133+ if (Object .prototype .hasOwnProperty .call (customSet , key ) && rawData [key ]) {
134+ customSet [key ] = rawData [key ]
135+ }
136+ }
137+
138+ nextTick (() => {
139+ setPageCustomColor (customSet .theme )
140+ setPageHeaderFontColor (customSet .header_font_color )
141+ })
142+ }
143+ })
101144 const online = route .query .online
102145 setFormatOnline (online )
103146
104- let name = route .query .name
105- if (name ) {
106- assistantName .value = decodeURIComponent (name .toString ())
107- }
108147 const now = Date .now ()
109148 assistantStore .setFlag (now )
110149 assistantStore .setId (assistantId ?.toString () || ' ' )
@@ -145,7 +184,7 @@ onBeforeUnmount(() => {
145184 z-index : 100 ;
146185 height : 56px ;
147186 line-height : 56px ;
148- background : var (--ed-color-primary-14 , #1cba9014 );
187+ background : var (--ed-color-primary-1a , #1cba901a );
149188 height : 56px ;
150189 padding : 0 16px ;
151190 display : flex ;
@@ -159,6 +198,7 @@ onBeforeUnmount(() => {
159198 font-weight : 500 ;
160199 font-size : 16px ;
161200 line-height : 24px ;
201+ color : var (--ed-text-color-primary );
162202 }
163203
164204 .ed-icon {
0 commit comments