|
58 | 58 | <el-container :loading="loading"> |
59 | 59 | <el-main |
60 | 60 | class="chat-record-list" |
61 | | - :class="{ 'hide-sidebar': !isAssistant && !chatListSideBarShow }" |
| 61 | + :class="{ |
| 62 | + 'hide-sidebar': !isAssistant && !chatListSideBarShow, |
| 63 | + 'assistant-chat-main': isAssistant, |
| 64 | + }" |
62 | 65 | > |
63 | 66 | <div v-if="computedMessages.length == 0 && !loading" class="welcome-content-block"> |
64 | 67 | <div class="welcome-content"> |
65 | 68 | <div class="greeting"> |
66 | 69 | <el-icon size="32"> |
67 | 70 | <logo_fold /> |
68 | 71 | </el-icon> |
69 | | - {{ t('qa.greeting') }} |
| 72 | + {{ isAssistant ? t('embedded.i_am_sqlbot') : t('qa.greeting') }} |
| 73 | + </div> |
| 74 | + <div class="sub"> |
| 75 | + {{ isAssistant ? t('embedded.predict_data_etc') : t('qa.hint_description') }} |
| 76 | + </div> |
| 77 | + <div v-if="isAssistant" class="sub assistant-sub"> |
| 78 | + {{ t('embedded.intelligent_data_query') }} |
70 | 79 | </div> |
71 | | - <div class="sub">{{ t('qa.hint_description') }}</div> |
72 | 80 | <el-button |
73 | | - v-if="currentChatId === undefined" |
| 81 | + v-if="!isAssistant && currentChatId === undefined" |
74 | 82 | size="large" |
75 | 83 | type="primary" |
76 | 84 | class="greeting-btn" |
|
256 | 264 | </div> |
257 | 265 | </el-scrollbar> |
258 | 266 | </el-main> |
259 | | - <el-footer |
260 | | - v-if="computedMessages.length > 0 || (isAssistant && currentChatId)" |
261 | | - class="chat-footer" |
262 | | - > |
| 267 | + <el-footer v-if="computedMessages.length > 0 || isAssistant" class="chat-footer"> |
263 | 268 | <div class="input-wrapper" @click="clickInput"> |
264 | | - <div class="datasource"> |
| 269 | + <div v-if="!isAssistant" class="datasource"> |
265 | 270 | <template v-if="currentChat.datasource && currentChat.datasource_name"> |
266 | 271 | {{ t('qa.selected_datasource') }}: |
267 | 272 | <img |
@@ -414,9 +419,17 @@ const createNewChatSimple = async () => { |
414 | 419 | currentChatId.value = undefined |
415 | 420 | await createNewChat() |
416 | 421 | } |
417 | | -
|
| 422 | +const isAssistantRepeatEmpty = () => { |
| 423 | + return ( |
| 424 | + isAssistant.value && |
| 425 | + (currentChatId.value === null || typeof currentChatId.value === 'undefined') |
| 426 | + ) |
| 427 | +} |
418 | 428 | const createNewChat = async () => { |
419 | 429 | goEmpty() |
| 430 | + if (isAssistantRepeatEmpty()) { |
| 431 | + return |
| 432 | + } |
420 | 433 | if (isAssistant.value) { |
421 | 434 | const assistantChat = await assistantStore.setChat() |
422 | 435 | if (assistantChat) { |
@@ -531,13 +544,23 @@ function onChatStop() { |
531 | 544 | isTyping.value = false |
532 | 545 | console.debug('onChatStop') |
533 | 546 | } |
534 | | -
|
| 547 | +const assistantPrepareSend = async () => { |
| 548 | + if ( |
| 549 | + isAssistant.value && |
| 550 | + (currentChatId.value == null || typeof currentChatId.value == 'undefined') |
| 551 | + ) { |
| 552 | + const assistantChat = await assistantStore.setChat() |
| 553 | + if (assistantChat) { |
| 554 | + onChatCreatedQuick(assistantChat as any) |
| 555 | + } |
| 556 | + } |
| 557 | +} |
535 | 558 | const sendMessage = async () => { |
536 | 559 | if (!inputMessage.value.trim()) return |
537 | 560 |
|
538 | 561 | loading.value = true |
539 | 562 | isTyping.value = true |
540 | | -
|
| 563 | + assistantPrepareSend() |
541 | 564 | const currentRecord = new ChatRecord() |
542 | 565 | currentRecord.create_time = new Date() |
543 | 566 | currentRecord.chat_id = currentChatId.value |
@@ -840,6 +863,9 @@ onMounted(() => { |
840 | 863 | border-radius: 12px; |
841 | 864 | } |
842 | 865 | } |
| 866 | + .assistant-chat-main { |
| 867 | + padding: 0 0 20px 0; |
| 868 | + } |
843 | 869 |
|
844 | 870 | .chat-scroll { |
845 | 871 | width: 100%; |
|
0 commit comments