Skip to content

Commit d442c06

Browse files
perf: Assistant base
1 parent 1e18095 commit d442c06

File tree

4 files changed

+119
-206
lines changed

4 files changed

+119
-206
lines changed

frontend/src/router/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import DashboardPreview from '@//views/dashboard/preview/SQPreviewSingle.vue'
1111
import Dashboard from '@/views/dashboard/index.vue'
1212
import Model from '@/views/system/model/Model.vue'
1313
import Embedded from '@/views/system/embedded/index.vue'
14-
import assistant from '@/views/embedded/assistant.vue'
14+
import assistant from '@/views/embedded/index.vue'
1515
import Member from '@/views/system/member/index.vue'
1616
import Permission from '@/views/system/permission/index.vue'
1717
import User from '@/views/system/user/User.vue'

frontend/src/views/chat/index.vue

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
@on-click-side-bar-btn="hideSideBar"
1616
/>
1717
</el-aside>
18-
<div v-if="!isAssistant && !chatListSideBarShow" class="hidden-sidebar-btn">
18+
<div
19+
v-if="isAssistant || !chatListSideBarShow"
20+
class="hidden-sidebar-btn"
21+
:class="{ 'assistant-popover-sidebar': isAssistant }"
22+
>
1923
<el-popover
24+
:visible="isAssistant ? floatPopoverVisible : null"
2025
:width="280"
2126
placement="bottom-start"
22-
popper-style="padding: 0;
23-
height: 654px;
24-
border: 1px solid rgba(222, 224, 227, 1);
25-
border-radius: 6px;
26-
"
27+
:popper-style="{ ...defaultFloatPopoverStyle }"
2728
>
2829
<template #reference>
2930
<el-button link type="primary" class="icon-btn" @click="showSideBar">
@@ -264,11 +265,11 @@
264265
<template v-if="currentChat.datasource && currentChat.datasource_name">
265266
{{ t('qa.selected_datasource') }}:
266267
<img
268+
v-if="currentChatEngineType"
267269
style="margin-left: 4px; margin-right: 4px"
268270
:src="currentChatEngineType"
269271
width="16px"
270272
height="16px"
271-
v-if="currentChatEngineType"
272273
alt=""
273274
/>
274275
<span class="name">
@@ -339,8 +340,14 @@ import { useAssistantStore } from '@/stores/assistant'
339340
const props = defineProps<{
340341
startChatDsId?: number
341342
}>()
342-
343+
const floatPopoverVisible = ref(false)
343344
const assistantStore = useAssistantStore()
345+
const defaultFloatPopoverStyle = ref({
346+
padding: '0',
347+
height: '654px',
348+
border: '1px solid rgba(222, 224, 227, 1)',
349+
borderRadius: '6px',
350+
})
344351
345352
const isAssistant = computed(() => assistantStore.getAssistant)
346353
@@ -444,26 +451,6 @@ const currentChatEngineType = computed(() => {
444451
return (dsTypeWithImg.find((ele) => currentChat.value.ds_type === ele.type) || {}).img
445452
})
446453
447-
function toAssistantHistory(chat: Chat) {
448-
currentChat.value = new ChatInfo(chat)
449-
if (chat !== undefined && chat.id !== undefined && !loading.value) {
450-
currentChatId.value = chat.id
451-
loading.value = true
452-
chatApi
453-
.get(chat.id)
454-
.then((res) => {
455-
const info = chatApi.toChatInfo(res)
456-
if (info) {
457-
currentChat.value = info
458-
onClickHistory(info)
459-
}
460-
})
461-
.finally(() => {
462-
loading.value = false
463-
})
464-
}
465-
}
466-
467454
function onChatDeleted(id: number) {
468455
console.log('deleted', id)
469456
}
@@ -474,6 +461,10 @@ function onChatRenamed(chat: Chat) {
474461
475462
const chatListSideBarShow = ref<boolean>(true)
476463
function hideSideBar() {
464+
if (isAssistant.value) {
465+
floatPopoverVisible.value = false
466+
return
467+
}
477468
chatListSideBarShow.value = false
478469
}
479470
@@ -714,13 +705,6 @@ const handleCtrlEnter = (e: KeyboardEvent) => {
714705
})
715706
}
716707
717-
const getHistoryList = () => {
718-
return chatList.value
719-
}
720-
const getCurrentChatId = () => {
721-
return currentChatId.value
722-
}
723-
724708
const inputRef = ref()
725709
726710
function clickInput() {
@@ -768,12 +752,24 @@ function stop(func?: (...p: any[]) => void, ...param: any[]) {
768752
func(...param)
769753
}
770754
}
771-
755+
const showFloatPopover = () => {
756+
if (isAssistant.value && !floatPopoverVisible.value) {
757+
floatPopoverVisible.value = true
758+
}
759+
}
760+
const assistantPrepareInit = () => {
761+
if (!isAssistant.value) {
762+
return
763+
}
764+
Object.assign(defaultFloatPopoverStyle.value, {
765+
height: '100% !important',
766+
inset: '0px auto auto 0px',
767+
})
768+
goEmpty()
769+
}
772770
defineExpose({
773-
getHistoryList,
774-
toAssistantHistory,
775-
getCurrentChatId,
776771
createNewChat,
772+
showFloatPopover,
777773
})
778774
779775
const hiddenChatCreatorRef = ref()
@@ -791,6 +787,7 @@ function jumpCreatChat() {
791787
792788
onMounted(() => {
793789
getChatList(jumpCreatChat)
790+
assistantPrepareInit()
794791
})
795792
</script>
796793

@@ -800,7 +797,11 @@ onMounted(() => {
800797
position: relative;
801798
802799
border-radius: 12px;
803-
800+
.assistant-popover-sidebar {
801+
button {
802+
display: none;
803+
}
804+
}
804805
.hidden-sidebar-btn {
805806
z-index: 1;
806807
position: absolute;

0 commit comments

Comments
 (0)