feat(i18n): replace hardcoded Chinese strings with i18n calls across frontend
Replace all user-visible hardcoded Chinese strings in Vue/TS source files
with proper i18n function calls and add corresponding translation keys
to all 4 locale files (zh-CN, en-US, ko-KR, ru-RU).
Changes:
- Replace 80+ hardcoded Chinese strings across 30+ source files
- Add ~450 new translation keys per locale file
- Cover components, views, utils, hooks, and API modules
- Remove Chinese fallback patterns (|| '中文') from existing t() calls
- Add mermaid toolbar and ollama date format translations
Intentionally preserved (backend API values / backward compatibility):
- FAQ CSV column headers and parsing constants
- RelevanceLevel type and Record key mappings
- Graph database engine status comparison ('未启用')
- Language name labels ('简体中文')
This commit is contained in:
@@ -175,7 +175,7 @@ let docSearchDebounce: ReturnType<typeof setTimeout> | null = null;
|
||||
const docSearchKeyword = ref('');
|
||||
const selectedFileType = ref('');
|
||||
const fileTypeOptions = computed(() => [
|
||||
{ content: t('knowledgeBase.allFileTypes') || '全部类型', value: '' },
|
||||
{ content: t('knowledgeBase.allFileTypes'), value: '' },
|
||||
{ content: 'PDF', value: 'pdf' },
|
||||
{ content: 'DOCX', value: 'docx' },
|
||||
{ content: 'DOC', value: 'doc' },
|
||||
@@ -184,7 +184,7 @@ const fileTypeOptions = computed(() => [
|
||||
{ content: 'TXT', value: 'txt' },
|
||||
{ content: 'MD', value: 'md' },
|
||||
{ content: 'URL', value: 'url' },
|
||||
{ content: t('knowledgeBase.typeManual') || '手动创建', value: 'manual' },
|
||||
{ content: t('knowledgeBase.typeManual'), value: 'manual' },
|
||||
]);
|
||||
type TagInputInstance = ComponentPublicInstance<{ focus: () => void; select: () => void }>;
|
||||
const tagDropdownOptions = computed(() =>
|
||||
@@ -261,7 +261,7 @@ const getKnowledgeType = (item: any) => {
|
||||
return t('knowledgeBase.typeURL') || 'URL';
|
||||
}
|
||||
if (item.type === 'manual') {
|
||||
return t('knowledgeBase.typeManual') || '手动创建';
|
||||
return t('knowledgeBase.typeManual');
|
||||
}
|
||||
if (item.file_type) {
|
||||
return item.file_type.toUpperCase();
|
||||
@@ -486,7 +486,7 @@ const handleKnowledgeTagChange = async (knowledgeId: string, tagValue: string) =
|
||||
// Pass the tag value directly (empty string means no tag)
|
||||
const tagIdToUpdate = tagValue || null;
|
||||
await updateKnowledgeTagBatch({ updates: { [knowledgeId]: tagIdToUpdate } });
|
||||
MessagePlugin.success(t('knowledgeBase.tagUpdateSuccess') || '分类已更新');
|
||||
MessagePlugin.success(t('knowledgeBase.tagUpdateSuccess'));
|
||||
loadKnowledgeFiles(kbId.value);
|
||||
loadTags(kbId.value);
|
||||
} catch (error: any) {
|
||||
@@ -824,7 +824,7 @@ const handleDocumentActionSelect = (data: { value: string }) => {
|
||||
|
||||
const ensureDocumentKbReady = () => {
|
||||
if (isFAQ.value) {
|
||||
MessagePlugin.warning('当前知识库类型不支持该操作');
|
||||
MessagePlugin.warning(t('knowledgeBase.operationNotSupportedForType'));
|
||||
return false;
|
||||
}
|
||||
if (!kbId.value) {
|
||||
@@ -861,7 +861,7 @@ const handleDocumentUpload = async (event: Event) => {
|
||||
if (!files || files.length === 0) return;
|
||||
|
||||
if (!kbId.value) {
|
||||
MessagePlugin.error("缺少知识库ID");
|
||||
MessagePlugin.error(t('error.missingKbId'));
|
||||
resetUploadInput();
|
||||
return;
|
||||
}
|
||||
@@ -880,13 +880,13 @@ const handleDocumentUpload = async (event: Event) => {
|
||||
|
||||
if (validFiles.length === 0) {
|
||||
if (skippedCount > 0) {
|
||||
MessagePlugin.warning(`所选文件类型暂无可用解析引擎,已全部跳过`);
|
||||
MessagePlugin.warning(t('knowledgeBase.allFilesSkippedNoEngine'));
|
||||
}
|
||||
resetUploadInput();
|
||||
return;
|
||||
}
|
||||
if (skippedCount > 0) {
|
||||
MessagePlugin.warning(`${skippedCount} 个文件因无可用解析引擎被跳过`);
|
||||
MessagePlugin.warning(t('knowledgeBase.filesSkippedNoEngine', { count: skippedCount }));
|
||||
}
|
||||
|
||||
let successCount = 0;
|
||||
@@ -904,14 +904,14 @@ const handleDocumentUpload = async (event: Event) => {
|
||||
successCount++;
|
||||
} else {
|
||||
failCount++;
|
||||
let errorMessage = "上传失败!";
|
||||
let errorMessage = t('knowledgeBase.uploadFailed');
|
||||
if (responseData?.error?.message) {
|
||||
errorMessage = responseData.error.message;
|
||||
} else if (responseData?.message) {
|
||||
errorMessage = responseData.message;
|
||||
}
|
||||
if (responseData?.code === 'duplicate_file' || responseData?.error?.code === 'duplicate_file') {
|
||||
errorMessage = "文件已存在";
|
||||
errorMessage = t('knowledgeBase.fileExists');
|
||||
}
|
||||
if (totalCount === 1) {
|
||||
MessagePlugin.error(errorMessage);
|
||||
@@ -919,7 +919,7 @@ const handleDocumentUpload = async (event: Event) => {
|
||||
}
|
||||
} catch (error: any) {
|
||||
failCount++;
|
||||
let errorMessage = error?.error?.message || error?.message || "上传失败!";
|
||||
let errorMessage = error?.error?.message || error?.message || t('knowledgeBase.uploadFailed');
|
||||
if (error?.code === 'duplicate_file') {
|
||||
errorMessage = "文件已存在";
|
||||
}
|
||||
@@ -938,15 +938,15 @@ const handleDocumentUpload = async (event: Event) => {
|
||||
|
||||
if (totalCount === 1) {
|
||||
if (successCount === 1) {
|
||||
MessagePlugin.success("上传成功!");
|
||||
MessagePlugin.success(t('knowledgeBase.uploadSuccess'));
|
||||
}
|
||||
} else {
|
||||
if (failCount === 0) {
|
||||
MessagePlugin.success(`所有文件上传成功(${successCount}个)`);
|
||||
MessagePlugin.success(t('knowledgeBase.allUploadSuccess', { count: successCount }));
|
||||
} else if (successCount > 0) {
|
||||
MessagePlugin.warning(`部分文件上传成功(成功:${successCount},失败:${failCount})`);
|
||||
MessagePlugin.warning(t('knowledgeBase.partialUploadSuccess', { success: successCount, fail: failCount }));
|
||||
} else {
|
||||
MessagePlugin.error(`所有文件上传失败(${failCount}个)`);
|
||||
MessagePlugin.error(t('knowledgeBase.allUploadFailed', { count: failCount }));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -960,7 +960,7 @@ const handleFolderUpload = async (event: Event) => {
|
||||
if (!files || files.length === 0) return;
|
||||
|
||||
if (!kbId.value) {
|
||||
MessagePlugin.error("缺少知识库ID");
|
||||
MessagePlugin.error(t('error.missingKbId'));
|
||||
if (input) input.value = '';
|
||||
return;
|
||||
}
|
||||
@@ -1075,7 +1075,7 @@ const handleURLImportCancel = () => {
|
||||
const handleURLImportConfirm = async () => {
|
||||
const url = urlInputValue.value.trim();
|
||||
if (!url) {
|
||||
MessagePlugin.warning(t('knowledgeBase.urlRequired') || '请输入URL');
|
||||
MessagePlugin.warning(t('knowledgeBase.urlRequired'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1083,12 +1083,12 @@ const handleURLImportConfirm = async () => {
|
||||
try {
|
||||
new URL(url);
|
||||
} catch (error) {
|
||||
MessagePlugin.warning(t('knowledgeBase.invalidURL') || '请输入有效的URL');
|
||||
MessagePlugin.warning(t('knowledgeBase.invalidURL'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!kbId.value) {
|
||||
MessagePlugin.error("缺少知识库ID");
|
||||
MessagePlugin.error(t('error.missingKbId'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1102,25 +1102,25 @@ const handleURLImportConfirm = async () => {
|
||||
}));
|
||||
const isSuccess = responseData?.success || responseData?.code === 200 || responseData?.status === 'success' || (!responseData?.error && responseData);
|
||||
if (isSuccess) {
|
||||
MessagePlugin.success(t('knowledgeBase.urlImportSuccess') || 'URL导入成功!');
|
||||
MessagePlugin.success(t('knowledgeBase.urlImportSuccess'));
|
||||
urlDialogVisible.value = false;
|
||||
urlInputValue.value = '';
|
||||
} else {
|
||||
let errorMessage = t('knowledgeBase.urlImportFailed') || "URL导入失败!";
|
||||
let errorMessage = t('knowledgeBase.urlImportFailed');
|
||||
if (responseData?.error?.message) {
|
||||
errorMessage = responseData.error.message;
|
||||
} else if (responseData?.message) {
|
||||
errorMessage = responseData.message;
|
||||
}
|
||||
if (responseData?.code === 'duplicate_url' || responseData?.error?.code === 'duplicate_url') {
|
||||
errorMessage = t('knowledgeBase.urlExists') || "该URL已存在";
|
||||
errorMessage = t('knowledgeBase.urlExists');
|
||||
}
|
||||
MessagePlugin.error(errorMessage);
|
||||
}
|
||||
} catch (error: any) {
|
||||
let errorMessage = error?.error?.message || error?.message || t('knowledgeBase.urlImportFailed') || "URL导入失败!";
|
||||
let errorMessage = error?.error?.message || error?.message || t('knowledgeBase.urlImportFailed');
|
||||
if (error?.code === 'duplicate_url') {
|
||||
errorMessage = t('knowledgeBase.urlExists') || "该URL已存在";
|
||||
errorMessage = t('knowledgeBase.urlExists');
|
||||
}
|
||||
MessagePlugin.error(errorMessage);
|
||||
} finally {
|
||||
@@ -1703,7 +1703,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
</div>
|
||||
<div class="card-popover-extra">
|
||||
<span v-if="(hoveredCardItem as any).created_at" class="card-popover-created">
|
||||
{{ t('knowledgeBase.createdAt') || '创建' }}:{{ formatDocTime((hoveredCardItem as any).created_at) }}
|
||||
{{ t('knowledgeBase.createdAt') }}:{{ formatDocTime((hoveredCardItem as any).created_at) }}
|
||||
</span>
|
||||
<span v-if="formatFileSize((hoveredCardItem as any).file_size)" class="card-popover-size">
|
||||
{{ formatFileSize((hoveredCardItem as any).file_size) }}
|
||||
@@ -1711,11 +1711,11 @@ async function createNewSession(value: string): Promise<void> {
|
||||
</div>
|
||||
</template>
|
||||
<div class="card-popover-meta">
|
||||
<span class="card-popover-time">{{ t('knowledgeBase.updatedAt') || '更新' }}:{{ formatDocTime(hoveredCardItem.updated_at) }}</span>
|
||||
<span class="card-popover-time">{{ t('knowledgeBase.updatedAt') }}:{{ formatDocTime(hoveredCardItem.updated_at) }}</span>
|
||||
<span v-if="getTagName(hoveredCardItem.tag_id)" class="card-popover-tag">{{ getTagName(hoveredCardItem.tag_id) }}</span>
|
||||
<span class="card-popover-type">{{ getKnowledgeType(hoveredCardItem) }}</span>
|
||||
</div>
|
||||
<div class="card-popover-hint">{{ t('knowledgeBase.clickToViewFull') || '点击卡片查看全文与分段' }}</div>
|
||||
<div class="card-popover-hint">{{ t('knowledgeBase.clickToViewFull') }}</div>
|
||||
</template>
|
||||
</div>
|
||||
</Teleport>
|
||||
@@ -1754,27 +1754,27 @@ async function createNewSession(value: string): Promise<void> {
|
||||
<!-- URL 导入对话框 -->
|
||||
<t-dialog
|
||||
v-model:visible="urlDialogVisible"
|
||||
:header="$t('knowledgeBase.importURLTitle') || '导入网页'"
|
||||
:header="$t('knowledgeBase.importURLTitle')"
|
||||
:confirm-btn="{
|
||||
content: $t('common.confirm') || '确认',
|
||||
content: $t('common.confirm'),
|
||||
theme: 'primary',
|
||||
loading: urlImporting,
|
||||
}"
|
||||
:cancel-btn="{ content: $t('common.cancel') || '取消' }"
|
||||
:cancel-btn="{ content: $t('common.cancel') }"
|
||||
@confirm="handleURLImportConfirm"
|
||||
@cancel="handleURLImportCancel"
|
||||
width="500px"
|
||||
>
|
||||
<div class="url-import-form">
|
||||
<div class="url-input-label">{{ $t('knowledgeBase.urlLabel') || 'URL地址' }}</div>
|
||||
<div class="url-input-label">{{ $t('knowledgeBase.urlLabel') }}</div>
|
||||
<t-input
|
||||
v-model="urlInputValue"
|
||||
:placeholder="$t('knowledgeBase.urlPlaceholder') || '请输入网页URL,例如:https://example.com'"
|
||||
:placeholder="$t('knowledgeBase.urlPlaceholder')"
|
||||
clearable
|
||||
autofocus
|
||||
@keydown.enter="handleURLImportConfirm"
|
||||
/>
|
||||
<div class="url-input-tip">{{ $t('knowledgeBase.urlTip') || '支持导入各类网页内容,系统会自动提取和解析网页中的文本内容' }}</div>
|
||||
<div class="url-input-tip">{{ $t('knowledgeBase.urlTip') }}</div>
|
||||
</div>
|
||||
</t-dialog>
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ const navItems = computed(() => {
|
||||
items.push({ key: 'faq', icon: 'help-circle', label: t('knowledgeEditor.sidebar.faq') })
|
||||
} else {
|
||||
items.push(
|
||||
{ key: 'parser', icon: 'file-search', label: '解析引擎' },
|
||||
{ key: 'parser', icon: 'file-search', label: t('settings.parserEngine') },
|
||||
{ key: 'storage', icon: 'cloud', label: t('knowledgeEditor.sidebar.storage') },
|
||||
{ key: 'chunking', icon: 'file-copy', label: t('knowledgeEditor.sidebar.chunking') },
|
||||
{ key: 'graph', icon: 'chart-bubble', label: t('knowledgeEditor.sidebar.graph') },
|
||||
|
||||
@@ -490,8 +490,8 @@
|
||||
<!-- 空间下知识库空状态 -->
|
||||
<div v-if="spaceSelectionOrgId && !spaceKbsLoading && spaceKbsList.length === 0" class="empty-state">
|
||||
<img class="empty-img" src="@/assets/img/upload.svg" alt="">
|
||||
<span class="empty-txt">{{ $t('knowledgeList.empty.sharedTitle') || '暂无共享知识库' }}</span>
|
||||
<span class="empty-desc">{{ $t('knowledgeList.empty.sharedDescription') || '您可以加入组织或请求他人共享知识库给您' }}</span>
|
||||
<span class="empty-txt">{{ $t('knowledgeList.empty.sharedTitle') }}</span>
|
||||
<span class="empty-desc">{{ $t('knowledgeList.empty.sharedDescription') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
<div class="import-result-header">
|
||||
<div class="header-left">
|
||||
<t-icon name="check-circle-filled" size="20px" class="result-icon" />
|
||||
<span class="result-title">最近导入结果</span>
|
||||
<span class="result-title">{{ $t('faqManager.import.recentResult') }}</span>
|
||||
</div>
|
||||
<div class="header-right">
|
||||
<span class="result-time">{{ formatImportTime(importResult.imported_at) }}</span>
|
||||
@@ -102,16 +102,16 @@
|
||||
<div class="import-result-body">
|
||||
<div class="import-result-stats">
|
||||
<div class="stat-item">
|
||||
<span class="stat-label">导入数据</span>
|
||||
<span class="stat-value">{{ importResult.total_entries }}条</span>
|
||||
<span class="stat-label">{{ $t('faqManager.import.totalData') }}</span>
|
||||
<span class="stat-value">{{ importResult.total_entries }}{{ $t('faqManager.import.unit') }}</span>
|
||||
</div>
|
||||
<div class="stat-item success">
|
||||
<span class="stat-label">成功</span>
|
||||
<span class="stat-value">{{ importResult.success_count }}条</span>
|
||||
<span class="stat-label">{{ $t('faqManager.import.success') }}</span>
|
||||
<span class="stat-value">{{ importResult.success_count }}{{ $t('faqManager.import.unit') }}</span>
|
||||
</div>
|
||||
<div v-if="importResult.failed_count > 0" class="stat-item failed">
|
||||
<span class="stat-label">失败</span>
|
||||
<span class="stat-value">{{ importResult.failed_count }}条</span>
|
||||
<span class="stat-label">{{ $t('faqManager.import.failed') }}</span>
|
||||
<span class="stat-value">{{ importResult.failed_count }}{{ $t('faqManager.import.unit') }}</span>
|
||||
<t-button
|
||||
v-if="importResult.failed_entries_url"
|
||||
variant="outline"
|
||||
@@ -121,17 +121,17 @@
|
||||
@click="downloadFailedEntries"
|
||||
>
|
||||
<t-icon name="download" size="14px" />
|
||||
下载原因
|
||||
{{ $t('faqManager.import.downloadReasons') }}
|
||||
</t-button>
|
||||
</div>
|
||||
<div v-if="importResult.skipped_count > 0" class="stat-item skipped">
|
||||
<span class="stat-label">跳过</span>
|
||||
<span class="stat-value">{{ importResult.skipped_count }}条</span>
|
||||
<span class="stat-label">{{ $t('faqManager.import.skipped') }}</span>
|
||||
<span class="stat-value">{{ importResult.skipped_count }}{{ $t('faqManager.import.unit') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="import-mode-tag">
|
||||
<t-tag size="small" variant="light" theme="success">
|
||||
{{ importResult.import_mode === 'append' ? '追加模式' : '替换模式' }}
|
||||
{{ importResult.import_mode === 'append' ? $t('faqManager.import.appendMode') : $t('faqManager.import.replaceMode') }}
|
||||
</t-tag>
|
||||
</div>
|
||||
</div>
|
||||
@@ -156,14 +156,14 @@
|
||||
}"
|
||||
/>
|
||||
<span class="progress-title">
|
||||
{{ importState.taskStatus.status === 'running' ? '导入中...' :
|
||||
importState.taskStatus.status === 'success' ? '导入完成' :
|
||||
importState.taskStatus.status === 'failed' ? '导入失败' : '等待中...' }}
|
||||
{{ importState.taskStatus.status === 'running' ? $t('faqManager.import.importing') :
|
||||
importState.taskStatus.status === 'success' ? $t('faqManager.import.importDone') :
|
||||
importState.taskStatus.status === 'failed' ? $t('faqManager.import.importFailed') : $t('faqManager.import.waiting') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="progress-right">
|
||||
<span class="progress-count">
|
||||
{{ importState.taskStatus.processed }}/{{ importState.taskStatus.total }} 条
|
||||
{{ importState.taskStatus.processed }}/{{ importState.taskStatus.total }} {{ $t('faqManager.import.unit') }}
|
||||
</span>
|
||||
<t-button
|
||||
v-if="importState.taskStatus.status === 'success' || importState.taskStatus.status === 'failed'"
|
||||
@@ -820,8 +820,8 @@
|
||||
|
||||
<div class="setting-row vertical">
|
||||
<div class="setting-info">
|
||||
<label>{{ $t('knowledgeBase.category') || '分类' }}</label>
|
||||
<p class="desc">{{ $t('knowledgeEditor.faq.tagDesc') || '为 FAQ 条目选择分类' }}</p>
|
||||
<label>{{ $t('knowledgeBase.category') }}</label>
|
||||
<p class="desc">{{ $t('knowledgeEditor.faq.tagDesc') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-select
|
||||
@@ -829,7 +829,7 @@
|
||||
class="full-width-input"
|
||||
:options="tagSelectOptions"
|
||||
clearable
|
||||
:placeholder="$t('knowledgeEditor.faq.tagPlaceholder') || '选择分类'"
|
||||
:placeholder="$t('knowledgeEditor.faq.tagPlaceholder')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -968,8 +968,8 @@
|
||||
:loading="importState.importing && !importState.taskId"
|
||||
:disabled="importState.taskStatus?.status === 'running'"
|
||||
>
|
||||
{{ importState.taskStatus?.status === 'success' ? $t('common.close') :
|
||||
importState.taskStatus?.status === 'failed' ? '重试' :
|
||||
{{ importState.taskStatus?.status === 'success' ? $t('common.close') :
|
||||
importState.taskStatus?.status === 'failed' ? $t('common.retry') :
|
||||
$t('knowledgeEditor.faqImport.importButton') }}
|
||||
</t-button>
|
||||
</div>
|
||||
@@ -1634,8 +1634,8 @@ const loadTags = async (reset = false) => {
|
||||
}
|
||||
|
||||
const getTagName = (tagId?: number) => {
|
||||
if (!tagId) return t('knowledgeBase.untagged') || '未分类'
|
||||
return tagMap.value[tagId]?.name || (t('knowledgeBase.untagged') || '未分类')
|
||||
if (!tagId) return t('knowledgeBase.untagged')
|
||||
return tagMap.value[tagId]?.name || (t('knowledgeBase.untagged'))
|
||||
}
|
||||
|
||||
const handleTagFilterChange = (value: number) => {
|
||||
@@ -1835,7 +1835,7 @@ const handleFaqMenuAction = (event: Event) => {
|
||||
} else if (detail.action === 'batch') {
|
||||
// 批量操作通过左侧菜单的下拉菜单处理
|
||||
if (selectedRowKeys.value.length === 0) {
|
||||
MessagePlugin.warning(t('knowledgeEditor.faq.selectEntriesFirst') || '请先选中要操作的FAQ条目')
|
||||
MessagePlugin.warning(t('knowledgeEditor.faq.selectEntriesFirst'))
|
||||
}
|
||||
} else if (detail.action === 'batchTag') {
|
||||
if (canEdit.value && selectedRowKeys.value.length > 0) {
|
||||
@@ -2239,7 +2239,7 @@ const handleMenuDelete = async (entry: FAQEntry) => {
|
||||
const openImportDialog = () => {
|
||||
// 如果正在导入,不允许打开导入对话框
|
||||
if (importState.taskStatus?.status === 'running') {
|
||||
MessagePlugin.warning('导入正在进行中,请等待完成后再试')
|
||||
MessagePlugin.warning(t('faqManager.import.importInProgress'))
|
||||
return
|
||||
}
|
||||
stopPolling()
|
||||
@@ -2344,7 +2344,7 @@ const parseCSVFile = async (file: File): Promise<FAQEntryPayload[]> => {
|
||||
}
|
||||
},
|
||||
error: (error: Error) => {
|
||||
reject(new Error(`CSV解析失败: ${error.message}`))
|
||||
reject(new Error(`CSV parse failed: ${error.message}`))
|
||||
},
|
||||
})
|
||||
})
|
||||
@@ -2702,7 +2702,7 @@ const closeImportResult = async () => {
|
||||
// 下载失败条目原因
|
||||
const downloadFailedEntries = () => {
|
||||
if (!importResult.value?.failed_entries_url) {
|
||||
MessagePlugin.warning('暂无失败记录可下载')
|
||||
MessagePlugin.warning(t('faqManager.import.noFailedRecords'))
|
||||
return
|
||||
}
|
||||
// 直接打开下载链接
|
||||
@@ -2914,7 +2914,7 @@ const downloadExcelExample = () => {
|
||||
const exportLoading = ref(false)
|
||||
const handleExportCSV = async () => {
|
||||
if (!props.kbId) {
|
||||
MessagePlugin.warning(t('knowledgeBase.selectKnowledgeBase') || '请先选择知识库')
|
||||
MessagePlugin.warning(t('knowledgeBase.selectKnowledgeBase'))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2929,10 +2929,10 @@ const handleExportCSV = async () => {
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
URL.revokeObjectURL(url)
|
||||
MessagePlugin.success(t('knowledgeEditor.faqExport.exportSuccess') || '导出成功')
|
||||
MessagePlugin.success(t('knowledgeEditor.faqExport.exportSuccess'))
|
||||
} catch (error: any) {
|
||||
console.error('Export failed:', error)
|
||||
MessagePlugin.error(t('knowledgeEditor.faqExport.exportFailed') || '导出失败')
|
||||
MessagePlugin.error(t('knowledgeEditor.faqExport.exportFailed'))
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<template>
|
||||
<div class="kb-parser-settings">
|
||||
<div class="section-header">
|
||||
<h2>解析引擎</h2>
|
||||
<p class="section-description">为不同文件类型选择文档解析引擎。未配置的文件类型将使用内置解析引擎。</p>
|
||||
<h2>{{ $t('kbSettings.parser.title') }}</h2>
|
||||
<p class="section-description">{{ $t('kbSettings.parser.description') }}</p>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="loading-inline">
|
||||
<t-loading size="small" />
|
||||
<span>加载中...</span>
|
||||
<span>{{ $t('kbSettings.parser.loading') }}</span>
|
||||
</div>
|
||||
|
||||
<div v-else-if="fileTypeGroups.length === 0" class="empty-hint">
|
||||
<p>暂无可用解析引擎,或文档解析服务未配置。</p>
|
||||
<p>{{ $t('kbSettings.parser.noEngineAvailable') }}</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="settings-group">
|
||||
@@ -35,7 +35,7 @@
|
||||
@change="(val: string) => handleEngineChange(group.extensions, val)"
|
||||
style="width: 280px;"
|
||||
:status="hasAvailableEngine(group.extensions) ? 'default' : 'warning'"
|
||||
placeholder="无可用引擎"
|
||||
:placeholder="$t('kbSettings.parser.noEngine')"
|
||||
>
|
||||
<t-option
|
||||
v-for="opt in getEngineOptions(group.extensions)"
|
||||
@@ -45,7 +45,7 @@
|
||||
:disabled="opt.disabled"
|
||||
>
|
||||
<t-tooltip
|
||||
:content="`支持格式: ${opt.fileTypes.map(t => '.' + t).join(' ')}`"
|
||||
:content="$t('kbSettings.supportedFormats') + ': ' + opt.fileTypes.map(ft => '.' + ft).join(' ')"
|
||||
placement="left"
|
||||
:show-arrow="false"
|
||||
>
|
||||
@@ -57,25 +57,25 @@
|
||||
theme="primary"
|
||||
variant="light"
|
||||
size="small"
|
||||
>默认</t-tag>
|
||||
>{{ $t('kbSettings.parser.default') }}</t-tag>
|
||||
<t-tag
|
||||
v-if="opt.disabled"
|
||||
theme="danger"
|
||||
variant="light"
|
||||
size="small"
|
||||
>不可用</t-tag>
|
||||
>{{ $t('kbSettings.parser.unavailable') }}</t-tag>
|
||||
</div>
|
||||
<div class="engine-option-desc">{{ opt.desc }}</div>
|
||||
<div v-if="opt.disabled && opt.reason" class="engine-option-reason">
|
||||
{{ opt.reason }}
|
||||
<a class="go-settings" @click.stop.prevent="goToParserSettings">去设置 →</a>
|
||||
<a class="go-settings" @click.stop.prevent="goToParserSettings">{{ $t('kbSettings.parser.goSettings') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</t-tooltip>
|
||||
</t-option>
|
||||
</t-select>
|
||||
<div v-if="!hasAvailableEngine(group.extensions)" class="no-engine-warning">
|
||||
<a class="go-settings" @click.prevent="goToParserSettings">前往配置 →</a>
|
||||
<a class="go-settings" @click.prevent="goToParserSettings">{{ $t('kbSettings.parser.goConfig') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -85,10 +85,13 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, computed, onMounted, onUnmounted } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { getParserEngines, type ParserEngineInfo } from '@/api/system'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
import { storeToRefs } from 'pinia'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
export interface ParserEngineRule {
|
||||
file_types: string[]
|
||||
engine: string
|
||||
@@ -144,14 +147,14 @@ const fileTypeGroups = computed(() => {
|
||||
const txtExts = ['txt'].filter(e => ft.has(e))
|
||||
const imageExts = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'tiff', 'webp'].filter(e => ft.has(e))
|
||||
|
||||
if (pdfExts.length) groups.push({ key: 'pdf', label: 'PDF 文档', icon: 'file-pdf', extensions: pdfExts })
|
||||
if (officeExts.length) groups.push({ key: 'office', label: 'Word 文档', icon: 'file-word', extensions: officeExts })
|
||||
if (pptExts.length) groups.push({ key: 'ppt', label: '演示文稿', icon: 'file-powerpoint', extensions: pptExts })
|
||||
if (excelExts.length) groups.push({ key: 'excel', label: 'Excel 表格', icon: 'file-excel', extensions: excelExts })
|
||||
if (csvExts.length) groups.push({ key: 'csv', label: 'CSV 文件', icon: 'file-excel', extensions: csvExts })
|
||||
if (pdfExts.length) groups.push({ key: 'pdf', label: t('kbSettings.parser.fileTypePdf'), icon: 'file-pdf', extensions: pdfExts })
|
||||
if (officeExts.length) groups.push({ key: 'office', label: t('kbSettings.parser.fileTypeWord'), icon: 'file-word', extensions: officeExts })
|
||||
if (pptExts.length) groups.push({ key: 'ppt', label: t('kbSettings.parser.fileTypePpt'), icon: 'file-powerpoint', extensions: pptExts })
|
||||
if (excelExts.length) groups.push({ key: 'excel', label: t('kbSettings.parser.fileTypeExcel'), icon: 'file-excel', extensions: excelExts })
|
||||
if (csvExts.length) groups.push({ key: 'csv', label: t('kbSettings.parser.fileTypeCsv'), icon: 'file-excel', extensions: csvExts })
|
||||
if (mdExts.length) groups.push({ key: 'markdown', label: 'Markdown', icon: 'file-code', extensions: mdExts })
|
||||
if (txtExts.length) groups.push({ key: 'text', label: '纯文本', icon: 'file', extensions: txtExts })
|
||||
if (imageExts.length) groups.push({ key: 'image', label: '图片', icon: 'image', extensions: imageExts })
|
||||
if (txtExts.length) groups.push({ key: 'text', label: t('kbSettings.parser.fileTypeText'), icon: 'file', extensions: txtExts })
|
||||
if (imageExts.length) groups.push({ key: 'image', label: t('kbSettings.parser.fileTypeImage'), icon: 'image', extensions: imageExts })
|
||||
|
||||
return groups
|
||||
})
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
<template>
|
||||
<div class="kb-storage-settings">
|
||||
<div class="section-header">
|
||||
<h2>存储引擎</h2>
|
||||
<h2>{{ $t('kbSettings.storage.title') }}</h2>
|
||||
<p class="section-description">
|
||||
选择文件存储引擎,影响文档上传存储和文档中图片的存储方式。参数在全局设置中配置。
|
||||
{{ $t('kbSettings.storage.description') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="loading-inline">
|
||||
<t-loading size="small" />
|
||||
<span>加载中...</span>
|
||||
<span>{{ $t('kbSettings.storage.loading') }}</span>
|
||||
</div>
|
||||
|
||||
<div v-else class="settings-group">
|
||||
<div class="setting-row">
|
||||
<div class="setting-info">
|
||||
<label>存储引擎</label>
|
||||
<p class="desc">选择该知识库使用的存储引擎,需在全局设置中已配置对应引擎。</p>
|
||||
<label>{{ $t('kbSettings.storage.engineLabel') }}</label>
|
||||
<p class="desc">{{ $t('kbSettings.storage.engineDesc') }}</p>
|
||||
</div>
|
||||
<div class="setting-control">
|
||||
<t-select
|
||||
v-model="localProvider"
|
||||
size="medium"
|
||||
placeholder="请选择存储引擎"
|
||||
:placeholder="$t('kbSettings.storage.selectPlaceholder')"
|
||||
style="width: 100%; min-width: 220px;"
|
||||
:disabled="props.hasFiles"
|
||||
@change="handleChange"
|
||||
@@ -36,14 +36,14 @@
|
||||
>
|
||||
<span class="select-option">
|
||||
<span>{{ opt.label }}</span>
|
||||
<t-tag v-if="opt.disabled" theme="warning" variant="light" size="small">未配置</t-tag>
|
||||
<t-tag v-else-if="opt.available === false" theme="danger" variant="light" size="small">不可用</t-tag>
|
||||
<t-tag v-if="opt.disabled" theme="warning" variant="light" size="small">{{ $t('kbSettings.storage.notConfigured') }}</t-tag>
|
||||
<t-tag v-else-if="opt.available === false" theme="danger" variant="light" size="small">{{ $t('kbSettings.storage.unavailable') }}</t-tag>
|
||||
</span>
|
||||
</t-option>
|
||||
</t-select>
|
||||
<p v-if="props.hasFiles" class="option-hint locked-hint">知识库中已有文件,无法切换存储引擎。如需更换,请先清空知识库中的所有文件。</p>
|
||||
<p v-if="props.hasFiles" class="option-hint locked-hint">{{ $t('kbSettings.storage.lockedHint') }}</p>
|
||||
<p v-else-if="selectedOption?.desc" class="option-hint">{{ selectedOption.desc }}</p>
|
||||
<a v-if="showGoSettings" href="javascript:void(0)" class="go-settings" @click.prevent="goToStorageSettings">去全局设置中配置</a>
|
||||
<a v-if="showGoSettings" href="javascript:void(0)" class="go-settings" @click.prevent="goToStorageSettings">{{ $t('kbSettings.storage.goGlobalSettings') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -52,9 +52,12 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch, onMounted } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { getStorageEngineConfig, getStorageEngineStatus, type StorageEngineStatusItem } from '@/api/system'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const props = defineProps<{
|
||||
storageProvider: string
|
||||
hasFiles?: boolean
|
||||
@@ -79,29 +82,29 @@ const engineOptions = computed(() => {
|
||||
return [
|
||||
{
|
||||
value: 'local',
|
||||
label: 'Local(本地存储)',
|
||||
desc: '仅适合单机部署,简单轻量',
|
||||
label: t('kbSettings.storage.engineLocal'),
|
||||
desc: t('kbSettings.storage.engineLocalDesc'),
|
||||
available: statusMap.local !== false,
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
value: 'minio',
|
||||
label: 'MinIO',
|
||||
desc: 'S3 兼容,适合内网或私有云',
|
||||
desc: t('kbSettings.storage.engineMinioDesc'),
|
||||
available: statusMap.minio,
|
||||
disabled: statusMap.minio === false,
|
||||
},
|
||||
{
|
||||
value: 'cos',
|
||||
label: '腾讯云 COS',
|
||||
desc: '公有云部署,支持 CDN 加速',
|
||||
label: t('kbSettings.storage.engineCos'),
|
||||
desc: t('kbSettings.storage.engineCosDesc'),
|
||||
available: statusMap.cos,
|
||||
disabled: statusMap.cos === false,
|
||||
},
|
||||
{
|
||||
value: 'tos',
|
||||
label: '火山引擎 TOS',
|
||||
desc: '火山引擎对象存储,适合公有云部署',
|
||||
label: t('kbSettings.storage.engineTos'),
|
||||
desc: t('kbSettings.storage.engineTosDesc'),
|
||||
available: statusMap.tos,
|
||||
disabled: statusMap.tos === false,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user