feat: Enhance knowledge base management with new create action and improved UI
- Added a new "Create Knowledge Base" action in the menu for easier knowledge base creation. - Updated localization strings in English, Russian, and Chinese to include a subtitle for knowledge base management. - Improved UI components to better display knowledge base options and actions, including a new header subtitle in the KnowledgeBaseList view. - Refactored related components to streamline the knowledge base list and FAQ entry management.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, onUnmounted, watch, reactive, computed, nextTick, type ComponentPublicInstance } from "vue";
|
||||
import { MessagePlugin } from "tdesign-vue-next";
|
||||
import { ref, onMounted, onUnmounted, watch, reactive, computed, nextTick, h, type ComponentPublicInstance } from "vue";
|
||||
import { MessagePlugin, Icon as TIcon } from "tdesign-vue-next";
|
||||
import DocContent from "@/components/doc-content.vue";
|
||||
import useKnowledgeBase from '@/hooks/useKnowledgeBase';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
@@ -34,7 +34,7 @@ const uploadInputRef = ref<HTMLInputElement | null>(null);
|
||||
const uploading = ref(false);
|
||||
const kbLoading = ref(false);
|
||||
const isFAQ = computed(() => (kbInfo.value?.type || '') === 'faq');
|
||||
const knowledgeList = ref<Array<{ id: string; name: string }>>([]);
|
||||
const knowledgeList = ref<Array<{ id: string; name: string; type?: string }>>([]);
|
||||
let { cardList, total, moreIndex, details, getKnowled, delKnowledge, openMore, onVisibleChange, getCardDetails, getfDetails } = useKnowledgeBase(kbId.value)
|
||||
let isCardDetails = ref(false);
|
||||
let timeout: ReturnType<typeof setInterval> | null = null;
|
||||
@@ -345,6 +345,7 @@ const loadKnowledgeList = async () => {
|
||||
knowledgeList.value = (res?.data || []).map((item: any) => ({
|
||||
id: String(item.id),
|
||||
name: item.name,
|
||||
type: item.type || 'document',
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('Failed to load knowledge list:', error);
|
||||
@@ -580,6 +581,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' }),
|
||||
}))
|
||||
);
|
||||
|
||||
@@ -718,30 +720,6 @@ async function createNewSession(value: string): Promise<void> {
|
||||
</div>
|
||||
<p class="document-subtitle">{{ $t('knowledgeEditor.document.subtitle') }}</p>
|
||||
</div>
|
||||
<div class="document-header-actions">
|
||||
<t-button
|
||||
class="document-action-btn primary"
|
||||
size="medium"
|
||||
:loading="uploading"
|
||||
:disabled="uploading"
|
||||
@click="handleDocumentUploadClick"
|
||||
>
|
||||
<template #icon>
|
||||
<t-icon name="upload" />
|
||||
</template>
|
||||
{{ $t('upload.uploadDocument') }}
|
||||
</t-button>
|
||||
<t-button
|
||||
class="document-action-btn secondary"
|
||||
size="medium"
|
||||
@click="handleManualCreate"
|
||||
>
|
||||
<template #icon>
|
||||
<t-icon name="edit" />
|
||||
</template>
|
||||
{{ $t('upload.onlineEdit') }}
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
<input
|
||||
ref="uploadInputRef"
|
||||
@@ -1544,64 +1522,6 @@ async function createNewSession(value: string): Promise<void> {
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.document-header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
|
||||
.document-action-btn {
|
||||
min-width: 148px;
|
||||
height: 38px;
|
||||
border-radius: 8px;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
padding: 0 18px;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
:deep(.t-icon) {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
&.primary {
|
||||
background: linear-gradient(90deg, #07c05f, #05a04f);
|
||||
border-color: transparent;
|
||||
color: #fff;
|
||||
box-shadow: 0 6px 14px rgba(7, 192, 95, 0.2);
|
||||
|
||||
&:hover {
|
||||
background: linear-gradient(90deg, #08d067, #05a04f);
|
||||
box-shadow: 0 8px 16px rgba(7, 192, 95, 0.25);
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.7;
|
||||
box-shadow: none;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
&.secondary {
|
||||
background: #ffffff;
|
||||
border-color: #07c05f;
|
||||
color: #07c05f;
|
||||
|
||||
&:hover {
|
||||
background: #f3fdf7;
|
||||
border-color: #05a04f;
|
||||
color: #059669;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.document-upload-input {
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
<div class="kb-list-container">
|
||||
<!-- 头部 -->
|
||||
<div class="header">
|
||||
<h2>{{ $t('knowledgeBase.title') }}</h2>
|
||||
<div class="action-buttons">
|
||||
<button class="create-btn ghost" @click="openCreateModal">
|
||||
<t-icon name="add" size="16px" class="btn-icon" />
|
||||
<span>{{ $t('knowledgeList.create') }}</span>
|
||||
</button>
|
||||
<div class="header-title">
|
||||
<h2>{{ $t('knowledgeBase.title') }}</h2>
|
||||
<p class="header-subtitle">{{ $t('knowledgeList.subtitle') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-divider"></div>
|
||||
|
||||
<!-- 未初始化知识库提示 -->
|
||||
<div v-if="hasUninitializedKbs" class="warning-banner">
|
||||
@@ -177,11 +175,6 @@ onMounted(() => {
|
||||
fetchList()
|
||||
})
|
||||
|
||||
// 打开创建知识库弹窗
|
||||
const openCreateModal = () => {
|
||||
uiStore.openCreateKB()
|
||||
}
|
||||
|
||||
const openMore = (index: number) => {
|
||||
// 只记录当前打开的索引,用于显示激活样式
|
||||
// 弹窗的开关由 v-model 自动管理
|
||||
@@ -274,7 +267,13 @@ const handleKBEditorSuccess = (kbId: string) => {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 20px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
.header-title {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
margin: 0;
|
||||
@@ -286,72 +285,19 @@ const handleKBEditorSuccess = (kbId: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.create-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 10px 24px;
|
||||
height: 40px;
|
||||
border-radius: 8px;
|
||||
.header-subtitle {
|
||||
margin: 0;
|
||||
color: #00000099;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
.btn-icon {
|
||||
flex-shrink: 0;
|
||||
font-size: 16px;
|
||||
}
|
||||
font-weight: 400;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.create-btn.primary {
|
||||
background: #07c05f;
|
||||
color: #fff;
|
||||
border: none;
|
||||
box-shadow: 0 2px 6px 0 rgba(7, 192, 95, 0.2);
|
||||
|
||||
&:hover {
|
||||
background: #05a855;
|
||||
box-shadow: 0 3px 8px 0 rgba(7, 192, 95, 0.28);
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: #048f45;
|
||||
}
|
||||
}
|
||||
|
||||
.create-btn.ghost {
|
||||
background: #ffffff;
|
||||
color: #07c05f;
|
||||
border: 1.5px solid #d4edde;
|
||||
box-shadow: none;
|
||||
|
||||
.btn-icon {
|
||||
color: #07c05f;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #f6fdf9;
|
||||
border-color: #07c05f;
|
||||
color: #059669;
|
||||
|
||||
.btn-icon {
|
||||
color: #059669;
|
||||
}
|
||||
}
|
||||
|
||||
&:active {
|
||||
background: #ecfdf5;
|
||||
border-color: #05a855;
|
||||
}
|
||||
.header-divider {
|
||||
height: 1px;
|
||||
background: #e7ebf0;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.warning-banner {
|
||||
|
||||
@@ -52,28 +52,6 @@
|
||||
</div>
|
||||
<p class="faq-subtitle">{{ $t('knowledgeEditor.faq.subtitle') }}</p>
|
||||
</div>
|
||||
<div class="faq-header-actions">
|
||||
<t-button
|
||||
class="faq-action-btn primary"
|
||||
size="medium"
|
||||
@click="openEditor()"
|
||||
>
|
||||
<template #icon>
|
||||
<t-icon name="add" />
|
||||
</template>
|
||||
{{ $t('knowledgeEditor.faq.editorCreate') }}
|
||||
</t-button>
|
||||
<t-dropdown
|
||||
:options="toolbarActionOptions"
|
||||
placement="bottom-left"
|
||||
trigger="click"
|
||||
@click="handleToolbarAction"
|
||||
>
|
||||
<t-button class="faq-action-btn secondary icon-only" size="medium">
|
||||
<t-icon name="more" />
|
||||
</t-button>
|
||||
</t-dropdown>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="faq-main">
|
||||
@@ -988,9 +966,9 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, watch, onMounted, computed, nextTick, onUnmounted } from 'vue'
|
||||
import { ref, reactive, watch, onMounted, computed, nextTick, onUnmounted, h } from 'vue'
|
||||
import type { ComponentPublicInstance } from 'vue'
|
||||
import { MessagePlugin, DialogPlugin } from 'tdesign-vue-next'
|
||||
import { MessagePlugin, DialogPlugin, Icon as TIcon } from 'tdesign-vue-next'
|
||||
import type { FormRules, FormInstanceFunctions } from 'tdesign-vue-next'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useRouter } from 'vue-router'
|
||||
@@ -1122,6 +1100,7 @@ const knowledgeDropdownOptions = computed(() =>
|
||||
.map((item) => ({
|
||||
content: item.name,
|
||||
value: item.id,
|
||||
prefixIcon: () => h(TIcon, { name: item.type === 'faq' ? 'help-circle' : 'file', size: '16px' }),
|
||||
})),
|
||||
)
|
||||
|
||||
@@ -2781,13 +2760,6 @@ watch(() => entries.value.map(e => ({
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.faq-header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
|
||||
.tag-filter-bar {
|
||||
@@ -2802,56 +2774,6 @@ watch(() => entries.value.map(e => ({
|
||||
}
|
||||
}
|
||||
|
||||
.faq-action-btn {
|
||||
min-width: 148px;
|
||||
height: 38px;
|
||||
border-radius: 8px;
|
||||
font-family: "PingFang SC";
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
padding: 0 18px;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
:deep(.t-icon) {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
&.primary {
|
||||
background: linear-gradient(90deg, #07c05f, #05a04f);
|
||||
border-color: transparent;
|
||||
color: #fff;
|
||||
box-shadow: 0 6px 14px rgba(7, 192, 95, 0.2);
|
||||
|
||||
&:hover {
|
||||
background: linear-gradient(90deg, #08d067, #05a04f);
|
||||
box-shadow: 0 8px 16px rgba(7, 192, 95, 0.25);
|
||||
}
|
||||
}
|
||||
|
||||
&.secondary {
|
||||
background: #ffffff;
|
||||
border-color: #07c05f;
|
||||
color: #07c05f;
|
||||
|
||||
&:hover {
|
||||
background: #f3fdf7;
|
||||
border-color: #05a04f;
|
||||
color: #059669;
|
||||
}
|
||||
}
|
||||
|
||||
&.icon-only {
|
||||
min-width: auto;
|
||||
width: 38px;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.kb-settings-button {
|
||||
width: 30px;
|
||||
|
||||
Reference in New Issue
Block a user