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',
},
syncHistory: 'Sync History',
refreshLogs: 'Refresh logs',
noLogs: 'No sync records yet',
logStatus: {
running: 'Syncing',
+2
View File
@@ -3411,6 +3411,7 @@ export default {
resumed: "재개됨",
pauseFailed: "일시정지 실패",
logs: "로그",
moreActions: "추가 작업",
lastSync: "마지막 동기화",
lastStatus: "결과",
schedule: "동기화 주기",
@@ -3461,6 +3462,7 @@ export default {
strategy: "동기화 전략",
},
syncHistory: "동기화 이력",
refreshLogs: "로그 새로고침",
noLogs: "동기화 기록이 없습니다",
logStatus: {
running: "동기화 중",
+2
View File
@@ -3318,6 +3318,7 @@ export default {
resumed: 'Возобновлено',
pauseFailed: 'Не удалось приостановить',
logs: 'Журнал',
moreActions: 'Дополнительные действия',
lastSync: 'Последняя синхронизация',
lastStatus: 'Результат',
schedule: 'Расписание',
@@ -3368,6 +3369,7 @@ export default {
strategy: 'Стратегия',
},
syncHistory: 'История синхронизации',
refreshLogs: 'Обновить журнал',
noLogs: 'Нет записей синхронизации',
logStatus: {
running: 'Синхронизация',
+1
View File
@@ -3417,6 +3417,7 @@ export default {
strategy: "同步策略",
},
syncHistory: "同步历史",
refreshLogs: "刷新日志",
noLogs: "暂无同步记录",
logStatus: {
running: "同步中",
@@ -25,6 +25,7 @@
>
<t-icon :name="item.icon" class="nav-icon" />
<span class="nav-label">{{ item.label }}</span>
<span v-if="item.badge" class="nav-badge">{{ item.badge }}</span>
</div>
</div>
</div>
@@ -214,7 +215,7 @@
<!-- 数据源管理(仅编辑模式) -->
<div v-if="mode === 'edit' && kbId" v-show="currentSection === 'datasource'" class="section">
<DataSourceSettings :kb-id="kbId" />
<DataSourceSettings :kb-id="kbId" @count="dsCount = $event" />
</div>
<!-- 共享设置(仅编辑模式) -->
@@ -281,9 +282,10 @@ const loading = ref(false)
const allModels = ref<any[]>([])
const hasFiles = ref(false)
const initialStorageProvider = ref<string>('')
const dsCount = ref(0)
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: '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: 'advanced', icon: 'setting', label: t('knowledgeEditor.sidebar.advanced') }
)
// 数据源管理:仅文档类型知识库 + 编辑模式
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) {
items.push({ key: 'share', icon: 'share', label: t('knowledgeEditor.sidebar.share') })
}
@@ -925,6 +925,27 @@ watch(
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 {
flex: 1;
display: flex;
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { MessagePlugin } from 'tdesign-vue-next'
import { MessagePlugin, DialogPlugin } from 'tdesign-vue-next'
import { useI18n } from 'vue-i18n'
import {
listDataSources,
@@ -15,6 +15,7 @@ import DataSourceEditorDialog from './DataSourceEditorDialog.vue'
import DataSourceSyncLogs from './DataSourceSyncLogs.vue'
const props = defineProps<{ kbId: string }>()
const emit = defineEmits<{ (e: 'count', value: number): void }>()
const { t } = useI18n()
const dataSources = ref<DataSource[]>([])
@@ -25,11 +26,13 @@ const logsVisible = ref(false)
const logsDsId = ref('')
const logsDsName = ref('')
async function loadList() {
loading.value = true
try {
const res = await listDataSources(props.kbId)
dataSources.value = res?.data || res || []
emit('count', dataSources.value.length)
} catch (e: any) {
console.error(e)
} finally {
@@ -53,14 +56,23 @@ function openLogs(ds: DataSource) {
logsVisible.value = true
}
async function handleDelete(ds: DataSource) {
try {
await deleteDataSource(ds.id)
MessagePlugin.success(t('datasource.deleteSuccess'))
loadList()
} catch {
MessagePlugin.error(t('datasource.deleteFailed'))
}
function handleDelete(ds: DataSource) {
const confirmDialog = DialogPlugin.confirm({
header: t('datasource.delete'),
body: t('datasource.deleteConfirm'),
confirmBtn: { content: t('datasource.delete'), theme: 'danger' },
cancelBtn: t('common.cancel'),
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) {
@@ -93,10 +105,11 @@ async function handleResume(ds: DataSource) {
}
}
function statusColor(status: string) {
if (status === 'active') return 'var(--td-success-color)'
if (status === 'error') return 'var(--td-error-color)'
return 'var(--td-text-color-placeholder)'
function statusTheme(status: string): 'success' | 'danger' | 'default' | 'warning' {
if (status === 'active') return 'success'
if (status === 'error') return 'danger'
if (status === 'paused') return 'warning'
return 'default'
}
function statusLabel(status: string) {
@@ -124,7 +137,6 @@ function lastSyncFullTime(ds: DataSource) {
return new Date(ds.last_sync_at).toLocaleString()
}
// Build sync result pills from latest_sync_log
function syncResultPills(ds: DataSource) {
const log = ds.latest_sync_log
if (!log) return []
@@ -165,47 +177,62 @@ onMounted(loadList)
<template>
<div class="ds-settings">
<!-- Section header: title only, no button here -->
<div class="section-header">
<h2 class="section-title">{{ t('datasource.title') }}</h2>
<p class="section-desc">{{ t('datasource.description') }}</p>
</div>
<div v-if="loading" class="ds-loading">
<t-loading />
<t-loading size="small" />
</div>
<div v-else-if="dataSources.length === 0" class="ds-empty">
<t-icon name="cloud-download" size="48px" style="color: var(--td-text-color-placeholder)" />
<p>{{ t('datasource.empty') }}</p>
<t-button variant="outline" @click="openCreate">{{ t('datasource.addFirst') }}</t-button>
<div class="ds-empty-icon">
<t-icon name="cloud-download" size="32px" />
</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 v-else class="ds-list">
<!-- Data source cards -->
<div v-for="ds in dataSources" :key="ds.id" class="ds-card">
<div class="ds-card-header">
<div class="ds-card-title">
<span class="ds-type-badge">{{ connectorLabel(ds.type) }}</span>
<span class="ds-name">{{ ds.name }}</span>
</div>
<div class="ds-card-header-right">
<div class="ds-status">
<span class="ds-status-dot" :style="{ background: statusColor(ds.status) }"></span>
{{ statusLabel(ds.status) }}
<div class="ds-card-identity">
<div class="ds-name-row">
<span class="ds-name">{{ ds.name }}</span>
<t-tag size="small" :theme="statusTheme(ds.status)" variant="light-outline">
{{ statusLabel(ds.status) }}
</t-tag>
</div>
<t-dropdown trigger="click" :min-column-width="100">
<t-button size="small" variant="text" shape="square">
<template #icon><t-icon name="more" /></template>
<span class="ds-type-label">{{ connectorLabel(ds.type) }}</span>
</div>
<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-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>
<t-dropdown-menu>
<t-dropdown-item @click="openEdit(ds)">
<t-icon name="edit" /> {{ t('datasource.edit') }}
</t-dropdown-item>
<t-dropdown-item @click="openLogs(ds)">
<t-icon name="history" /> {{ t('datasource.logs') }}
</t-dropdown-item>
<t-dropdown-item
v-if="ds.status === 'active'"
@click="handlePause(ds)"
@@ -227,7 +254,6 @@ onMounted(loadList)
</div>
</div>
<!-- Info grid -->
<div class="ds-card-body">
<div class="ds-info-cell">
<span class="ds-info-label">{{ t('datasource.syncModeLabel') }}</span>
@@ -239,43 +265,34 @@ onMounted(loadList)
</div>
<div class="ds-info-cell">
<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 class="ds-info-cell">
<span class="ds-info-label">{{ t('datasource.lastStatus') }}</span>
<span class="ds-info-value">
<span v-if="ds.latest_sync_log" :style="{ color: lastSyncStatusColor(ds) }">{{ lastSyncStatusLabel(ds) }}</span>
<span v-else>--</span>
<span v-for="pill in syncResultPills(ds)" :key="pill.cls" :class="['ds-pill', pill.cls]">{{ pill.text }}</span>
<template v-if="ds.latest_sync_log">
<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>
</template>
<span v-else class="ds-info-placeholder">--</span>
</span>
</div>
</div>
<div v-if="ds.error_message" class="ds-error">
<t-icon name="error-circle" size="14px" />
{{ ds.error_message }}
</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>
<t-icon name="error-circle-filled" size="14px" />
<span>{{ ds.error_message }}</span>
</div>
</div>
<!-- Add card at the end -->
<div class="ds-card-add" @click="openCreate">
<t-icon name="add" size="20px" />
<t-icon name="add" size="18px" />
<span>{{ t('datasource.addCard') }}</span>
</div>
</div>
<!-- Editor dialog -->
<DataSourceEditorDialog
v-model:visible="editorVisible"
:kb-id="kbId"
@@ -283,7 +300,6 @@ onMounted(loadList)
@saved="onEditorSaved"
/>
<!-- Sync logs drawer -->
<DataSourceSyncLogs
v-model:visible="logsVisible"
:data-source-id="logsDsId"
@@ -297,79 +313,114 @@ onMounted(loadList)
padding: 0;
}
/* --- Section header: matches KBModelConfig / KBStorageSettings pattern --- */
/* --- Section header --- */
.section-header {
margin-bottom: 20px;
}
.section-title {
margin: 0 0 8px 0;
font-size: 20px;
margin: 0 0 6px 0;
font-size: 18px;
font-weight: 600;
color: var(--td-text-color-primary);
letter-spacing: -0.01em;
}
.section-desc {
margin: 0;
font-size: 14px;
font-size: 13px;
color: var(--td-text-color-placeholder);
line-height: 22px;
line-height: 20px;
}
/* --- Loading / Empty --- */
.ds-loading, .ds-empty {
/* --- Loading --- */
.ds-loading {
display: flex;
align-items: center;
justify-content: center;
padding: 60px 0;
}
/* --- Empty state --- */
.ds-empty {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 60px 0;
gap: 12px;
color: var(--td-text-color-placeholder);
padding: 56px 24px;
gap: 16px;
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 --- */
.ds-list {
display: flex;
flex-direction: column;
gap: 12px;
gap: 10px;
}
/* --- Card --- */
.ds-card {
position: relative;
border: 1px solid var(--td-border-level-2-color);
border-radius: 8px;
padding: 16px;
transition: border-color 0.2s;
border-radius: 10px;
padding: 16px 18px;
background: var(--td-bg-color-container);
transition: border-color 0.2s, box-shadow 0.2s;
}
.ds-card:hover {
border-color: var(--td-brand-color-hover);
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}
/* --- Card header --- */
.ds-card-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
gap: 12px;
}
.ds-card-title {
.ds-card-identity {
display: flex;
flex-direction: column;
gap: 2px;
min-width: 0;
flex: 1;
}
.ds-name-row {
display: flex;
align-items: center;
gap: 8px;
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 {
font-size: 14px;
font-weight: 600;
@@ -377,35 +428,32 @@ onMounted(loadList)
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
line-height: 22px;
}
.ds-card-header-right {
display: flex;
align-items: center;
gap: 8px;
flex-shrink: 0;
}
.ds-status {
display: flex;
align-items: center;
gap: 6px;
.ds-type-label {
font-size: 12px;
color: var(--td-text-color-secondary);
color: var(--td-text-color-placeholder);
line-height: 18px;
}
.ds-status-dot {
width: 6px;
height: 6px;
border-radius: 50%;
.ds-card-actions {
display: flex;
align-items: center;
gap: 2px;
flex-shrink: 0;
margin-top: 2px;
}
/* --- Info grid --- */
.ds-card-body {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px 24px;
margin-bottom: 12px;
gap: 10px 24px;
margin-top: 14px;
padding: 12px 14px;
background: var(--td-bg-color-secondarycontainer);
border-radius: 8px;
}
.ds-info-cell {
@@ -415,8 +463,9 @@ onMounted(loadList)
}
.ds-info-label {
font-size: 11px;
font-size: 12px;
color: var(--td-text-color-placeholder);
line-height: 18px;
}
.ds-info-value {
@@ -426,13 +475,18 @@ onMounted(loadList)
align-items: center;
gap: 4px;
flex-wrap: wrap;
line-height: 20px;
}
.ds-info-placeholder {
color: var(--td-text-color-placeholder);
}
/* --- Sync result pills --- */
.ds-pill {
font-size: 11px;
padding: 0 5px;
border-radius: 3px;
padding: 1px 6px;
border-radius: 4px;
font-weight: 500;
font-variant-numeric: tabular-nums;
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.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.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 {
display: flex;
align-items: flex-start;
@@ -452,18 +506,10 @@ onMounted(loadList)
color: var(--td-error-color);
font-size: 12px;
background: var(--td-error-color-1);
padding: 6px 10px;
border-radius: 4px;
margin-bottom: 12px;
}
/* --- 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;
padding: 8px 12px;
border-radius: 6px;
margin-top: 10px;
line-height: 20px;
}
/* --- Add card --- */
@@ -472,11 +518,11 @@ onMounted(loadList)
align-items: center;
justify-content: center;
gap: 6px;
padding: 12px;
padding: 14px;
border: 1px dashed var(--td-border-level-2-color);
border-radius: 8px;
border-radius: 10px;
color: var(--td-text-color-placeholder);
font-size: 12px;
font-size: 13px;
cursor: pointer;
transition: all 0.2s;
}
@@ -484,6 +530,6 @@ onMounted(loadList)
.ds-card-add:hover {
border-color: var(--td-brand-color);
color: var(--td-brand-color);
background: var(--td-brand-color-light);
background: rgba(0, 82, 217, 0.04);
}
</style>
@@ -14,15 +14,20 @@ const logs = ref<SyncLog[]>([])
const loading = ref(false)
const expandedId = ref('')
watch(visible, async (v) => {
if (!v || !props.dataSourceId) return
expandedId.value = ''
async function fetchLogs() {
if (!props.dataSourceId) return
loading.value = true
try {
const res = await getSyncLogs(props.dataSourceId, 50, 0)
logs.value = res?.data || res || []
} catch { /* ignore */ }
loading.value = false
}
watch(visible, (v) => {
if (!v) return
expandedId.value = ''
fetchLogs()
})
function toggleExpand(id: string) {
@@ -122,11 +127,29 @@ const groupedLogs = computed(() => {
<template>
<t-drawer
v-model:visible="visible"
:header="props.dataSourceName ? `${t('datasource.syncHistory')} · ${props.dataSourceName}` : t('datasource.syncHistory')"
size="480px"
destroy-on-close
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-else-if="logs.length === 0" class="logs-empty">
@@ -432,10 +455,25 @@ const groupedLogs = computed(() => {
word-break: break-word;
}
/* --- Drawer overrides --- */
.ds-logs-drawer :deep(.t-drawer__header) {
/* --- Drawer header --- */
.logs-drawer-header {
display: flex;
align-items: center;
justify-content: space-between;
width: 100%;
}
.logs-drawer-title {
font-size: 15px;
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;
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
autoTagID := ""
autoTagName := connectorDisplayLabel(ds.Type) + "·" + ds.Name
autoTagName := ds.Name
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)
} else if autoTag != nil {
@@ -687,27 +687,3 @@ func timePtr(t time.Time) *time.Time {
utc := t.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
}