fix: yuque dataset file folder can enter (#3593)

This commit is contained in:
heheer
2025-01-14 20:40:00 +08:00
committed by archer
parent 0d9f54cbf3
commit 68f5afeba0
3 changed files with 10 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ export type APIFileItem = {
type: 'file' | 'folder';
updateTime: Date;
createTime: Date;
canEnter?: boolean;
};
export type APIFileServer = {

View File

@@ -99,7 +99,13 @@ export const useApiDatasetRequest = ({ apiServer }: { apiServer: APIFileServer }
if (files.some((file) => !file.id || !file.name || typeof file.type === 'undefined')) {
return Promise.reject('Invalid file data format');
}
return files;
const formattedFiles = files.map((file) => ({
...file,
canEnter: file.type === 'folder'
}));
return formattedFiles;
};
const getFileContent = async ({ teamId, apiFileId }: { teamId: string; apiFileId: string }) => {

View File

@@ -49,7 +49,6 @@ const CustomAPIFileInput = () => {
parentId: '',
parentName: ''
});
const [parentUuid, setParentUuid] = useState<string>('');
const [paths, setPaths] = useState<ParentTreePathItemType[]>([]);
const [searchKey, setSearchKey] = useState('');
@@ -128,7 +127,7 @@ const CustomAPIFileInput = () => {
const handleItemClick = useCallback(
(item: APIFileItem) => {
if (item.type === 'folder') {
if (item.canEnter) {
setPaths((state) => [...state, { parentId: item.id, parentName: item.name }]);
return setParent({
parentId: item.id,
@@ -251,6 +250,7 @@ const CustomAPIFileInput = () => {
<Box fontSize={'sm'} fontWeight={'medium'} color={'myGray.900'}>
{item.name}
</Box>
{item.canEnter && <MyIcon name="core/chat/chevronRight" w={'18px'} ml={2} />}
</Flex>
);
})}