mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
update knowledge_kb (#34)
* update typescript * add chunk api * remove useless code
This commit is contained in:
@ -1,14 +1,21 @@
|
||||
import { connect } from 'umi';
|
||||
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 { rsaPsw } from '@/utils'
|
||||
import styles from './index.less';
|
||||
import type { kFModelState } from './model'
|
||||
|
||||
type FieldType = {
|
||||
name?: string;
|
||||
};
|
||||
const Index = ({ kFModel, dispatch, getKfList, kb_id }) => {
|
||||
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 = () => {
|
||||
|
||||
@ -21,4 +21,8 @@
|
||||
|
||||
.column {
|
||||
min-width: 200px
|
||||
}
|
||||
|
||||
.tochunks {
|
||||
cursor: pointer;
|
||||
}
|
||||
@ -1,14 +1,15 @@
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { connect, useNavigate, useLocation } from 'umi'
|
||||
import { Space, Table, Tag, Input, Button, Switch, Popover, Dropdown, } from 'antd';
|
||||
import { connect, Dispatch, useNavigate } from 'umi'
|
||||
import { Space, Table, Input, Button, Switch, Dropdown, } from 'antd';
|
||||
import type { MenuProps } from 'antd';
|
||||
import { PlusOutlined, DownOutlined } from '@ant-design/icons'
|
||||
import { DownOutlined } from '@ant-design/icons'
|
||||
import { debounce } from 'lodash';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import UploadFile from './upload'
|
||||
import CreateEPModal from './createEFileModal'
|
||||
import SegmentSetModal from './segmentSetModal'
|
||||
import styles from './index.less'
|
||||
import type { kFModelState } from './model'
|
||||
|
||||
interface DataType {
|
||||
name: string;
|
||||
@ -21,32 +22,37 @@ interface DataType {
|
||||
parser_id: string
|
||||
}
|
||||
|
||||
interface kFProps {
|
||||
dispatch: Dispatch;
|
||||
kFModel: kFModelState;
|
||||
kb_id: string
|
||||
}
|
||||
|
||||
|
||||
const Index: React.FC = ({ kFModel, dispatch, id }) => {
|
||||
const Index: React.FC<kFProps> = ({ kFModel, dispatch, kb_id }) => {
|
||||
const { data, loading } = kFModel
|
||||
const [inputValue, setInputValue] = useState('')
|
||||
const [doc_id, setDocId] = useState('0')
|
||||
const [parser_id, setParserId] = useState('0')
|
||||
const changeValue = (value: string) => {
|
||||
{
|
||||
console.log(value)
|
||||
let navigate = useNavigate();
|
||||
const getKfList = (keywords?: string) => {
|
||||
const payload = {
|
||||
kb_id,
|
||||
keywords
|
||||
}
|
||||
if (!keywords) {
|
||||
delete payload.keywords
|
||||
}
|
||||
}
|
||||
const getKfList = () => {
|
||||
dispatch({
|
||||
type: 'kFModel/getKfList',
|
||||
payload: {
|
||||
kb_id: id
|
||||
}
|
||||
payload
|
||||
});
|
||||
}
|
||||
useEffect(() => {
|
||||
if (id) {
|
||||
if (kb_id) {
|
||||
getKfList()
|
||||
}
|
||||
}, [id])
|
||||
const debounceChange = debounce(changeValue, 300)
|
||||
}, [kb_id])
|
||||
const debounceChange = debounce(getKfList, 300)
|
||||
const debounceCallback = useCallback((value: string) => debounceChange(value), [])
|
||||
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => {
|
||||
const value = e.target.value
|
||||
@ -101,7 +107,7 @@ const Index: React.FC = ({ kFModel, dispatch, id }) => {
|
||||
key: '1',
|
||||
label: (
|
||||
<div>
|
||||
<UploadFile kb_id={id} getKfList={getKfList} />
|
||||
<UploadFile kb_id={kb_id} getKfList={getKfList} />
|
||||
</div>
|
||||
|
||||
),
|
||||
@ -116,7 +122,7 @@ const Index: React.FC = ({ kFModel, dispatch, id }) => {
|
||||
// disabled: true,
|
||||
},
|
||||
]
|
||||
}, [id]);
|
||||
}, [kb_id]);
|
||||
const chunkItems: MenuProps['items'] = [
|
||||
{
|
||||
key: '1',
|
||||
@ -138,12 +144,16 @@ const Index: React.FC = ({ kFModel, dispatch, id }) => {
|
||||
// disabled: true,
|
||||
},
|
||||
]
|
||||
const toChunk = (id: string) => {
|
||||
console.log(id)
|
||||
navigate(`/knowledge/add/setting?activeKey=file&id=${kb_id}&doc_id=${id}`);
|
||||
}
|
||||
const columns: ColumnsType<DataType> = [
|
||||
{
|
||||
title: '名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
render: (text) => <a><img className={styles.img} src='https://gw.alipayobjects.com/zos/antfincdn/efFD%24IOql2/weixintupian_20170331104822.jpg' alt="" />{text}</a>,
|
||||
render: (text: any, { id }) => <div className={styles.tochunks} onClick={() => toChunk(id)}><img className={styles.img} src='https://gw.alipayobjects.com/zos/antfincdn/efFD%24IOql2/weixintupian_20170331104822.jpg' alt="" />{text}</div>,
|
||||
className: `${styles.column}`
|
||||
},
|
||||
{
|
||||
@ -198,7 +208,7 @@ const Index: React.FC = ({ kFModel, dispatch, id }) => {
|
||||
return <>
|
||||
<div className={styles.filter}>
|
||||
<div className="search">
|
||||
<Input placeholder="搜索" value={inputValue} allowClear onChange={handleInputChange} />
|
||||
<Input placeholder="搜索" value={inputValue} style={{ width: 220 }} allowClear onChange={handleInputChange} />
|
||||
</div>
|
||||
<div className="operate">
|
||||
<Dropdown menu={{ items: actionItems }} trigger={['click']} >
|
||||
@ -210,7 +220,7 @@ const Index: React.FC = ({ kFModel, dispatch, id }) => {
|
||||
</div>
|
||||
</div>
|
||||
<Table rowKey='id' columns={columns} dataSource={data} loading={loading} pagination={false} scroll={{ scrollToFirstRowOnChange: true, x: true }} />
|
||||
<CreateEPModal getKfList={getKfList} kb_id={id} />
|
||||
<CreateEPModal getKfList={getKfList} kb_id={kb_id} />
|
||||
<SegmentSetModal getKfList={getKfList} parser_id={parser_id} doc_id={doc_id} />
|
||||
</>
|
||||
};
|
||||
|
||||
@ -1,15 +1,42 @@
|
||||
import { message } from 'antd';
|
||||
import { addParam } from '@/utils';
|
||||
import { Effect, Reducer, Subscription } from 'umi'
|
||||
import kbService from '@/services/kbService';
|
||||
|
||||
const Model = {
|
||||
export interface kFModelState {
|
||||
isShowCEFwModal: boolean;
|
||||
isShowTntModal: boolean;
|
||||
isShowSegmentSetModal: boolean;
|
||||
loading: boolean;
|
||||
tenantIfo: any;
|
||||
data: any[]
|
||||
}
|
||||
export interface kFModelType {
|
||||
namespace: 'kFModel';
|
||||
state: kFModelState;
|
||||
effects: {
|
||||
createKf: Effect;
|
||||
updateKf: Effect;
|
||||
getKfDetail: Effect;
|
||||
getKfList: Effect;
|
||||
updateDocumentStatus: Effect;
|
||||
document_rm: Effect;
|
||||
document_create: Effect;
|
||||
document_change_parser: Effect;
|
||||
};
|
||||
reducers: {
|
||||
updateState: Reducer<kFModelState>;
|
||||
};
|
||||
subscriptions: { setup: Subscription };
|
||||
}
|
||||
const Model: kFModelType = {
|
||||
namespace: 'kFModel',
|
||||
state: {
|
||||
isShowCEFwModal: false,
|
||||
isShowTntModal: false,
|
||||
isShowSegmentSetModal: false,
|
||||
loading: false,
|
||||
tenantIfo: {}
|
||||
tenantIfo: {},
|
||||
data: []
|
||||
},
|
||||
subscriptions: {
|
||||
setup({ dispatch, history }) {
|
||||
|
||||
@ -1,15 +1,22 @@
|
||||
import { connect } from 'umi';
|
||||
import React from 'react';
|
||||
import { connect, Dispatch } from 'umi';
|
||||
import i18n from 'i18next';
|
||||
import { useTranslation, Trans } from 'react-i18next'
|
||||
import { Input, Modal, Form, Tag, Space } from 'antd'
|
||||
import { rsaPsw } from '@/utils'
|
||||
import { useTranslation, } from 'react-i18next'
|
||||
import { Modal, Tag, Space } from 'antd'
|
||||
import { useEffect, useState } from 'react';
|
||||
import styles from './index.less';
|
||||
import type { kFModelState } from './model'
|
||||
import type { settingModelState } from '@/pages/setting/model'
|
||||
const { CheckableTag } = Tag;
|
||||
type FieldType = {
|
||||
name?: string;
|
||||
};
|
||||
const Index = ({ kFModel, settingModel, dispatch, getKfList, parser_id, doc_id }) => {
|
||||
interface kFProps {
|
||||
dispatch: Dispatch;
|
||||
kFModel: kFModelState;
|
||||
settingModel: settingModelState;
|
||||
getKfList: () => void;
|
||||
parser_id: string;
|
||||
doc_id: string;
|
||||
}
|
||||
const Index: React.FC<kFProps> = ({ kFModel, settingModel, dispatch, getKfList, parser_id, doc_id }) => {
|
||||
const [selectedTag, setSelectedTag] = useState('')
|
||||
const { tenantIfo = {} } = settingModel
|
||||
const { parser_ids = '' } = tenantIfo
|
||||
|
||||
@ -1,20 +1,23 @@
|
||||
import React from 'react';
|
||||
import { connect } from 'umi'
|
||||
import { UploadOutlined } from '@ant-design/icons';
|
||||
import type { UploadProps } from 'antd';
|
||||
import { Button, message, Upload } from 'antd';
|
||||
import { Button, Upload } from 'antd';
|
||||
import uploadService from '@/services/uploadService'
|
||||
|
||||
|
||||
const Index = ({ kb_id, getKfList }) => {
|
||||
console.log(kb_id)
|
||||
const createRequest = async function ({ file, onSuccess, onError }) {
|
||||
interface PropsType {
|
||||
kb_id: string;
|
||||
getKfList: () => void
|
||||
}
|
||||
type UploadRequestOption = Parameters<
|
||||
NonNullable<UploadProps["customRequest"]>
|
||||
>[0];
|
||||
const Index: React.FC<PropsType> = ({ kb_id, getKfList }) => {
|
||||
const createRequest: (props: UploadRequestOption) => void = async function ({ file, onSuccess, onError }) {
|
||||
const { retcode, data } = await uploadService.uploadFile(file, kb_id);
|
||||
if (retcode === 0) {
|
||||
onSuccess(data, file);
|
||||
onSuccess && onSuccess(data, file);
|
||||
|
||||
} else {
|
||||
onError(data);
|
||||
onError && onError(data);
|
||||
}
|
||||
getKfList && getKfList()
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user