feat(datasource): add icons and improve data source feedback
- Introduced new icons for Feishu, Notion, and Yuque data sources to enhance visual representation. - Updated localization files to include success and failure messages for data source creation and synchronization. - Enhanced DataSourceEditorDialog and DataSourceSettings components with improved user feedback during data source operations. - Added DataSourceTypeIcon component for consistent icon display across data source settings.
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -3404,6 +3404,8 @@ export default {
|
||||
syncDeletions: 'Sync deletions (remove knowledge when deleted at source)',
|
||||
createAndSync: 'Create & Sync Now',
|
||||
createSuccess: 'Data source created',
|
||||
createAndSyncSuccess: 'Data source created and sync task submitted',
|
||||
createButSyncFailed: 'Data source created, but failed to trigger sync',
|
||||
updateSuccess: 'Data source updated',
|
||||
saveFailed: 'Failed to save',
|
||||
step: {
|
||||
|
||||
@@ -3403,6 +3403,8 @@ export default {
|
||||
syncDeletions: "同步删除(源端删除时同步删除知识库中的条目)",
|
||||
createAndSync: "创建并立即同步",
|
||||
createSuccess: "数据源创建成功",
|
||||
createAndSyncSuccess: "数据源创建成功,同步任务已提交",
|
||||
createButSyncFailed: "数据源已创建,但触发同步失败",
|
||||
updateSuccess: "数据源更新成功",
|
||||
saveFailed: "保存失败",
|
||||
step: {
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useI18n } from 'vue-i18n'
|
||||
import {
|
||||
createDataSource,
|
||||
updateDataSource,
|
||||
triggerSync,
|
||||
validateConnection,
|
||||
validateCredentials,
|
||||
listResources,
|
||||
@@ -12,6 +13,7 @@ import {
|
||||
type DataSource,
|
||||
type Resource,
|
||||
} from '@/api/datasource'
|
||||
import DataSourceTypeIcon from './DataSourceTypeIcon.vue'
|
||||
|
||||
const props = defineProps<{
|
||||
kbId: string
|
||||
@@ -269,6 +271,8 @@ async function handleSubmit() {
|
||||
form.value.config.resource_ids = selectedResourceIds.value
|
||||
submitting.value = true
|
||||
try {
|
||||
let dataSourceId = tempDsId.value
|
||||
|
||||
if (tempDsId.value) {
|
||||
await updateDataSource(tempDsId.value, {
|
||||
...form.value,
|
||||
@@ -276,13 +280,27 @@ async function handleSubmit() {
|
||||
status: 'active',
|
||||
} as any)
|
||||
} else {
|
||||
await createDataSource({
|
||||
const res = await createDataSource({
|
||||
...form.value,
|
||||
knowledge_base_id: props.kbId,
|
||||
status: 'active',
|
||||
} as any)
|
||||
const created = res?.data || res
|
||||
dataSourceId = created.id
|
||||
tempDsId.value = created.id
|
||||
}
|
||||
MessagePlugin.success(isEdit.value ? t('datasource.updateSuccess') : t('datasource.createSuccess'))
|
||||
|
||||
if (isEdit.value) {
|
||||
MessagePlugin.success(t('datasource.updateSuccess'))
|
||||
} else {
|
||||
try {
|
||||
await triggerSync(dataSourceId)
|
||||
MessagePlugin.success(t('datasource.createAndSyncSuccess'))
|
||||
} catch (e: any) {
|
||||
MessagePlugin.warning(e?.message || e?.error || t('datasource.createButSyncFailed'))
|
||||
}
|
||||
}
|
||||
|
||||
emit('saved')
|
||||
visible.value = false
|
||||
} catch (e: any) {
|
||||
@@ -353,6 +371,7 @@ const stepTitles = computed(() => [
|
||||
@click="selectType(def)"
|
||||
>
|
||||
<div class="ds-type-header">
|
||||
<DataSourceTypeIcon :type="def.type" :size="20" />
|
||||
<span class="ds-type-name">{{ t(`datasource.connector.${def.type}`) }}</span>
|
||||
<span v-if="!def.available" class="ds-type-soon">{{ t('datasource.comingSoon') }}</span>
|
||||
</div>
|
||||
@@ -598,10 +617,10 @@ const stepTitles = computed(() => [
|
||||
.ds-type-card:hover:not(.disabled) { border-color: var(--td-brand-color); background: var(--td-brand-color-light); }
|
||||
.ds-type-card.disabled { opacity: 0.5; cursor: not-allowed; }
|
||||
|
||||
.ds-type-header { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
|
||||
.ds-type-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
|
||||
.ds-type-name { font-size: 13px; font-weight: 600; }
|
||||
.ds-type-soon { font-size: 10px; color: var(--td-text-color-placeholder); background: var(--td-bg-color-component); padding: 1px 6px; border-radius: 3px; }
|
||||
.ds-type-desc { font-size: 11px; color: var(--td-text-color-secondary); }
|
||||
.ds-type-desc { font-size: 11px; color: var(--td-text-color-secondary); line-height: 1.5; }
|
||||
|
||||
/* --- Step 1: collapsible prereq --- */
|
||||
.ds-prereq-bar {
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
import { humanizeCron, relativeTime } from '@/utils/cronHumanize'
|
||||
import DataSourceEditorDialog from './DataSourceEditorDialog.vue'
|
||||
import DataSourceSyncLogs from './DataSourceSyncLogs.vue'
|
||||
import DataSourceTypeIcon from './DataSourceTypeIcon.vue'
|
||||
|
||||
const props = defineProps<{ kbId: string }>()
|
||||
const emit = defineEmits<{ (e: 'count', value: number): void }>()
|
||||
@@ -202,6 +203,7 @@ onMounted(loadList)
|
||||
<div v-for="ds in dataSources" :key="ds.id" class="ds-card">
|
||||
<div class="ds-card-header">
|
||||
<div class="ds-card-title-wrap">
|
||||
<DataSourceTypeIcon :type="ds.type" :size="24" />
|
||||
<div class="ds-title-text">
|
||||
<div class="ds-name-row">
|
||||
<span class="ds-name" :title="ds.name">{{ ds.name }}</span>
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<script setup lang="ts">
|
||||
import feishuIcon from '@/assets/img/datasource-feishu.ico'
|
||||
import notionIcon from '@/assets/img/datasource-notion.ico'
|
||||
import yuqueIcon from '@/assets/img/datasource-yuque.ico'
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
type: string
|
||||
size?: number
|
||||
}>(), {
|
||||
size: 20,
|
||||
})
|
||||
|
||||
const iconMap: Record<string, string> = {
|
||||
feishu: feishuIcon,
|
||||
notion: notionIcon,
|
||||
yuque: yuqueIcon,
|
||||
}
|
||||
|
||||
function fallbackText(type: string) {
|
||||
switch (type) {
|
||||
case 'feishu':
|
||||
return 'F'
|
||||
case 'notion':
|
||||
return 'N'
|
||||
case 'yuque':
|
||||
return 'Y'
|
||||
default:
|
||||
return type.slice(0, 1).toUpperCase() || '?'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span
|
||||
class="ds-type-icon"
|
||||
:style="{ width: `${size}px`, height: `${size}px` }"
|
||||
>
|
||||
<img
|
||||
v-if="iconMap[type]"
|
||||
:src="iconMap[type]"
|
||||
:alt="type"
|
||||
:style="{ width: `${size}px`, height: `${size}px` }"
|
||||
>
|
||||
<span v-else class="ds-type-icon-fallback">{{ fallbackText(type) }}</span>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.ds-type-icon {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
overflow: hidden;
|
||||
border-radius: 6px;
|
||||
background: var(--td-bg-color-component);
|
||||
}
|
||||
|
||||
.ds-type-icon img {
|
||||
display: block;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.ds-type-icon-fallback {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: var(--td-text-color-placeholder);
|
||||
}
|
||||
</style>
|
||||
@@ -775,4 +775,3 @@ func RegisterDataSourceRoutes(r *gin.RouterGroup, handler *handler.DataSourceHan
|
||||
ds.GET("/logs/:log_id", handler.GetSyncLog)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user