File tree Expand file tree Collapse file tree 4 files changed +36
-9
lines changed
Expand file tree Collapse file tree 4 files changed +36
-9
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,9 @@ const router = createRouter({
3636 path : 'index' ,
3737 name : 'chat' ,
3838 component : chat ,
39+ props : ( route ) => {
40+ return { startChatDsId : route . query . start_chat }
41+ } ,
3942 meta : { title : t ( 'menu.Data Q&A' ) , icon : 'chat' } ,
4043 } ,
4144 ] ,
Original file line number Diff line number Diff line change @@ -3,7 +3,15 @@ import { chatApi, ChatInfo } from '@/api/chat.ts'
33import { onMounted , ref } from ' vue'
44import { datasourceApi } from ' @/api/datasource.ts'
55import DatasourceItemCard from ' ../ds/DatasourceItemCard.vue'
6- import { useRoute } from ' vue-router'
6+
7+ const props = withDefaults (
8+ defineProps <{
9+ hidden? : boolean
10+ }>(),
11+ {
12+ hidden: false ,
13+ }
14+ )
715
816const dsList = ref <Array <any >>([])
917
@@ -14,7 +22,6 @@ function listDs() {
1422 dsList .value = res
1523 })
1624}
17- const route = useRoute ()
1825
1926const dialogVisible = ref (false )
2027
@@ -67,20 +74,21 @@ function createChat(datasource: number) {
6774}
6875
6976onMounted (() => {
77+ if (props .hidden ) {
78+ return
79+ }
7080 listDs ()
71- const id = route .query .id as unknown as number
72- if (! id ) return
73- createChat (id )
7481})
7582
7683defineExpose ({
7784 showDs ,
7885 hideDs ,
86+ createChat ,
7987})
8088 </script >
8189
8290<template >
83- <div >
91+ <div v-if = " !hidden " >
8492 <el-drawer
8593 ref =" DatasourceListRef"
8694 v-model =" dialogVisible"
Original file line number Diff line number Diff line change 285285 </el-container >
286286
287287 <ChatCreator v-if =" !isAssistant" ref =" chatCreatorRef" @on-chat-created =" onChatCreatedQuick" />
288+ <ChatCreator ref =" hiddenChatCreatorRef" hidden @on-chat-created =" onChatCreatedQuick" />
288289 </el-container >
289290</template >
290291
@@ -313,6 +314,11 @@ import logo from '@/assets/LOGO.svg'
313314import icon_send_filled from ' @/assets/svg/icon_send_filled.svg'
314315
315316import { useAssistantStore } from ' @/stores/assistant'
317+
318+ const props = defineProps <{
319+ startChatDsId? : number
320+ }>()
321+
316322const assistantStore = useAssistantStore ()
317323
318324const isAssistant = computed (() => assistantStore .getAssistant )
@@ -367,7 +373,6 @@ const computedMessages = computed<Array<ChatMessage>>(() => {
367373 })
368374 }
369375
370- console .log (messages )
371376 return messages
372377})
373378
@@ -390,7 +395,6 @@ const createNewChat = async () => {
390395 }
391396 return
392397 }
393- console .log (chatCreatorRef .value )
394398 chatCreatorRef .value ?.showDs ()
395399}
396400
@@ -745,6 +749,18 @@ defineExpose({
745749 getCurrentChatId ,
746750 createNewChat ,
747751})
752+
753+ const hiddenChatCreatorRef = ref ()
754+
755+ onMounted (() => {
756+ if (props .startChatDsId ) {
757+ const _id = props .startChatDsId
758+ nextTick (() => {
759+ hiddenChatCreatorRef .value ?.createChat (_id )
760+ })
761+ // todo remove 'start_chat' in url
762+ }
763+ })
748764 </script >
749765
750766<style lang="less" scoped>
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ const handleQuestion = (id: string) => {
9797 router .push ({
9898 path: ' /chat/index' ,
9999 query: {
100- id ,
100+ start_chat: id ,
101101 },
102102 })
103103}
You can’t perform that action at this time.
0 commit comments