balibabu
commited on
Commit
·
503735c
1
Parent(s):
e6acaf6
feat: Modify the color of the svg icon in the header according to the selected state and feat: extract routing information from the knowledge base into constants (#51)
Browse files* feat: Modify the color of the svg icon in the header according to the selected state
* feat: add translation icon to header
* feat: shorten the route length of the knowledge base
* feat: extract routing information from the knowledge base into constants
- web/src/assets/svg/chat-star.svg +3 -3
- web/src/assets/svg/file-management.svg +12 -0
- web/src/assets/svg/knowledge-base.svg +12 -0
- web/src/assets/svg/knowledge-configration.svg +9 -0
- web/src/assets/svg/knowledge-dataset.svg +8 -0
- web/src/assets/svg/knowledge-testing.svg +20 -0
- web/src/assets/svg/moon.svg +5 -0
- web/src/assets/svg/translation.svg +5 -0
- web/src/constants/knowledge.ts +5 -0
- web/src/layouts/components/header/index.less +6 -1
- web/src/layouts/components/header/index.tsx +15 -7
- web/src/layouts/components/right-toolbar/index.less +17 -0
- web/src/layouts/components/right-toolbar/index.tsx +39 -0
- web/src/layouts/components/user/index.tsx +7 -9
- web/src/less/variable.less +13 -0
- web/src/pages/add-knowledge/components/knowledge-file/index.tsx +4 -2
- web/src/pages/add-knowledge/components/knowledge-setting/index.tsx +3 -1
- web/src/pages/add-knowledge/components/knowledge-sidebar/index.less +63 -0
- web/src/pages/add-knowledge/components/knowledge-sidebar/index.tsx +118 -0
- web/src/pages/add-knowledge/constant.ts +9 -0
- web/src/pages/add-knowledge/index.less +14 -18
- web/src/pages/add-knowledge/index.tsx +45 -80
- web/src/pages/add-knowledge/model.ts +0 -2
- web/src/pages/knowledge/index.tsx +1 -1
- web/src/pages/knowledge/knowledge-card/index.tsx +5 -5
- web/src/routes.ts +1 -1
web/src/assets/svg/chat-star.svg
CHANGED
|
|
web/src/assets/svg/file-management.svg
ADDED
|
web/src/assets/svg/knowledge-base.svg
ADDED
|
web/src/assets/svg/knowledge-configration.svg
ADDED
|
web/src/assets/svg/knowledge-dataset.svg
ADDED
|
web/src/assets/svg/knowledge-testing.svg
ADDED
|
web/src/assets/svg/moon.svg
ADDED
|
web/src/assets/svg/translation.svg
ADDED
|
web/src/constants/knowledge.ts
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
export enum KnowledgeRouteKey {
|
2 |
+
Dataset = 'dataset',
|
3 |
+
Testing = 'testing',
|
4 |
+
Configration = 'configration',
|
5 |
+
}
|
web/src/layouts/components/header/index.less
CHANGED
@@ -26,9 +26,14 @@
|
|
26 |
}
|
27 |
|
28 |
.radioGroup {
|
29 |
-
background: rgba(249, 249, 249, 1) !important;
|
30 |
& > label {
|
|
|
|
|
31 |
border: 0 !important;
|
|
|
|
|
|
|
|
|
32 |
&::before {
|
33 |
display: none !important;
|
34 |
}
|
|
|
26 |
}
|
27 |
|
28 |
.radioGroup {
|
|
|
29 |
& > label {
|
30 |
+
height: 40px;
|
31 |
+
line-height: 40px;
|
32 |
border: 0 !important;
|
33 |
+
background-color: rgba(249, 249, 249, 1);
|
34 |
+
font-weight: @fontWeight700;
|
35 |
+
font-family: 'Nunito Sans';
|
36 |
+
color: rgba(29, 25, 41, 1);
|
37 |
&::before {
|
38 |
display: none !important;
|
39 |
}
|
web/src/layouts/components/header/index.tsx
CHANGED
@@ -1,12 +1,14 @@
|
|
1 |
import { ReactComponent as StarIon } from '@/assets/svg/chat-star.svg';
|
|
|
|
|
2 |
import { ReactComponent as Logo } from '@/assets/svg/logo.svg';
|
3 |
import { Layout, Radio, Space, theme } from 'antd';
|
|
|
4 |
|
5 |
import styles from './index.less';
|
6 |
|
7 |
import { useMemo } from 'react';
|
8 |
import { useLocation, useNavigate } from 'umi';
|
9 |
-
import User from '../user';
|
10 |
|
11 |
const { Header } = Layout;
|
12 |
|
@@ -18,13 +20,15 @@ const RagHeader = () => {
|
|
18 |
const { pathname } = useLocation();
|
19 |
|
20 |
const tagsData = [
|
21 |
-
{ path: '/knowledge', name: '
|
22 |
-
{ path: '/chat', name: '
|
23 |
-
{ path: '/file', name: '
|
24 |
];
|
25 |
|
26 |
const currentPath = useMemo(() => {
|
27 |
-
return
|
|
|
|
|
28 |
}, [pathname]);
|
29 |
|
30 |
const handleChange = (path: string) => {
|
@@ -57,16 +61,20 @@ const RagHeader = () => {
|
|
57 |
<Radio.Button
|
58 |
value={item.name}
|
59 |
onClick={() => handleChange(item.path)}
|
|
|
60 |
>
|
61 |
<Space>
|
62 |
-
<
|
|
|
|
|
|
|
63 |
{item.name}
|
64 |
</Space>
|
65 |
</Radio.Button>
|
66 |
))}
|
67 |
</Radio.Group>
|
68 |
</Space>
|
69 |
-
<
|
70 |
</Header>
|
71 |
);
|
72 |
};
|
|
|
1 |
import { ReactComponent as StarIon } from '@/assets/svg/chat-star.svg';
|
2 |
+
import { ReactComponent as FileIcon } from '@/assets/svg/file-management.svg';
|
3 |
+
import { ReactComponent as KnowledgeBaseIcon } from '@/assets/svg/knowledge-base.svg';
|
4 |
import { ReactComponent as Logo } from '@/assets/svg/logo.svg';
|
5 |
import { Layout, Radio, Space, theme } from 'antd';
|
6 |
+
import Toolbar from '../right-toolbar';
|
7 |
|
8 |
import styles from './index.less';
|
9 |
|
10 |
import { useMemo } from 'react';
|
11 |
import { useLocation, useNavigate } from 'umi';
|
|
|
12 |
|
13 |
const { Header } = Layout;
|
14 |
|
|
|
20 |
const { pathname } = useLocation();
|
21 |
|
22 |
const tagsData = [
|
23 |
+
{ path: '/knowledge', name: 'Knowledge Base', icon: KnowledgeBaseIcon },
|
24 |
+
{ path: '/chat', name: 'Chat', icon: StarIon },
|
25 |
+
{ path: '/file', name: 'File Management', icon: FileIcon },
|
26 |
];
|
27 |
|
28 |
const currentPath = useMemo(() => {
|
29 |
+
return (
|
30 |
+
tagsData.find((x) => pathname.startsWith(x.path))?.name || 'knowledge'
|
31 |
+
);
|
32 |
}, [pathname]);
|
33 |
|
34 |
const handleChange = (path: string) => {
|
|
|
61 |
<Radio.Button
|
62 |
value={item.name}
|
63 |
onClick={() => handleChange(item.path)}
|
64 |
+
key={item.name}
|
65 |
>
|
66 |
<Space>
|
67 |
+
<item.icon
|
68 |
+
className={styles.radioButtonIcon}
|
69 |
+
stroke={item.name === currentPath ? 'black' : 'white'}
|
70 |
+
></item.icon>
|
71 |
{item.name}
|
72 |
</Space>
|
73 |
</Radio.Button>
|
74 |
))}
|
75 |
</Radio.Group>
|
76 |
</Space>
|
77 |
+
<Toolbar></Toolbar>
|
78 |
</Header>
|
79 |
);
|
80 |
};
|
web/src/layouts/components/right-toolbar/index.less
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.toolbarWrapper {
|
2 |
+
:global(.ant-avatar) {
|
3 |
+
background-color: rgba(242, 243, 245, 1);
|
4 |
+
}
|
5 |
+
}
|
6 |
+
|
7 |
+
.circle {
|
8 |
+
display: inline-block;
|
9 |
+
line-height: 32px;
|
10 |
+
width: 32px;
|
11 |
+
text-align: center;
|
12 |
+
height: 32px;
|
13 |
+
border-radius: 50%;
|
14 |
+
background-color: rgba(242, 243, 245, 1);
|
15 |
+
vertical-align: middle;
|
16 |
+
cursor: pointer;
|
17 |
+
}
|
web/src/layouts/components/right-toolbar/index.tsx
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { ReactComponent as MoonIcon } from '@/assets/svg/moon.svg';
|
2 |
+
import { ReactComponent as TranslationIcon } from '@/assets/svg/translation.svg';
|
3 |
+
import { BellOutlined, GithubOutlined } from '@ant-design/icons';
|
4 |
+
import { Space } from 'antd';
|
5 |
+
import React from 'react';
|
6 |
+
import User from '../user';
|
7 |
+
import styled from './index.less';
|
8 |
+
|
9 |
+
const Circle = ({ children }: React.PropsWithChildren) => {
|
10 |
+
return <div className={styled.circle}>{children}</div>;
|
11 |
+
};
|
12 |
+
|
13 |
+
const handleGithubCLick = () => {
|
14 |
+
window.open('https://github.com/infiniflow/infinity', 'target');
|
15 |
+
};
|
16 |
+
|
17 |
+
const RightToolBar = () => {
|
18 |
+
return (
|
19 |
+
<div className={styled.toolbarWrapper}>
|
20 |
+
<Space wrap size={16}>
|
21 |
+
<Circle>
|
22 |
+
<GithubOutlined onClick={handleGithubCLick} />
|
23 |
+
</Circle>
|
24 |
+
<Circle>
|
25 |
+
<TranslationIcon />
|
26 |
+
</Circle>
|
27 |
+
<Circle>
|
28 |
+
<BellOutlined />
|
29 |
+
</Circle>
|
30 |
+
<Circle>
|
31 |
+
<MoonIcon />
|
32 |
+
</Circle>
|
33 |
+
<User></User>
|
34 |
+
</Space>
|
35 |
+
</div>
|
36 |
+
);
|
37 |
+
};
|
38 |
+
|
39 |
+
export default RightToolBar;
|
web/src/layouts/components/user/index.tsx
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import authorizationUtil from '@/utils/authorizationUtil';
|
2 |
import type { MenuProps } from 'antd';
|
3 |
-
import { Button, Dropdown } from 'antd';
|
4 |
import React, { useMemo } from 'react';
|
5 |
import { useTranslation } from 'react-i18next';
|
6 |
import { history } from 'umi';
|
@@ -39,14 +39,12 @@ const App: React.FC = () => {
|
|
39 |
}, []);
|
40 |
|
41 |
return (
|
42 |
-
|
43 |
-
<
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
</Dropdown>
|
49 |
-
</>
|
50 |
);
|
51 |
};
|
52 |
|
|
|
1 |
import authorizationUtil from '@/utils/authorizationUtil';
|
2 |
import type { MenuProps } from 'antd';
|
3 |
+
import { Avatar, Button, Dropdown } from 'antd';
|
4 |
import React, { useMemo } from 'react';
|
5 |
import { useTranslation } from 'react-i18next';
|
6 |
import { history } from 'umi';
|
|
|
39 |
}, []);
|
40 |
|
41 |
return (
|
42 |
+
<Dropdown menu={{ items }} placement="bottomLeft" arrow>
|
43 |
+
<Avatar
|
44 |
+
size={32}
|
45 |
+
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png"
|
46 |
+
/>
|
47 |
+
</Dropdown>
|
|
|
|
|
48 |
);
|
49 |
};
|
50 |
|
web/src/less/variable.less
CHANGED
@@ -1 +1,14 @@
|
|
1 |
@fontWeight600: 600;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
@fontWeight600: 600;
|
2 |
+
@fontWeight700: 700;
|
3 |
+
|
4 |
+
@gray2: rgba(29, 25, 41, 1);
|
5 |
+
@gray3: rgba(52, 48, 62, 1);
|
6 |
+
@gray8: rgba(165, 163, 169, 1);
|
7 |
+
@gray11: rgba(232, 232, 234, 1);
|
8 |
+
|
9 |
+
@fontSize12: 12px;
|
10 |
+
@fontSize14: 14px;
|
11 |
+
@fontSize16: 16px;
|
12 |
+
@fontSize18: 18px;
|
13 |
+
|
14 |
+
@fontFamilyNunitoSans: 'Nunito Sans';
|
web/src/pages/add-knowledge/components/knowledge-file/index.tsx
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import { getOneNamespaceEffectsLoading } from '@/utils/stroreUtil';
|
2 |
import { DownOutlined } from '@ant-design/icons';
|
3 |
import type { MenuProps } from 'antd';
|
@@ -158,8 +159,9 @@ const KnowledgeFile: React.FC<KFProps> = ({ kb_id }) => {
|
|
158 |
},
|
159 |
];
|
160 |
const toChunk = (id: string) => {
|
161 |
-
|
162 |
-
|
|
|
163 |
};
|
164 |
const columns: ColumnsType<DataType> = [
|
165 |
{
|
|
|
1 |
+
import { KnowledgeRouteKey } from '@/constants/knowledge';
|
2 |
import { getOneNamespaceEffectsLoading } from '@/utils/stroreUtil';
|
3 |
import { DownOutlined } from '@ant-design/icons';
|
4 |
import type { MenuProps } from 'antd';
|
|
|
159 |
},
|
160 |
];
|
161 |
const toChunk = (id: string) => {
|
162 |
+
navigate(
|
163 |
+
`/knowledge/${KnowledgeRouteKey.Dataset}?id=${kb_id}&doc_id=${id}`,
|
164 |
+
);
|
165 |
};
|
166 |
const columns: ColumnsType<DataType> = [
|
167 |
{
|
web/src/pages/add-knowledge/components/knowledge-setting/index.tsx
CHANGED
@@ -1,7 +1,9 @@
|
|
|
|
1 |
import { Button, Form, Input, Radio, Select, Space, Tag } from 'antd';
|
2 |
import React, { useCallback, useEffect, useState } from 'react';
|
3 |
import { useDispatch, useNavigate, useSelector } from 'umi';
|
4 |
import styles from './index.less';
|
|
|
5 |
const { CheckableTag } = Tag;
|
6 |
const layout = {
|
7 |
labelCol: { span: 8 },
|
@@ -67,7 +69,7 @@ const KnowledgeSetting: React.FC<kSProps> = ({ kb_id }) => {
|
|
67 |
},
|
68 |
});
|
69 |
retcode === 0 &&
|
70 |
-
navigate(`/knowledge
|
71 |
}
|
72 |
} catch (error) {
|
73 |
console.warn(error);
|
|
|
1 |
+
import { KnowledgeRouteKey } from '@/constants/knowledge';
|
2 |
import { Button, Form, Input, Radio, Select, Space, Tag } from 'antd';
|
3 |
import React, { useCallback, useEffect, useState } from 'react';
|
4 |
import { useDispatch, useNavigate, useSelector } from 'umi';
|
5 |
import styles from './index.less';
|
6 |
+
|
7 |
const { CheckableTag } = Tag;
|
8 |
const layout = {
|
9 |
labelCol: { span: 8 },
|
|
|
69 |
},
|
70 |
});
|
71 |
retcode === 0 &&
|
72 |
+
navigate(`/knowledge/${KnowledgeRouteKey.Dataset}?id=${kb_id}`);
|
73 |
}
|
74 |
} catch (error) {
|
75 |
console.warn(error);
|
web/src/pages/add-knowledge/components/knowledge-sidebar/index.less
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.sidebarWrapper {
|
2 |
+
max-width: 288px;
|
3 |
+
padding: 32px 24px 24px 24px;
|
4 |
+
flex-direction: column;
|
5 |
+
|
6 |
+
.sidebarTop {
|
7 |
+
text-align: center;
|
8 |
+
.knowledgeLogo {
|
9 |
+
}
|
10 |
+
.knowledgeTitle {
|
11 |
+
font-family: 'Nunito Sans';
|
12 |
+
font-size: 16px;
|
13 |
+
line-height: 24px;
|
14 |
+
font-weight: @fontWeight700;
|
15 |
+
color: @gray2;
|
16 |
+
margin-bottom: 6px;
|
17 |
+
}
|
18 |
+
.knowledgeDescription {
|
19 |
+
font-family: 'Nunito Sans';
|
20 |
+
font-size: 12px;
|
21 |
+
font-weight: @fontWeight600;
|
22 |
+
color: @gray8;
|
23 |
+
margin: 0;
|
24 |
+
}
|
25 |
+
padding-bottom: 20px;
|
26 |
+
}
|
27 |
+
.divider {
|
28 |
+
height: 2px;
|
29 |
+
background-image: linear-gradient(
|
30 |
+
to right,
|
31 |
+
@gray11 0%,
|
32 |
+
@gray11 50%,
|
33 |
+
transparent 50%
|
34 |
+
);
|
35 |
+
background-size: 10px 2px;
|
36 |
+
background-repeat: repeat-x;
|
37 |
+
}
|
38 |
+
|
39 |
+
.menuWrapper {
|
40 |
+
padding-top: 10px;
|
41 |
+
|
42 |
+
.menu {
|
43 |
+
border: none;
|
44 |
+
font-size: @fontSize14;
|
45 |
+
font-weight: @fontWeight600;
|
46 |
+
}
|
47 |
+
|
48 |
+
.defaultWidth {
|
49 |
+
width: 240px;
|
50 |
+
}
|
51 |
+
|
52 |
+
.minWidth {
|
53 |
+
width: 50px;
|
54 |
+
}
|
55 |
+
|
56 |
+
.menuText {
|
57 |
+
color: @gray3;
|
58 |
+
font-family: @fontFamilyNunitoSans;
|
59 |
+
font-size: @fontSize14;
|
60 |
+
font-weight: @fontWeight700;
|
61 |
+
}
|
62 |
+
}
|
63 |
+
}
|
web/src/pages/add-knowledge/components/knowledge-sidebar/index.tsx
ADDED
@@ -0,0 +1,118 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { ReactComponent as ConfigrationIcon } from '@/assets/svg/knowledge-configration.svg';
|
2 |
+
import { ReactComponent as DatasetIcon } from '@/assets/svg/knowledge-dataset.svg';
|
3 |
+
import { ReactComponent as TestingIcon } from '@/assets/svg/knowledge-testing.svg';
|
4 |
+
import { getWidth } from '@/utils';
|
5 |
+
import { AntDesignOutlined } from '@ant-design/icons';
|
6 |
+
import { Avatar, Menu, MenuProps, Space } from 'antd';
|
7 |
+
import classNames from 'classnames';
|
8 |
+
import { useEffect, useMemo, useState } from 'react';
|
9 |
+
import { useNavigate, useParams, useSelector } from 'umi';
|
10 |
+
import { KnowledgeRouteKey, routeMap } from '../../constant';
|
11 |
+
import styles from './index.less';
|
12 |
+
|
13 |
+
const KnowledgeSidebar = () => {
|
14 |
+
const kAModel = useSelector((state: any) => state.kAModel);
|
15 |
+
const { id } = kAModel;
|
16 |
+
let navigate = useNavigate();
|
17 |
+
const params = useParams();
|
18 |
+
const activeKey = params.module || KnowledgeRouteKey.Dataset;
|
19 |
+
|
20 |
+
const [windowWidth, setWindowWidth] = useState(getWidth());
|
21 |
+
const [collapsed, setCollapsed] = useState(false);
|
22 |
+
|
23 |
+
const handleSelect: MenuProps['onSelect'] = (e) => {
|
24 |
+
navigate(`/knowledge/${e.key}?id=${id}`);
|
25 |
+
};
|
26 |
+
|
27 |
+
type MenuItem = Required<MenuProps>['items'][number];
|
28 |
+
|
29 |
+
function getItem(
|
30 |
+
label: React.ReactNode,
|
31 |
+
key: React.Key,
|
32 |
+
icon?: React.ReactNode,
|
33 |
+
disabled?: boolean,
|
34 |
+
children?: MenuItem[],
|
35 |
+
type?: 'group',
|
36 |
+
): MenuItem {
|
37 |
+
return {
|
38 |
+
key,
|
39 |
+
icon,
|
40 |
+
children,
|
41 |
+
label,
|
42 |
+
type,
|
43 |
+
disabled,
|
44 |
+
} as MenuItem;
|
45 |
+
}
|
46 |
+
const items: MenuItem[] = useMemo(() => {
|
47 |
+
return [
|
48 |
+
getItem(
|
49 |
+
routeMap[KnowledgeRouteKey.Dataset], // TODO: Change icon color when selected
|
50 |
+
KnowledgeRouteKey.Dataset,
|
51 |
+
<DatasetIcon />,
|
52 |
+
),
|
53 |
+
getItem(
|
54 |
+
routeMap[KnowledgeRouteKey.Testing],
|
55 |
+
KnowledgeRouteKey.Testing,
|
56 |
+
<TestingIcon />,
|
57 |
+
),
|
58 |
+
getItem(
|
59 |
+
routeMap[KnowledgeRouteKey.Configration],
|
60 |
+
KnowledgeRouteKey.Configration,
|
61 |
+
<ConfigrationIcon />,
|
62 |
+
),
|
63 |
+
];
|
64 |
+
}, [id]);
|
65 |
+
|
66 |
+
useEffect(() => {
|
67 |
+
if (windowWidth.width > 957) {
|
68 |
+
setCollapsed(false);
|
69 |
+
} else {
|
70 |
+
setCollapsed(true);
|
71 |
+
}
|
72 |
+
}, [windowWidth.width]);
|
73 |
+
|
74 |
+
// 标记一下
|
75 |
+
useEffect(() => {
|
76 |
+
const widthSize = () => {
|
77 |
+
const width = getWidth();
|
78 |
+
console.log(width);
|
79 |
+
|
80 |
+
setWindowWidth(width);
|
81 |
+
};
|
82 |
+
window.addEventListener('resize', widthSize);
|
83 |
+
return () => {
|
84 |
+
window.removeEventListener('resize', widthSize);
|
85 |
+
};
|
86 |
+
}, []);
|
87 |
+
|
88 |
+
return (
|
89 |
+
<div className={styles.sidebarWrapper}>
|
90 |
+
<div className={styles.sidebarTop}>
|
91 |
+
<Space size={8} direction="vertical">
|
92 |
+
<Avatar size={64} icon={<AntDesignOutlined />} />
|
93 |
+
<div className={styles.knowledgeTitle}>Cloud Computing</div>
|
94 |
+
</Space>
|
95 |
+
<p className={styles.knowledgeDescription}>
|
96 |
+
A scalable, secure cloud-based database optimized for high-performance
|
97 |
+
computing and data storage.
|
98 |
+
</p>
|
99 |
+
</div>
|
100 |
+
<div className={styles.divider}></div>
|
101 |
+
<div className={styles.menuWrapper}>
|
102 |
+
<Menu
|
103 |
+
selectedKeys={[activeKey]}
|
104 |
+
// mode="inline"
|
105 |
+
className={classNames(styles.menu, {
|
106 |
+
[styles.defaultWidth]: windowWidth.width > 957,
|
107 |
+
[styles.minWidth]: windowWidth.width <= 957,
|
108 |
+
})}
|
109 |
+
inlineCollapsed={collapsed}
|
110 |
+
items={items}
|
111 |
+
onSelect={handleSelect}
|
112 |
+
/>
|
113 |
+
</div>
|
114 |
+
</div>
|
115 |
+
);
|
116 |
+
};
|
117 |
+
|
118 |
+
export default KnowledgeSidebar;
|
web/src/pages/add-knowledge/constant.ts
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { KnowledgeRouteKey } from '@/constants/knowledge';
|
2 |
+
|
3 |
+
export const routeMap = {
|
4 |
+
[KnowledgeRouteKey.Dataset]: 'Dataset',
|
5 |
+
[KnowledgeRouteKey.Testing]: 'Retrieval testing',
|
6 |
+
[KnowledgeRouteKey.Configration]: 'Configuration',
|
7 |
+
};
|
8 |
+
|
9 |
+
export * from '@/constants/knowledge';
|
web/src/pages/add-knowledge/index.less
CHANGED
@@ -1,19 +1,15 @@
|
|
1 |
.container {
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
overflow-x: auto;
|
17 |
-
height: 100%;
|
18 |
-
}
|
19 |
-
}
|
|
|
1 |
.container {
|
2 |
+
display: flex;
|
3 |
+
height: 100%;
|
4 |
+
.contentWrapper {
|
5 |
+
flex: 1;
|
6 |
+
overflow-x: auto;
|
7 |
+
height: 100%;
|
8 |
+
background-color: rgba(247, 248, 250, 1);
|
9 |
+
padding: 16px 20px 28px 40px;
|
10 |
+
}
|
11 |
+
.content {
|
12 |
+
background-color: white;
|
13 |
+
margin-top: 16px;
|
14 |
+
}
|
15 |
+
}
|
|
|
|
|
|
|
|
web/src/pages/add-knowledge/index.tsx
CHANGED
@@ -1,39 +1,46 @@
|
|
1 |
-
import {
|
2 |
-
import {
|
3 |
-
import
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
7 |
import Chunk from './components/knowledge-chunk';
|
8 |
import File from './components/knowledge-file';
|
9 |
import Search from './components/knowledge-search';
|
10 |
import Setting from './components/knowledge-setting';
|
|
|
|
|
11 |
import styles from './index.less';
|
12 |
|
13 |
const KnowledgeAdding = () => {
|
14 |
const dispatch = useDispatch();
|
15 |
const kAModel = useSelector((state: any) => state.kAModel);
|
16 |
-
const
|
|
|
17 |
|
18 |
-
const [collapsed, setCollapsed] = useState(false);
|
19 |
-
const [windowWidth, setWindowWidth] = useState(getWidth());
|
20 |
-
let navigate = useNavigate();
|
21 |
const location = useLocation();
|
|
|
|
|
|
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
-
setWindowWidth(width);
|
31 |
-
};
|
32 |
-
window.addEventListener('resize', widthSize);
|
33 |
-
return () => {
|
34 |
-
window.removeEventListener('resize', widthSize);
|
35 |
-
};
|
36 |
-
}, []);
|
37 |
useEffect(() => {
|
38 |
const search: string = location.search.slice(1);
|
39 |
const map = search.split('&').reduce<Record<string, string>>((obj, cur) => {
|
@@ -51,66 +58,24 @@ const KnowledgeAdding = () => {
|
|
51 |
});
|
52 |
}, [location]);
|
53 |
|
54 |
-
useEffect(() => {
|
55 |
-
if (windowWidth.width > 957) {
|
56 |
-
setCollapsed(false);
|
57 |
-
} else {
|
58 |
-
setCollapsed(true);
|
59 |
-
}
|
60 |
-
}, [windowWidth.width]);
|
61 |
-
|
62 |
-
type MenuItem = Required<MenuProps>['items'][number];
|
63 |
-
|
64 |
-
function getItem(
|
65 |
-
label: React.ReactNode,
|
66 |
-
key: React.Key,
|
67 |
-
icon?: React.ReactNode,
|
68 |
-
disabled?: boolean,
|
69 |
-
children?: MenuItem[],
|
70 |
-
type?: 'group',
|
71 |
-
): MenuItem {
|
72 |
-
return {
|
73 |
-
key,
|
74 |
-
icon,
|
75 |
-
children,
|
76 |
-
label,
|
77 |
-
type,
|
78 |
-
disabled,
|
79 |
-
} as MenuItem;
|
80 |
-
}
|
81 |
-
const items: MenuItem[] = useMemo(() => {
|
82 |
-
const disabled = !id;
|
83 |
-
return [
|
84 |
-
getItem('配置', 'setting', <ToolOutlined />),
|
85 |
-
getItem('知识库', 'file', <BarsOutlined />, disabled),
|
86 |
-
getItem('搜索测试', 'search', <SearchOutlined />, disabled),
|
87 |
-
];
|
88 |
-
}, [id]);
|
89 |
-
|
90 |
-
const handleSelect: MenuProps['onSelect'] = (e) => {
|
91 |
-
navigate(`/knowledge/add/setting?activeKey=${e.key}&id=${id}`);
|
92 |
-
};
|
93 |
-
|
94 |
return (
|
95 |
<>
|
96 |
<div className={styles.container}>
|
97 |
-
<
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
}
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
{activeKey === 'search' && <Search kb_id={id} />}
|
113 |
-
{activeKey === 'file' && !!doc_id && <Chunk doc_id={doc_id} />}
|
114 |
</div>
|
115 |
</div>
|
116 |
</>
|
|
|
1 |
+
import { Breadcrumb } from 'antd';
|
2 |
+
import { useEffect, useMemo } from 'react';
|
3 |
+
import {
|
4 |
+
useDispatch,
|
5 |
+
useLocation,
|
6 |
+
useNavigate,
|
7 |
+
useParams,
|
8 |
+
useSelector,
|
9 |
+
} from 'umi';
|
10 |
import Chunk from './components/knowledge-chunk';
|
11 |
import File from './components/knowledge-file';
|
12 |
import Search from './components/knowledge-search';
|
13 |
import Setting from './components/knowledge-setting';
|
14 |
+
import Siderbar from './components/knowledge-sidebar';
|
15 |
+
import { KnowledgeRouteKey, routeMap } from './constant';
|
16 |
import styles from './index.less';
|
17 |
|
18 |
const KnowledgeAdding = () => {
|
19 |
const dispatch = useDispatch();
|
20 |
const kAModel = useSelector((state: any) => state.kAModel);
|
21 |
+
const navigate = useNavigate();
|
22 |
+
const { id, doc_id } = kAModel;
|
23 |
|
|
|
|
|
|
|
24 |
const location = useLocation();
|
25 |
+
const params = useParams();
|
26 |
+
const activeKey: KnowledgeRouteKey =
|
27 |
+
(params.module as KnowledgeRouteKey) || KnowledgeRouteKey.Dataset;
|
28 |
|
29 |
+
const gotoList = () => {
|
30 |
+
navigate('/knowledge');
|
31 |
+
};
|
32 |
+
|
33 |
+
const breadcrumbItems = useMemo(() => {
|
34 |
+
return [
|
35 |
+
{
|
36 |
+
title: <a onClick={gotoList}>Knowledge Base</a>,
|
37 |
+
},
|
38 |
+
{
|
39 |
+
title: routeMap[activeKey],
|
40 |
+
},
|
41 |
+
];
|
42 |
+
}, [activeKey]);
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
useEffect(() => {
|
45 |
const search: string = location.search.slice(1);
|
46 |
const map = search.split('&').reduce<Record<string, string>>((obj, cur) => {
|
|
|
58 |
});
|
59 |
}, [location]);
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
return (
|
62 |
<>
|
63 |
<div className={styles.container}>
|
64 |
+
<Siderbar></Siderbar>
|
65 |
+
<div className={styles.contentWrapper}>
|
66 |
+
<Breadcrumb items={breadcrumbItems} />
|
67 |
+
<div className={styles.content}>
|
68 |
+
{activeKey === KnowledgeRouteKey.Dataset && !doc_id && (
|
69 |
+
<File kb_id={id} />
|
70 |
+
)}
|
71 |
+
{activeKey === KnowledgeRouteKey.Configration && (
|
72 |
+
<Setting kb_id={id} />
|
73 |
+
)}
|
74 |
+
{activeKey === KnowledgeRouteKey.Testing && <Search kb_id={id} />}
|
75 |
+
{activeKey === KnowledgeRouteKey.Dataset && !!doc_id && (
|
76 |
+
<Chunk doc_id={doc_id} />
|
77 |
+
)}
|
78 |
+
</div>
|
|
|
|
|
79 |
</div>
|
80 |
</div>
|
81 |
</>
|
web/src/pages/add-knowledge/model.ts
CHANGED
@@ -3,7 +3,6 @@ export interface kAModelState {
|
|
3 |
isShowPSwModal: boolean;
|
4 |
isShowTntModal: boolean;
|
5 |
tenantIfo: any;
|
6 |
-
activeKey: string;
|
7 |
id: string;
|
8 |
doc_id: string;
|
9 |
}
|
@@ -14,7 +13,6 @@ const model: DvaModel<kAModelState> = {
|
|
14 |
isShowPSwModal: false,
|
15 |
isShowTntModal: false,
|
16 |
tenantIfo: {},
|
17 |
-
activeKey: 'setting',
|
18 |
id: '',
|
19 |
doc_id: '',
|
20 |
},
|
|
|
3 |
isShowPSwModal: boolean;
|
4 |
isShowTntModal: boolean;
|
5 |
tenantIfo: any;
|
|
|
6 |
id: string;
|
7 |
doc_id: string;
|
8 |
}
|
|
|
13 |
isShowPSwModal: false,
|
14 |
isShowTntModal: false,
|
15 |
tenantIfo: {},
|
|
|
16 |
id: '',
|
17 |
doc_id: '',
|
18 |
},
|
web/src/pages/knowledge/index.tsx
CHANGED
@@ -20,7 +20,7 @@ const Knowledge = () => {
|
|
20 |
}, []);
|
21 |
|
22 |
const handleAddKnowledge = () => {
|
23 |
-
navigate(`add/setting
|
24 |
};
|
25 |
|
26 |
useEffect(() => {
|
|
|
20 |
}, []);
|
21 |
|
22 |
const handleAddKnowledge = () => {
|
23 |
+
navigate(`add/setting`);
|
24 |
};
|
25 |
|
26 |
useEffect(() => {
|
web/src/pages/knowledge/knowledge-card/index.tsx
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
import { ReactComponent as MoreIcon } from '@/assets/svg/more.svg';
|
|
|
2 |
import { formatDate } from '@/utils/date';
|
3 |
import {
|
4 |
-
AntDesignOutlined,
|
5 |
CalendarOutlined,
|
6 |
DeleteOutlined,
|
7 |
FileTextOutlined,
|
8 |
UserOutlined,
|
9 |
} from '@ant-design/icons';
|
10 |
-
import { Avatar, Card, Dropdown, MenuProps, Space
|
11 |
import { MouseEvent } from 'react';
|
12 |
import { useDispatch, useNavigate } from 'umi';
|
13 |
|
@@ -47,7 +47,7 @@ const KnowledgeCard = ({ item }: IProps) => {
|
|
47 |
};
|
48 |
|
49 |
const handleCardClick = () => {
|
50 |
-
navigate(
|
51 |
};
|
52 |
|
53 |
const onConfirmDelete = (e?: MouseEvent<HTMLElement>) => {
|
@@ -97,7 +97,7 @@ const KnowledgeCard = ({ item }: IProps) => {
|
|
97 |
{formatDate(item.update_date)}
|
98 |
</span>
|
99 |
</div>
|
100 |
-
<Avatar.Group size={25}>
|
101 |
<Avatar src="https://api.dicebear.com/7.x/miniavs/svg?seed=1" />
|
102 |
<a href="https://ant.design">
|
103 |
<Avatar style={{ backgroundColor: '#f56a00' }}>K</Avatar>
|
@@ -112,7 +112,7 @@ const KnowledgeCard = ({ item }: IProps) => {
|
|
112 |
style={{ backgroundColor: '#1677ff' }}
|
113 |
icon={<AntDesignOutlined />}
|
114 |
/>
|
115 |
-
</Avatar.Group>
|
116 |
</div>
|
117 |
</div>
|
118 |
</div>
|
|
|
1 |
import { ReactComponent as MoreIcon } from '@/assets/svg/more.svg';
|
2 |
+
import { KnowledgeRouteKey } from '@/constants/knowledge';
|
3 |
import { formatDate } from '@/utils/date';
|
4 |
import {
|
|
|
5 |
CalendarOutlined,
|
6 |
DeleteOutlined,
|
7 |
FileTextOutlined,
|
8 |
UserOutlined,
|
9 |
} from '@ant-design/icons';
|
10 |
+
import { Avatar, Card, Dropdown, MenuProps, Space } from 'antd';
|
11 |
import { MouseEvent } from 'react';
|
12 |
import { useDispatch, useNavigate } from 'umi';
|
13 |
|
|
|
47 |
};
|
48 |
|
49 |
const handleCardClick = () => {
|
50 |
+
navigate(`/knowledge/${KnowledgeRouteKey.Dataset}?id=${item.id}`);
|
51 |
};
|
52 |
|
53 |
const onConfirmDelete = (e?: MouseEvent<HTMLElement>) => {
|
|
|
97 |
{formatDate(item.update_date)}
|
98 |
</span>
|
99 |
</div>
|
100 |
+
{/* <Avatar.Group size={25}>
|
101 |
<Avatar src="https://api.dicebear.com/7.x/miniavs/svg?seed=1" />
|
102 |
<a href="https://ant.design">
|
103 |
<Avatar style={{ backgroundColor: '#f56a00' }}>K</Avatar>
|
|
|
112 |
style={{ backgroundColor: '#1677ff' }}
|
113 |
icon={<AntDesignOutlined />}
|
114 |
/>
|
115 |
+
</Avatar.Group> */}
|
116 |
</div>
|
117 |
</div>
|
118 |
</div>
|
web/src/routes.ts
CHANGED
@@ -16,7 +16,7 @@ const routes = [
|
|
16 |
component: '@/pages/knowledge',
|
17 |
},
|
18 |
{
|
19 |
-
path: '/knowledge
|
20 |
component: '@/pages/add-knowledge',
|
21 |
},
|
22 |
{
|
|
|
16 |
component: '@/pages/knowledge',
|
17 |
},
|
18 |
{
|
19 |
+
path: '/knowledge/:module',
|
20 |
component: '@/pages/add-knowledge',
|
21 |
},
|
22 |
{
|