Skip to content

Commit b79159c

Browse files
committed
fix: bug fix
1 parent a418015 commit b79159c

File tree

1 file changed

+53
-4
lines changed

1 file changed

+53
-4
lines changed

frontend/src/views/chat/ChatCreator.vue

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<script lang="ts" setup>
22
import { onMounted, ref, computed, shallowRef } from 'vue'
33
import 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'
47
import icon_searchOutline_outlined from '@/assets/svg/icon_search-outline_outlined.svg'
58
import { chatApi, ChatInfo } from '@/api/chat.ts'
69
import { datasourceApi } from '@/api/datasource.ts'
@@ -15,6 +18,8 @@ const props = withDefaults(
1518
}
1619
)
1720
21+
const router = useRouter()
22+
const searchLoading = ref(false)
1823
const datasourceConfigvVisible = ref(false)
1924
const keywords = ref('')
2025
const datasourceList = shallowRef([] as any[])
@@ -32,9 +37,15 @@ const beforeClose = () => {
3237
const emits = defineEmits(['onChatCreated'])
3338
3439
function 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
4051
const innerDs = ref()
@@ -89,6 +100,10 @@ onMounted(() => {
89100
}
90101
})
91102
103+
const handleAddDatasource = () => {
104+
router.push('/ds/index')
105+
}
106+
92107
defineExpose({
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

Comments
 (0)