File size: 1,164 Bytes
f305776
362ec6c
6b8fc2c
362ec6c
f305776
fad2ec7
362ec6c
 
fad2ec7
362ec6c
fad2ec7
362ec6c
fad2ec7
6b8fc2c
362ec6c
f305776
 
362ec6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f305776
 
 
362ec6c
 
6b8fc2c
362ec6c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { useKnowledgeBaseId } from '@/hooks/knowledgeHook';
import uploadService from '@/services/uploadService';
import type { UploadProps } from 'antd';
import React from 'react';
import { Link } from 'umi';
interface PropsType {
  kb_id: string;
  getKfList: () => void;
}

type UploadRequestOption = Parameters<
  NonNullable<UploadProps['customRequest']>
>[0];

const FileUpload: React.FC<PropsType> = ({ kb_id, getKfList }) => {
  const knowledgeBaseId = useKnowledgeBaseId();

  const createRequest: (props: UploadRequestOption) => void = async function ({

    file,

    onSuccess,

    onError,

  }) {
    const { retcode, data } = await uploadService.uploadFile(file, kb_id);
    if (retcode === 0) {
      onSuccess && onSuccess(data, file);
    } else {
      onError && onError(data);
    }
    getKfList && getKfList();
  };
  const uploadProps: UploadProps = {
    customRequest: createRequest,
    showUploadList: false,
  };
  return (
    // <Upload {...uploadProps}>
    <Link to={`/knowledge/dataset/upload?id=${knowledgeBaseId}`}>导入文件</Link>
    // </Upload>
  );
};

export default FileUpload;