feat: Enhance document and FAQ management UI with localization updates

- Added a new document management section with titles and subtitles in English, Russian, and Chinese.
- Updated the FAQ management interface to include subtitles for better user guidance.
- Improved layout and styling for document and FAQ sections to enhance user experience.
- Ensured localization support for new UI elements across multiple languages.
This commit is contained in:
wizardchen
2025-11-15 03:29:40 +08:00
parent 546ceed32f
commit fa237a8c13
6 changed files with 1551 additions and 695 deletions
+402
View File
@@ -0,0 +1,402 @@
<template>
<div
ref="wrapperRef"
class="faq-tag-wrapper"
@mouseenter="handleMouseEnter"
@mouseleave="handleMouseLeave"
>
<slot />
<Teleport to="body">
<Transition name="fade">
<div
v-if="showTooltip && content"
ref="tooltipRef"
class="faq-tag-tooltip"
:class="tooltipClass"
:style="tooltipStyle"
>
<div class="tooltip-content">{{ content }}</div>
</div>
</Transition>
</Teleport>
</div>
</template>
<script setup lang="ts">
import { ref, computed, nextTick, onMounted, onUnmounted, watch } from 'vue'
const props = defineProps<{
content: string
placement?: 'top' | 'bottom' | 'left' | 'right'
type?: 'answer' | 'similar' | 'negative'
}>()
const showTooltip = ref(false)
const tooltipRef = ref<HTMLElement | null>(null)
const wrapperRef = ref<HTMLElement | null>(null)
const tooltipStyle = ref<{ top: string; left: string }>({ top: '0px', left: '0px' })
const tooltipClass = computed(() => {
return {
[`tooltip-${props.type || 'answer'}`]: true,
[`placement-${props.placement || 'top'}`]: true,
}
})
const updatePosition = async () => {
if (!wrapperRef.value || !tooltipRef.value) return
await nextTick()
// 再次检查,确保DOM已渲染
if (!tooltipRef.value) return
const rect = wrapperRef.value.getBoundingClientRect()
const tooltipRect = tooltipRef.value.getBoundingClientRect()
const placement = props.placement || 'top'
let top = 0
let left = 0
switch (placement) {
case 'top':
top = rect.top - tooltipRect.height - 8
left = rect.left + (rect.width / 2) - (tooltipRect.width / 2)
break
case 'bottom':
top = rect.bottom + 8
left = rect.left + (rect.width / 2) - (tooltipRect.width / 2)
break
case 'left':
top = rect.top + (rect.height / 2) - (tooltipRect.height / 2)
left = rect.left - tooltipRect.width - 8
break
case 'right':
top = rect.top + (rect.height / 2) - (tooltipRect.height / 2)
left = rect.right + 8
break
}
// 边界检测
const padding = 8
if (left < padding) left = padding
if (left + tooltipRect.width > window.innerWidth - padding) {
left = window.innerWidth - tooltipRect.width - padding
}
if (top < padding) {
// 如果上方空间不足,改为下方显示
if (placement === 'top') {
top = rect.bottom + 8
} else {
top = padding
}
}
if (top + tooltipRect.height > window.innerHeight - padding) {
top = window.innerHeight - tooltipRect.height - padding
}
tooltipStyle.value = {
top: `${top}px`,
left: `${left}px`,
}
}
const handleMouseEnter = () => {
showTooltip.value = true
nextTick(() => {
updatePosition()
})
}
const handleMouseLeave = () => {
showTooltip.value = false
}
onMounted(() => {
window.addEventListener('scroll', updatePosition, true)
window.addEventListener('resize', updatePosition)
})
onUnmounted(() => {
window.removeEventListener('scroll', updatePosition, true)
window.removeEventListener('resize', updatePosition)
})
watch(showTooltip, (newVal) => {
if (newVal) {
nextTick(() => {
updatePosition()
})
}
})
</script>
<style scoped lang="less">
.faq-tag-wrapper {
display: inline-block;
position: relative;
max-width: 100%;
min-width: 0;
overflow: visible;
flex-shrink: 1;
flex: 0 1 auto;
// 确保内部的tag也能正确收缩
:deep(.t-tag) {
max-width: 100% !important;
min-width: 0 !important;
width: auto !important;
display: inline-flex !important;
}
:deep(.t-tag span),
:deep(.t-tag > span) {
display: block !important;
overflow: hidden !important;
text-overflow: ellipsis !important;
white-space: nowrap !important;
max-width: 100% !important;
min-width: 0 !important;
}
}
.faq-tag-tooltip {
position: fixed;
z-index: 9999;
max-width: 360px;
min-width: 120px;
padding: 12px 16px;
background: #FFFFFF;
color: #111827;
border: 1px solid #E7E7E7;
border-radius: 8px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
font-family: "PingFang SC";
font-size: 13px;
line-height: 1.6;
word-break: break-word;
pointer-events: none;
&::before {
content: '';
position: absolute;
width: 0;
height: 0;
border: 6px solid transparent;
}
&.placement-top::before {
bottom: -12px;
left: 50%;
transform: translateX(-50%);
border-top-color: #E7E7E7;
filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
}
&.placement-top::after {
content: '';
position: absolute;
bottom: -11px;
left: 50%;
transform: translateX(-50%);
width: 0;
height: 0;
border: 6px solid transparent;
border-top-color: #FFFFFF;
}
&.placement-bottom::before {
top: -12px;
left: 50%;
transform: translateX(-50%);
border-bottom-color: #E7E7E7;
filter: drop-shadow(0 -2px 4px rgba(0, 0, 0, 0.08));
}
&.placement-bottom::after {
content: '';
position: absolute;
top: -11px;
left: 50%;
transform: translateX(-50%);
width: 0;
height: 0;
border: 6px solid transparent;
border-bottom-color: #FFFFFF;
}
&.placement-left::before {
right: -12px;
top: 50%;
transform: translateY(-50%);
border-left-color: #E7E7E7;
filter: drop-shadow(2px 0 4px rgba(0, 0, 0, 0.08));
}
&.placement-left::after {
content: '';
position: absolute;
right: -11px;
top: 50%;
transform: translateY(-50%);
width: 0;
height: 0;
border: 6px solid transparent;
border-left-color: #FFFFFF;
}
&.placement-right::before {
left: -12px;
top: 50%;
transform: translateY(-50%);
border-right-color: #E7E7E7;
filter: drop-shadow(-2px 0 4px rgba(0, 0, 0, 0.08));
}
&.placement-right::after {
content: '';
position: absolute;
left: -11px;
top: 50%;
transform: translateY(-50%);
width: 0;
height: 0;
border: 6px solid transparent;
border-right-color: #FFFFFF;
}
&.tooltip-answer {
border-color: #07C05F;
background: #FFFFFF;
box-shadow: 0 4px 16px rgba(7, 192, 95, 0.15);
&::before {
border-top-color: #07C05F;
}
&.placement-bottom::before {
border-bottom-color: #07C05F;
}
&.placement-left::before {
border-left-color: #07C05F;
}
&.placement-right::before {
border-right-color: #07C05F;
}
&::after {
border-top-color: #FFFFFF;
}
&.placement-bottom::after {
border-bottom-color: #FFFFFF;
}
&.placement-left::after {
border-left-color: #FFFFFF;
}
&.placement-right::after {
border-right-color: #FFFFFF;
}
}
&.tooltip-similar {
border-color: #07C05F;
background: #FFFFFF;
box-shadow: 0 4px 16px rgba(7, 192, 95, 0.15);
&::before {
border-top-color: #07C05F;
}
&.placement-bottom::before {
border-bottom-color: #07C05F;
}
&.placement-left::before {
border-left-color: #07C05F;
}
&.placement-right::before {
border-right-color: #07C05F;
}
&::after {
border-top-color: #FFFFFF;
}
&.placement-bottom::after {
border-bottom-color: #FFFFFF;
}
&.placement-left::after {
border-left-color: #FFFFFF;
}
&.placement-right::after {
border-right-color: #FFFFFF;
}
}
&.tooltip-negative {
border-color: #07C05F;
background: #FFFFFF;
box-shadow: 0 4px 16px rgba(7, 192, 95, 0.15);
&::before {
border-top-color: #07C05F;
}
&.placement-bottom::before {
border-bottom-color: #07C05F;
}
&.placement-left::before {
border-left-color: #07C05F;
}
&.placement-right::before {
border-right-color: #07C05F;
}
&::after {
border-top-color: #FFFFFF;
}
&.placement-bottom::after {
border-bottom-color: #FFFFFF;
}
&.placement-left::after {
border-left-color: #FFFFFF;
}
&.placement-right::after {
border-right-color: #FFFFFF;
}
}
}
.tooltip-content {
color: #111827;
white-space: pre-wrap;
word-break: break-word;
}
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.15s ease;
}
.fade-enter-from {
opacity: 0;
}
.fade-leave-to {
opacity: 0;
}
</style>
+5
View File
@@ -716,8 +716,13 @@ export default {
updateSuccess: 'Configuration saved successfully',
indexModeRequired: 'Please select an indexing mode for FAQ knowledge bases'
},
document: {
title: 'Document Management',
subtitle: 'Upload and manage documents, supporting parsing and chunking of multiple file formats',
},
faq: {
title: 'FAQ Configuration',
subtitle: 'Manage FAQ entries with batch import, edit, and search testing',
description: 'Configure indexing strategy and guidance for FAQ-style knowledge bases',
indexModeLabel: 'Indexing Mode',
indexModeDescription: 'Question-only indexing improves precision, question+answer improves recall.',
+1
View File
@@ -807,6 +807,7 @@ export default {
},
faq: {
title: 'Настройки FAQ',
subtitle: 'Управление записями FAQ с пакетным импортом, редактированием и тестированием поиска',
description: 'Определите стратегию индексации и общие правила для FAQ-базы знаний',
indexModeLabel: 'Режим индексации',
indexModeDescription: 'Только вопросы дают более высокую точность, вопросы+ответы повышают полноту выдачи.',
+5
View File
@@ -1029,8 +1029,13 @@ export default {
updateSuccess: "配置保存成功",
indexModeRequired: "请选择 FAQ 的索引方式",
},
document: {
title: "文档管理",
subtitle: "上传和管理文档,支持多种文件格式的解析与分块",
},
faq: {
title: "FAQ 配置",
subtitle: "管理 FAQ 条目,支持批量导入、编辑和检索测试",
description: "设置 FAQ 知识库的索引策略和问答组织方式",
indexModeLabel: "索引方式",
indexModeDescription: "仅索引问题可提升精度,索引问答可提高召回率",
+45 -1
View File
@@ -290,6 +290,13 @@ async function createNewSession(value: string): Promise<void> {
<template>
<template v-if="!isFAQ">
<div v-show="cardList.length" class="knowledge-card-box" style="position: relative">
<!-- Header -->
<div class="document-header">
<div class="document-header-title">
<h2>{{ $t('knowledgeEditor.document.title') }}</h2>
<p class="document-subtitle">{{ $t('knowledgeEditor.document.subtitle') }}</p>
</div>
</div>
<div class="knowledge-card-wrap" ref="knowledgeScroll" @scroll="handleScroll">
<div class="knowledge-card" v-for="(item, index) in cardList" :key="index" @click="openCardDetails(item)">
<div class="card-content">
@@ -407,6 +414,43 @@ async function createNewSession(value: string): Promise<void> {
<style scoped lang="less">
.knowledge-card-box {
flex: 1;
display: flex;
flex-direction: column;
height: 100%;
}
// Header 样式
.document-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 24px 44px 0;
margin-bottom: 20px;
flex-shrink: 0;
.document-header-title {
display: flex;
flex-direction: column;
gap: 4px;
}
h2 {
margin: 0;
color: #000000e6;
font-family: "PingFang SC";
font-size: 24px;
font-weight: 600;
line-height: 32px;
}
.document-subtitle {
margin: 0;
color: #00000099;
font-family: "PingFang SC";
font-size: 14px;
font-weight: 400;
line-height: 20px;
}
}
.faq-manager-wrapper {
@@ -457,7 +501,7 @@ async function createNewSession(value: string): Promise<void> {
.knowledge-card-wrap {
// padding: 24px 44px;
padding: 24px 44px 80px 44px;
padding: 0 44px 80px 44px;
box-sizing: border-box;
display: grid;
gap: 20px;
File diff suppressed because it is too large Load Diff