Merge remote-tracking branch 'wizard/master'
This commit is contained in:
Generated
+1
-1
@@ -3907,7 +3907,7 @@
|
||||
},
|
||||
"node_modules/xlsx": {
|
||||
"version": "0.20.2",
|
||||
"resolved": "file:../packages/xlsx-0.20.2.tgz",
|
||||
"resolved": "file:packages/xlsx-0.20.2.tgz",
|
||||
"integrity": "sha512-+nKZ39+nvK7Qq6i0PvWWRA4j/EkfWOtkP/YhMtupm+lJIiHxUrgTr1CcKv1nBk1rHtkRRQ3O2+Ih/q/sA+FXZA==",
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
|
||||
@@ -44,6 +44,10 @@ export function uploadKnowledgeFile(kbId: string, data = {}) {
|
||||
return postUpload(`/api/v1/knowledge-bases/${kbId}/knowledge/file`, data);
|
||||
}
|
||||
|
||||
export function createKnowledgeFromURL(kbId: string, data: { url: string; enable_multimodel?: boolean }) {
|
||||
return post(`/api/v1/knowledge-bases/${kbId}/knowledge/url`, data);
|
||||
}
|
||||
|
||||
export function createManualKnowledge(kbId: string, data: { title: string; content: string; status: string }) {
|
||||
return post(`/api/v1/knowledge-bases/${kbId}/knowledge/manual`, data);
|
||||
}
|
||||
|
||||
@@ -23,9 +23,29 @@
|
||||
<div class="form-item">
|
||||
<label class="form-label required">{{ $t('model.editor.sourceLabel') }}</label>
|
||||
<t-radio-group v-model="formData.source">
|
||||
<t-radio value="local">{{ $t('model.editor.sourceLocal') }}</t-radio>
|
||||
<t-radio
|
||||
value="local"
|
||||
:disabled="ollamaServiceStatus === false"
|
||||
>
|
||||
{{ $t('model.editor.sourceLocal') }}
|
||||
</t-radio>
|
||||
<t-radio value="remote">{{ $t('model.editor.sourceRemote') }}</t-radio>
|
||||
</t-radio-group>
|
||||
|
||||
<!-- Ollama不可用时的提示信息 -->
|
||||
<div v-if="ollamaServiceStatus === false" class="ollama-unavailable-tip">
|
||||
<t-icon name="error-circle-filled" class="tip-icon" />
|
||||
<span class="tip-text">{{ $t('model.editor.ollamaUnavailable') }}</span>
|
||||
<t-button
|
||||
variant="text"
|
||||
size="small"
|
||||
theme="primary"
|
||||
@click="goToOllamaSettings"
|
||||
class="tip-link"
|
||||
>
|
||||
{{ $t('model.editor.goToOllamaSettings') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Ollama 本地模型选择器 -->
|
||||
@@ -205,10 +225,11 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, computed, onUnmounted } from 'vue'
|
||||
import { ref, watch, computed, onUnmounted, nextTick } from 'vue'
|
||||
import { MessagePlugin } from 'tdesign-vue-next'
|
||||
import { checkOllamaModels, checkRemoteModel, testEmbeddingModel, checkRerankModel, listOllamaModels, downloadOllamaModel, getDownloadProgress, type OllamaModelInfo } from '@/api/initialization'
|
||||
import { checkOllamaModels, checkRemoteModel, testEmbeddingModel, checkRerankModel, listOllamaModels, downloadOllamaModel, getDownloadProgress, checkOllamaStatus, type OllamaModelInfo } from '@/api/initialization'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useUIStore } from '@/stores/ui'
|
||||
|
||||
interface ModelFormData {
|
||||
id: string
|
||||
@@ -229,6 +250,7 @@ interface Props {
|
||||
}
|
||||
|
||||
const { t } = useI18n()
|
||||
const uiStore = useUIStore()
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
visible: false,
|
||||
@@ -268,6 +290,10 @@ const downloadProgress = ref(0)
|
||||
const currentDownloadModel = ref('')
|
||||
let downloadInterval: any = null
|
||||
|
||||
// Ollama 服务状态
|
||||
const ollamaServiceStatus = ref<boolean | null>(null)
|
||||
const checkingOllamaStatus = ref(false)
|
||||
|
||||
const formData = ref<ModelFormData>({
|
||||
id: '',
|
||||
name: '',
|
||||
@@ -344,12 +370,50 @@ const getBaseUrlPlaceholder = () => {
|
||||
: t('model.editor.baseUrlPlaceholder')
|
||||
}
|
||||
|
||||
// 检查Ollama服务状态
|
||||
const checkOllamaServiceStatus = async () => {
|
||||
console.log('开始检查Ollama服务状态...')
|
||||
checkingOllamaStatus.value = true
|
||||
try {
|
||||
const result = await checkOllamaStatus()
|
||||
ollamaServiceStatus.value = result.available
|
||||
console.log('Ollama服务状态检查完成:', result.available)
|
||||
} catch (error) {
|
||||
console.error('检查Ollama服务状态失败:', error)
|
||||
ollamaServiceStatus.value = false
|
||||
} finally {
|
||||
checkingOllamaStatus.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 打开Ollama设置窗口
|
||||
const goToOllamaSettings = async () => {
|
||||
console.log('点击跳转到Ollama设置按钮')
|
||||
// 关闭当前弹窗
|
||||
emit('update:visible', false)
|
||||
|
||||
// 先关闭设置弹窗(如果已打开)
|
||||
if (uiStore.showSettingsModal) {
|
||||
uiStore.closeSettings()
|
||||
// 等待 DOM 更新
|
||||
await nextTick()
|
||||
}
|
||||
|
||||
// 打开设置窗口并直接跳转到Ollama设置
|
||||
console.log('调用uiStore.openSettings')
|
||||
uiStore.openSettings('ollama')
|
||||
console.log('uiStore.openSettings调用完成')
|
||||
}
|
||||
|
||||
// 监听 visible 变化,初始化表单
|
||||
watch(() => props.visible, (val) => {
|
||||
if (val) {
|
||||
// 锁定背景滚动
|
||||
document.body.style.overflow = 'hidden'
|
||||
|
||||
|
||||
// 检查Ollama服务状态
|
||||
checkOllamaServiceStatus()
|
||||
|
||||
if (props.modelData) {
|
||||
formData.value = { ...props.modelData }
|
||||
} else {
|
||||
@@ -781,24 +845,25 @@ const handleCancel = () => {
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.45);
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1000;
|
||||
backdrop-filter: blur(6px);
|
||||
overflow: hidden; // 防止背景滚动
|
||||
backdrop-filter: blur(4px);
|
||||
overflow: hidden;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
// 弹窗主体
|
||||
.model-editor-modal {
|
||||
position: relative;
|
||||
width: 90vw;
|
||||
max-width: 600px;
|
||||
max-height: 85vh;
|
||||
width: 100%;
|
||||
max-width: 560px;
|
||||
max-height: 90vh;
|
||||
background: #fff;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
|
||||
box-shadow: 0 6px 28px rgba(15, 23, 42, 0.08);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
@@ -807,57 +872,53 @@ const handleCancel = () => {
|
||||
// 关闭按钮
|
||||
.close-btn {
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
top: 16px;
|
||||
right: 16px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: none;
|
||||
background: #f5f5f5;
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #666;
|
||||
transition: background-color 0.2s ease, color 0.2s ease;
|
||||
color: #666666;
|
||||
transition: all 0.15s ease;
|
||||
z-index: 10;
|
||||
|
||||
&:hover {
|
||||
background: rgba(7, 192, 95, 0.1);
|
||||
color: #07C05F;
|
||||
background: #f5f5f5;
|
||||
color: #333333;
|
||||
}
|
||||
}
|
||||
|
||||
// 标题区域
|
||||
.modal-header {
|
||||
padding: 28px 32px 20px;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
padding: 24px 24px 16px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
flex-shrink: 0;
|
||||
background: linear-gradient(to bottom, #ffffff 0%, #fafafa 100%);
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
margin: 0 0 8px 0;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 20px;
|
||||
margin: 0 0 6px 0;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #1a1a1a;
|
||||
letter-spacing: -0.3px;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.modal-desc {
|
||||
margin: 0;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
color: #666666;
|
||||
line-height: 22px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
// 内容区域
|
||||
.modal-body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 28px 32px;
|
||||
padding: 24px;
|
||||
background: #ffffff;
|
||||
|
||||
// 自定义滚动条
|
||||
@@ -873,16 +934,16 @@ const handleCancel = () => {
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: #d0d0d0;
|
||||
border-radius: 3px;
|
||||
transition: background 0.2s;
|
||||
transition: background 0.15s;
|
||||
|
||||
&:hover {
|
||||
background: #07C05F;
|
||||
background: #b0b0b0;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.t-form) {
|
||||
.t-form-item {
|
||||
display: none; // 隐藏 t-form-item,使用自定义的 form-item
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -898,16 +959,14 @@ const handleCancel = () => {
|
||||
|
||||
.form-label {
|
||||
display: block;
|
||||
margin-bottom: 10px;
|
||||
font-family: "PingFang SC";
|
||||
margin-bottom: 8px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #333333;
|
||||
letter-spacing: -0.2px;
|
||||
|
||||
&.required::after {
|
||||
content: '*';
|
||||
color: #FA5151;
|
||||
color: #f56c6c;
|
||||
margin-left: 4px;
|
||||
font-weight: 600;
|
||||
}
|
||||
@@ -919,23 +978,29 @@ const handleCancel = () => {
|
||||
:deep(.t-textarea),
|
||||
:deep(.t-input-number) {
|
||||
width: 100%;
|
||||
font-size: 14px;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
font-size: 13px;
|
||||
|
||||
.t-input__inner,
|
||||
input {
|
||||
font-size: 14px;
|
||||
.t-input__wrap,
|
||||
input,
|
||||
textarea {
|
||||
font-size: 13px;
|
||||
border-radius: 6px;
|
||||
transition: all 0.2s ease;
|
||||
border-color: #d9d9d9;
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
|
||||
&:hover .t-input__inner,
|
||||
&:hover input {
|
||||
border-color: #07C05F;
|
||||
&:hover .t-input__wrap,
|
||||
&:hover input,
|
||||
&:hover textarea {
|
||||
border-color: #b3b3b3;
|
||||
}
|
||||
|
||||
|
||||
&.t-is-focused .t-input__inner,
|
||||
&.t-is-focused input {
|
||||
&.t-is-focused .t-input__wrap,
|
||||
&.t-is-focused input,
|
||||
&.t-is-focused textarea {
|
||||
border-color: #07C05F;
|
||||
box-shadow: 0 0 0 2px rgba(7, 192, 95, 0.1);
|
||||
}
|
||||
@@ -944,13 +1009,12 @@ const handleCancel = () => {
|
||||
// 单选按钮组
|
||||
:deep(.t-radio-group) {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
|
||||
gap: 24px;
|
||||
|
||||
.t-radio {
|
||||
margin-right: 0;
|
||||
font-size: 14px;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
font-size: 13px;
|
||||
|
||||
&:hover {
|
||||
.t-radio__label {
|
||||
color: #07C05F;
|
||||
@@ -959,11 +1023,11 @@ const handleCancel = () => {
|
||||
}
|
||||
|
||||
.t-radio__label {
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
color: #333333;
|
||||
transition: color 0.2s ease;
|
||||
transition: color 0.15s ease;
|
||||
}
|
||||
|
||||
|
||||
.t-radio__input:checked + .t-radio__label {
|
||||
color: #07C05F;
|
||||
font-weight: 500;
|
||||
@@ -972,44 +1036,55 @@ const handleCancel = () => {
|
||||
|
||||
// 复选框
|
||||
:deep(.t-checkbox) {
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
|
||||
.t-checkbox__label {
|
||||
font-size: 14px;
|
||||
color: #000000e6;
|
||||
font-size: 13px;
|
||||
color: #333333;
|
||||
}
|
||||
}
|
||||
|
||||
// 底部按钮区域
|
||||
.modal-footer {
|
||||
padding: 20px 32px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
padding: 16px 24px;
|
||||
border-top: 1px solid #e5e7eb;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
flex-shrink: 0;
|
||||
background: #fafafa;
|
||||
|
||||
|
||||
:deep(.t-button) {
|
||||
min-width: 88px;
|
||||
min-width: 80px;
|
||||
height: 36px;
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
border-radius: 6px;
|
||||
|
||||
transition: all 0.15s ease;
|
||||
|
||||
&.t-button--theme-primary {
|
||||
background: #07C05F;
|
||||
border-color: #07C05F;
|
||||
|
||||
|
||||
&:hover {
|
||||
background: #06b04d;
|
||||
border-color: #06b04d;
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: #059642;
|
||||
border-color: #059642;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
&.t-button--variant-outline {
|
||||
color: #666666;
|
||||
border-color: #d9d9d9;
|
||||
|
||||
&:hover {
|
||||
border-color: #07C05F;
|
||||
color: #07C05F;
|
||||
background: rgba(7, 192, 95, 0.04);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1018,7 +1093,11 @@ const handleCancel = () => {
|
||||
// 过渡动画
|
||||
.modal-enter-active,
|
||||
.modal-leave-active {
|
||||
transition: all 0.3s ease;
|
||||
transition: opacity 0.2s ease;
|
||||
|
||||
.model-editor-modal {
|
||||
transition: transform 0.2s ease, opacity 0.2s ease;
|
||||
}
|
||||
}
|
||||
|
||||
.modal-enter-from,
|
||||
@@ -1027,6 +1106,7 @@ const handleCancel = () => {
|
||||
|
||||
.model-editor-modal {
|
||||
transform: scale(0.95);
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1039,20 +1119,25 @@ const handleCancel = () => {
|
||||
.test-message {
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
|
||||
flex: 1;
|
||||
|
||||
&.success {
|
||||
color: #07C05F;
|
||||
color: #059669;
|
||||
}
|
||||
|
||||
|
||||
&.error {
|
||||
color: #e34d59;
|
||||
color: #f56c6c;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
:deep(.t-button) {
|
||||
min-width: 100px;
|
||||
min-width: 88px;
|
||||
height: 32px;
|
||||
font-size: 13px;
|
||||
border-radius: 6px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
|
||||
.status-icon {
|
||||
font-size: 16px;
|
||||
flex-shrink: 0;
|
||||
@@ -1062,7 +1147,7 @@ const handleCancel = () => {
|
||||
}
|
||||
|
||||
&.unavailable {
|
||||
color: #e34d59;
|
||||
color: #f56c6c;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1163,16 +1248,24 @@ const handleCancel = () => {
|
||||
.t-select {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
:deep(.t-button) {
|
||||
height: 32px;
|
||||
font-size: 13px;
|
||||
border-radius: 6px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.refresh-btn {
|
||||
margin-top: 0;
|
||||
font-size: 12px;
|
||||
font-size: 13px;
|
||||
color: #666666;
|
||||
flex-shrink: 0;
|
||||
|
||||
|
||||
&:hover {
|
||||
color: #07C05F;
|
||||
background: rgba(7, 192, 95, 0.04);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1207,5 +1300,65 @@ const handleCancel = () => {
|
||||
color: #07C05F;
|
||||
}
|
||||
}
|
||||
|
||||
// Ollama不可用提示样式
|
||||
.ollama-unavailable-tip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 12px;
|
||||
padding: 10px 12px;
|
||||
background: #fef2f2;
|
||||
border: 1px solid #fecaca;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
|
||||
.tip-icon {
|
||||
color: #f56c6c;
|
||||
font-size: 16px;
|
||||
flex-shrink: 0;
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
.tip-text {
|
||||
color: #dc2626;
|
||||
flex: 1;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
:deep(.tip-link) {
|
||||
color: #07C05F;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
padding: 4px 6px 4px 10px !important;
|
||||
min-height: auto !important;
|
||||
height: auto !important;
|
||||
line-height: 1.4 !important;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
display: inline-flex !important;
|
||||
align-items: center !important;
|
||||
gap: 1px;
|
||||
border-radius: 4px;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
background: rgba(7, 192, 95, 0.08) !important;
|
||||
color: #05a04f !important;
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: rgba(7, 192, 95, 0.12) !important;
|
||||
}
|
||||
|
||||
.t-icon {
|
||||
font-size: 14px !important;
|
||||
margin: 0 !important;
|
||||
line-height: 1 !important;
|
||||
display: inline-flex !important;
|
||||
align-items: center !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ renderer.image = function (href, title, text) {
|
||||
<figcaption style="text-align: left;">${text || ''}</figcaption>
|
||||
</figure>`;
|
||||
};
|
||||
const props = defineProps(["visible", "details"]);
|
||||
const props = defineProps(["visible", "details", "knowledgeType", "sourceInfo"]);
|
||||
const emit = defineEmits(["closeDoc", "getDoc"]);
|
||||
watch(() => props.details.md, (newVal) => {
|
||||
nextTick(async () => {
|
||||
@@ -100,6 +100,91 @@ const handleClose = () => {
|
||||
emit("closeDoc", false);
|
||||
doc.scrollTop = 0;
|
||||
};
|
||||
|
||||
// 获取显示标题
|
||||
const getDisplayTitle = () => {
|
||||
if (!props.details.title) return '';
|
||||
if (props.details.type === 'file') {
|
||||
// 文件类型去掉扩展名
|
||||
const lastDotIndex = props.details.title.lastIndexOf(".");
|
||||
return lastDotIndex > 0 ? props.details.title.substring(0, lastDotIndex) : props.details.title;
|
||||
}
|
||||
// URL和手动创建直接返回标题
|
||||
return props.details.title;
|
||||
};
|
||||
|
||||
// 获取类型标签
|
||||
const getTypeLabel = () => {
|
||||
switch (props.details.type) {
|
||||
case 'url':
|
||||
return t('knowledgeBase.typeURL') || '网页';
|
||||
case 'manual':
|
||||
return t('knowledgeBase.typeManual') || '手动创建';
|
||||
case 'file':
|
||||
return props.details.file_type ? props.details.file_type.toUpperCase() : t('knowledgeBase.typeFile') || '文件';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
// 获取类型主题色
|
||||
const getTypeTheme = () => {
|
||||
switch (props.details.type) {
|
||||
case 'url':
|
||||
return 'primary';
|
||||
case 'manual':
|
||||
return 'success';
|
||||
case 'file':
|
||||
return 'default';
|
||||
default:
|
||||
return 'default';
|
||||
}
|
||||
};
|
||||
|
||||
// 获取内容标签
|
||||
const getContentLabel = () => {
|
||||
switch (props.details.type) {
|
||||
case 'url':
|
||||
return t('knowledgeBase.webContent') || '网页内容';
|
||||
case 'manual':
|
||||
return t('knowledgeBase.documentContent') || '文档内容';
|
||||
case 'file':
|
||||
default:
|
||||
return t('knowledgeBase.fileContent') || '文件内容';
|
||||
}
|
||||
};
|
||||
|
||||
// 获取时间标签
|
||||
const getTimeLabel = () => {
|
||||
switch (props.details.type) {
|
||||
case 'url':
|
||||
return t('knowledgeBase.importTime') || '导入时间';
|
||||
case 'manual':
|
||||
return t('knowledgeBase.createTime') || '创建时间';
|
||||
case 'file':
|
||||
default:
|
||||
return t('knowledgeBase.uploadTime') || '上传时间';
|
||||
}
|
||||
};
|
||||
|
||||
// 获取Chunk样式类
|
||||
const getChunkClass = (index: number) => {
|
||||
return index % 2 !== 0 ? 'chunk-odd' : 'chunk-even';
|
||||
};
|
||||
|
||||
// 获取Chunk元数据
|
||||
const getChunkMeta = (item: any) => {
|
||||
if (!item) return '';
|
||||
const parts = [];
|
||||
if (item.char_count) {
|
||||
parts.push(`${item.char_count} ${t('knowledgeBase.characters') || '字符'}`);
|
||||
}
|
||||
if (item.token_count) {
|
||||
parts.push(`${item.token_count} tokens`);
|
||||
}
|
||||
return parts.join(' · ');
|
||||
};
|
||||
|
||||
const downloadFile = () => {
|
||||
downKnowledgeDetails(props.details.id)
|
||||
.then((result) => {
|
||||
@@ -139,10 +224,17 @@ const handleDetailsScroll = () => {
|
||||
<template>
|
||||
<div class="doc_content" ref="mdContentWrap">
|
||||
<t-drawer :visible="visible" :zIndex="2000" :closeBtn="true" @close="handleClose">
|
||||
<template #header>{{
|
||||
details.title.substring(0, details.title.lastIndexOf("."))
|
||||
}}</template>
|
||||
<div class="doc_box">
|
||||
<template #header>
|
||||
<div class="drawer-header">
|
||||
<span class="header-title">{{ getDisplayTitle() }}</span>
|
||||
<t-tag v-if="details.type" size="small" :theme="getTypeTheme()" variant="light">
|
||||
{{ getTypeLabel() }}
|
||||
</t-tag>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 文件类型专属区域 -->
|
||||
<div v-if="details.type === 'file'" class="doc_box">
|
||||
<a :href="url" style="display: none" ref="down" :download="details.title"></a>
|
||||
<span class="label">{{ $t('knowledgeBase.fileName') }}</span>
|
||||
<div class="download_box">
|
||||
@@ -152,17 +244,48 @@ const handleDetailsScroll = () => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- URL类型专属区域 -->
|
||||
<div v-else-if="details.type === 'url'" class="url_box">
|
||||
<span class="label">{{ $t('knowledgeBase.urlSource') || '来源网址' }}</span>
|
||||
<div class="url_link_box">
|
||||
<a :href="details.source" target="_blank" class="url_link">
|
||||
<t-icon name="link" size="14px" />
|
||||
<span class="url_text">{{ details.source }}</span>
|
||||
<t-icon name="jump" size="14px" class="jump-icon" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 手动创建类型专属区域 -->
|
||||
<div v-else-if="details.type === 'manual'" class="manual_box">
|
||||
<span class="label">{{ $t('knowledgeBase.documentTitle') || '文档标题' }}</span>
|
||||
<div class="manual_title_box">
|
||||
<span class="manual_title">{{ details.title }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content_header">
|
||||
<span class="label">{{ $t('knowledgeBase.fileContent') }}</span>
|
||||
<span class="time"> {{ $t('knowledgeBase.uploadTime') }}:{{ details.time }} </span>
|
||||
<span class="label">{{ getContentLabel() }}</span>
|
||||
<span class="time"> {{ getTimeLabel() }}:{{ details.time }} </span>
|
||||
</div>
|
||||
|
||||
<div v-if="details.md.length == 0" class="no_content">{{ $t('common.noData') }}</div>
|
||||
<div v-else class="content" v-for="(item, index) in details.md" :key="index" :style="index % 2 !== 0
|
||||
? 'background: #07c05f26;'
|
||||
: 'background: #3032360f;'
|
||||
">
|
||||
<div class="md-content" v-html="processMarkdown(item.content)"></div>
|
||||
<div v-else class="chunk-list">
|
||||
<div
|
||||
class="chunk-item"
|
||||
v-for="(item, index) in details.md"
|
||||
:key="index"
|
||||
:class="getChunkClass(index)"
|
||||
>
|
||||
<div class="chunk-header">
|
||||
<span class="chunk-index">{{ $t('knowledgeBase.segment') || '片段' }} {{ index + 1 }}</span>
|
||||
<span class="chunk-meta">{{ getChunkMeta(item) }}</span>
|
||||
</div>
|
||||
<div class="md-content" v-html="processMarkdown(item.content)"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<t-button @click="handleClose">{{ $t('common.confirm') }}</t-button>
|
||||
<t-button theme="default" @click="handleClose">{{ $t('common.cancel') }}</t-button>
|
||||
@@ -185,16 +308,24 @@ const handleDetailsScroll = () => {
|
||||
padding: 16px 24px;
|
||||
}
|
||||
|
||||
.content {
|
||||
word-break: break-word;
|
||||
padding: 4px;
|
||||
gap: 4px;
|
||||
margin-top: 12px;
|
||||
.drawer-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
|
||||
.header-title {
|
||||
flex: 1;
|
||||
font-weight: 600;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.doc_box {
|
||||
.doc_box, .url_box, .manual_box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.label {
|
||||
@@ -206,6 +337,7 @@ const handleDetailsScroll = () => {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
// 文件下载区域
|
||||
.download_box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -238,13 +370,71 @@ const handleDetailsScroll = () => {
|
||||
}
|
||||
}
|
||||
|
||||
// URL链接区域
|
||||
.url_link_box {
|
||||
border-radius: 4px;
|
||||
border: 1px solid #d0e8dc;
|
||||
background: #f0fdf4;
|
||||
padding: 8px 12px;
|
||||
|
||||
.url_link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
color: #059669;
|
||||
text-decoration: none;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
color: #07c05f;
|
||||
background: #e6f7ed;
|
||||
border-radius: 3px;
|
||||
padding: 4px 6px;
|
||||
margin: -4px -6px;
|
||||
|
||||
.jump-icon {
|
||||
transform: translateX(2px);
|
||||
}
|
||||
}
|
||||
|
||||
.url_text {
|
||||
flex: 1;
|
||||
font-size: 13px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.jump-icon {
|
||||
transition: transform 0.2s ease;
|
||||
flex-shrink: 0;
|
||||
color: #059669;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 手动创建标题区域
|
||||
.manual_title_box {
|
||||
border-radius: 4px;
|
||||
border: 1px solid #dcdcdc;
|
||||
background: #f0fdf4;
|
||||
padding: 8px 12px;
|
||||
|
||||
.manual_title {
|
||||
color: #1d2129;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
word-break: break-word;
|
||||
}
|
||||
}
|
||||
|
||||
.content_header {
|
||||
margin-top: 22px;
|
||||
margin-bottom: 24px;
|
||||
margin-bottom: 16px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.time {
|
||||
margin-left: 12px;
|
||||
color: #00000066;
|
||||
font-size: 12px;
|
||||
font-style: normal;
|
||||
@@ -258,5 +448,68 @@ const handleDetailsScroll = () => {
|
||||
font-size: 12px;
|
||||
padding: 16px;
|
||||
background: #fbfbfb;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
// Chunk列表样式
|
||||
.chunk-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.chunk-item {
|
||||
border-radius: 6px;
|
||||
padding: 12px;
|
||||
transition: all 0.2s ease;
|
||||
border: 1px solid transparent;
|
||||
|
||||
&.chunk-even {
|
||||
background: #3032360f;
|
||||
}
|
||||
|
||||
&.chunk-odd {
|
||||
background: #07c05f0d;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-color: #07c05f;
|
||||
box-shadow: 0 2px 8px rgba(7, 192, 95, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
.chunk-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 8px;
|
||||
padding-bottom: 6px;
|
||||
border-bottom: 1px solid #e7e7e7;
|
||||
|
||||
.chunk-index {
|
||||
color: #00000099;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.chunk-meta {
|
||||
color: #00000066;
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
.md-content {
|
||||
word-break: break-word;
|
||||
line-height: 1.6;
|
||||
color: #1d2129;
|
||||
}
|
||||
|
||||
// 保留旧样式作为兼容(已被chunk-item替代)
|
||||
.content {
|
||||
word-break: break-word;
|
||||
padding: 4px;
|
||||
gap: 4px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -664,6 +664,7 @@ onBeforeUnmount(() => {
|
||||
width="880px"
|
||||
top="5%"
|
||||
class="manual-knowledge-editor"
|
||||
destroy-on-close
|
||||
>
|
||||
<div class="editor-body" v-if="initialLoaded">
|
||||
<div class="form-row">
|
||||
@@ -674,12 +675,7 @@ onBeforeUnmount(() => {
|
||||
:loading="kbLoading"
|
||||
:options="kbOptions"
|
||||
:placeholder="$t('manualEditor.form.knowledgeBasePlaceholder')"
|
||||
:popup-props="{
|
||||
attach: 'body',
|
||||
overlayStyle: { zIndex: 3000 },
|
||||
onVisibleChange: (visible) => console.log('[ManualEditor] Select dropdown visible:', visible)
|
||||
}"
|
||||
@focus="() => console.log('[ManualEditor] Select focused, options:', kbOptions)"
|
||||
:popup-props="{ attach: 'body' }"
|
||||
>
|
||||
<template #empty>
|
||||
<div style="padding: 20px; text-align: center; color: #999;">
|
||||
@@ -1047,21 +1043,11 @@ onBeforeUnmount(() => {
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- 全局样式:确保在dialog中的select下拉列表能够正常显示 -->
|
||||
<style lang="less">
|
||||
// TDesign Select 下拉框在 Dialog 中的 z-index 修复
|
||||
.t-select__dropdown {
|
||||
z-index: 3000 !important;
|
||||
}
|
||||
|
||||
// 确保挂载到 body 的 select popup 能正常显示
|
||||
body > .t-popup {
|
||||
z-index: 3000 !important;
|
||||
}
|
||||
|
||||
// 针对 manual-knowledge-editor 中的 select
|
||||
.manual-knowledge-editor + .t-select__dropdown,
|
||||
.manual-knowledge-editor ~ .t-select__dropdown {
|
||||
z-index: 3000 !important;
|
||||
// 全局样式:确保 select 下拉列表在 dialog 之上
|
||||
.t-popup {
|
||||
z-index: 2600 !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
@@ -32,6 +32,27 @@
|
||||
<span class="kb-action-title">{{ t('upload.uploadDocument') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="menu_item kb-action-item" @click.stop="handleDocFolderUploadClick">
|
||||
<div class="kb-action-icon-wrapper">
|
||||
<svg class="kb-action-icon" width="18" height="18" viewBox="0 0 24 24" fill="none">
|
||||
<path d="M22 19C22 19.5304 21.7893 20.0391 21.4142 20.4142C21.0391 20.7893 20.5304 21 20 21H4C3.46957 21 2.96086 20.7893 2.58579 20.4142C2.21071 20.0391 2 19.5304 2 19V5C2 4.46957 2.21071 3.96086 2.58579 3.58579C2.96086 3.21071 3.46957 3 4 3H9L11 6H20C20.5304 6 21.0391 6.21071 21.4142 6.58579C21.7893 6.96086 22 7.46957 22 8V19Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M12 11V17M9 14H15" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="kb-action-content">
|
||||
<span class="kb-action-title">{{ t('upload.uploadFolder') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="menu_item kb-action-item" @click.stop="handleDocURLImport">
|
||||
<div class="kb-action-icon-wrapper">
|
||||
<svg class="kb-action-icon" width="18" height="18" viewBox="0 0 24 24" fill="none">
|
||||
<path d="M10 13C10.4295 13.5741 10.9774 14.0491 11.6066 14.3929C12.2357 14.7367 12.9315 14.9411 13.6467 14.9923C14.3618 15.0435 15.0796 14.9403 15.7513 14.6897C16.4231 14.4392 17.0331 14.047 17.54 13.54L20.54 10.54C21.4508 9.59695 21.9548 8.33394 21.9434 7.02296C21.932 5.71198 21.4061 4.45791 20.4791 3.53087C19.5521 2.60383 18.298 2.07799 16.987 2.0666C15.676 2.0552 14.413 2.55918 13.47 3.46997L11.75 5.17997M14 11C13.5705 10.4258 13.0226 9.95078 12.3934 9.60703C11.7642 9.26327 11.0685 9.05885 10.3533 9.00763C9.63819 8.95641 8.92037 9.0596 8.24861 9.31018C7.57685 9.56077 6.96685 9.9529 6.45996 10.46L3.45996 13.46C2.54917 14.403 2.04519 15.666 2.05659 16.977C2.06798 18.288 2.59382 19.542 3.52086 20.4691C4.44791 21.3961 5.70197 21.9219 7.01295 21.9333C8.32393 21.9447 9.58694 21.4408 10.53 20.53L12.24 18.82" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="kb-action-content">
|
||||
<span class="kb-action-title">{{ t('knowledgeBase.importURL') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="menu_item kb-action-item" @click.stop="handleDocManualCreate">
|
||||
<div class="kb-action-icon-wrapper">
|
||||
<svg class="kb-action-icon" width="18" height="18" viewBox="0 0 18 18" fill="none">
|
||||
@@ -117,8 +138,16 @@
|
||||
type="file"
|
||||
class="kb-upload-input"
|
||||
accept=".pdf,.docx,.doc,.txt,.md,.jpg,.jpeg,.png"
|
||||
multiple
|
||||
@change="handleDocFileChange"
|
||||
/>
|
||||
<input
|
||||
ref="docFolderInput"
|
||||
type="file"
|
||||
class="kb-upload-input"
|
||||
webkitdirectory
|
||||
@change="handleDocFolderChange"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -127,7 +156,7 @@ import { storeToRefs } from 'pinia';
|
||||
import { onMounted, watch, computed, ref, reactive } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { getSessionsList, delSession } from "@/api/chat/index";
|
||||
import { getKnowledgeBaseById, uploadKnowledgeFile } from '@/api/knowledge-base';
|
||||
import { getKnowledgeBaseById, uploadKnowledgeFile, createKnowledgeFromURL } from '@/api/knowledge-base';
|
||||
import { logout as logoutApi } from '@/api/auth';
|
||||
import { useMenuStore } from '@/stores/menu';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
@@ -222,6 +251,7 @@ const bottomMenuItems = computed<MenuItem[]>(() => {
|
||||
const currentKbName = ref<string>('')
|
||||
const currentKbInfo = ref<any>(null)
|
||||
const docUploadInput = ref<HTMLInputElement | null>(null)
|
||||
const docFolderInput = ref<HTMLInputElement | null>(null)
|
||||
const pendingUploadKbId = ref<string | null>(null)
|
||||
|
||||
const showKbActions = computed(() => (isInKnowledgeBase.value && !!currentKbInfo.value) || isInKnowledgeBaseList.value)
|
||||
@@ -586,39 +616,236 @@ const handleDocUploadClick = async () => {
|
||||
|
||||
const handleDocFileChange = async (event: Event) => {
|
||||
const input = event.target as HTMLInputElement
|
||||
const file = input?.files?.[0]
|
||||
if (!file) {
|
||||
pendingUploadKbId.value = null
|
||||
return
|
||||
}
|
||||
if (kbFileTypeVerification(file)) {
|
||||
input.value = ''
|
||||
const files = input?.files
|
||||
if (!files || files.length === 0) {
|
||||
pendingUploadKbId.value = null
|
||||
return
|
||||
}
|
||||
|
||||
const kbId = pendingUploadKbId.value || (await ensureDocKnowledgeBaseReady())
|
||||
pendingUploadKbId.value = null
|
||||
if (!kbId) {
|
||||
input.value = ''
|
||||
return
|
||||
}
|
||||
try {
|
||||
await uploadKnowledgeFile(kbId, { file })
|
||||
|
||||
// 过滤有效文件
|
||||
const validFiles: File[] = []
|
||||
let invalidCount = 0
|
||||
const isSingleFile = files.length === 1
|
||||
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i]
|
||||
// 单文件时显示错误,多文件时静默过滤
|
||||
if (kbFileTypeVerification(file, !isSingleFile)) {
|
||||
invalidCount++
|
||||
} else {
|
||||
validFiles.push(file)
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有有效文件,多文件时显示汇总提示
|
||||
if (validFiles.length === 0) {
|
||||
if (!isSingleFile && invalidCount > 0) {
|
||||
MessagePlugin.error(t('knowledgeBase.noValidFilesSelected'))
|
||||
}
|
||||
// 单文件的错误已经在 kbFileTypeVerification 中显示了
|
||||
input.value = ''
|
||||
return
|
||||
}
|
||||
|
||||
// 批量上传
|
||||
let successCount = 0
|
||||
let failCount = 0
|
||||
const totalCount = validFiles.length
|
||||
const failedFiles: Array<{ name: string; reason: string }> = []
|
||||
|
||||
// 显示上传提示
|
||||
if (totalCount > 1) {
|
||||
if (invalidCount > 0) {
|
||||
MessagePlugin.info(t('knowledgeBase.uploadingValidFiles', {
|
||||
valid: totalCount,
|
||||
total: files.length
|
||||
}))
|
||||
} else {
|
||||
MessagePlugin.info(t('knowledgeBase.uploadingMultiple', { total: totalCount }))
|
||||
}
|
||||
}
|
||||
|
||||
for (const file of validFiles) {
|
||||
try {
|
||||
await uploadKnowledgeFile(kbId, { file })
|
||||
successCount++
|
||||
} catch (error: any) {
|
||||
failCount++
|
||||
let errorReason = error?.error?.message || error?.message || t('knowledgeBase.uploadFailed')
|
||||
if (error?.code === 'duplicate_file' || error?.error?.code === 'duplicate_file') {
|
||||
errorReason = t('knowledgeBase.fileExists')
|
||||
}
|
||||
|
||||
// 只在单文件上传时显示详细错误
|
||||
if (totalCount === 1) {
|
||||
MessagePlugin.error(errorReason)
|
||||
} else {
|
||||
// 多文件上传时记录失败信息
|
||||
failedFiles.push({ name: file.name, reason: errorReason })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 显示上传结果
|
||||
if (successCount > 0) {
|
||||
window.dispatchEvent(new CustomEvent('knowledgeFileUploaded', {
|
||||
detail: { kbId }
|
||||
}))
|
||||
MessagePlugin.success(t('knowledgeBase.uploadSuccess'))
|
||||
} catch (error: any) {
|
||||
let errorMessage = error?.error?.message || error?.message || t('knowledgeBase.uploadFailed')
|
||||
if (error?.code === 'duplicate_file' || error?.error?.code === 'duplicate_file') {
|
||||
errorMessage = t('knowledgeBase.fileExists')
|
||||
}
|
||||
|
||||
if (totalCount === 1) {
|
||||
if (successCount === 1) {
|
||||
MessagePlugin.success(t('knowledgeBase.uploadSuccess'))
|
||||
}
|
||||
MessagePlugin.error(errorMessage)
|
||||
} finally {
|
||||
if (input) {
|
||||
input.value = ''
|
||||
// 单文件失败时已经在上面显示了详细错误
|
||||
} else {
|
||||
if (failCount === 0) {
|
||||
MessagePlugin.success(t('knowledgeBase.uploadAllSuccess', { count: successCount }))
|
||||
} else if (successCount > 0) {
|
||||
// 部分成功,显示详细失败信息
|
||||
const failedList = failedFiles.map(f => `• ${f.name}: ${f.reason}`).join('\n')
|
||||
MessagePlugin.warning({
|
||||
content: t('knowledgeBase.uploadPartialSuccess', {
|
||||
success: successCount,
|
||||
fail: failCount
|
||||
}) + '\n\n' + t('knowledgeBase.failedFilesList') + '\n' + failedList,
|
||||
duration: 8000,
|
||||
closeBtn: true
|
||||
})
|
||||
} else {
|
||||
// 全部失败,显示详细失败信息
|
||||
const failedList = failedFiles.slice(0, 5).map(f => `• ${f.name}: ${f.reason}`).join('\n')
|
||||
const moreCount = failedFiles.length > 5 ? failedFiles.length - 5 : 0
|
||||
MessagePlugin.error({
|
||||
content: t('knowledgeBase.uploadAllFailed') + '\n\n' +
|
||||
t('knowledgeBase.failedFilesList') + '\n' + failedList +
|
||||
(moreCount > 0 ? `\n${t('knowledgeBase.andMoreFiles', { count: moreCount })}` : ''),
|
||||
duration: 8000,
|
||||
closeBtn: true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
input.value = ''
|
||||
}
|
||||
|
||||
const handleDocFolderUploadClick = async () => {
|
||||
const kbId = await ensureDocKnowledgeBaseReady()
|
||||
if (!kbId) return
|
||||
pendingUploadKbId.value = kbId
|
||||
docFolderInput.value?.click()
|
||||
}
|
||||
|
||||
const handleDocFolderChange = async (event: Event) => {
|
||||
const input = event.target as HTMLInputElement
|
||||
const files = input?.files
|
||||
if (!files || files.length === 0) {
|
||||
pendingUploadKbId.value = null
|
||||
return
|
||||
}
|
||||
|
||||
const kbId = pendingUploadKbId.value || (await ensureDocKnowledgeBaseReady())
|
||||
pendingUploadKbId.value = null
|
||||
if (!kbId) {
|
||||
input.value = ''
|
||||
return
|
||||
}
|
||||
|
||||
// 过滤有效文件(文件夹上传始终使用静默模式)
|
||||
const validFiles: File[] = []
|
||||
let invalidCount = 0
|
||||
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i]
|
||||
// 文件夹上传时始终静默过滤
|
||||
if (kbFileTypeVerification(file, true)) {
|
||||
invalidCount++
|
||||
} else {
|
||||
validFiles.push(file)
|
||||
}
|
||||
}
|
||||
|
||||
// 如果没有有效文件,直接返回
|
||||
if (validFiles.length === 0) {
|
||||
if (invalidCount > 0) {
|
||||
MessagePlugin.error(t('knowledgeBase.noValidFilesInFolder', { total: files.length }))
|
||||
} else {
|
||||
MessagePlugin.error(t('knowledgeBase.noValidFiles'))
|
||||
}
|
||||
input.value = ''
|
||||
return
|
||||
}
|
||||
|
||||
// 显示过滤后的上传提示
|
||||
const totalCount = validFiles.length
|
||||
if (invalidCount > 0) {
|
||||
MessagePlugin.info(t('knowledgeBase.uploadingValidFiles', {
|
||||
valid: totalCount,
|
||||
total: files.length
|
||||
}))
|
||||
} else {
|
||||
MessagePlugin.info(t('knowledgeBase.uploadingFolder', { total: totalCount }))
|
||||
}
|
||||
|
||||
// 批量上传文件夹内容
|
||||
let successCount = 0
|
||||
let failCount = 0
|
||||
const failedFiles: Array<{ name: string; reason: string }> = []
|
||||
|
||||
for (const file of validFiles) {
|
||||
try {
|
||||
await uploadKnowledgeFile(kbId, { file })
|
||||
successCount++
|
||||
} catch (error: any) {
|
||||
failCount++
|
||||
let errorReason = error?.error?.message || error?.message || t('knowledgeBase.uploadFailed')
|
||||
if (error?.code === 'duplicate_file' || error?.error?.code === 'duplicate_file') {
|
||||
errorReason = t('knowledgeBase.fileExists')
|
||||
}
|
||||
failedFiles.push({ name: file.name, reason: errorReason })
|
||||
}
|
||||
}
|
||||
|
||||
if (successCount > 0) {
|
||||
window.dispatchEvent(new CustomEvent('knowledgeFileUploaded', {
|
||||
detail: { kbId }
|
||||
}))
|
||||
}
|
||||
|
||||
if (failCount === 0) {
|
||||
MessagePlugin.success(t('knowledgeBase.uploadAllSuccess', { count: successCount }))
|
||||
} else if (successCount > 0) {
|
||||
// 部分成功,显示详细失败信息
|
||||
const failedList = failedFiles.map(f => `• ${f.name}: ${f.reason}`).join('\n')
|
||||
MessagePlugin.warning({
|
||||
content: t('knowledgeBase.uploadPartialSuccess', {
|
||||
success: successCount,
|
||||
fail: failCount
|
||||
}) + '\n\n' + t('knowledgeBase.failedFilesList') + '\n' + failedList,
|
||||
duration: 8000,
|
||||
closeBtn: true
|
||||
})
|
||||
} else {
|
||||
// 全部失败,显示详细失败信息
|
||||
const failedList = failedFiles.slice(0, 5).map(f => `• ${f.name}: ${f.reason}`).join('\n')
|
||||
const moreCount = failedFiles.length > 5 ? failedFiles.length - 5 : 0
|
||||
MessagePlugin.error({
|
||||
content: t('knowledgeBase.uploadAllFailed') + '\n\n' +
|
||||
t('knowledgeBase.failedFilesList') + '\n' + failedList +
|
||||
(moreCount > 0 ? `\n${t('knowledgeBase.andMoreFiles', { count: moreCount })}` : ''),
|
||||
duration: 8000,
|
||||
closeBtn: true
|
||||
})
|
||||
}
|
||||
|
||||
input.value = ''
|
||||
}
|
||||
|
||||
const handleDocManualCreate = async () => {
|
||||
@@ -636,6 +863,15 @@ const handleDocManualCreate = async () => {
|
||||
})
|
||||
}
|
||||
|
||||
const handleDocURLImport = async () => {
|
||||
const kbId = await ensureDocKnowledgeBaseReady()
|
||||
if (!kbId) return
|
||||
|
||||
window.dispatchEvent(new CustomEvent('openURLImportDialog', {
|
||||
detail: { kbId }
|
||||
}))
|
||||
}
|
||||
|
||||
const dispatchFaqMenuAction = (action: 'create' | 'import', kbId: string) => {
|
||||
window.dispatchEvent(new CustomEvent('faqMenuAction', {
|
||||
detail: { action, kbId }
|
||||
@@ -720,19 +956,18 @@ const handleCreateKnowledgeBase = () => {
|
||||
|
||||
.kb-action-wrapper {
|
||||
border: 1px solid #e7e9eb;
|
||||
border-radius: 10px;
|
||||
padding: 10px;
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
margin-bottom: 12px;
|
||||
background: #fafcfc;
|
||||
box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
|
||||
}
|
||||
|
||||
.kb-action-label {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: #8b9196;
|
||||
margin-bottom: 8px;
|
||||
padding: 0 6px;
|
||||
margin-bottom: 6px;
|
||||
padding: 0 4px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.3px;
|
||||
}
|
||||
@@ -740,29 +975,26 @@ const handleCreateKnowledgeBase = () => {
|
||||
.kb-action-menu {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.kb-action-item {
|
||||
background: #fff;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #eef1f2;
|
||||
transition: all 0.12s ease;
|
||||
transition: background-color 0.08s ease, border-color 0.08s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 12px;
|
||||
gap: 8px;
|
||||
padding: 8px 10px;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background: #f0fdf6;
|
||||
border-color: #10b981;
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 2px 6px rgba(16, 185, 129, 0.08);
|
||||
|
||||
.kb-action-icon {
|
||||
color: #059669;
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.kb-action-title {
|
||||
@@ -771,26 +1003,25 @@ const handleCreateKnowledgeBase = () => {
|
||||
}
|
||||
|
||||
&:active {
|
||||
transform: translateY(0);
|
||||
box-shadow: 0 1px 3px rgba(16, 185, 129, 0.1);
|
||||
background: #e6f9f0;
|
||||
}
|
||||
}
|
||||
|
||||
.kb-action-icon-wrapper {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 6px;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 5px;
|
||||
background: #f0fdf6;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
transition: all 0.12s ease;
|
||||
transition: background-color 0.08s ease;
|
||||
}
|
||||
|
||||
.kb-action-icon {
|
||||
color: #10b981;
|
||||
transition: all 0.12s ease;
|
||||
transition: color 0.08s ease;
|
||||
}
|
||||
|
||||
.kb-action-item:hover .kb-action-icon-wrapper {
|
||||
@@ -806,7 +1037,7 @@ const handleCreateKnowledgeBase = () => {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: #0f172a;
|
||||
transition: color 0.12s ease;
|
||||
transition: color 0.08s ease;
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
|
||||
@@ -22,7 +22,10 @@ export default function (knowledgeBaseId?: string) {
|
||||
time: "",
|
||||
md: [] as any[],
|
||||
id: "",
|
||||
total: 0
|
||||
total: 0,
|
||||
type: "",
|
||||
source: "",
|
||||
file_type: ""
|
||||
});
|
||||
const getKnowled = (
|
||||
query: { page: number; page_size: number; tag_id?: string } = { page: 1, page_size: 35 },
|
||||
@@ -130,15 +133,21 @@ export default function (knowledgeBaseId?: string) {
|
||||
time: "",
|
||||
md: [],
|
||||
id: "",
|
||||
type: "",
|
||||
source: "",
|
||||
file_type: ""
|
||||
});
|
||||
getKnowledgeDetails(item.id)
|
||||
.then((result: any) => {
|
||||
if (result.success && result.data) {
|
||||
const { data } = result;
|
||||
Object.assign(details, {
|
||||
title: data.file_name,
|
||||
title: data.file_name || data.title || data.source || '未命名文档',
|
||||
time: formatStringDate(new Date(data.updated_at)),
|
||||
id: data.id,
|
||||
type: data.type || 'file',
|
||||
source: data.source || '',
|
||||
file_type: data.file_type || ''
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
@@ -50,6 +50,44 @@ export default {
|
||||
uploadFailed: 'File upload failed!',
|
||||
docActionUnsupported: 'This knowledge base type does not support this action',
|
||||
fileExists: 'File already exists',
|
||||
uploadingMultiple: 'Uploading {total} files...',
|
||||
uploadAllSuccess: 'Successfully uploaded {count} files!',
|
||||
uploadPartialSuccess: 'Upload completed: {success} succeeded, {fail} failed',
|
||||
uploadAllFailed: 'All files failed to upload',
|
||||
uploadingFolder: 'Uploading {total} files from folder...',
|
||||
uploadingValidFiles: 'Uploading {valid}/{total} valid files...',
|
||||
noValidFiles: 'No valid files',
|
||||
noValidFilesInFolder: 'All {total} files in folder are unsupported',
|
||||
noValidFilesSelected: 'All selected files are unsupported',
|
||||
unsupportedFileType: 'Unsupported file type',
|
||||
failedFilesList: 'Failed files:',
|
||||
andMoreFiles: '...and {count} more files',
|
||||
uploadFile: 'Upload File',
|
||||
uploadFileDesc: 'Supports PDF, Word, TXT, etc.',
|
||||
importURL: 'Import from URL',
|
||||
importURLDesc: 'Import via URL link',
|
||||
importURLTitle: 'Import from URL',
|
||||
manualCreate: 'Manual Create',
|
||||
manualCreateDesc: 'Write document content directly',
|
||||
urlRequired: 'Please enter a URL',
|
||||
invalidURL: 'Please enter a valid URL',
|
||||
urlImportSuccess: 'URL imported successfully!',
|
||||
urlImportFailed: 'URL import failed!',
|
||||
urlExists: 'This URL already exists',
|
||||
urlLabel: 'URL Address',
|
||||
urlPlaceholder: 'Enter webpage URL, e.g., https://example.com',
|
||||
urlTip: 'Supports importing various webpage contents. The system will automatically extract and parse text content from the webpage',
|
||||
typeURL: 'URL',
|
||||
typeManual: 'Manual',
|
||||
typeFile: 'File',
|
||||
urlSource: 'Source URL',
|
||||
documentTitle: 'Document Title',
|
||||
webContent: 'Web Content',
|
||||
documentContent: 'Document Content',
|
||||
importTime: 'Import Time',
|
||||
createTime: 'Create Time',
|
||||
characters: 'chars',
|
||||
segment: 'Segment',
|
||||
notInitialized: 'Knowledge base is not initialized. Please configure models in settings before uploading files',
|
||||
getInfoFailed: 'Failed to get knowledge base information, file upload is not possible',
|
||||
missingId: 'Knowledge base ID is missing',
|
||||
@@ -712,6 +750,11 @@ export default {
|
||||
features: {
|
||||
knowledgeGraph: 'Knowledge Graph Enabled',
|
||||
multimodal: 'Multimodal Enabled'
|
||||
},
|
||||
stats: {
|
||||
documents: 'Document Count',
|
||||
faqEntries: 'FAQ Entries',
|
||||
chunks: 'Chunk Count'
|
||||
}
|
||||
},
|
||||
knowledgeEditor: {
|
||||
@@ -1283,6 +1326,8 @@ export default {
|
||||
downloadCompleted: '{name} downloaded successfully',
|
||||
downloadFailed: 'Failed to download {name}',
|
||||
downloadStartFailed: 'Failed to start download',
|
||||
ollamaUnavailable: 'Ollama service is unavailable, local models cannot be selected',
|
||||
goToOllamaSettings: 'Open Settings',
|
||||
validation: {
|
||||
modelNameRequired: 'Please enter the model name',
|
||||
modelNameEmpty: 'Model name cannot be empty',
|
||||
@@ -1340,6 +1385,7 @@ export default {
|
||||
},
|
||||
upload: {
|
||||
uploadDocument: 'Upload Document',
|
||||
uploadFolder: 'Upload Folder',
|
||||
onlineEdit: 'Online Edit',
|
||||
deleteRecord: 'Delete Record'
|
||||
},
|
||||
|
||||
@@ -50,6 +50,44 @@ export default {
|
||||
uploadFailed: 'Ошибка загрузки файла!',
|
||||
docActionUnsupported: 'Этот тип базы знаний не поддерживает данную операцию',
|
||||
fileExists: 'Файл уже существует',
|
||||
uploadingMultiple: 'Загрузка {total} файлов...',
|
||||
uploadAllSuccess: 'Успешно загружено {count} файлов!',
|
||||
uploadPartialSuccess: 'Загрузка завершена: успешно {success}, ошибка {fail}',
|
||||
uploadAllFailed: 'Все файлы не удалось загрузить',
|
||||
uploadingFolder: 'Загрузка {total} файлов из папки...',
|
||||
uploadingValidFiles: 'Загрузка {valid}/{total} действительных файлов...',
|
||||
noValidFiles: 'Нет действительных файлов',
|
||||
noValidFilesInFolder: 'Все {total} файлов в папке не поддерживаются',
|
||||
noValidFilesSelected: 'Все выбранные файлы не поддерживаются',
|
||||
unsupportedFileType: 'Неподдерживаемый тип файла',
|
||||
failedFilesList: 'Неудавшиеся файлы:',
|
||||
andMoreFiles: '...и ещё {count} файлов',
|
||||
uploadFile: 'Загрузить файл',
|
||||
uploadFileDesc: 'Поддерживает PDF, Word, TXT и т.д.',
|
||||
importURL: 'Импорт из URL',
|
||||
importURLDesc: 'Импорт по ссылке URL',
|
||||
importURLTitle: 'Импорт из URL',
|
||||
manualCreate: 'Создать вручную',
|
||||
manualCreateDesc: 'Написать содержимое документа напрямую',
|
||||
urlRequired: 'Пожалуйста, введите URL',
|
||||
invalidURL: 'Пожалуйста, введите корректный URL',
|
||||
urlImportSuccess: 'URL успешно импортирован!',
|
||||
urlImportFailed: 'Ошибка импорта URL!',
|
||||
urlExists: 'Этот URL уже существует',
|
||||
urlLabel: 'Адрес URL',
|
||||
urlPlaceholder: 'Введите URL веб-страницы, например: https://example.com',
|
||||
urlTip: 'Поддерживает импорт различного веб-содержимого. Система автоматически извлечет и проанализирует текстовое содержимое с веб-страницы',
|
||||
typeURL: 'URL',
|
||||
typeManual: 'Вручную',
|
||||
typeFile: 'Файл',
|
||||
urlSource: 'Исходный URL',
|
||||
documentTitle: 'Название документа',
|
||||
webContent: 'Веб-содержимое',
|
||||
documentContent: 'Содержимое документа',
|
||||
importTime: 'Время импорта',
|
||||
createTime: 'Время создания',
|
||||
characters: 'символов',
|
||||
segment: 'Фрагмент',
|
||||
notInitialized: 'База знаний не инициализирована. Пожалуйста, настройте модели в разделе настроек перед загрузкой файлов',
|
||||
getInfoFailed: 'Не удалось получить информацию о базе знаний, загрузка файла невозможна',
|
||||
missingId: 'Отсутствует ID базы знаний',
|
||||
@@ -759,6 +797,8 @@ export default {
|
||||
downloadCompleted: '{name} успешно загружена',
|
||||
downloadFailed: 'Не удалось загрузить {name}',
|
||||
downloadStartFailed: 'Не удалось запустить загрузку',
|
||||
ollamaUnavailable: 'Сервис Ollama недоступен, локальные модели недоступны для выбора',
|
||||
goToOllamaSettings: 'Открыть настройки',
|
||||
validation: {
|
||||
modelNameRequired: 'Введите название модели',
|
||||
modelNameEmpty: 'Название модели не может быть пустым',
|
||||
@@ -799,6 +839,11 @@ export default {
|
||||
features: {
|
||||
knowledgeGraph: 'Граф знаний включен',
|
||||
multimodal: 'Мультимодальность включена'
|
||||
},
|
||||
stats: {
|
||||
documents: 'Количество документов',
|
||||
faqEntries: 'FAQ записи',
|
||||
chunks: 'Количество фрагментов'
|
||||
}
|
||||
},
|
||||
knowledgeEditor: {
|
||||
@@ -1175,6 +1220,7 @@ export default {
|
||||
},
|
||||
upload: {
|
||||
uploadDocument: 'Загрузить документ',
|
||||
uploadFolder: 'Загрузить папку',
|
||||
onlineEdit: 'Онлайн редактирование',
|
||||
deleteRecord: 'Удалить запись'
|
||||
},
|
||||
|
||||
@@ -49,6 +49,44 @@ export default {
|
||||
uploadSuccess: "文件上传成功!",
|
||||
uploadFailed: "文件上传失败!",
|
||||
fileExists: "文件已存在",
|
||||
uploadingMultiple: "正在上传 {total} 个文件...",
|
||||
uploadAllSuccess: "成功上传 {count} 个文件!",
|
||||
uploadPartialSuccess: "上传完成:成功 {success} 个,失败 {fail} 个",
|
||||
uploadAllFailed: "所有文件上传失败",
|
||||
uploadingFolder: "正在上传文件夹中的 {total} 个文件...",
|
||||
uploadingValidFiles: "正在上传 {valid}/{total} 个有效文件...",
|
||||
noValidFiles: "没有有效的文件",
|
||||
noValidFilesInFolder: "文件夹中的 {total} 个文件均不支持",
|
||||
noValidFilesSelected: "选中的文件均不支持",
|
||||
unsupportedFileType: "不支持的文件格式",
|
||||
failedFilesList: "失败文件列表:",
|
||||
andMoreFiles: "...及其他 {count} 个文件",
|
||||
uploadFile: "上传文件",
|
||||
uploadFileDesc: "支持 PDF、Word、TXT 等",
|
||||
importURL: "导入网页",
|
||||
importURLDesc: "通过URL链接导入",
|
||||
importURLTitle: "导入网页",
|
||||
manualCreate: "手动创建",
|
||||
manualCreateDesc: "直接编写文档内容",
|
||||
urlRequired: "请输入URL",
|
||||
invalidURL: "请输入有效的URL",
|
||||
urlImportSuccess: "URL导入成功!",
|
||||
urlImportFailed: "URL导入失败!",
|
||||
urlExists: "该URL已存在",
|
||||
urlLabel: "URL地址",
|
||||
urlPlaceholder: "请输入网页URL,例如:https://example.com",
|
||||
urlTip: "支持导入各类网页内容,系统会自动提取和解析网页中的文本内容",
|
||||
typeURL: "网页",
|
||||
typeManual: "手动创建",
|
||||
typeFile: "文件",
|
||||
urlSource: "来源网址",
|
||||
documentTitle: "文档标题",
|
||||
webContent: "网页内容",
|
||||
documentContent: "文档内容",
|
||||
importTime: "导入时间",
|
||||
createTime: "创建时间",
|
||||
characters: "字符",
|
||||
segment: "片段",
|
||||
docActionUnsupported: "当前知识库类型不支持该操作",
|
||||
notInitialized:
|
||||
"该知识库尚未完成初始化配置,请先前往设置页面配置模型信息后再上传文件",
|
||||
@@ -851,6 +889,8 @@ export default {
|
||||
downloadCompleted: "{name} 下载完成",
|
||||
downloadFailed: "{name} 下载失败",
|
||||
downloadStartFailed: "启动下载失败",
|
||||
ollamaUnavailable: "Ollama服务不可用,无法选择本地模型",
|
||||
goToOllamaSettings: "查看设置",
|
||||
validation: {
|
||||
modelNameRequired: "请输入模型名称",
|
||||
modelNameEmpty: "模型名称不能为空",
|
||||
@@ -908,6 +948,7 @@ export default {
|
||||
},
|
||||
upload: {
|
||||
uploadDocument: "上传文档",
|
||||
uploadFolder: "上传文件夹",
|
||||
onlineEdit: "在线编辑",
|
||||
deleteRecord: "删除记录",
|
||||
},
|
||||
@@ -1034,6 +1075,11 @@ export default {
|
||||
knowledgeGraph: "已启用知识图谱",
|
||||
multimodal: "已启用多模态",
|
||||
},
|
||||
stats: {
|
||||
documents: "文档数量",
|
||||
faqEntries: "问答条目",
|
||||
chunks: "分块数量",
|
||||
},
|
||||
},
|
||||
knowledgeEditor: {
|
||||
titleCreate: "新建知识库",
|
||||
|
||||
@@ -22,22 +22,28 @@ export function formatStringDate(date: any) {
|
||||
year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second
|
||||
);
|
||||
}
|
||||
export function kbFileTypeVerification(file: any) {
|
||||
export function kbFileTypeVerification(file: any, silent = false) {
|
||||
let validTypes = ["pdf", "txt", "md", "docx", "doc", "jpg", "jpeg", "png", "csv", "xlsx", "xls"];
|
||||
let type = file.name.substring(file.name.lastIndexOf(".") + 1);
|
||||
if (!validTypes.includes(type)) {
|
||||
MessagePlugin.error("文件类型错误!");
|
||||
if (!silent) {
|
||||
MessagePlugin.error("文件类型错误!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
(type == "pdf" || type == "docx" || type == "doc") &&
|
||||
file.size > 31457280
|
||||
) {
|
||||
MessagePlugin.error("pdf/doc文件不能超过30M!");
|
||||
if (!silent) {
|
||||
MessagePlugin.error("pdf/doc文件不能超过30M!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if ((type == "txt" || type == "md") && file.size > 31457280) {
|
||||
MessagePlugin.error("txt/md文件不能超过30M!");
|
||||
if (!silent) {
|
||||
MessagePlugin.error("txt/md文件不能超过30M!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -125,7 +125,7 @@ const toolArguments = computed(() => props.arguments || {});
|
||||
|
||||
<style lang="less" scoped>
|
||||
.tool-result-renderer {
|
||||
margin: 8px 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.fallback-output {
|
||||
|
||||
@@ -7,9 +7,14 @@
|
||||
</div>
|
||||
<!-- 非 Agent 模式下才显示传统的 markdown 渲染 -->
|
||||
<div ref="parentMd" v-if="!session.hideContent && !session.isAgentMode">
|
||||
<!-- 消息正在总结中则渲染加载gif -->
|
||||
<img v-if="session.thinking" class="botanswer_laoding_gif" src="@/assets/img/botanswer_loading.gif"
|
||||
:alt="$t('chat.summaryInProgress')">
|
||||
<!-- 消息正在总结中则渲染加载动画 -->
|
||||
<div v-if="session.thinking" class="thinking-loading">
|
||||
<div class="loading-typing">
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 直接渲染完整内容,避免切分导致的问题,样式与 thinking 一致 -->
|
||||
<div class="content-wrapper">
|
||||
<div class="ai-markdown-template markdown-content" v-html="processMarkdown(content || session.content)"></div>
|
||||
@@ -339,6 +344,46 @@ onMounted(async () => {
|
||||
margin-left: 16px;
|
||||
}
|
||||
|
||||
.thinking-loading {
|
||||
margin-left: 16px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.loading-typing {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
|
||||
span {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: #07c05f;
|
||||
animation: typingBounce 1.4s ease-in-out infinite;
|
||||
|
||||
&:nth-child(1) {
|
||||
animation-delay: 0s;
|
||||
}
|
||||
|
||||
&:nth-child(2) {
|
||||
animation-delay: 0.2s;
|
||||
}
|
||||
|
||||
&:nth-child(3) {
|
||||
animation-delay: 0.4s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes typingBounce {
|
||||
0%, 60%, 100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
30% {
|
||||
transform: translateY(-8px);
|
||||
}
|
||||
}
|
||||
|
||||
.img_loading {
|
||||
background: #3032360f;
|
||||
height: 230px;
|
||||
|
||||
@@ -127,61 +127,29 @@ const formatMetadataValue = (value: unknown) => {
|
||||
.document-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.document-summary {
|
||||
.summary-main {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.summary-value {
|
||||
font-size: 13px;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.summary-meta {
|
||||
margin-top: 8px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.summary-errors {
|
||||
margin-top: 10px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid @card-border;
|
||||
}
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.meta-chip {
|
||||
font-size: 12px;
|
||||
color: #555;
|
||||
background: #ffffff;
|
||||
font-size: 11px;
|
||||
color: #6b7280;
|
||||
background: #f9fafb;
|
||||
border: 1px solid @card-border;
|
||||
border-radius: 12px;
|
||||
padding: 2px 10px;
|
||||
line-height: 1.6;
|
||||
border-radius: 10px;
|
||||
padding: 2px 8px;
|
||||
line-height: 1.5;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.documents-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.document-card {
|
||||
margin: 0 10px 10px 10px;
|
||||
margin: 0 8px 8px 8px;
|
||||
|
||||
.document-header {
|
||||
align-items: center;
|
||||
}
|
||||
@@ -192,24 +160,24 @@ const formatMetadataValue = (value: unknown) => {
|
||||
}
|
||||
|
||||
.doc-title {
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: #222;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.status-pill {
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
color: #07c05f;
|
||||
border: 1px solid rgba(7, 192, 95, 0.5);
|
||||
border-radius: 12px;
|
||||
padding: 2px 10px;
|
||||
border: 1px solid rgba(7, 192, 95, 0.3);
|
||||
border-radius: 10px;
|
||||
padding: 2px 8px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
}
|
||||
|
||||
.info-section {
|
||||
margin-top: 0;
|
||||
padding: 8px 0;
|
||||
padding: 6px 0;
|
||||
|
||||
&:first-of-type {
|
||||
padding-top: 4px;
|
||||
@@ -218,66 +186,71 @@ const formatMetadataValue = (value: unknown) => {
|
||||
|
||||
.info-field {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-bottom: 6px;
|
||||
font-size: 13px;
|
||||
gap: 10px;
|
||||
margin-bottom: 5px;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
|
||||
.field-label {
|
||||
color: #8b8b8b;
|
||||
min-width: 100px;
|
||||
font-weight: 600;
|
||||
color: #6b7280;
|
||||
min-width: 90px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.field-value {
|
||||
flex: 1;
|
||||
color: #333;
|
||||
color: #374151;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.metadata-section {
|
||||
padding-top: 12px;
|
||||
padding-top: 10px;
|
||||
border-top: 1px dashed @card-border;
|
||||
}
|
||||
|
||||
.metadata-list {
|
||||
list-style: none;
|
||||
margin: 6px 0 0;
|
||||
margin: 4px 0 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
gap: 3px;
|
||||
|
||||
li {
|
||||
font-size: 12px;
|
||||
color: #333;
|
||||
font-size: 11px;
|
||||
color: #374151;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.metadata-key {
|
||||
font-weight: 600;
|
||||
margin-right: 4px;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.metadata-value {
|
||||
font-family: 'Monaco', 'Courier New', monospace;
|
||||
font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
|
||||
color: #374151;
|
||||
}
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
font-size: 13px;
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
color: #9ca3af;
|
||||
text-align: center;
|
||||
padding: 16px;
|
||||
padding: 14px;
|
||||
border: 1px dashed @card-border;
|
||||
border-radius: @card-radius;
|
||||
background: #fff;
|
||||
background: #f9fafb;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: 'Monaco', 'Courier New', monospace;
|
||||
font-size: 11px;
|
||||
background: #f0f0f0;
|
||||
font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
|
||||
font-size: 10px;
|
||||
background: #f3f4f6;
|
||||
padding: 2px 4px;
|
||||
border-radius: 3px;
|
||||
border-radius: 2px;
|
||||
color: #374151;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -36,10 +36,10 @@ const props = defineProps<Props>();
|
||||
|
||||
<style lang="less" scoped>
|
||||
.plan-display {
|
||||
font-size: 13px;
|
||||
color: #666;
|
||||
font-size: 12px;
|
||||
color: #6b7280;
|
||||
background: transparent;
|
||||
padding: 8px 0 8px 12px;
|
||||
padding: 6px 0 6px 12px;
|
||||
margin: 0;
|
||||
border: none !important;
|
||||
box-shadow: none !important;
|
||||
@@ -49,15 +49,15 @@ const props = defineProps<Props>();
|
||||
.plan-steps {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.step-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
padding: 2px 0;
|
||||
transition: all 0.2s;
|
||||
gap: 7px;
|
||||
padding: 1px 0;
|
||||
transition: all 0.15s;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
@@ -65,7 +65,7 @@ const props = defineProps<Props>();
|
||||
|
||||
&.status-in_progress {
|
||||
.step-description {
|
||||
color: #333;
|
||||
color: #374151;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
@@ -100,27 +100,27 @@ const props = defineProps<Props>();
|
||||
|
||||
.step-description {
|
||||
flex: 1;
|
||||
color: #666;
|
||||
color: #6b7280;
|
||||
line-height: 1.5;
|
||||
font-size: 13px;
|
||||
font-size: 12px;
|
||||
|
||||
&.completed {
|
||||
text-decoration: line-through;
|
||||
color: #999;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.sparkle {
|
||||
margin-left: 4px;
|
||||
font-size: 12px;
|
||||
margin-left: 3px;
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
.no-steps {
|
||||
padding: 8px 12px;
|
||||
padding: 12px;
|
||||
text-align: center;
|
||||
color: #9ca3af;
|
||||
font-style: italic;
|
||||
font-size: 13px;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -127,90 +127,13 @@ const getRelevanceLabel = (level: RelevanceLevel): string => {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 0 0 0 12px;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.search-params {
|
||||
padding: 10px 12px;
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #e7e7e7;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
|
||||
.params-main {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.param-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
|
||||
.param-label {
|
||||
font-weight: 600;
|
||||
color: #666;
|
||||
min-width: 75px;
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.param-value {
|
||||
color: #333;
|
||||
flex: 1;
|
||||
word-break: break-word;
|
||||
line-height: 1.5;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
|
||||
.params-meta {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
padding-top: 6px;
|
||||
border-top: 1px solid #e7e7e7;
|
||||
|
||||
.param-meta-item {
|
||||
font-size: 11px;
|
||||
color: #666;
|
||||
background: #ffffff;
|
||||
padding: 3px 8px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #e7e7e7;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.stats-card {
|
||||
padding: 8px 12px;
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #e7e7e7;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
|
||||
.stats-label {
|
||||
font-weight: 600;
|
||||
color: #666;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.stats-item-inline {
|
||||
color: #333;
|
||||
}
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.results-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.result-item {
|
||||
@@ -221,14 +144,14 @@ const getRelevanceLabel = (level: RelevanceLevel): string => {
|
||||
}
|
||||
|
||||
.result-header {
|
||||
padding: 4px 0;
|
||||
padding: 2px 0;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
transition: color 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
gap: 6px;
|
||||
transition: color 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
color: #07c05f;
|
||||
@@ -242,24 +165,26 @@ const getRelevanceLabel = (level: RelevanceLevel): string => {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.result-index {
|
||||
font-size: 11px;
|
||||
color: #8b8b8b;
|
||||
color: #9ca3af;
|
||||
font-weight: 600;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.relevance-badge {
|
||||
flex-shrink: 0;
|
||||
font-size: 11px;
|
||||
padding: 2px 6px;
|
||||
font-size: 10px;
|
||||
padding: 2px 5px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.knowledge-title {
|
||||
font-size: 12px;
|
||||
color: #333;
|
||||
color: #374151;
|
||||
flex: 1;
|
||||
font-weight: 500;
|
||||
overflow: hidden;
|
||||
@@ -268,7 +193,6 @@ const getRelevanceLabel = (level: RelevanceLevel): string => {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
|
||||
// Popup overlay styles
|
||||
:deep([class*="result-popup-"]) {
|
||||
.t-popup__content {
|
||||
@@ -278,14 +202,14 @@ const getRelevanceLabel = (level: RelevanceLevel): string => {
|
||||
overflow-x: hidden;
|
||||
padding: 0;
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
|
||||
word-wrap: break-word;
|
||||
word-break: break-word;
|
||||
}
|
||||
}
|
||||
|
||||
.info-section {
|
||||
margin-top: 8px;
|
||||
margin-top: 6px;
|
||||
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
@@ -293,32 +217,32 @@ const getRelevanceLabel = (level: RelevanceLevel): string => {
|
||||
}
|
||||
|
||||
.full-content {
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
line-height: 1.8;
|
||||
padding: 12px;
|
||||
font-size: 12px;
|
||||
color: #374151;
|
||||
line-height: 1.6;
|
||||
padding: 10px;
|
||||
background: #ffffff;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #e7e7e7;
|
||||
border: 1px solid #e5e7eb;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
margin-bottom: 8px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.info-field {
|
||||
font-size: 11px;
|
||||
margin-bottom: 3px;
|
||||
margin-bottom: 4px;
|
||||
|
||||
.field-label {
|
||||
min-width: 60px;
|
||||
font-size: 11px;
|
||||
font-size: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: 'Monaco', 'Courier New', monospace;
|
||||
font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
|
||||
font-size: 10px;
|
||||
background: #f0f0f0;
|
||||
background: #f3f4f6;
|
||||
padding: 1px 4px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
@@ -23,30 +23,32 @@ useI18n(); // ensure component reacts to locale changes if needed
|
||||
@import './tool-results.less';
|
||||
|
||||
.thinking-display {
|
||||
padding: 8px 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.thinking-content {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
padding: 10px 12px;
|
||||
background: #f3f3f3;
|
||||
gap: 10px;
|
||||
padding: 12px 14px;
|
||||
background: #f9fafb;
|
||||
border-radius: 6px;
|
||||
border-left: 3px solid #8b8b8b;
|
||||
border-left: 3px solid #9ca3af;
|
||||
}
|
||||
|
||||
.thinking-icon {
|
||||
font-size: 16px;
|
||||
flex-shrink: 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.thinking-text {
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
line-height: 1.6;
|
||||
font-size: 15px;
|
||||
color: #1f2937;
|
||||
line-height: 1.65;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
flex: 1;
|
||||
font-weight: 400;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -181,30 +181,31 @@ const indexKey = (index: number, item: WebFetchResultItem): string => {
|
||||
.web-fetch-results {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
padding: 8px 8px 0 8px;
|
||||
gap: 6px;
|
||||
padding: 6px 6px 0 6px;
|
||||
}
|
||||
|
||||
.results-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.result-index {
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: #8b8b8b;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.result-link {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
color: #1f2937;
|
||||
font-size: 13px;
|
||||
color: #374151;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
text-decoration: none;
|
||||
transition: color 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
color: #07c05f;
|
||||
@@ -213,29 +214,30 @@ const indexKey = (index: number, item: WebFetchResultItem): string => {
|
||||
}
|
||||
|
||||
.result-domain {
|
||||
font-size: 13px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: #1f2937;
|
||||
color: #374151;
|
||||
}
|
||||
|
||||
.meta-pill {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 2px 8px;
|
||||
padding: 2px 6px;
|
||||
border-radius: 999px;
|
||||
background: #e8f8f0;
|
||||
background: rgba(7, 192, 95, 0.08);
|
||||
color: #0f7a49;
|
||||
font-size: 11px;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.meta-text {
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.result-content.expanded {
|
||||
padding-top: 12px;
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.info-field .field-value a {
|
||||
@@ -248,13 +250,14 @@ const indexKey = (index: number, item: WebFetchResultItem): string => {
|
||||
}
|
||||
|
||||
.raw-length {
|
||||
font-size: 12px;
|
||||
color: #8b8b8b;
|
||||
font-size: 11px;
|
||||
color: #9ca3af;
|
||||
margin-left: 4px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.action-button {
|
||||
margin-top: 8px;
|
||||
margin-top: 6px;
|
||||
}
|
||||
|
||||
.info-section-title.error {
|
||||
|
||||
@@ -150,20 +150,20 @@ const formatDate = (dateStr: string): string => {
|
||||
.web-search-results {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 8px 8px 0 8px;
|
||||
gap: 8px;
|
||||
padding: 0 0 0 12px;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.results-groups {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.results-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.group-header {
|
||||
@@ -199,14 +199,13 @@ const formatDate = (dateStr: string): string => {
|
||||
.results-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.result-item {
|
||||
// padding: 6px 8px;
|
||||
background: #ffffff;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
border-radius: 0;
|
||||
transition: none;
|
||||
}
|
||||
|
||||
@@ -215,30 +214,30 @@ const formatDate = (dateStr: string): string => {
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
margin-bottom: 0;
|
||||
/* Ensure links inside header remain clickable despite shared styles */
|
||||
padding: 2px 0;
|
||||
|
||||
:deep(a) {
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.result-index {
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: #8b8b8b;
|
||||
color: #9ca3af;
|
||||
flex-shrink: 0;
|
||||
padding-top: 1px;
|
||||
min-width: 28px;
|
||||
min-width: 24px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.result-title-link {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
flex: 1;
|
||||
text-decoration: none;
|
||||
color: #1f2937;
|
||||
transition: color 0.2s ease;
|
||||
color: #374151;
|
||||
transition: color 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
color: #07c05f;
|
||||
@@ -250,10 +249,10 @@ const formatDate = (dateStr: string): string => {
|
||||
}
|
||||
|
||||
.result-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
color: #1f2937;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
color: inherit;
|
||||
flex: 1;
|
||||
word-break: break-word;
|
||||
overflow: hidden;
|
||||
@@ -267,47 +266,25 @@ const formatDate = (dateStr: string): string => {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.result-domain {
|
||||
font-size: 12px;
|
||||
color: #6b7280;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.external-link-icon {
|
||||
font-size: 11px;
|
||||
color: #9ca3af;
|
||||
flex-shrink: 0;
|
||||
transition: color 0.2s ease;
|
||||
}
|
||||
|
||||
.result-title-link:hover .external-link-icon {
|
||||
color: #07c05f;
|
||||
}
|
||||
|
||||
.result-title-text {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.result-title-text .result-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
line-height: 1.3;
|
||||
color: #1f2937;
|
||||
flex: 1;
|
||||
word-break: break-word;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
|
||||
.result-title {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
color: #374151;
|
||||
}
|
||||
}
|
||||
|
||||
.result-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-top: 6px;
|
||||
padding-top: 6px;
|
||||
gap: 8px;
|
||||
margin-top: 4px;
|
||||
padding-top: 4px;
|
||||
border-top: 1px solid #f3f4f6;
|
||||
font-size: 10px;
|
||||
color: #9ca3af;
|
||||
@@ -315,7 +292,7 @@ const formatDate = (dateStr: string): string => {
|
||||
.meta-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.meta-icon {
|
||||
@@ -324,13 +301,14 @@ const formatDate = (dateStr: string): string => {
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
padding: 20px;
|
||||
padding: 16px;
|
||||
text-align: center;
|
||||
color: #9ca3af;
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
background: #f9fafb;
|
||||
border-radius: 6px;
|
||||
border: 1px solid #e5e7eb;
|
||||
border: 1px dashed #e5e7eb;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -10,49 +10,50 @@
|
||||
@relevance-weak: #bdbdbd;
|
||||
|
||||
// Card colors
|
||||
@card-bg: #f8f9fa;
|
||||
@card-border: #e7e7e7;
|
||||
@card-bg: #ffffff;
|
||||
@card-border: #e5e7eb;
|
||||
@card-hover-border: #07c05f;
|
||||
@card-radius: 8px;
|
||||
@card-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
|
||||
@card-shadow-hover: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||
@card-radius: 6px;
|
||||
@card-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
|
||||
@card-shadow-hover: 0 2px 6px rgba(7, 192, 95, 0.08);
|
||||
|
||||
// Animation timing
|
||||
@transition-time: 0.3s;
|
||||
@transition-time: 0.2s;
|
||||
|
||||
// Tool result container
|
||||
.tool-result-container {
|
||||
margin: 8px 0;
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
// Relevance badge styles
|
||||
.relevance-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 4px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
gap: 4px;
|
||||
gap: 3px;
|
||||
line-height: 1.4;
|
||||
|
||||
&.high {
|
||||
background-color: @relevance-high;
|
||||
color: white;
|
||||
background-color: rgba(0, 168, 112, 0.12);
|
||||
color: @relevance-high;
|
||||
}
|
||||
|
||||
&.medium {
|
||||
background-color: @relevance-medium;
|
||||
color: white;
|
||||
background-color: rgba(255, 152, 0, 0.12);
|
||||
color: #d67700;
|
||||
}
|
||||
|
||||
&.low {
|
||||
background-color: @relevance-low;
|
||||
color: white;
|
||||
background-color: rgba(117, 117, 117, 0.12);
|
||||
color: @relevance-low;
|
||||
}
|
||||
|
||||
&.weak {
|
||||
background-color: @relevance-weak;
|
||||
color: #333;
|
||||
background-color: rgba(189, 189, 189, 0.12);
|
||||
color: #666;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,25 +63,26 @@
|
||||
align-items: center;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
font-size: 11px;
|
||||
background-color: #e7e7e7;
|
||||
color: #666;
|
||||
font-size: 10px;
|
||||
background-color: #f3f4f6;
|
||||
color: #6b7280;
|
||||
gap: 2px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
// Result card
|
||||
.result-card {
|
||||
background: #ffffff;
|
||||
background: @card-bg;
|
||||
border: 1px solid @card-border;
|
||||
border-radius: @card-radius;
|
||||
margin-bottom: 0;
|
||||
overflow: hidden;
|
||||
transition: all @transition-time ease;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
|
||||
transition: border-color @transition-time ease, box-shadow @transition-time ease;
|
||||
box-shadow: @card-shadow;
|
||||
|
||||
&:hover {
|
||||
border-color: @card-hover-border;
|
||||
box-shadow: 0 2px 8px rgba(7, 192, 95, 0.12);
|
||||
box-shadow: @card-shadow-hover;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,9 +96,10 @@
|
||||
gap: 8px;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
transition: background-color 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
background: rgba(7, 192, 95, 0.05);
|
||||
background: rgba(7, 192, 95, 0.04);
|
||||
}
|
||||
|
||||
* {
|
||||
@@ -107,22 +110,24 @@
|
||||
.result-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
gap: 6px;
|
||||
flex: 1;
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.result-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
color: #8b8b8b;
|
||||
font-size: 11px;
|
||||
color: #6b7280;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.result-content {
|
||||
padding: 0 12px 12px 12px;
|
||||
padding: 0;
|
||||
border-top: 1px solid @card-border;
|
||||
background: white;
|
||||
max-height: 0;
|
||||
@@ -139,11 +144,11 @@
|
||||
|
||||
.expand-icon {
|
||||
font-size: 12px;
|
||||
color: #8b8b8b;
|
||||
transition: transform 0.2s ease;
|
||||
color: #9ca3af;
|
||||
transition: transform 0.15s ease, color 0.15s ease;
|
||||
|
||||
&.expanded {
|
||||
transform: rotate(90deg);
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,44 +162,48 @@
|
||||
}
|
||||
|
||||
.info-section-title {
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
color: #666;
|
||||
color: #6b7280;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
margin-bottom: 6px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.info-field {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 4px;
|
||||
font-size: 13px;
|
||||
margin-bottom: 6px;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
|
||||
.field-label {
|
||||
color: #8b8b8b;
|
||||
color: #6b7280;
|
||||
min-width: 80px;
|
||||
flex-shrink: 0;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.field-value {
|
||||
color: #333;
|
||||
color: #374151;
|
||||
flex: 1;
|
||||
word-break: break-word;
|
||||
}
|
||||
}
|
||||
|
||||
// Statistics card (for KB counts, etc.)
|
||||
.stats-card {
|
||||
background: #f0f7ff;
|
||||
border: 1px solid #d6e4ff;
|
||||
border-radius: 6px;
|
||||
background: rgba(7, 192, 95, 0.04);
|
||||
border: 1px solid rgba(7, 192, 95, 0.15);
|
||||
border-radius: @card-radius;
|
||||
padding: 10px 12px;
|
||||
margin-bottom: 12px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.stats-title {
|
||||
font-size: 13px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
color: #374151;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
@@ -205,17 +214,18 @@
|
||||
}
|
||||
|
||||
.stats-item {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
font-size: 11px;
|
||||
color: #6b7280;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
// Grid layout for cards
|
||||
.card-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||
gap: 12px;
|
||||
gap: 10px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
@@ -224,8 +234,8 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
padding: 8px 0;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
padding: 6px 0;
|
||||
border-bottom: 1px solid #f3f4f6;
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
@@ -234,9 +244,9 @@
|
||||
|
||||
// Content preview (truncated)
|
||||
.content-preview {
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
line-height: 1.5;
|
||||
font-size: 12px;
|
||||
color: #374151;
|
||||
line-height: 1.6;
|
||||
max-height: 60px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
@@ -247,13 +257,13 @@
|
||||
|
||||
// Full content
|
||||
.full-content {
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
font-size: 12px;
|
||||
color: #374151;
|
||||
line-height: 1.6;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
padding: 8px;
|
||||
background: #f5f5f5;
|
||||
padding: 10px;
|
||||
background: #f9fafb;
|
||||
border-radius: 4px;
|
||||
border: 1px solid @card-border;
|
||||
}
|
||||
@@ -261,36 +271,43 @@
|
||||
// Action buttons
|
||||
.action-button {
|
||||
padding: 4px 10px;
|
||||
font-size: 12px;
|
||||
font-size: 11px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid @card-border;
|
||||
background: white;
|
||||
color: #666;
|
||||
color: #6b7280;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
transition: all 0.15s ease;
|
||||
font-weight: 500;
|
||||
|
||||
&:hover {
|
||||
border-color: @card-hover-border;
|
||||
color: @card-hover-border;
|
||||
background: rgba(7, 192, 95, 0.04);
|
||||
}
|
||||
}
|
||||
|
||||
// Empty state
|
||||
.empty-state {
|
||||
padding: 24px;
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
color: #8b8b8b;
|
||||
font-size: 14px;
|
||||
color: #9ca3af;
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
background: #f9fafb;
|
||||
border-radius: @card-radius;
|
||||
border: 1px dashed @card-border;
|
||||
}
|
||||
|
||||
// Code block
|
||||
.code-block {
|
||||
font-family: 'Monaco', 'Courier New', monospace;
|
||||
font-size: 12px;
|
||||
background: #f5f5f5;
|
||||
font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
|
||||
font-size: 11px;
|
||||
background: #f9fafb;
|
||||
padding: 8px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid @card-border;
|
||||
overflow-x: auto;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,12 @@
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="loading"
|
||||
style="height: 41px;display: flex;align-items: center;background: #fff;width: 58px;">
|
||||
<img class="botanswer_laoding_gif" src="@/assets/img/botanswer_loading.gif" :alt="$t('chat.waitingForAnswer')">
|
||||
style="height: 41px;display: flex;align-items: center;padding-left: 4px;">
|
||||
<div class="loading-typing">
|
||||
<span></span>
|
||||
<span></span>
|
||||
<span></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -872,5 +876,40 @@ onBeforeRouteUpdate((to, from, next) => {
|
||||
height: 18px;
|
||||
margin-left: 16px;
|
||||
}
|
||||
|
||||
.loading-typing {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
|
||||
span {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: #07c05f;
|
||||
animation: typingBounce 1.4s ease-in-out infinite;
|
||||
|
||||
&:nth-child(1) {
|
||||
animation-delay: 0s;
|
||||
}
|
||||
|
||||
&:nth-child(2) {
|
||||
animation-delay: 0.2s;
|
||||
}
|
||||
|
||||
&:nth-child(3) {
|
||||
animation-delay: 0.4s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes typingBounce {
|
||||
0%, 60%, 100% {
|
||||
transform: translateY(0);
|
||||
}
|
||||
30% {
|
||||
transform: translateY(-8px);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -21,6 +21,7 @@ import {
|
||||
updateKnowledgeBaseTag,
|
||||
deleteKnowledgeBaseTag,
|
||||
uploadKnowledgeFile,
|
||||
createKnowledgeFromURL,
|
||||
listKnowledgeBases,
|
||||
} from "@/api/knowledge-base/index";
|
||||
import FAQEntryManager from './components/FAQEntryManager.vue';
|
||||
@@ -118,6 +119,20 @@ const formatDocTime = (time?: string) => {
|
||||
return formatted.slice(2, 16) // "YY-MM-DD HH:mm"
|
||||
}
|
||||
|
||||
// 获取知识条目的显示类型
|
||||
const getKnowledgeType = (item: any) => {
|
||||
if (item.type === 'url') {
|
||||
return t('knowledgeBase.typeURL') || 'URL';
|
||||
}
|
||||
if (item.type === 'manual') {
|
||||
return t('knowledgeBase.typeManual') || '手动创建';
|
||||
}
|
||||
if (item.file_type) {
|
||||
return item.file_type.toUpperCase();
|
||||
}
|
||||
return '--';
|
||||
}
|
||||
|
||||
const loadKnowledgeFiles = (kbIdValue: string) => {
|
||||
if (!kbIdValue) return;
|
||||
getKnowled(
|
||||
@@ -384,16 +399,28 @@ const handleFileUploaded = (event: CustomEvent) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 监听从菜单触发的URL导入事件
|
||||
const handleOpenURLImportDialog = (event: CustomEvent) => {
|
||||
const eventKbId = event.detail.kbId;
|
||||
console.log('接收到URL导入对话框打开事件,知识库ID:', eventKbId, '当前知识库ID:', kbId.value);
|
||||
if (eventKbId && eventKbId === kbId.value && !isFAQ.value) {
|
||||
urlDialogVisible.value = true;
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
loadKnowledgeBaseInfo(kbId.value);
|
||||
loadKnowledgeList();
|
||||
|
||||
// 监听文件上传事件
|
||||
window.addEventListener('knowledgeFileUploaded', handleFileUploaded as EventListener);
|
||||
// 监听URL导入对话框打开事件
|
||||
window.addEventListener('openURLImportDialog', handleOpenURLImportDialog as EventListener);
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('knowledgeFileUploaded', handleFileUploaded as EventListener);
|
||||
window.removeEventListener('openURLImportDialog', handleOpenURLImportDialog as EventListener);
|
||||
});
|
||||
watch(() => cardList.value, (newValue) => {
|
||||
if (isFAQ.value) return;
|
||||
@@ -560,6 +587,76 @@ const handleManualCreate = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// URL 导入相关
|
||||
const urlDialogVisible = ref(false);
|
||||
const urlInputValue = ref('');
|
||||
const urlImporting = ref(false);
|
||||
|
||||
const handleURLImportClick = () => {
|
||||
if (!ensureDocumentKbReady()) return;
|
||||
urlInputValue.value = '';
|
||||
urlDialogVisible.value = true;
|
||||
};
|
||||
|
||||
const handleURLImportCancel = () => {
|
||||
urlDialogVisible.value = false;
|
||||
urlInputValue.value = '';
|
||||
};
|
||||
|
||||
const handleURLImportConfirm = async () => {
|
||||
const url = urlInputValue.value.trim();
|
||||
if (!url) {
|
||||
MessagePlugin.warning(t('knowledgeBase.urlRequired') || '请输入URL');
|
||||
return;
|
||||
}
|
||||
|
||||
// 简单的URL格式验证
|
||||
try {
|
||||
new URL(url);
|
||||
} catch (error) {
|
||||
MessagePlugin.warning(t('knowledgeBase.invalidURL') || '请输入有效的URL');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!kbId.value) {
|
||||
MessagePlugin.error("缺少知识库ID");
|
||||
return;
|
||||
}
|
||||
|
||||
urlImporting.value = true;
|
||||
try {
|
||||
const responseData: any = await createKnowledgeFromURL(kbId.value, { url });
|
||||
window.dispatchEvent(new CustomEvent('knowledgeFileUploaded', {
|
||||
detail: { kbId: kbId.value }
|
||||
}));
|
||||
const isSuccess = responseData?.success || responseData?.code === 200 || responseData?.status === 'success' || (!responseData?.error && responseData);
|
||||
if (isSuccess) {
|
||||
MessagePlugin.success(t('knowledgeBase.urlImportSuccess') || 'URL导入成功!');
|
||||
urlDialogVisible.value = false;
|
||||
urlInputValue.value = '';
|
||||
} else {
|
||||
let errorMessage = t('knowledgeBase.urlImportFailed') || "URL导入失败!";
|
||||
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已存在";
|
||||
}
|
||||
MessagePlugin.error(errorMessage);
|
||||
}
|
||||
} catch (error: any) {
|
||||
let errorMessage = error?.error?.message || error?.message || t('knowledgeBase.urlImportFailed') || "URL导入失败!";
|
||||
if (error?.code === 'duplicate_url') {
|
||||
errorMessage = t('knowledgeBase.urlExists') || "该URL已存在";
|
||||
}
|
||||
MessagePlugin.error(errorMessage);
|
||||
} finally {
|
||||
urlImporting.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const handleOpenKBSettings = () => {
|
||||
if (!kbId.value) {
|
||||
MessagePlugin.warning(t('knowledgeEditor.messages.missingId'));
|
||||
@@ -581,7 +678,7 @@ const knowledgeDropdownOptions = computed(() =>
|
||||
knowledgeList.value.map((item) => ({
|
||||
content: item.name,
|
||||
value: item.id,
|
||||
prefixIcon: () => h(TIcon, { name: item.type === 'faq' ? 'help-circle' : 'folder', size: '16px' }),
|
||||
prefixIcon: () => h(TIcon, { name: item.type === 'faq' ? 'chat-bubble-help' : 'folder', size: '16px' }),
|
||||
}))
|
||||
);
|
||||
|
||||
@@ -898,6 +995,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
>
|
||||
<template v-if="cardList.length">
|
||||
<div class="doc-card-list">
|
||||
<!-- 现有文档卡片 -->
|
||||
<div
|
||||
class="knowledge-card"
|
||||
v-for="(item, index) in cardList"
|
||||
@@ -975,7 +1073,7 @@ async function createNewSession(value: string): Promise<void> {
|
||||
</t-dropdown>
|
||||
</div>
|
||||
<div class="card-type">
|
||||
<span>{{ item.file_type }}</span>
|
||||
<span>{{ getKnowledgeType(item) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1012,6 +1110,34 @@ async function createNewSession(value: string): Promise<void> {
|
||||
</div>
|
||||
</div>
|
||||
</t-dialog>
|
||||
|
||||
<!-- URL 导入对话框 -->
|
||||
<t-dialog
|
||||
v-model:visible="urlDialogVisible"
|
||||
:header="$t('knowledgeBase.importURLTitle') || '导入网页'"
|
||||
:confirm-btn="{
|
||||
content: $t('common.confirm') || '确认',
|
||||
theme: 'primary',
|
||||
loading: urlImporting,
|
||||
}"
|
||||
: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>
|
||||
<t-input
|
||||
v-model="urlInputValue"
|
||||
:placeholder="$t('knowledgeBase.urlPlaceholder') || '请输入网页URL,例如:https://example.com'"
|
||||
clearable
|
||||
autofocus
|
||||
@keydown.enter="handleURLImportConfirm"
|
||||
/>
|
||||
<div class="url-input-tip">{{ $t('knowledgeBase.urlTip') || '支持导入各类网页内容,系统会自动提取和解析网页中的文本内容' }}</div>
|
||||
</div>
|
||||
</t-dialog>
|
||||
|
||||
<DocContent :visible="isCardDetails" :details="details" @closeDoc="closeDoc" @getDoc="getDoc"></DocContent>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1989,6 +2115,24 @@ async function createNewSession(value: string): Promise<void> {
|
||||
border: 2px solid #07c05f;
|
||||
}
|
||||
|
||||
.url-import-form {
|
||||
padding: 8px 0;
|
||||
|
||||
.url-input-label {
|
||||
color: #1d2129;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.url-input-tip {
|
||||
color: #86909c;
|
||||
font-size: 12px;
|
||||
margin-top: 8px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.knowledge-card-upload {
|
||||
color: #000000e6;
|
||||
font-family: "PingFang SC";
|
||||
|
||||
@@ -74,7 +74,10 @@
|
||||
<div class="bottom-left">
|
||||
<div class="type-badge" :class="{ 'document': (kb.type || 'document') === 'document', 'faq': kb.type === 'faq' }">
|
||||
<t-icon :name="kb.type === 'faq' ? 'chat-bubble-help' : 'folder'" size="14px" />
|
||||
<span>{{ kb.type === 'faq' ? $t('knowledgeEditor.basic.typeFAQ') : $t('knowledgeEditor.basic.typeDocument') }}</span>
|
||||
<span>
|
||||
{{ kb.type === 'faq' ? $t('knowledgeEditor.basic.typeFAQ') : $t('knowledgeEditor.basic.typeDocument') }}
|
||||
({{ kb.type === 'faq' ? (kb.chunk_count || 0) : (kb.knowledge_count || 0) }})
|
||||
</span>
|
||||
</div>
|
||||
<div class="feature-badges">
|
||||
<t-tooltip v-if="kb.extract_config?.enabled" :content="$t('knowledgeList.features.knowledgeGraph')" placement="top">
|
||||
@@ -167,6 +170,8 @@ interface KB {
|
||||
vlm_config?: { enabled?: boolean; model_id?: string };
|
||||
extract_config?: { enabled?: boolean };
|
||||
cos_config?: { provider?: string; bucket_name?: string };
|
||||
knowledge_count?: number;
|
||||
chunk_count?: number;
|
||||
}
|
||||
|
||||
const kbs = ref<KB[]>([])
|
||||
|
||||
@@ -1097,11 +1097,10 @@ const kbInfo = ref<any>(null)
|
||||
const knowledgeList = ref<Array<{ id: string; name: string; type?: string }>>([])
|
||||
const knowledgeDropdownOptions = computed(() =>
|
||||
knowledgeList.value
|
||||
.filter((item) => !item.type || item.type === 'document')
|
||||
.map((item) => ({
|
||||
content: item.name,
|
||||
value: item.id,
|
||||
prefixIcon: () => h(TIcon, { name: 'file', size: '16px' }),
|
||||
prefixIcon: () => h(TIcon, { name: item.type === 'document' ? 'folder' : 'chat-bubble-help', size: '16px' }),
|
||||
})),
|
||||
)
|
||||
|
||||
|
||||
@@ -564,20 +564,20 @@ onMounted(() => {
|
||||
.section-description {
|
||||
font-size: 14px;
|
||||
color: #666666;
|
||||
margin: 0;
|
||||
margin: 0 0 20px 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
.model-category-section {
|
||||
margin-bottom: 24px;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 8px;
|
||||
padding: 24px;
|
||||
background: #ffffff;
|
||||
margin-bottom: 32px;
|
||||
padding-bottom: 32px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
padding-bottom: 0;
|
||||
border-bottom: none;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -585,20 +585,20 @@ onMounted(() => {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
.header-info {
|
||||
flex: 1;
|
||||
|
||||
h3 {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
color: #333333;
|
||||
margin: 0 0 4px 0;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
color: #666666;
|
||||
margin: 0;
|
||||
line-height: 1.5;
|
||||
@@ -612,72 +612,65 @@ onMounted(() => {
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-weight: 500;
|
||||
|
||||
height: 32px;
|
||||
padding: 0 16px;
|
||||
font-size: 14px;
|
||||
flex-shrink: 0;
|
||||
|
||||
.add-icon {
|
||||
font-size: 16px;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
font-size: 14px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.model-list-container {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 12px;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.model-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 12px;
|
||||
padding: 12px 16px;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 6px;
|
||||
background: #fafafa;
|
||||
transition: all 0.2s;
|
||||
transition: all 0.15s ease;
|
||||
position: relative;
|
||||
overflow: visible;
|
||||
|
||||
&:hover {
|
||||
border-color: #07C05F;
|
||||
background: #ffffff;
|
||||
background: #f9fdfb;
|
||||
box-shadow: 0 1px 4px rgba(7, 192, 95, 0.08);
|
||||
}
|
||||
|
||||
// 内置模型置灰样式
|
||||
// 内置模型样式
|
||||
&.builtin-model {
|
||||
opacity: 0.7;
|
||||
background: #f5f5f5;
|
||||
background: #f8f9fa;
|
||||
border-color: #d9d9d9;
|
||||
cursor: not-allowed;
|
||||
|
||||
&:hover {
|
||||
border-color: #d9d9d9;
|
||||
background: #f5f5f5;
|
||||
opacity: 0.8;
|
||||
border-color: #c0c0c0;
|
||||
background: #f5f6f7;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.model-info {
|
||||
.model-name {
|
||||
color: #999999;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.model-meta {
|
||||
color: #999999;
|
||||
|
||||
.source-tag {
|
||||
background: #e5e5e5;
|
||||
color: #999999;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.model-actions {
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -689,7 +682,7 @@ onMounted(() => {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #333333;
|
||||
margin-bottom: 4px;
|
||||
margin-bottom: 6px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
@@ -698,15 +691,16 @@ onMounted(() => {
|
||||
.model-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
gap: 12px;
|
||||
font-size: 12px;
|
||||
color: #666666;
|
||||
|
||||
.source-tag {
|
||||
padding: 1px 6px;
|
||||
padding: 2px 8px;
|
||||
background: #e5e7eb;
|
||||
border-radius: 3px;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.model-id {
|
||||
@@ -726,14 +720,14 @@ onMounted(() => {
|
||||
gap: 4px;
|
||||
flex-shrink: 0;
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s ease;
|
||||
transition: opacity 0.15s ease;
|
||||
position: relative;
|
||||
z-index: 1001; // 确保高于设置窗口的z-index (9999)
|
||||
z-index: 1001;
|
||||
|
||||
.more-btn {
|
||||
color: #666666;
|
||||
color: #999999;
|
||||
padding: 4px;
|
||||
|
||||
|
||||
&:hover {
|
||||
background: #f5f7fa;
|
||||
color: #333333;
|
||||
@@ -746,25 +740,25 @@ onMounted(() => {
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
padding: 80px 0;
|
||||
padding: 48px 0;
|
||||
text-align: center;
|
||||
|
||||
.empty-text {
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
color: #999999;
|
||||
margin: 0 0 16px 0;
|
||||
}
|
||||
}
|
||||
|
||||
.builtin-models-info {
|
||||
margin-top: 20px;
|
||||
margin-top: 16px;
|
||||
|
||||
.info-box {
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #e5e7eb;
|
||||
background: #f0fdf6;
|
||||
border: 1px solid #d1fae5;
|
||||
border-left: 3px solid #07C05F;
|
||||
border-radius: 4px;
|
||||
padding: 12px 16px;
|
||||
border-radius: 6px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.info-header {
|
||||
@@ -776,42 +770,48 @@ onMounted(() => {
|
||||
.info-icon {
|
||||
font-size: 16px;
|
||||
color: #07C05F;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.info-title {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #333333;
|
||||
color: #059669;
|
||||
}
|
||||
}
|
||||
|
||||
.info-content {
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
color: #666666;
|
||||
color: #065f46;
|
||||
|
||||
p {
|
||||
margin: 0 0 8px 0;
|
||||
margin: 0 0 6px 0;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
&.doc-link {
|
||||
margin-top: 8px;
|
||||
margin-top: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
|
||||
.link-icon {
|
||||
font-size: 14px;
|
||||
font-size: 13px;
|
||||
color: #07C05F;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #07C05F;
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
transition: color 0.2s;
|
||||
transition: color 0.15s;
|
||||
|
||||
&:hover {
|
||||
color: #06b04d;
|
||||
color: #059669;
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
@@ -819,4 +819,111 @@ onMounted(() => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TDesign 组件样式覆盖
|
||||
:deep(.t-button) {
|
||||
&.add-model-btn {
|
||||
border-radius: 6px;
|
||||
font-weight: 500;
|
||||
transition: all 0.15s ease;
|
||||
|
||||
&:hover {
|
||||
background: #06b04d;
|
||||
border-color: #06b04d;
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: #059642;
|
||||
border-color: #059642;
|
||||
}
|
||||
}
|
||||
|
||||
&.t-size-s {
|
||||
height: 32px;
|
||||
padding: 0 12px;
|
||||
font-size: 13px;
|
||||
border-radius: 6px;
|
||||
|
||||
&.t-button--variant-outline {
|
||||
color: #666666;
|
||||
border-color: #d9d9d9;
|
||||
|
||||
&:hover {
|
||||
color: #07C05F;
|
||||
border-color: #07C05F;
|
||||
background: rgba(7, 192, 95, 0.04);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tag 样式优化
|
||||
:deep(.t-tag) {
|
||||
border-radius: 3px;
|
||||
padding: 2px 8px;
|
||||
font-size: 11px;
|
||||
font-weight: 500;
|
||||
border: none;
|
||||
|
||||
&.t-tag--theme-primary {
|
||||
background: #e0f2fe;
|
||||
color: #0369a1;
|
||||
}
|
||||
|
||||
&.t-tag--theme-success {
|
||||
background: #dcfce7;
|
||||
color: #059669;
|
||||
}
|
||||
|
||||
&.t-size-s {
|
||||
height: 20px;
|
||||
line-height: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
// Dropdown 菜单样式优化
|
||||
:deep(.t-popup__content) {
|
||||
.t-dropdown__menu {
|
||||
background: #ffffff;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
|
||||
padding: 4px;
|
||||
min-width: 140px;
|
||||
}
|
||||
|
||||
.t-dropdown__item {
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
margin: 2px 0;
|
||||
font-size: 13px;
|
||||
color: #333333;
|
||||
transition: all 0.15s ease;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background: #f5f7fa;
|
||||
color: #07C05F;
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: #e8f5ed;
|
||||
}
|
||||
|
||||
// 删除按钮特殊样式 - 覆盖默认 hover 样式
|
||||
&.t-dropdown__item--theme-error {
|
||||
color: #f56c6c;
|
||||
|
||||
&:hover {
|
||||
background: #fef0f0;
|
||||
color: #e53e3e !important; // 使用 !important 确保覆盖默认样式
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: #fde2e2;
|
||||
color: #c53030;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -154,3 +154,12 @@ func (r *chunkRepository) DeleteByKnowledgeList(ctx context.Context, tenantID ui
|
||||
"tenant_id = ? AND knowledge_id in ?", tenantID, knowledgeIDs,
|
||||
).Delete(&types.Chunk{}).Error
|
||||
}
|
||||
|
||||
// CountChunksByKnowledgeBaseID counts the number of chunks in a knowledge base
|
||||
func (r *chunkRepository) CountChunksByKnowledgeBaseID(ctx context.Context, tenantID uint, kbID string) (int64, error) {
|
||||
var count int64
|
||||
err := r.db.WithContext(ctx).Model(&types.Chunk{}).
|
||||
Where("tenant_id = ? AND knowledge_base_id = ?", tenantID, kbID).
|
||||
Count(&count).Error
|
||||
return count, err
|
||||
}
|
||||
|
||||
@@ -220,3 +220,12 @@ func (r *knowledgeRepository) UpdateKnowledgeColumn(ctx context.Context, id stri
|
||||
err := r.db.WithContext(ctx).Model(&types.Knowledge{}).Where("id = ?", id).Update(column, value).Error
|
||||
return err
|
||||
}
|
||||
|
||||
// CountKnowledgeByKnowledgeBaseID counts the number of knowledge items in a knowledge base
|
||||
func (r *knowledgeRepository) CountKnowledgeByKnowledgeBaseID(ctx context.Context, tenantID uint, kbID string) (int64, error) {
|
||||
var count int64
|
||||
err := r.db.WithContext(ctx).Model(&types.Knowledge{}).
|
||||
Where("tenant_id = ? AND knowledge_base_id = ?", tenantID, kbID).
|
||||
Count(&count).Error
|
||||
return count, err
|
||||
}
|
||||
|
||||
@@ -122,6 +122,29 @@ func (s *knowledgeBaseService) ListKnowledgeBases(ctx context.Context) ([]*types
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Query knowledge count and chunk count for each knowledge base
|
||||
for _, kb := range kbs {
|
||||
kb.EnsureDefaults()
|
||||
|
||||
// Get knowledge count
|
||||
if kb.Type == types.KnowledgeBaseTypeDocument {
|
||||
knowledgeCount, err := s.kgRepo.CountKnowledgeByKnowledgeBaseID(ctx, tenantID, kb.ID)
|
||||
if err != nil {
|
||||
logger.Warnf(ctx, "Failed to get knowledge count for knowledge base %s: %v", kb.ID, err)
|
||||
} else {
|
||||
kb.KnowledgeCount = knowledgeCount
|
||||
}
|
||||
} else if kb.Type == types.KnowledgeBaseTypeFAQ {
|
||||
// Get chunk count
|
||||
chunkCount, err := s.chunkRepo.CountChunksByKnowledgeBaseID(ctx, tenantID, kb.ID)
|
||||
if err != nil {
|
||||
logger.Warnf(ctx, "Failed to get chunk count for knowledge base %s: %v", kb.ID, err)
|
||||
} else {
|
||||
kb.ChunkCount = chunkCount
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
logger.Infof(
|
||||
ctx,
|
||||
"Knowledge base list retrieved successfully, tenant ID: %d, knowledge base count: %d",
|
||||
|
||||
@@ -37,6 +37,8 @@ type ChunkRepository interface {
|
||||
DeleteChunksByKnowledgeID(ctx context.Context, tenantID uint, knowledgeID string) error
|
||||
// DeleteByKnowledgeList deletes all chunks for a knowledge list
|
||||
DeleteByKnowledgeList(ctx context.Context, tenantID uint, knowledgeIDs []string) error
|
||||
// CountChunksByKnowledgeBaseID counts the number of chunks in a knowledge base.
|
||||
CountChunksByKnowledgeBaseID(ctx context.Context, tenantID uint, kbID string) (int64, error)
|
||||
}
|
||||
|
||||
// ChunkService defines the interface for chunk service operations
|
||||
|
||||
@@ -102,4 +102,6 @@ type KnowledgeRepository interface {
|
||||
// AminusB returns the difference set of A and B.
|
||||
AminusB(ctx context.Context, Atenant uint, A string, Btenant uint, B string) ([]string, error)
|
||||
UpdateKnowledgeColumn(ctx context.Context, id string, column string, value interface{}) error
|
||||
// CountKnowledgeByKnowledgeBaseID counts the number of knowledge items in a knowledge base.
|
||||
CountKnowledgeByKnowledgeBaseID(ctx context.Context, tenantID uint, kbID string) (int64, error)
|
||||
}
|
||||
|
||||
@@ -69,6 +69,10 @@ type KnowledgeBase struct {
|
||||
UpdatedAt time.Time `yaml:"updated_at" json:"updated_at"`
|
||||
// Deletion time of the knowledge base
|
||||
DeletedAt gorm.DeletedAt `yaml:"deleted_at" json:"deleted_at" gorm:"index"`
|
||||
// Knowledge count (not stored in database, calculated on query)
|
||||
KnowledgeCount int64 `yaml:"knowledge_count" json:"knowledge_count" gorm:"-"`
|
||||
// Chunk count (not stored in database, calculated on query)
|
||||
ChunkCount int64 `yaml:"chunk_count" json:"chunk_count" gorm:"-"`
|
||||
}
|
||||
|
||||
// KnowledgeBaseConfig represents the knowledge base configuration
|
||||
|
||||
Reference in New Issue
Block a user