Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
Go agentagenticaichatbotdsh-pluginembeddingsevaluationgenerative-aigolangknowledge-basellmmulti-tenantollamaopenaiquestion-answeringragrerankingsemantic-searchvector-searchwiki
feat: Add download options for example files in FAQ Entry Manager
wizardchen1d0b228e8189
diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.tsindex 332c79b22..2f03b7f4d 100644--- a/frontend/src/i18n/locales/en-US.ts+++ b/frontend/src/i18n/locales/en-US.ts@@ -790,6 +790,10 @@ export default {invalidJSON: 'Invalid JSON format',unsupportedFormat: 'Unsupported file format',selectFile: 'Please select a file to import first',+ downloadExample: 'Download Example',+ downloadExampleJSON: 'Download JSON Example',+ downloadExampleCSV: 'Download CSV Example',+ downloadExampleExcel: 'Download Excel Example',},models: {title: 'Model Configuration',diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.tsindex 87b624650..fcf3b8b6f 100644--- a/frontend/src/i18n/locales/ru-RU.ts+++ b/frontend/src/i18n/locales/ru-RU.ts@@ -875,6 +875,10 @@ export default {invalidJSON: 'Неверный формат JSON',unsupportedFormat: 'Формат файла не поддерживается',selectFile: 'Сначала выберите файл для импорта',+ downloadExample: 'Скачать пример',+ downloadExampleJSON: 'Скачать пример JSON',+ downloadExampleCSV: 'Скачать пример CSV',+ downloadExampleExcel: 'Скачать пример Excel',},models: {title: 'Конфигурация моделей',diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.tsindex 69e566c6c..abea811ba 100644--- a/frontend/src/i18n/locales/zh-CN.ts+++ b/frontend/src/i18n/locales/zh-CN.ts@@ -1103,6 +1103,10 @@ export default {invalidJSON: "JSON 文件格式不正确",unsupportedFormat: "暂不支持该文件格式",selectFile: "请先选择需要导入的文件",+ downloadExample: "下载示例文件",+ downloadExampleJSON: "下载 JSON 示例",+ downloadExampleCSV: "下载 CSV 示例",+ downloadExampleExcel: "下载 Excel 示例",},models: {title: "模型配置",diff --git a/frontend/src/views/knowledge/components/FAQEntryManager.vue b/frontend/src/views/knowledge/components/FAQEntryManager.vueindex bd673868a..8fb0a3d15 100644--- a/frontend/src/views/knowledge/components/FAQEntryManager.vue+++ b/frontend/src/views/knowledge/components/FAQEntryManager.vue@@ -393,7 +393,21 @@<!-- 文件上传区域 --><div class="import-form-item">- <label class="import-form-label required">{{ $t('knowledgeEditor.faqImport.fileLabel') }}</label>+ <div class="file-label-row">+ <label class="import-form-label required">{{ $t('knowledgeEditor.faqImport.fileLabel') }}</label>+ <t-dropdown+ :options="downloadExampleOptions"+ placement="bottom-right"+ trigger="click"+ @click="handleDownloadExample"+ class="download-example-dropdown"+ >+ <t-button theme="default" variant="outline" size="small" class="download-example-btn">+ <t-icon name="download" size="16px" />+ <span>{{ $t('knowledgeEditor.faqImport.downloadExample') }}</span>+ </t-button>+ </t-dropdown>+ </div><div class="file-upload-wrapper"><inputref="fileInputRef"@@ -1113,6 +1127,100 @@ const handleImport = async () => {}}+// 下载示例文件选项+const downloadExampleOptions = computed(() => [+ { content: t('knowledgeEditor.faqImport.downloadExampleJSON'), value: 'json' },+ { content: t('knowledgeEditor.faqImport.downloadExampleCSV'), value: 'csv' },+ { content: t('knowledgeEditor.faqImport.downloadExampleExcel'), value: 'excel' },+])++// 示例数据+const exampleData: FAQEntryPayload[] = [+ {+ standard_question: '什么是 WeKnora?',+ answers: ['WeKnora 是一个智能知识库管理系统', '它支持多种知识库类型和导入方式'],+ similar_questions: ['WeKnora 是什么?', '介绍一下 WeKnora'],+ negative_questions: ['这不是 WeKnora', '与 WeKnora 无关'],+ },+ {+ standard_question: '如何创建知识库?',+ answers: ['点击"新建知识库"按钮', '选择知识库类型并填写相关信息', '完成创建后即可开始使用'],+ similar_questions: ['怎么创建知识库?', '如何新建知识库?'],+ negative_questions: [],+ },+]++// 下载示例文件+const handleDownloadExample = (data: { value: string }) => {+ const { value } = data+ switch (value) {+ case 'json':+ downloadJSONExample()+ break+ case 'csv':+ downloadCSVExample()+ break+ case 'excel':+ downloadExcelExample()+ break+ }+}++// 下载 JSON 示例+const downloadJSONExample = () => {+ const jsonStr = JSON.stringify(exampleData, null, 2)+ const blob = new Blob([jsonStr], { type: 'application/json;charset=utf-8' })+ const url = URL.createObjectURL(blob)+ const link = document.createElement('a')+ link.href = url+ link.download = 'faq_example.json'+ document.body.appendChild(link)+ link.click()+ document.body.removeChild(link)+ URL.revokeObjectURL(url)+}++// 下载 CSV 示例+const downloadCSVExample = () => {+ const headers = ['standard_question', 'answers', 'similar_questions', 'negative_questions']+ const rows = exampleData.map((item) => {+ return [+ item.standard_question,+ item.answers.join(';'),+ item.similar_questions.join(';'),+ item.negative_questions.join(';'),+ ]+ })+ const csvContent = [+ headers.join(','),+ ...rows.map((row) => row.map((cell) => `"${cell.replace(/"/g, '""')}"`).join(',')),+ ].join('\n')+ const blob = new Blob(['\ufeff' + csvContent], { type: 'text/csv;charset=utf-8' })+ const url = URL.createObjectURL(blob)+ const link = document.createElement('a')+ link.href = url+ link.download = 'faq_example.csv'+ document.body.appendChild(link)+ link.click()+ document.body.removeChild(link)+ URL.revokeObjectURL(url)+}++// 下载 Excel 示例+const downloadExcelExample = () => {+ const worksheet = XLSX.utils.json_to_sheet(+ exampleData.map((item) => ({+ standard_question: item.standard_question,+ answers: item.answers.join(';'),+ similar_questions: item.similar_questions.join(';'),+ negative_questions: item.negative_questions.join(';'),+ })),+ )+ const workbook = XLSX.utils.book_new()+ XLSX.utils.book_append_sheet(workbook, worksheet, 'FAQ')+ XLSX.writeFile(workbook, 'faq_example.xlsx')+}+watch(() => props.kbId,() => {@@ -1838,15 +1946,57 @@ watch(() => entries.value.map(e => ({}}+// 文件标签行+.file-label-row {+ display: flex;+ align-items: center;+ justify-content: space-between;+ margin-bottom: 10px;+ gap: 12px;+}++// 下载示例按钮+.download-example-btn {+ display: flex;+ align-items: center;+ gap: 6px;+ font-family: "PingFang SC";+ font-size: 13px;+ font-weight: 500;+ padding: 6px 14px;+ border-radius: 6px;+ border: 1px solid #E7E7E7;+ background: #ffffff;+ color: #333333;+ transition: all 0.2s ease;+ cursor: pointer;+ white-space: nowrap;++ &:hover {+ border-color: #07C05F;+ color: #07C05F;+ background: #f0fdf4;+ }++ &:active {+ background: #e0f9ea;+ }++ :deep(.t-icon) {+ font-size: 16px;+ }+}+// 导入表单标签.import-form-label {display: block;- margin-bottom: 10px;+ margin-bottom: 0;font-family: "PingFang SC";font-size: 14px;font-weight: 500;color: #333333;letter-spacing: -0.2px;+ flex: 1;&.required::after {content: '*';@@ -1856,21 +2006,36 @@ watch(() => entries.value.map(e => ({}}-// 单选按钮组样式+// 单选按钮组样式 - 符合项目主题风格:deep(.import-radio-group) {+ .t-radio-group--filled {+ background: #f5f5f5;+ border-radius: 6px;+ padding: 2px;+ }+.t-radio-button {font-family: "PingFang SC";font-size: 14px;+ border-color: #d9d9d9;transition: all 0.2s ease;- &:hover {- border-color: #07C05F;+ &:hover:not(.t-is-disabled) {+ border-color: #07c05f;+ color: #07c05f;}&.t-is-checked {- background-color: #07C05F;- border-color: #07C05F;- color: #ffffff;+ background: #07c05f;+ border-color: #07c05f;+ color: #fff;+ font-weight: 500;++ &:hover:not(.t-is-disabled) {+ background: #05a04f;+ border-color: #05a04f;+ color: #fff;+ }}}}