Skip to content

Commit

Permalink
adapt old api format
Browse files Browse the repository at this point in the history
  • Loading branch information
newfish-cmyk committed Jan 21, 2025
1 parent 97822fd commit d4451e7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
15 changes: 12 additions & 3 deletions packages/service/core/dataset/apiDataset/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const useApiDatasetRequest = ({ apiServer }: { apiServer: APIFileServer }
offset: number;
pageSize: number;
}) => {
const { list, total } = await request<APIFileListResponse>(
const response = await request<APIFileListResponse>(
`/v1/file/list`,
{
searchKey,
Expand All @@ -99,9 +99,18 @@ export const useApiDatasetRequest = ({ apiServer }: { apiServer: APIFileServer }
'POST'
);

if (!Array.isArray(list)) {
return Promise.reject('Invalid file list format');
let list: any[] = [];
let total = 0;

// 兼容旧的数据格式
if (Array.isArray(response)) {
list = response;
total = response.length;
} else {
list = response.list;
total = response.total;
}

if (list.some((file) => !file.id || !file.name || typeof file.type === 'undefined')) {
return Promise.reject('Invalid file data format');
}
Expand Down
1 change: 1 addition & 0 deletions projects/app/src/pages/api/core/dataset/apiDataset/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ async function handler(req: NextApiRequest) {
yuqueServer,
parentId,
nextPageToken,
offset,
pageSize
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export const getFeishuAndYuqueDatasetFileList = async (data: {
yuqueServer?: YuqueServer;
parentId?: string;
nextPageToken?: string;
pageSize?: number;
pageSize: number;
offset: number;
}) => {
const res = await POST<GetApiDatasetFileListResponse>('/core/dataset/systemApiDataset', {
type: 'list',
Expand Down

0 comments on commit d4451e7

Please sign in to comment.