mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-04-21 13:40:00 +08:00
80 lines
2.3 KiB
TypeScript
80 lines
2.3 KiB
TypeScript
import React from 'react'
|
|
import { connect, Dispatch } from 'umi';
|
|
import i18n from 'i18next';
|
|
import { useTranslation, Trans } from 'react-i18next'
|
|
import { Input, Modal, Form } from 'antd'
|
|
import styles from './index.less';
|
|
import type { kFModelState } from './model'
|
|
|
|
type FieldType = {
|
|
name?: string;
|
|
};
|
|
interface kFProps {
|
|
dispatch: Dispatch;
|
|
kFModel: kFModelState;
|
|
getKfList: () => void;
|
|
kb_id: string
|
|
}
|
|
const Index: React.FC<kFProps> = ({ kFModel, dispatch, getKfList, kb_id }) => {
|
|
const { isShowCEFwModal } = kFModel
|
|
const { t } = useTranslation()
|
|
const handleCancel = () => {
|
|
dispatch({
|
|
type: 'kFModel/updateState',
|
|
payload: {
|
|
isShowCEFwModal: false
|
|
}
|
|
});
|
|
};
|
|
const [form] = Form.useForm()
|
|
const handleOk = async () => {
|
|
try {
|
|
const values = await form.validateFields();
|
|
dispatch({
|
|
type: 'kFModel/document_create',
|
|
payload: {
|
|
name: values.name,
|
|
kb_id
|
|
},
|
|
callback: () => {
|
|
dispatch({
|
|
type: 'kFModel/updateState',
|
|
payload: {
|
|
isShowCEFwModal: false
|
|
}
|
|
});
|
|
getKfList && getKfList()
|
|
}
|
|
});
|
|
|
|
} catch (errorInfo) {
|
|
console.log('Failed:', errorInfo);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Modal title="Basic Modal" open={isShowCEFwModal} onOk={handleOk} onCancel={handleCancel}>
|
|
<Form
|
|
form={form}
|
|
name="validateOnly"
|
|
labelCol={{ span: 8 }}
|
|
wrapperCol={{ span: 16 }}
|
|
style={{ maxWidth: 600 }}
|
|
autoComplete="off"
|
|
>
|
|
<Form.Item<FieldType>
|
|
label="文件名"
|
|
name="name"
|
|
rules={[{ required: true, message: 'Please input value!' }]}
|
|
>
|
|
<Input />
|
|
</Form.Item>
|
|
|
|
</Form>
|
|
</Modal >
|
|
|
|
|
|
);
|
|
}
|
|
export default connect(({ kFModel, loading }) => ({ kFModel, loading }))(Index);
|