Skip to content

Commit

Permalink
feat: cache upload file
Browse files Browse the repository at this point in the history
  • Loading branch information
Aralhi committed Jan 2, 2024
1 parent 77694cb commit 8a17007
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions web/components/knowledge/doc-upload-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import { apiInterceptors, addDocument, uploadDocument } from '@/client/api';
import { RcFile, UploadChangeParam } from 'antd/es/upload';
import { File, StepChangeParams } from '@/types/knowledge';
import { UploadRequestOption as RcCustomRequestOptions } from 'rc-upload/lib/interface';
import classNames from 'classnames';

type FileParams = {
file: RcFile;
fileList: FileList;
};

type IProps = {
className: string;
handleStepChange: (params: StepChangeParams) => void;
spaceName: string;
docType: string;
Expand All @@ -30,7 +32,7 @@ const { Dragger } = Upload;
const { TextArea } = Input;

export default function DocUploadForm(props: IProps) {
const { handleStepChange, spaceName, docType } = props;
const { className, handleStepChange, spaceName, docType } = props;
const { t } = useTranslation();
const [form] = Form.useForm();
const [spinning, setSpinning] = useState<boolean>(false);
Expand Down Expand Up @@ -186,7 +188,7 @@ export default function DocUploadForm(props: IProps) {
<Form
form={form}
size="large"
className="mt-4"
className={classNames('mt-4', className)}
layout="vertical"
name="basic"
initialValues={{ remember: true }}
Expand Down
8 changes: 7 additions & 1 deletion web/pages/knowledge/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import DocUploadForm from '@/components/knowledge/doc-upload-form';
import SpaceForm from '@/components/knowledge/space-form';
import DocTypeForm from '@/components/knowledge/doc-type-form';
import Segmentation from '@/components/knowledge/segmentation';
import classNames from 'classnames';

const Knowledge = () => {
const [spaceList, setSpaceList] = useState<Array<ISpace> | null>([]);
Expand Down Expand Up @@ -94,7 +95,12 @@ const Knowledge = () => {
<Steps current={activeStep} items={addKnowledgeSteps} />
{activeStep === 0 && <SpaceForm handleStepChange={handleStepChange} />}
{activeStep === 1 && <DocTypeForm handleStepChange={handleStepChange} />}
{activeStep === 2 && <DocUploadForm spaceName={spaceName} docType={docType} handleStepChange={handleStepChange} />}
<DocUploadForm
className={classNames({ hidden: activeStep !== 2 })}
spaceName={spaceName}
docType={docType}
handleStepChange={handleStepChange}
/>
{activeStep === 3 && <Segmentation spaceName={spaceName} docType={docType} uploadFiles={files} handleStepChange={handleStepChange} />}
</Modal>
</div>
Expand Down

0 comments on commit 8a17007

Please sign in to comment.