mirror of
https://gitee.com/yudaocode/yudao-ui-admin-vben.git
synced 2025-12-30 10:32:25 +00:00
feat:【antd】【ai】知识库的 knowledge document 优化(编辑)
This commit is contained in:
@@ -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">
|
||||
|
||||
@@ -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>
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user