feat(i18n): update localization files for new UI elements and actions

- Added translations for "Refresh logs" in English, Korean, Russian, and Chinese.
- Enhanced the knowledge base editor modal to include a badge for data source count.
- Improved data source settings UI with a confirmation dialog for deletion and a refresh button in sync logs.
- Updated the data source sync logs component to fetch logs on visibility change and added a refresh option in the header.
This commit is contained in:
wizardchen
2026-03-30 13:32:39 +08:00
committed by lyingbug
parent 11cabd5952
commit d5ec5dc0ea
8 changed files with 245 additions and 158 deletions
+1
View File
@@ -3419,6 +3419,7 @@ export default {
strategy: 'Strategy', strategy: 'Strategy',
}, },
syncHistory: 'Sync History', syncHistory: 'Sync History',
refreshLogs: 'Refresh logs',
noLogs: 'No sync records yet', noLogs: 'No sync records yet',
logStatus: { logStatus: {
running: 'Syncing', running: 'Syncing',
+2
View File
@@ -3411,6 +3411,7 @@ export default {
resumed: "재개됨", resumed: "재개됨",
pauseFailed: "일시정지 실패", pauseFailed: "일시정지 실패",
logs: "로그", logs: "로그",
moreActions: "추가 작업",
lastSync: "마지막 동기화", lastSync: "마지막 동기화",
lastStatus: "결과", lastStatus: "결과",
schedule: "동기화 주기", schedule: "동기화 주기",
@@ -3461,6 +3462,7 @@ export default {
strategy: "동기화 전략", strategy: "동기화 전략",
}, },
syncHistory: "동기화 이력", syncHistory: "동기화 이력",
refreshLogs: "로그 새로고침",
noLogs: "동기화 기록이 없습니다", noLogs: "동기화 기록이 없습니다",
logStatus: { logStatus: {
running: "동기화 중", running: "동기화 중",
+2
View File
@@ -3318,6 +3318,7 @@ export default {
resumed: 'Возобновлено', resumed: 'Возобновлено',
pauseFailed: 'Не удалось приостановить', pauseFailed: 'Не удалось приостановить',
logs: 'Журнал', logs: 'Журнал',
moreActions: 'Дополнительные действия',
lastSync: 'Последняя синхронизация', lastSync: 'Последняя синхронизация',
lastStatus: 'Результат', lastStatus: 'Результат',
schedule: 'Расписание', schedule: 'Расписание',
@@ -3368,6 +3369,7 @@ export default {
strategy: 'Стратегия', strategy: 'Стратегия',
}, },
syncHistory: 'История синхронизации', syncHistory: 'История синхронизации',
refreshLogs: 'Обновить журнал',
noLogs: 'Нет записей синхронизации', noLogs: 'Нет записей синхронизации',
logStatus: { logStatus: {
running: 'Синхронизация', running: 'Синхронизация',
+1
View File
@@ -3417,6 +3417,7 @@ export default {
strategy: "同步策略", strategy: "同步策略",
}, },
syncHistory: "同步历史", syncHistory: "同步历史",
refreshLogs: "刷新日志",
noLogs: "暂无同步记录", noLogs: "暂无同步记录",
logStatus: { logStatus: {
running: "同步中", running: "同步中",
@@ -25,6 +25,7 @@
> >
<t-icon :name="item.icon" class="nav-icon" /> <t-icon :name="item.icon" class="nav-icon" />
<span class="nav-label">{{ item.label }}</span> <span class="nav-label">{{ item.label }}</span>
<span v-if="item.badge" class="nav-badge">{{ item.badge }}</span>
</div> </div>
</div> </div>
</div> </div>
@@ -214,7 +215,7 @@
<!-- 数据源管理(仅编辑模式) --> <!-- 数据源管理(仅编辑模式) -->
<div v-if="mode === 'edit' && kbId" v-show="currentSection === 'datasource'" class="section"> <div v-if="mode === 'edit' && kbId" v-show="currentSection === 'datasource'" class="section">
<DataSourceSettings :kb-id="kbId" /> <DataSourceSettings :kb-id="kbId" @count="dsCount = $event" />
</div> </div>
<!-- 共享设置(仅编辑模式) --> <!-- 共享设置(仅编辑模式) -->
@@ -281,9 +282,10 @@ const loading = ref(false)
const allModels = ref<any[]>([]) const allModels = ref<any[]>([])
const hasFiles = ref(false) const hasFiles = ref(false)
const initialStorageProvider = ref<string>('') const initialStorageProvider = ref<string>('')
const dsCount = ref(0)
const navItems = computed(() => { const navItems = computed(() => {
const items = [ const items: { key: string; icon: string; label: string; badge?: number }[] = [
{ key: 'basic', icon: 'info-circle', label: t('knowledgeEditor.sidebar.basic') }, { key: 'basic', icon: 'info-circle', label: t('knowledgeEditor.sidebar.basic') },
{ key: 'models', icon: 'control-platform', label: t('knowledgeEditor.sidebar.models') } { key: 'models', icon: 'control-platform', label: t('knowledgeEditor.sidebar.models') }
] ]
@@ -298,12 +300,10 @@ const navItems = computed(() => {
{ key: 'multimodal', icon: 'image', label: t('knowledgeEditor.sidebar.multimodal') }, { key: 'multimodal', icon: 'image', label: t('knowledgeEditor.sidebar.multimodal') },
{ key: 'advanced', icon: 'setting', label: t('knowledgeEditor.sidebar.advanced') } { key: 'advanced', icon: 'setting', label: t('knowledgeEditor.sidebar.advanced') }
) )
// 数据源管理:仅文档类型知识库 + 编辑模式
if (props.mode === 'edit' && props.kbId) { if (props.mode === 'edit' && props.kbId) {
items.push({ key: 'datasource', icon: 'cloud-download', label: t('knowledgeEditor.sidebar.datasource') }) items.push({ key: 'datasource', icon: 'cloud-download', label: t('knowledgeEditor.sidebar.datasource'), badge: dsCount.value || undefined })
} }
} }
// 共享设置:编辑模式下所有类型都可用
if (props.mode === 'edit' && props.kbId) { if (props.mode === 'edit' && props.kbId) {
items.push({ key: 'share', icon: 'share', label: t('knowledgeEditor.sidebar.share') }) items.push({ key: 'share', icon: 'share', label: t('knowledgeEditor.sidebar.share') })
} }
@@ -925,6 +925,27 @@ watch(
flex: 1; flex: 1;
} }
.nav-badge {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 18px;
height: 18px;
padding: 0 5px;
border-radius: 9px;
font-size: 11px;
font-weight: 600;
background: var(--td-bg-color-component);
color: var(--td-text-color-secondary);
line-height: 1;
flex-shrink: 0;
}
.nav-item.active .nav-badge {
background: var(--td-brand-color);
color: #fff;
}
.settings-content { .settings-content {
flex: 1; flex: 1;
display: flex; display: flex;
@@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import { MessagePlugin } from 'tdesign-vue-next' import { MessagePlugin, DialogPlugin } from 'tdesign-vue-next'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { import {
listDataSources, listDataSources,
@@ -15,6 +15,7 @@ import DataSourceEditorDialog from './DataSourceEditorDialog.vue'
import DataSourceSyncLogs from './DataSourceSyncLogs.vue' import DataSourceSyncLogs from './DataSourceSyncLogs.vue'
const props = defineProps<{ kbId: string }>() const props = defineProps<{ kbId: string }>()
const emit = defineEmits<{ (e: 'count', value: number): void }>()
const { t } = useI18n() const { t } = useI18n()
const dataSources = ref<DataSource[]>([]) const dataSources = ref<DataSource[]>([])
@@ -25,11 +26,13 @@ const logsVisible = ref(false)
const logsDsId = ref('') const logsDsId = ref('')
const logsDsName = ref('') const logsDsName = ref('')
async function loadList() { async function loadList() {
loading.value = true loading.value = true
try { try {
const res = await listDataSources(props.kbId) const res = await listDataSources(props.kbId)
dataSources.value = res?.data || res || [] dataSources.value = res?.data || res || []
emit('count', dataSources.value.length)
} catch (e: any) { } catch (e: any) {
console.error(e) console.error(e)
} finally { } finally {
@@ -53,14 +56,23 @@ function openLogs(ds: DataSource) {
logsVisible.value = true logsVisible.value = true
} }
async function handleDelete(ds: DataSource) { function handleDelete(ds: DataSource) {
try { const confirmDialog = DialogPlugin.confirm({
await deleteDataSource(ds.id) header: t('datasource.delete'),
MessagePlugin.success(t('datasource.deleteSuccess')) body: t('datasource.deleteConfirm'),
loadList() confirmBtn: { content: t('datasource.delete'), theme: 'danger' },
} catch { cancelBtn: t('common.cancel'),
MessagePlugin.error(t('datasource.deleteFailed')) onConfirm: async () => {
} try {
await deleteDataSource(ds.id)
MessagePlugin.success(t('datasource.deleteSuccess'))
loadList()
} catch {
MessagePlugin.error(t('datasource.deleteFailed'))
}
confirmDialog.destroy()
},
})
} }
async function handleSync(ds: DataSource) { async function handleSync(ds: DataSource) {
@@ -93,10 +105,11 @@ async function handleResume(ds: DataSource) {
} }
} }
function statusColor(status: string) { function statusTheme(status: string): 'success' | 'danger' | 'default' | 'warning' {
if (status === 'active') return 'var(--td-success-color)' if (status === 'active') return 'success'
if (status === 'error') return 'var(--td-error-color)' if (status === 'error') return 'danger'
return 'var(--td-text-color-placeholder)' if (status === 'paused') return 'warning'
return 'default'
} }
function statusLabel(status: string) { function statusLabel(status: string) {
@@ -124,7 +137,6 @@ function lastSyncFullTime(ds: DataSource) {
return new Date(ds.last_sync_at).toLocaleString() return new Date(ds.last_sync_at).toLocaleString()
} }
// Build sync result pills from latest_sync_log
function syncResultPills(ds: DataSource) { function syncResultPills(ds: DataSource) {
const log = ds.latest_sync_log const log = ds.latest_sync_log
if (!log) return [] if (!log) return []
@@ -165,47 +177,62 @@ onMounted(loadList)
<template> <template>
<div class="ds-settings"> <div class="ds-settings">
<!-- Section header: title only, no button here -->
<div class="section-header"> <div class="section-header">
<h2 class="section-title">{{ t('datasource.title') }}</h2> <h2 class="section-title">{{ t('datasource.title') }}</h2>
<p class="section-desc">{{ t('datasource.description') }}</p> <p class="section-desc">{{ t('datasource.description') }}</p>
</div> </div>
<div v-if="loading" class="ds-loading"> <div v-if="loading" class="ds-loading">
<t-loading /> <t-loading size="small" />
</div> </div>
<div v-else-if="dataSources.length === 0" class="ds-empty"> <div v-else-if="dataSources.length === 0" class="ds-empty">
<t-icon name="cloud-download" size="48px" style="color: var(--td-text-color-placeholder)" /> <div class="ds-empty-icon">
<p>{{ t('datasource.empty') }}</p> <t-icon name="cloud-download" size="32px" />
<t-button variant="outline" @click="openCreate">{{ t('datasource.addFirst') }}</t-button> </div>
<div class="ds-empty-text">
<p class="ds-empty-title">{{ t('datasource.empty') }}</p>
</div>
<t-button theme="primary" @click="openCreate">
<template #icon><t-icon name="add" /></template>
{{ t('datasource.addFirst') }}
</t-button>
</div> </div>
<div v-else class="ds-list"> <div v-else class="ds-list">
<!-- Data source cards -->
<div v-for="ds in dataSources" :key="ds.id" class="ds-card"> <div v-for="ds in dataSources" :key="ds.id" class="ds-card">
<div class="ds-card-header"> <div class="ds-card-header">
<div class="ds-card-title"> <div class="ds-card-identity">
<span class="ds-type-badge">{{ connectorLabel(ds.type) }}</span> <div class="ds-name-row">
<span class="ds-name">{{ ds.name }}</span> <span class="ds-name">{{ ds.name }}</span>
</div> <t-tag size="small" :theme="statusTheme(ds.status)" variant="light-outline">
<div class="ds-card-header-right"> {{ statusLabel(ds.status) }}
<div class="ds-status"> </t-tag>
<span class="ds-status-dot" :style="{ background: statusColor(ds.status) }"></span>
{{ statusLabel(ds.status) }}
</div> </div>
<t-dropdown trigger="click" :min-column-width="100"> <span class="ds-type-label">{{ connectorLabel(ds.type) }}</span>
<t-button size="small" variant="text" shape="square"> </div>
<template #icon><t-icon name="more" /></template> <div class="ds-card-actions">
<t-tooltip :content="t('datasource.syncNow')">
<t-button size="small" variant="text" theme="primary" @click="handleSync(ds)">
<template #icon><t-icon name="refresh" /></template>
</t-button> </t-button>
</t-tooltip>
<t-tooltip :content="t('datasource.logs')">
<t-button size="small" variant="text" @click="openLogs(ds)">
<template #icon><t-icon name="history" /></template>
</t-button>
</t-tooltip>
<t-dropdown trigger="click" :min-column-width="120">
<t-tooltip :content="t('datasource.moreActions')">
<t-button size="small" variant="text" shape="square">
<template #icon><t-icon name="ellipsis" /></template>
</t-button>
</t-tooltip>
<template #dropdown> <template #dropdown>
<t-dropdown-menu> <t-dropdown-menu>
<t-dropdown-item @click="openEdit(ds)"> <t-dropdown-item @click="openEdit(ds)">
<t-icon name="edit" /> {{ t('datasource.edit') }} <t-icon name="edit" /> {{ t('datasource.edit') }}
</t-dropdown-item> </t-dropdown-item>
<t-dropdown-item @click="openLogs(ds)">
<t-icon name="history" /> {{ t('datasource.logs') }}
</t-dropdown-item>
<t-dropdown-item <t-dropdown-item
v-if="ds.status === 'active'" v-if="ds.status === 'active'"
@click="handlePause(ds)" @click="handlePause(ds)"
@@ -227,7 +254,6 @@ onMounted(loadList)
</div> </div>
</div> </div>
<!-- Info grid -->
<div class="ds-card-body"> <div class="ds-card-body">
<div class="ds-info-cell"> <div class="ds-info-cell">
<span class="ds-info-label">{{ t('datasource.syncModeLabel') }}</span> <span class="ds-info-label">{{ t('datasource.syncModeLabel') }}</span>
@@ -239,43 +265,34 @@ onMounted(loadList)
</div> </div>
<div class="ds-info-cell"> <div class="ds-info-cell">
<span class="ds-info-label">{{ t('datasource.lastSync') }}</span> <span class="ds-info-label">{{ t('datasource.lastSync') }}</span>
<span class="ds-info-value" :title="lastSyncFullTime(ds)">{{ lastSyncTime(ds) }}</span> <t-tooltip :content="lastSyncFullTime(ds)" :disabled="!lastSyncFullTime(ds)">
<span class="ds-info-value">{{ lastSyncTime(ds) }}</span>
</t-tooltip>
</div> </div>
<div class="ds-info-cell"> <div class="ds-info-cell">
<span class="ds-info-label">{{ t('datasource.lastStatus') }}</span> <span class="ds-info-label">{{ t('datasource.lastStatus') }}</span>
<span class="ds-info-value"> <span class="ds-info-value">
<span v-if="ds.latest_sync_log" :style="{ color: lastSyncStatusColor(ds) }">{{ lastSyncStatusLabel(ds) }}</span> <template v-if="ds.latest_sync_log">
<span v-else>--</span> <span :style="{ color: lastSyncStatusColor(ds), fontWeight: 500 }">{{ lastSyncStatusLabel(ds) }}</span>
<span v-for="pill in syncResultPills(ds)" :key="pill.cls" :class="['ds-pill', pill.cls]">{{ pill.text }}</span> <span v-for="pill in syncResultPills(ds)" :key="pill.cls" :class="['ds-pill', pill.cls]">{{ pill.text }}</span>
</template>
<span v-else class="ds-info-placeholder">--</span>
</span> </span>
</div> </div>
</div> </div>
<div v-if="ds.error_message" class="ds-error"> <div v-if="ds.error_message" class="ds-error">
<t-icon name="error-circle" size="14px" /> <t-icon name="error-circle-filled" size="14px" />
{{ ds.error_message }} <span>{{ ds.error_message }}</span>
</div>
<!-- Quick action -->
<div class="ds-card-footer">
<t-button size="small" variant="outline" theme="primary" @click="handleSync(ds)">
<template #icon><t-icon name="refresh" /></template>
{{ t('datasource.syncNow') }}
</t-button>
<t-button size="small" variant="text" @click="openLogs(ds)">
{{ t('datasource.logs') }}
</t-button>
</div> </div>
</div> </div>
<!-- Add card at the end -->
<div class="ds-card-add" @click="openCreate"> <div class="ds-card-add" @click="openCreate">
<t-icon name="add" size="20px" /> <t-icon name="add" size="18px" />
<span>{{ t('datasource.addCard') }}</span> <span>{{ t('datasource.addCard') }}</span>
</div> </div>
</div> </div>
<!-- Editor dialog -->
<DataSourceEditorDialog <DataSourceEditorDialog
v-model:visible="editorVisible" v-model:visible="editorVisible"
:kb-id="kbId" :kb-id="kbId"
@@ -283,7 +300,6 @@ onMounted(loadList)
@saved="onEditorSaved" @saved="onEditorSaved"
/> />
<!-- Sync logs drawer -->
<DataSourceSyncLogs <DataSourceSyncLogs
v-model:visible="logsVisible" v-model:visible="logsVisible"
:data-source-id="logsDsId" :data-source-id="logsDsId"
@@ -297,79 +313,114 @@ onMounted(loadList)
padding: 0; padding: 0;
} }
/* --- Section header: matches KBModelConfig / KBStorageSettings pattern --- */ /* --- Section header --- */
.section-header { .section-header {
margin-bottom: 20px; margin-bottom: 20px;
} }
.section-title { .section-title {
margin: 0 0 8px 0; margin: 0 0 6px 0;
font-size: 20px; font-size: 18px;
font-weight: 600; font-weight: 600;
color: var(--td-text-color-primary); color: var(--td-text-color-primary);
letter-spacing: -0.01em;
} }
.section-desc { .section-desc {
margin: 0; margin: 0;
font-size: 14px; font-size: 13px;
color: var(--td-text-color-placeholder); color: var(--td-text-color-placeholder);
line-height: 22px; line-height: 20px;
} }
/* --- Loading / Empty --- */ /* --- Loading --- */
.ds-loading, .ds-empty { .ds-loading {
display: flex;
align-items: center;
justify-content: center;
padding: 60px 0;
}
/* --- Empty state --- */
.ds-empty {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding: 60px 0; padding: 56px 24px;
gap: 12px; gap: 16px;
color: var(--td-text-color-placeholder); border: 1px dashed var(--td-border-level-2-color);
border-radius: 12px;
background: var(--td-bg-color-container);
}
.ds-empty-icon {
width: 56px;
height: 56px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 14px;
background: var(--td-brand-color-light);
color: var(--td-brand-color);
}
.ds-empty-text {
text-align: center;
}
.ds-empty-title {
margin: 0;
font-size: 14px;
color: var(--td-text-color-secondary);
line-height: 22px;
} }
/* --- List --- */ /* --- List --- */
.ds-list { .ds-list {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 12px; gap: 10px;
} }
/* --- Card --- */ /* --- Card --- */
.ds-card { .ds-card {
position: relative;
border: 1px solid var(--td-border-level-2-color); border: 1px solid var(--td-border-level-2-color);
border-radius: 8px; border-radius: 10px;
padding: 16px; padding: 16px 18px;
transition: border-color 0.2s; background: var(--td-bg-color-container);
transition: border-color 0.2s, box-shadow 0.2s;
} }
.ds-card:hover { .ds-card:hover {
border-color: var(--td-brand-color-hover); border-color: var(--td-brand-color-hover);
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
} }
/* --- Card header --- */
.ds-card-header { .ds-card-header {
display: flex; display: flex;
align-items: flex-start;
justify-content: space-between; justify-content: space-between;
align-items: center; gap: 12px;
margin-bottom: 12px;
} }
.ds-card-title { .ds-card-identity {
display: flex;
flex-direction: column;
gap: 2px;
min-width: 0;
flex: 1;
}
.ds-name-row {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; gap: 8px;
min-width: 0; min-width: 0;
} }
.ds-type-badge {
font-size: 11px;
padding: 2px 8px;
border-radius: 4px;
background: var(--td-brand-color-light);
color: var(--td-brand-color);
font-weight: 500;
flex-shrink: 0;
}
.ds-name { .ds-name {
font-size: 14px; font-size: 14px;
font-weight: 600; font-weight: 600;
@@ -377,35 +428,32 @@ onMounted(loadList)
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
line-height: 22px;
} }
.ds-card-header-right { .ds-type-label {
display: flex;
align-items: center;
gap: 8px;
flex-shrink: 0;
}
.ds-status {
display: flex;
align-items: center;
gap: 6px;
font-size: 12px; font-size: 12px;
color: var(--td-text-color-secondary); color: var(--td-text-color-placeholder);
line-height: 18px;
} }
.ds-status-dot { .ds-card-actions {
width: 6px; display: flex;
height: 6px; align-items: center;
border-radius: 50%; gap: 2px;
flex-shrink: 0;
margin-top: 2px;
} }
/* --- Info grid --- */ /* --- Info grid --- */
.ds-card-body { .ds-card-body {
display: grid; display: grid;
grid-template-columns: 1fr 1fr; grid-template-columns: 1fr 1fr;
gap: 8px 24px; gap: 10px 24px;
margin-bottom: 12px; margin-top: 14px;
padding: 12px 14px;
background: var(--td-bg-color-secondarycontainer);
border-radius: 8px;
} }
.ds-info-cell { .ds-info-cell {
@@ -415,8 +463,9 @@ onMounted(loadList)
} }
.ds-info-label { .ds-info-label {
font-size: 11px; font-size: 12px;
color: var(--td-text-color-placeholder); color: var(--td-text-color-placeholder);
line-height: 18px;
} }
.ds-info-value { .ds-info-value {
@@ -426,13 +475,18 @@ onMounted(loadList)
align-items: center; align-items: center;
gap: 4px; gap: 4px;
flex-wrap: wrap; flex-wrap: wrap;
line-height: 20px;
}
.ds-info-placeholder {
color: var(--td-text-color-placeholder);
} }
/* --- Sync result pills --- */ /* --- Sync result pills --- */
.ds-pill { .ds-pill {
font-size: 11px; font-size: 11px;
padding: 0 5px; padding: 1px 6px;
border-radius: 3px; border-radius: 4px;
font-weight: 500; font-weight: 500;
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
line-height: 18px; line-height: 18px;
@@ -442,9 +496,9 @@ onMounted(loadList)
.ds-pill.updated { background: var(--td-brand-color-light); color: var(--td-brand-color); } .ds-pill.updated { background: var(--td-brand-color-light); color: var(--td-brand-color); }
.ds-pill.deleted { background: var(--td-warning-color-1); color: var(--td-warning-color); } .ds-pill.deleted { background: var(--td-warning-color-1); color: var(--td-warning-color); }
.ds-pill.skipped { background: var(--td-bg-color-component); color: var(--td-text-color-placeholder); } .ds-pill.skipped { background: var(--td-bg-color-component); color: var(--td-text-color-placeholder); }
.ds-pill.failed { background: var(--td-error-color-1); color: var(--td-error-color); } .ds-pill.failed { background: var(--td-error-color-1); color: var(--td-error-color); }
/* --- Error --- */ /* --- Error alert --- */
.ds-error { .ds-error {
display: flex; display: flex;
align-items: flex-start; align-items: flex-start;
@@ -452,18 +506,10 @@ onMounted(loadList)
color: var(--td-error-color); color: var(--td-error-color);
font-size: 12px; font-size: 12px;
background: var(--td-error-color-1); background: var(--td-error-color-1);
padding: 6px 10px; padding: 8px 12px;
border-radius: 4px; border-radius: 6px;
margin-bottom: 12px; margin-top: 10px;
} line-height: 20px;
/* --- Footer actions --- */
.ds-card-footer {
display: flex;
align-items: center;
gap: 8px;
border-top: 1px solid var(--td-border-level-2-color);
padding-top: 12px;
} }
/* --- Add card --- */ /* --- Add card --- */
@@ -472,11 +518,11 @@ onMounted(loadList)
align-items: center; align-items: center;
justify-content: center; justify-content: center;
gap: 6px; gap: 6px;
padding: 12px; padding: 14px;
border: 1px dashed var(--td-border-level-2-color); border: 1px dashed var(--td-border-level-2-color);
border-radius: 8px; border-radius: 10px;
color: var(--td-text-color-placeholder); color: var(--td-text-color-placeholder);
font-size: 12px; font-size: 13px;
cursor: pointer; cursor: pointer;
transition: all 0.2s; transition: all 0.2s;
} }
@@ -484,6 +530,6 @@ onMounted(loadList)
.ds-card-add:hover { .ds-card-add:hover {
border-color: var(--td-brand-color); border-color: var(--td-brand-color);
color: var(--td-brand-color); color: var(--td-brand-color);
background: var(--td-brand-color-light); background: rgba(0, 82, 217, 0.04);
} }
</style> </style>
@@ -14,15 +14,20 @@ const logs = ref<SyncLog[]>([])
const loading = ref(false) const loading = ref(false)
const expandedId = ref('') const expandedId = ref('')
watch(visible, async (v) => { async function fetchLogs() {
if (!v || !props.dataSourceId) return if (!props.dataSourceId) return
expandedId.value = ''
loading.value = true loading.value = true
try { try {
const res = await getSyncLogs(props.dataSourceId, 50, 0) const res = await getSyncLogs(props.dataSourceId, 50, 0)
logs.value = res?.data || res || [] logs.value = res?.data || res || []
} catch { /* ignore */ } } catch { /* ignore */ }
loading.value = false loading.value = false
}
watch(visible, (v) => {
if (!v) return
expandedId.value = ''
fetchLogs()
}) })
function toggleExpand(id: string) { function toggleExpand(id: string) {
@@ -122,11 +127,29 @@ const groupedLogs = computed(() => {
<template> <template>
<t-drawer <t-drawer
v-model:visible="visible" v-model:visible="visible"
:header="props.dataSourceName ? `${t('datasource.syncHistory')} · ${props.dataSourceName}` : t('datasource.syncHistory')"
size="480px" size="480px"
destroy-on-close destroy-on-close
class="ds-logs-drawer" class="ds-logs-drawer"
> >
<template #header>
<div class="logs-drawer-header">
<span class="logs-drawer-title">
{{ props.dataSourceName ? `${t('datasource.syncHistory')} · ${props.dataSourceName}` : t('datasource.syncHistory') }}
</span>
<t-tooltip :content="t('datasource.refreshLogs')">
<t-button
size="small"
variant="text"
shape="square"
:loading="loading"
@click="fetchLogs"
>
<template #icon><t-icon name="refresh" /></template>
</t-button>
</t-tooltip>
</div>
</template>
<div v-if="loading" style="text-align:center;padding:60px"><t-loading /></div> <div v-if="loading" style="text-align:center;padding:60px"><t-loading /></div>
<div v-else-if="logs.length === 0" class="logs-empty"> <div v-else-if="logs.length === 0" class="logs-empty">
@@ -432,10 +455,25 @@ const groupedLogs = computed(() => {
word-break: break-word; word-break: break-word;
} }
/* --- Drawer overrides --- */ /* --- Drawer header --- */
.ds-logs-drawer :deep(.t-drawer__header) { .logs-drawer-header {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
}
.logs-drawer-title {
font-size: 15px; font-size: 15px;
font-weight: 600; font-weight: 600;
color: var(--td-text-color-primary);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* --- Drawer overrides --- */
.ds-logs-drawer :deep(.t-drawer__header) {
padding: 16px 24px; padding: 16px 24px;
border-bottom: 1px solid var(--td-border-level-2-color); border-bottom: 1px solid var(--td-border-level-2-color);
} }
@@ -446,7 +446,7 @@ func (s *DataSourceService) ProcessSync(ctx context.Context, task *asynq.Task) e
// Auto-tag: find or create a tag for this data source so synced items are easily identifiable // Auto-tag: find or create a tag for this data source so synced items are easily identifiable
autoTagID := "" autoTagID := ""
autoTagName := connectorDisplayLabel(ds.Type) + "·" + ds.Name autoTagName := ds.Name
if autoTag, tagErr := s.tagService.FindOrCreateTagByName(ctx, ds.KnowledgeBaseID, autoTagName); tagErr != nil { if autoTag, tagErr := s.tagService.FindOrCreateTagByName(ctx, ds.KnowledgeBaseID, autoTagName); tagErr != nil {
logger.Warnf(ctx, "failed to find/create auto-tag %q: %v (proceeding without tag)", autoTagName, tagErr) logger.Warnf(ctx, "failed to find/create auto-tag %q: %v (proceeding without tag)", autoTagName, tagErr)
} else if autoTag != nil { } else if autoTag != nil {
@@ -687,27 +687,3 @@ func timePtr(t time.Time) *time.Time {
utc := t.UTC() utc := t.UTC()
return &utc return &utc
} }
// connectorDisplayLabel returns a human-readable label for a connector type.
// Used to generate auto-tag names like "飞书·我的知识库".
func connectorDisplayLabel(connectorType string) string {
labels := map[string]string{
"feishu": "飞书",
"notion": "Notion",
"confluence": "Confluence",
"yuque": "语雀",
"github": "GitHub",
"google_drive": "Google Drive",
"onedrive": "OneDrive",
"dingtalk": "钉钉",
"wecom_doc": "企微文档",
"web_crawler": "网页爬虫",
"slack": "Slack",
"imap": "邮件",
"rss": "RSS",
}
if l, ok := labels[connectorType]; ok {
return l
}
return connectorType
}