File size: 3,972 Bytes
04aba1b
 
 
 
 
 
 
362ec6c
 
04aba1b
362ec6c
 
 
 
04aba1b
 
 
362ec6c
 
 
 
 
 
04aba1b
fad2ec7
6b8fc2c
 
 
04aba1b
6b8fc2c
 
 
 
 
04aba1b
6b8fc2c
 
04aba1b
6b8fc2c
362ec6c
 
04aba1b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b8fc2c
04aba1b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b8fc2c
04aba1b
 
 
 
 
 
 
 
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import { formatDate } from '@/utils/date';
import {
  DeleteOutlined,
  MinusSquareOutlined,
  PlusOutlined,
} from '@ant-design/icons';
import { Card, Col, FloatButton, Popconfirm, Row } from 'antd';
import { useCallback, useEffect } from 'react';
import { useDispatch, useNavigate, useSelector } from 'umi';
import styles from './index.less';

const Knowledge = () => {
  const dispatch = useDispatch();
  const knowledgeModel = useSelector((state: any) => state.knowledgeModel);
  const navigate = useNavigate();
  const { data = [] } = knowledgeModel;

  const fetchList = useCallback(() => {
    dispatch({
      type: 'knowledgeModel/getList',
      payload: {},
    });
  }, []);

  const confirm = (id: string) => {
    dispatch({
      type: 'knowledgeModel/rmKb',
      payload: {
        kb_id: id,
      },
    });
  };
  const handleAddKnowledge = () => {
    navigate(`add/setting?activeKey=setting`);
  };
  const handleEditKnowledge = (id: string) => {
    navigate(`add/setting?activeKey=file&id=${id}`);
  };
  useEffect(() => {
    fetchList();
  }, [fetchList]);
  return (
    <>

      <div className={styles.knowledge}>

        <FloatButton

          onClick={handleAddKnowledge}

          icon={<PlusOutlined />}

          type="primary"

          style={{ right: 24, top: 100 }}

        />

        <Row gutter={{ xs: 8, sm: 16, md: 24, lg: 32 }}>

          {data.map((item: any) => {

            return (

              <Col

                className="gutter-row"

                key={item.name}

                xs={24}

                sm={12}

                md={8}

                lg={6}

              >

                <Card

                  className={styles.card}

                  onClick={() => {

                    handleEditKnowledge(item.id);

                  }}

                >

                  <div className={styles.container}>

                    <div className={styles.content}>

                      <span className={styles.context}>{item.name}</span>

                      <span className={styles.delete}>

                        <Popconfirm

                          title="Delete the task"

                          description="Are you sure to delete this task?"

                          onConfirm={(e: any) => {

                            e.stopPropagation();

                            e.nativeEvent.stopImmediatePropagation();

                            confirm(item.id);

                          }}

                          okText="Yes"

                          cancelText="No"

                        >

                          <DeleteOutlined

                            onClick={(e) => {

                              e.stopPropagation();

                              e.nativeEvent.stopImmediatePropagation();

                            }}

                          />

                        </Popconfirm>

                      </span>

                    </div>

                    <div className={styles.footer}>

                      <span className={styles.text}>

                        <MinusSquareOutlined />

                        {item.doc_num}文档

                      </span>

                      <span className={styles.text}>

                        <MinusSquareOutlined />

                        {item.chunk_num}个

                      </span>

                      <span className={styles.text}>

                        <MinusSquareOutlined />

                        {item.token_num}千字符

                      </span>

                      <span style={{ float: 'right' }}>

                        {formatDate(item.update_date)}

                      </span>

                    </div>

                  </div>

                </Card>

              </Col>

            );

          })}

        </Row>

      </div>

    </>
  );
};

export default Knowledge;