feat: Refine FAQ Entry Manager UI and localization for clarity and usability

- Updated the FAQ Entry Manager layout to enhance the organization of question types with distinct styling for similar and negative questions.
- Improved localization strings in Chinese for better clarity, including simplified terms for document and FAQ types.
- Enhanced search results display by adding index numbers and optimizing the layout for better user experience.
- Implemented responsive design adjustments and improved styling for better visual consistency across components.
This commit is contained in:
wizardchen
2025-11-16 23:22:00 +08:00
parent 0c37b3b605
commit 7dd8861366
2 changed files with 120 additions and 66 deletions
+2 -2
View File
@@ -1002,8 +1002,8 @@ export default {
title: "基本信息", title: "基本信息",
description: "设置知识库的名称和描述信息", description: "设置知识库的名称和描述信息",
typeLabel: "知识库类型", typeLabel: "知识库类型",
typeDocument: "文档型", typeDocument: "文档",
typeFAQ: "FAQ 问答", typeFAQ: "问答",
typeDescription: "FAQ 类型适合结构化问答数据;文档型支持文件解析与分块。", typeDescription: "FAQ 类型适合结构化问答数据;文档型支持文件解析与分块。",
nameLabel: "知识库名称", nameLabel: "知识库名称",
namePlaceholder: "请输入知识库名称", namePlaceholder: "请输入知识库名称",
@@ -243,7 +243,7 @@
</div> </div>
<!-- 相似问 --> <!-- 相似问 -->
<div class="setting-row vertical setting-row-optional"> <div class="setting-row vertical setting-row-optional setting-row-similar">
<div class="setting-info"> <div class="setting-info">
<label class="optional-label">{{ $t('knowledgeEditor.faq.similarQuestions') }}</label> <label class="optional-label">{{ $t('knowledgeEditor.faq.similarQuestions') }}</label>
<p class="desc optional-desc">{{ $t('knowledgeEditor.faq.similarQuestionsDesc') }}</p> <p class="desc optional-desc">{{ $t('knowledgeEditor.faq.similarQuestionsDesc') }}</p>
@@ -289,7 +289,7 @@
</div> </div>
<!-- 反例 --> <!-- 反例 -->
<div class="setting-row vertical setting-row-optional"> <div class="setting-row vertical setting-row-optional setting-row-negative">
<div class="setting-info"> <div class="setting-info">
<label class="optional-label">{{ $t('knowledgeEditor.faq.negativeQuestions') }}</label> <label class="optional-label">{{ $t('knowledgeEditor.faq.negativeQuestions') }}</label>
<p class="desc optional-desc">{{ $t('knowledgeEditor.faq.negativeQuestionsDesc') }}</p> <p class="desc optional-desc">{{ $t('knowledgeEditor.faq.negativeQuestionsDesc') }}</p>
@@ -335,7 +335,7 @@
</div> </div>
<!-- 答案 --> <!-- 答案 -->
<div class="setting-row vertical setting-row-primary"> <div class="setting-row vertical setting-row-primary setting-row-answer">
<div class="setting-info"> <div class="setting-info">
<label class="required-label"> <label class="required-label">
{{ $t('knowledgeEditor.faq.answers') }} {{ $t('knowledgeEditor.faq.answers') }}
@@ -609,7 +609,6 @@
<!-- Search Results --> <!-- Search Results -->
<div v-if="searchResults.length > 0 || hasSearched" class="search-results"> <div v-if="searchResults.length > 0 || hasSearched" class="search-results">
<div class="results-header"> <div class="results-header">
<t-icon name="file-view" size="16px" />
<span>{{ $t('knowledgeEditor.faq.searchResults') }} ({{ searchResults.length }})</span> <span>{{ $t('knowledgeEditor.faq.searchResults') }} ({{ searchResults.length }})</span>
</div> </div>
<div v-if="searchResults.length === 0" class="no-results"> <div v-if="searchResults.length === 0" class="no-results">
@@ -617,24 +616,27 @@
</div> </div>
<div v-else class="results-list"> <div v-else class="results-list">
<div <div
v-for="result in searchResults" v-for="(result, index) in searchResults"
:key="result.id" :key="result.id"
class="result-card" class="result-card"
:class="{ 'expanded': result.expanded }" :class="{ 'expanded': result.expanded }"
> >
<div class="result-header" @click="toggleResult(result)"> <div class="result-header" @click="toggleResult(result)">
<div class="result-question-wrapper"> <div class="result-question-wrapper">
<div class="result-question">{{ result.standard_question }}</div> <div class="result-question">
<span class="result-index">{{ index + 1 }}.</span>
{{ result.standard_question }}
</div>
<div class="result-meta">
<t-tag size="small" variant="light-outline" class="score-tag">
{{ $t('knowledgeEditor.faq.score') }}: {{ (result.score || 0).toFixed(3) }}
</t-tag>
</div>
<t-icon <t-icon
:name="result.expanded ? 'chevron-up' : 'chevron-down'" :name="result.expanded ? 'chevron-up' : 'chevron-down'"
class="expand-icon" class="expand-icon"
/> />
</div> </div>
<div class="result-meta">
<t-tag size="small" variant="light-outline" class="score-tag">
{{ $t('knowledgeEditor.faq.score') }}: {{ (result.score || 0).toFixed(3) }}
</t-tag>
</div>
</div> </div>
<Transition name="slide-down"> <Transition name="slide-down">
<div v-if="result.expanded" class="result-body"> <div v-if="result.expanded" class="result-body">
@@ -1308,13 +1310,16 @@ const handleSearch = async () => {
vector_threshold: searchForm.vectorThreshold, vector_threshold: searchForm.vectorThreshold,
match_count: searchForm.matchCount, match_count: searchForm.matchCount,
}) })
searchResults.value = (res.data || []).map((entry: FAQEntry) => ({ const results = (res.data || []).map((entry: FAQEntry) => ({
...entry, ...entry,
similarCollapsed: false, // 相似问默认展开 similarCollapsed: false, // 相似问默认展开
negativeCollapsed: true, // 反例默认折叠 negativeCollapsed: true, // 反例默认折叠
answersCollapsed: true, // 答案默认折叠 answersCollapsed: true, // 答案默认折叠
expanded: false, expanded: false,
})) as FAQEntry[] })) as FAQEntry[]
// 按score从大到小排序
searchResults.value = results.sort((a, b) => (b.score || 0) - (a.score || 0))
} catch (error: any) { } catch (error: any) {
MessagePlugin.error(error?.message || t('common.operationFailed')) MessagePlugin.error(error?.message || t('common.operationFailed'))
searchResults.value = [] searchResults.value = []
@@ -2672,22 +2677,49 @@ watch(() => entries.value.map(e => ({
// 主要字段(标准问、答案)的强调样式 // 主要字段(标准问、答案)的强调样式
&.setting-row-primary { &.setting-row-primary {
background: #fafbfc; padding: 20px 0;
padding: 20px; padding-left: 12px;
margin: 0 -20px; position: relative;
border-left: 3px solid #07C05F;
border-bottom: 1px solid #e5e7eb;
border-radius: 0;
// 第一个(标准问)去掉顶部间距 // 第一个(标准问)去掉顶部间距
&:first-child { &:first-child {
padding-top: 0; padding-top: 0;
margin-top: 0; }
// 左侧颜色标记(标准问和答案都用绿色)
&::before {
content: '';
position: absolute;
left: 0;
top: 20px;
width: 3px;
height: calc(100% - 40px);
background: #07C05F;
border-radius: 0 2px 2px 0;
}
&:first-child::before {
top: 0;
height: calc(100% - 20px);
} }
} }
// 可选字段(相似问、反例)的次要样式 // 可选字段(相似问、反例)的次要样式
&.setting-row-optional { &.setting-row-optional {
padding-left: 12px;
position: relative;
// 左侧颜色标记
&::before {
content: '';
position: absolute;
left: 0;
top: 20px;
width: 3px;
height: calc(100% - 40px);
border-radius: 0 2px 2px 0;
}
.setting-info { .setting-info {
.optional-label { .optional-label {
color: #333333; color: #333333;
@@ -2699,6 +2731,21 @@ watch(() => entries.value.map(e => ({
} }
} }
} }
// 相似问的蓝色标记
&.setting-row-similar::before {
background: #3B82F6;
}
// 反例的橙色标记
&.setting-row-negative::before {
background: #F59E0B;
}
// 答案去掉底部边框
&.setting-row-answer {
border-bottom: none;
}
} }
.setting-info { .setting-info {
@@ -2709,7 +2756,7 @@ watch(() => entries.value.map(e => ({
label { label {
font-size: 15px; font-size: 15px;
font-weight: 500; font-weight: 500;
color: #07C05F; color: #333333;
display: block; display: block;
margin-bottom: 4px; margin-bottom: 4px;
} }
@@ -2717,7 +2764,7 @@ watch(() => entries.value.map(e => ({
.required-label { .required-label {
font-size: 15px; font-size: 15px;
font-weight: 600; font-weight: 600;
color: #07C05F !important; color: #333333;
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
gap: 4px; gap: 4px;
@@ -2733,7 +2780,7 @@ watch(() => entries.value.map(e => ({
.optional-label { .optional-label {
font-size: 15px; font-size: 15px;
font-weight: 600; font-weight: 600;
color: #07C05F !important; color: #333333;
display: block; display: block;
margin-bottom: 4px; margin-bottom: 4px;
} }
@@ -2927,7 +2974,6 @@ watch(() => entries.value.map(e => ({
:deep(.faq-search-drawer) { :deep(.faq-search-drawer) {
.t-drawer__body { .t-drawer__body {
padding: 20px; padding: 20px;
overflow-y: auto;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: 100%; height: 100%;
@@ -2947,7 +2993,18 @@ watch(() => entries.value.map(e => ({
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 16px; gap: 16px;
height: 100%; flex: 1;
min-height: 0;
overflow-y: auto;
padding-right: 0;
// 隐藏滚动条但保持滚动功能
scrollbar-width: none; // Firefox
-ms-overflow-style: none; // IE and Edge
&::-webkit-scrollbar {
display: none; // Chrome, Safari, Opera
}
} }
.search-form { .search-form {
@@ -3092,14 +3149,12 @@ watch(() => entries.value.map(e => ({
} }
.search-results { .search-results {
flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
min-height: 0;
padding-top: 20px; padding-top: 20px;
padding-left: 0;
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
overflow-x: hidden;
} }
.results-header { .results-header {
@@ -3107,11 +3162,15 @@ watch(() => entries.value.map(e => ({
align-items: center; align-items: center;
gap: 8px; gap: 8px;
margin-bottom: 16px; margin-bottom: 16px;
margin-left: 0;
margin-right: 0;
padding-left: 0;
font-family: "PingFang SC"; font-family: "PingFang SC";
font-size: 14px; font-size: 14px;
font-weight: 600; font-weight: 600;
color: #111827; color: #111827;
flex-shrink: 0; flex-shrink: 0;
justify-content: flex-start;
.t-icon { .t-icon {
color: #07C05F; color: #07C05F;
@@ -3133,31 +3192,9 @@ watch(() => entries.value.map(e => ({
} }
.results-list { .results-list {
flex: 1;
overflow-y: auto;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 12px; gap: 12px;
padding-right: 4px;
&::-webkit-scrollbar {
width: 6px;
}
&::-webkit-scrollbar-track {
background: #f5f5f5;
border-radius: 3px;
}
&::-webkit-scrollbar-thumb {
background: #d0d0d0;
border-radius: 3px;
transition: background 0.2s;
&:hover {
background: #07C05F;
}
}
} }
.result-card { .result-card {
@@ -3165,12 +3202,13 @@ watch(() => entries.value.map(e => ({
border-radius: 8px; border-radius: 8px;
background: #fff; background: #fff;
padding: 14px; padding: 14px;
transition: all 0.2s ease; transition: border-color 0.2s ease, box-shadow 0.2s ease;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
min-width: 0; min-width: 0;
overflow: hidden; overflow: visible;
position: relative;
&:hover { &:hover {
border-color: #07C05F; border-color: #07C05F;
@@ -3189,6 +3227,7 @@ watch(() => entries.value.map(e => ({
padding: 4px; padding: 4px;
margin: -4px; margin: -4px;
border-radius: 6px; border-radius: 6px;
position: relative;
&:hover { &:hover {
background-color: #F9FAFB; background-color: #F9FAFB;
@@ -3199,12 +3238,15 @@ watch(() => entries.value.map(e => ({
margin-bottom: 12px; margin-bottom: 12px;
padding-bottom: 12px; padding-bottom: 12px;
border-bottom: 1px solid #E7E7E7; border-bottom: 1px solid #E7E7E7;
margin-left: -4px;
margin-right: -4px;
padding-left: 4px;
padding-right: 4px;
} }
.result-question-wrapper { .result-question-wrapper {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between;
gap: 10px; gap: 10px;
width: 100%; width: 100%;
} }
@@ -3218,6 +3260,23 @@ watch(() => entries.value.map(e => ({
color: #111827; color: #111827;
line-height: 1.6; line-height: 1.6;
word-break: break-word; word-break: break-word;
display: flex;
align-items: flex-start;
gap: 6px;
.result-index {
flex-shrink: 0;
color: #07C05F;
font-weight: 600;
}
}
.result-meta {
display: flex;
gap: 8px;
flex-wrap: wrap;
flex-shrink: 0;
margin-left: auto;
} }
.expand-icon { .expand-icon {
@@ -3232,12 +3291,6 @@ watch(() => entries.value.map(e => ({
} }
} }
.result-meta {
display: flex;
gap: 8px;
flex-wrap: wrap;
}
.score-tag, .score-tag,
.match-type-tag { .match-type-tag {
font-size: 12px; font-size: 12px;
@@ -3251,12 +3304,13 @@ watch(() => entries.value.map(e => ({
flex-direction: column; flex-direction: column;
gap: 12px; gap: 12px;
padding-top: 12px; padding-top: 12px;
margin-top: 12px; margin-top: 0;
border-top: 1px solid #F3F4F6; border-top: 1px solid #F3F4F6;
position: relative;
width: 100%;
} }
// Slide down animation - 优化性能 // Slide down animation - 优化性能
// 使用 grid-template-rows 和 opacity/transform 来优化动画性能
.slide-down-enter-active { .slide-down-enter-active {
transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1),
transform 0.2s cubic-bezier(0.4, 0, 0.2, 1); transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
@@ -3273,22 +3327,22 @@ watch(() => entries.value.map(e => ({
.slide-down-enter-from { .slide-down-enter-from {
opacity: 0; opacity: 0;
transform: translateY(-8px) scale(0.98); transform: translateY(-8px);
} }
.slide-down-enter-to { .slide-down-enter-to {
opacity: 1; opacity: 1;
transform: translateY(0) scale(1); transform: translateY(0);
} }
.slide-down-leave-from { .slide-down-leave-from {
opacity: 1; opacity: 1;
transform: translateY(0) scale(1); transform: translateY(0);
} }
.slide-down-leave-to { .slide-down-leave-to {
opacity: 0; opacity: 0;
transform: translateY(-8px) scale(0.98); transform: translateY(-8px);
} }
.result-section { .result-section {