feat(knowledgeBase): add media dataset support and improve file handling

- Add media dataset translations in English and Chinese locales
- Add "mediaDataSet" and "uploadMedia" i18n keys for UI labels
- Enable media dataset creation option in Private component by uncommenting menu item
- Import and display image icon for media dataset menu option
- Refactor file ID handling in CreateDataset to support both string and array types
- Improve fileIds initialization logic to handle mixed input types
- Update CreateImageDataset component to use file chunking workflow
- Add navigation to parameter settings step after file upload
- Pass file IDs to dataset creation flow for media processing
- Add message API and navigate hook for improved UX feedback
This commit is contained in:
yujiangping
2025-12-25 20:17:58 +08:00
parent 99c501f188
commit c00e164567
5 changed files with 115 additions and 35 deletions

View File

@@ -53,8 +53,8 @@ interface CreateDatasetLocationState {
knowledgeBaseId?: string;
parentId?: string;
startStep?: StepKey;
fileId?: string;
fileIds?: string[];
fileId?: string | string[];
fileIds?: string | string[];
}
const CreateDataset = () => {
@@ -67,7 +67,11 @@ const CreateDataset = () => {
const knowledgeBaseId = locationState.knowledgeBaseId || routeKnowledgeBaseId;
const parentId = locationState.parentId;
const initialStepKey = locationState.startStep ?? 'selectFile';
const initialFileIds = locationState.fileIds ?? (locationState.fileId ? [locationState.fileId] : []);
const initialFileIds = (() => {
const fileIds = locationState.fileIds || locationState.fileId;
if (!fileIds) return [];
return Array.isArray(fileIds) ? fileIds : [fileIds];
})();
const [current, setCurrent] = useState<number>(stepIndexMap[initialStepKey]);
const tableRef = useRef<TableRef>(null);

View File

@@ -13,6 +13,7 @@ import folderIcon from '@/assets/images/knowledgeBase/folder.png';
import textIcon from '@/assets/images/knowledgeBase/text.png';
import editIcon from '@/assets/images/knowledgeBase/edit.png';
import blankIcon from '@/assets/images/knowledgeBase/blankDocument.png';
import imageIcon from '@/assets/images/knowledgeBase/image.png'
import { getKnowledgeBaseDetail, deleteDocument, downloadFile, updateKnowledgeBase } from '@/api/knowledgeBase';
import {
type CreateModalRef,
@@ -327,15 +328,15 @@ const Private: FC = () => {
// handleCreate('folder'); // 传入 type: 'folder'
},
},
// 暂时未实现
// {
// key: '3',
// icon: <img src={imageIcon} alt="image" style={{ width: 16, height: 16 }} />,
// label: t('knowledgeBase.imageDataSet'),
// onClick: () => {
// createImageDataset?.current?.handleOpen(knowledgeBaseId || '', parentId || '')
// },
// },
{
key: '3',
icon: <img src={imageIcon} alt="image" style={{ width: 16, height: 16 }} />,
label: t('knowledgeBase.mediaDataSet'),
onClick: () => {
createImageDataset?.current?.handleOpen(knowledgeBaseId || '', parentId || '')
},
},
// 暂时未实现
// {
// key: '4',
// icon: <img src={blankIcon} alt="blank" style={{ width: 16, height: 16 }} />,