feat:【antd】【ai】知识库的 knowledge document 优化(编辑)

This commit is contained in:
YunaiV
2025-11-14 09:43:47 +08:00
parent 132ce52e36
commit 33c066f0f0
4 changed files with 28 additions and 24 deletions

View File

@@ -16,14 +16,13 @@ import { Card } from 'ant-design-vue';
import { getKnowledgeDocument } from '#/api/ai/knowledge/document';
import ProcessStep from './ProcessStep.vue';
import SplitStep from './SplitStep.vue';
import UploadStep from './UploadStep.vue';
import ProcessStep from './modules/process-step.vue';
import SplitStep from './modules/split-step.vue';
import UploadStep from './modules/upload-step.vue';
const route = useRoute();
const router = useRouter();
// 组件引用
const uploadDocumentRef = ref();
const documentSegmentRef = ref();
const processCompleteRef = ref();
@@ -59,9 +58,9 @@ const tabs = useTabs();
function handleBack() {
// 关闭当前页签
tabs.closeCurrentTab();
// 跳转到列表页,使用路径, 目前后端的路由 name 'name'+ menuId
// 跳转到列表页
router.push({
path: `/ai/knowledge/document`,
name: 'AiKnowledgeDocument',
query: {
knowledgeId: route.query.knowledgeId,
},
@@ -92,6 +91,7 @@ async function initData() {
goToNextStep();
}
}
/** 切换到下一步 */
function goToNextStep() {
if (currentStep.value < steps.length - 1) {
@@ -106,11 +106,6 @@ function goToPrevStep() {
}
}
/** 初始化 */
onMounted(async () => {
await initData();
});
/** 添加组件卸载前的清理代码 */
onBeforeUnmount(() => {
// 清理所有的引用
@@ -118,12 +113,18 @@ onBeforeUnmount(() => {
documentSegmentRef.value = null;
processCompleteRef.value = null;
});
/** 暴露方法给子组件使用 */
defineExpose({
goToNextStep,
goToPrevStep,
handleBack,
});
/** 初始化 */
onMounted(async () => {
await initData();
});
</script>
<template>
@@ -168,13 +169,14 @@ defineExpose({
>
{{ index + 1 }}
</div>
<span class="whitespace-nowrap text-base font-bold">{{
step.title
}}</span>
<span class="whitespace-nowrap text-base font-bold">
{{ step.title }}
</span>
</div>
</div>
</div>
</div>
<!-- 主体内容 -->
<Card :body-style="{ padding: '10px' }" class="mb-4">
<div class="mt-12">

View File

@@ -67,6 +67,7 @@ async function splitContentFile(file: any) {
splitLoading.value = false;
}
}
/** 处理预览分段 */
async function handleAutoSegment() {
//
@@ -228,7 +229,7 @@ onMounted(async () => {
>
{{ file.name }}
<span v-if="file.segments" class="ml-1 text-sm text-gray-500">
({{ file.segments.length }}个分片)
({{ file.segments.length }} 个分片)
</span>
</Menu.Item>
</Menu>

View File

@@ -30,7 +30,6 @@ const { uploadUrl, httpRequest } = useUpload(); // 使用上传组件的钩子
const fileList = ref<UploadProps['fileList']>([]); //
const uploadingCount = ref(0); //
//
const supportedFileTypes = [
'TXT',
'MARKDOWN',
@@ -50,16 +49,14 @@ const supportedFileTypes = [
'PPT',
'MD',
'HTM',
];
]; //
const allowedExtensions = new Set(
supportedFileTypes.map((ext) => ext.toLowerCase()),
); //
const maxFileSize = 15; // (MB)
// accept
const acceptedFileTypes = computed(() =>
generateAcceptedFileTypes(supportedFileTypes),
);
); // accept
/** 表单数据 */
const modelData = computed({
@@ -68,6 +65,7 @@ const modelData = computed({
},
set: (val) => emit('update:modelValue', val),
});
/** 确保 list 属性存在 */
function ensureListExists() {
if (!props.modelValue.list) {
@@ -77,6 +75,7 @@ function ensureListExists() {
});
}
}
/** 是否所有文件都已上传完成 */
const isAllUploaded = computed(() => {
return (
@@ -112,7 +111,8 @@ function beforeUpload(file: any) {
uploadingCount.value++;
return true;
}
async function customRequest(info: UploadRequestOption<any>) {
async function customRequest(info: UploadRequestOption) {
const file = info.file as File;
const name = file?.name;
try {
@@ -142,6 +142,7 @@ async function customRequest(info: UploadRequestOption<any>) {
uploadingCount.value = Math.max(0, uploadingCount.value - 1);
}
}
/**
* 从列表中移除文件
*
@@ -231,9 +232,9 @@ onMounted(() => {
>
<div class="flex items-center">
<IconifyIcon icon="lucide:file-text" class="mr-2 text-blue-500" />
<span class="break-all text-sm text-gray-600">{{
file.name
}}</span>
<span class="break-all text-sm text-gray-600">
{{ file.name }}
</span>
</div>
<Button
danger