11<script lang="ts" setup>
22import { onMounted , ref , computed , shallowRef } from ' vue'
33import icon_close_outlined from ' @/assets/svg/operate/ope-close.svg'
4+ import icon_add_outlined from ' @/assets/svg/icon_add_outlined.svg'
5+ import { useRouter } from ' vue-router'
6+ import EmptyBackground from ' @/views/dashboard/common/EmptyBackground.vue'
47import icon_searchOutline_outlined from ' @/assets/svg/icon_search-outline_outlined.svg'
58import { chatApi , ChatInfo } from ' @/api/chat.ts'
69import { datasourceApi } from ' @/api/datasource.ts'
@@ -15,6 +18,8 @@ const props = withDefaults(
1518 }
1619)
1720
21+ const router = useRouter ()
22+ const searchLoading = ref (false )
1823const datasourceConfigvVisible = ref (false )
1924const keywords = ref (' ' )
2025const datasourceList = shallowRef ([] as any [])
@@ -32,9 +37,15 @@ const beforeClose = () => {
3237const emits = defineEmits ([' onChatCreated' ])
3338
3439function listDs() {
35- datasourceApi .list ().then ((res ) => {
36- datasourceList .value = res
37- })
40+ searchLoading .value = true
41+ datasourceApi
42+ .list ()
43+ .then ((res ) => {
44+ datasourceList .value = res
45+ })
46+ .finally (() => {
47+ searchLoading .value = false
48+ })
3849}
3950
4051const innerDs = ref ()
@@ -89,6 +100,10 @@ onMounted(() => {
89100 }
90101})
91102
103+ const handleAddDatasource = () => {
104+ router .push (' /ds/index' )
105+ }
106+
92107defineExpose ({
93108 showDs ,
94109 hideDs ,
@@ -126,7 +141,7 @@ defineExpose({
126141 <icon _close_outlined ></icon _close_outlined >
127142 </el-icon >
128143 </template >
129- <div class =" card-content" >
144+ <div v-if = " datasourceListWithSearch.length " class =" card-content" >
130145 <Card
131146 v-for =" ele in datasourceListWithSearch"
132147 :id =" ele.id"
@@ -140,6 +155,28 @@ defineExpose({
140155 @select-ds =" selectDsInDialog(ele)"
141156 ></Card >
142157 </div >
158+ <template v-if =" ! keywords && ! datasourceListWithSearch .length && ! searchLoading " >
159+ <EmptyBackground
160+ class =" datasource-yet_btn"
161+ :description =" $t('datasource.data_source_yet')"
162+ img-type =" noneWhite"
163+ />
164+
165+ <div style =" text-align : center ; margin-top : -10px " >
166+ <el-button type =" primary" @click =" handleAddDatasource" >
167+ <template #icon >
168+ <icon _add_outlined ></icon _add_outlined >
169+ </template >
170+ {{ $t('datasource.new_data_source') }}
171+ </el-button >
172+ </div >
173+ </template >
174+ <EmptyBackground
175+ v-if =" !!keywords && !datasourceListWithSearch.length"
176+ :description =" $t('datasource.relevant_content_found')"
177+ class =" datasource-yet"
178+ img-type =" tree"
179+ />
143180 <template #footer >
144181 <div class =" dialog-footer" >
145182 <el-button secondary :disabled =" loading" @click =" hideDs" >{{
@@ -165,5 +202,17 @@ defineExpose({
165202 max-height : 100% ;
166203 overflow-y : auto ;
167204 }
205+
206+ .datasource-yet {
207+ padding-bottom : 0 ;
208+ height : auto ;
209+ padding-top : 200px ;
210+ }
211+
212+ .datasource-yet_btn {
213+ height : auto !important ;
214+ padding-top : 200px ;
215+ padding-bottom : 0 ;
216+ }
168217}
169218 </style >
0 commit comments