balibabu
commited on
Commit
·
e441caf
1
Parent(s):
72412ac
remove showDeleteConfirm function and center the Empty of knowledge list and extract the text of the login page to en.json (#203)
Browse filesfeat: remove showDeleteConfirm function
feat: center the Empty of knowledge list
feat: extract the text of the login page to en.json
#204
- web/src/app.tsx +9 -9
- web/src/components/deleting-confirm/index.less +0 -0
- web/src/components/deleting-confirm/index.tsx +0 -39
- web/src/components/svg-icon.tsx +0 -1
- web/src/hooks/{commonHooks.ts → commonHooks.tsx} +44 -1
- web/src/hooks/knowledgeHook.ts +4 -2
- web/src/layouts/components/header/index.tsx +5 -3
- web/src/locales/en.json +30 -1
- web/src/pages/add-knowledge/components/knowledge-file/model.ts +0 -2
- web/src/pages/add-knowledge/components/knowledge-file/parsing-action-cell/index.tsx +2 -1
- web/src/pages/chat/hooks.ts +3 -2
- web/src/pages/knowledge/index.less +3 -0
- web/src/pages/knowledge/index.tsx +6 -6
- web/src/pages/knowledge/knowledge-card/index.tsx +2 -1
- web/src/pages/knowledge/knowledge-creating-modal/index.tsx +6 -4
- web/src/pages/login/index.tsx +20 -25
web/src/app.tsx
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
-
import { ConfigProvider } from 'antd';
|
2 |
-
import
|
3 |
|
4 |
export function rootContainer(container: ReactNode) {
|
5 |
-
return
|
6 |
-
ConfigProvider
|
7 |
-
|
8 |
-
theme: {
|
9 |
token: {
|
10 |
fontFamily: 'Inter',
|
11 |
},
|
12 |
-
}
|
13 |
-
|
14 |
-
|
|
|
15 |
);
|
16 |
}
|
|
|
1 |
+
import { App, ConfigProvider } from 'antd';
|
2 |
+
import { ReactNode } from 'react';
|
3 |
|
4 |
export function rootContainer(container: ReactNode) {
|
5 |
+
return (
|
6 |
+
<ConfigProvider
|
7 |
+
theme={{
|
|
|
8 |
token: {
|
9 |
fontFamily: 'Inter',
|
10 |
},
|
11 |
+
}}
|
12 |
+
>
|
13 |
+
<App> {container}</App>
|
14 |
+
</ConfigProvider>
|
15 |
);
|
16 |
}
|
web/src/components/deleting-confirm/index.less
DELETED
File without changes
|
web/src/components/deleting-confirm/index.tsx
DELETED
@@ -1,39 +0,0 @@
|
|
1 |
-
import { ExclamationCircleFilled } from '@ant-design/icons';
|
2 |
-
import { Modal } from 'antd';
|
3 |
-
|
4 |
-
const { confirm } = Modal;
|
5 |
-
|
6 |
-
interface IProps {
|
7 |
-
onOk?: (...args: any[]) => any;
|
8 |
-
onCancel?: (...args: any[]) => any;
|
9 |
-
}
|
10 |
-
|
11 |
-
export const showDeleteConfirm = ({
|
12 |
-
onOk,
|
13 |
-
onCancel,
|
14 |
-
}: IProps): Promise<number> => {
|
15 |
-
return new Promise((resolve, reject) => {
|
16 |
-
confirm({
|
17 |
-
title: 'Are you sure delete this item?',
|
18 |
-
icon: <ExclamationCircleFilled />,
|
19 |
-
content: 'Some descriptions',
|
20 |
-
okText: 'Yes',
|
21 |
-
okType: 'danger',
|
22 |
-
cancelText: 'No',
|
23 |
-
async onOk() {
|
24 |
-
try {
|
25 |
-
const ret = await onOk?.();
|
26 |
-
resolve(ret);
|
27 |
-
console.info(ret);
|
28 |
-
} catch (error) {
|
29 |
-
reject(error);
|
30 |
-
}
|
31 |
-
},
|
32 |
-
onCancel() {
|
33 |
-
onCancel?.();
|
34 |
-
},
|
35 |
-
});
|
36 |
-
});
|
37 |
-
};
|
38 |
-
|
39 |
-
export default showDeleteConfirm;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
web/src/components/svg-icon.tsx
CHANGED
@@ -4,7 +4,6 @@ import { IconComponentProps } from '@ant-design/icons/lib/components/Icon';
|
|
4 |
const importAll = (requireContext: __WebpackModuleApi.RequireContext) => {
|
5 |
const list = requireContext.keys().map((key) => {
|
6 |
const name = key.replace(/\.\/(.*)\.\w+$/, '$1');
|
7 |
-
console.log(name, requireContext(key));
|
8 |
return { name, value: requireContext(key) };
|
9 |
});
|
10 |
return list;
|
|
|
4 |
const importAll = (requireContext: __WebpackModuleApi.RequireContext) => {
|
5 |
const list = requireContext.keys().map((key) => {
|
6 |
const name = key.replace(/\.\/(.*)\.\w+$/, '$1');
|
|
|
7 |
return { name, value: requireContext(key) };
|
8 |
});
|
9 |
return list;
|
web/src/hooks/{commonHooks.ts → commonHooks.tsx}
RENAMED
@@ -1,5 +1,8 @@
|
|
|
|
|
|
1 |
import isEqual from 'lodash/isEqual';
|
2 |
-
import { useEffect, useRef, useState } from 'react';
|
|
|
3 |
|
4 |
export const useSetModalState = () => {
|
5 |
const [visible, setVisible] = useState(false);
|
@@ -72,3 +75,43 @@ export function useDynamicSVGImport(
|
|
72 |
|
73 |
return { error, loading, SvgIcon: ImportedIconRef.current };
|
74 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { ExclamationCircleFilled } from '@ant-design/icons';
|
2 |
+
import { App } from 'antd';
|
3 |
import isEqual from 'lodash/isEqual';
|
4 |
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
5 |
+
import { useTranslation } from 'react-i18next';
|
6 |
|
7 |
export const useSetModalState = () => {
|
8 |
const [visible, setVisible] = useState(false);
|
|
|
75 |
|
76 |
return { error, loading, SvgIcon: ImportedIconRef.current };
|
77 |
}
|
78 |
+
|
79 |
+
interface IProps {
|
80 |
+
onOk?: (...args: any[]) => any;
|
81 |
+
onCancel?: (...args: any[]) => any;
|
82 |
+
}
|
83 |
+
|
84 |
+
export const useShowDeleteConfirm = () => {
|
85 |
+
const { modal } = App.useApp();
|
86 |
+
const { t } = useTranslation();
|
87 |
+
|
88 |
+
const showDeleteConfirm = useCallback(
|
89 |
+
({ onOk, onCancel }: IProps): Promise<number> => {
|
90 |
+
return new Promise((resolve, reject) => {
|
91 |
+
modal.confirm({
|
92 |
+
title: t('common.deleteModalTitle'),
|
93 |
+
icon: <ExclamationCircleFilled />,
|
94 |
+
// content: 'Some descriptions',
|
95 |
+
okText: 'Yes',
|
96 |
+
okType: 'danger',
|
97 |
+
cancelText: 'No',
|
98 |
+
async onOk() {
|
99 |
+
try {
|
100 |
+
const ret = await onOk?.();
|
101 |
+
resolve(ret);
|
102 |
+
console.info(ret);
|
103 |
+
} catch (error) {
|
104 |
+
reject(error);
|
105 |
+
}
|
106 |
+
},
|
107 |
+
onCancel() {
|
108 |
+
onCancel?.();
|
109 |
+
},
|
110 |
+
});
|
111 |
+
});
|
112 |
+
},
|
113 |
+
[t, modal],
|
114 |
+
);
|
115 |
+
|
116 |
+
return showDeleteConfirm;
|
117 |
+
};
|
web/src/hooks/knowledgeHook.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import
|
2 |
import { IKnowledge } from '@/interfaces/database/knowledge';
|
3 |
import { useCallback, useEffect, useMemo } from 'react';
|
4 |
import { useDispatch, useSearchParams, useSelector } from 'umi';
|
@@ -17,6 +17,7 @@ export const useDeleteDocumentById = (): {
|
|
17 |
} => {
|
18 |
const dispatch = useDispatch();
|
19 |
const knowledgeBaseId = useKnowledgeBaseId();
|
|
|
20 |
|
21 |
const removeDocument = (documentId: string) => () => {
|
22 |
return dispatch({
|
@@ -79,6 +80,7 @@ export const useDeleteChunkByIds = (): {
|
|
79 |
removeChunk: (chunkIds: string[], documentId: string) => Promise<number>;
|
80 |
} => {
|
81 |
const dispatch = useDispatch();
|
|
|
82 |
|
83 |
const removeChunk = useCallback(
|
84 |
(chunkIds: string[], documentId: string) => () => {
|
@@ -97,7 +99,7 @@ export const useDeleteChunkByIds = (): {
|
|
97 |
(chunkIds: string[], documentId: string): Promise<number> => {
|
98 |
return showDeleteConfirm({ onOk: removeChunk(chunkIds, documentId) });
|
99 |
},
|
100 |
-
[removeChunk],
|
101 |
);
|
102 |
|
103 |
return {
|
|
|
1 |
+
import { useShowDeleteConfirm } from '@/hooks/commonHooks';
|
2 |
import { IKnowledge } from '@/interfaces/database/knowledge';
|
3 |
import { useCallback, useEffect, useMemo } from 'react';
|
4 |
import { useDispatch, useSearchParams, useSelector } from 'umi';
|
|
|
17 |
} => {
|
18 |
const dispatch = useDispatch();
|
19 |
const knowledgeBaseId = useKnowledgeBaseId();
|
20 |
+
const showDeleteConfirm = useShowDeleteConfirm();
|
21 |
|
22 |
const removeDocument = (documentId: string) => () => {
|
23 |
return dispatch({
|
|
|
80 |
removeChunk: (chunkIds: string[], documentId: string) => Promise<number>;
|
81 |
} => {
|
82 |
const dispatch = useDispatch();
|
83 |
+
const showDeleteConfirm = useShowDeleteConfirm();
|
84 |
|
85 |
const removeChunk = useCallback(
|
86 |
(chunkIds: string[], documentId: string) => () => {
|
|
|
99 |
(chunkIds: string[], documentId: string): Promise<number> => {
|
100 |
return showDeleteConfirm({ onOk: removeChunk(chunkIds, documentId) });
|
101 |
},
|
102 |
+
[removeChunk, showDeleteConfirm],
|
103 |
);
|
104 |
|
105 |
return {
|
web/src/layouts/components/header/index.tsx
CHANGED
@@ -8,6 +8,7 @@ import styles from './index.less';
|
|
8 |
|
9 |
import { useNavigateWithFromState } from '@/hooks/routeHook';
|
10 |
import { useCallback, useMemo } from 'react';
|
|
|
11 |
import { useLocation } from 'umi';
|
12 |
|
13 |
const { Header } = Layout;
|
@@ -18,14 +19,15 @@ const RagHeader = () => {
|
|
18 |
} = theme.useToken();
|
19 |
const navigate = useNavigateWithFromState();
|
20 |
const { pathname } = useLocation();
|
|
|
21 |
|
22 |
const tagsData = useMemo(
|
23 |
() => [
|
24 |
-
{ path: '/knowledge', name: '
|
25 |
-
{ path: '/chat', name: '
|
26 |
// { path: '/file', name: 'File Management', icon: FileIcon },
|
27 |
],
|
28 |
-
[],
|
29 |
);
|
30 |
|
31 |
const currentPath = useMemo(() => {
|
|
|
8 |
|
9 |
import { useNavigateWithFromState } from '@/hooks/routeHook';
|
10 |
import { useCallback, useMemo } from 'react';
|
11 |
+
import { useTranslation } from 'react-i18next';
|
12 |
import { useLocation } from 'umi';
|
13 |
|
14 |
const { Header } = Layout;
|
|
|
19 |
} = theme.useToken();
|
20 |
const navigate = useNavigateWithFromState();
|
21 |
const { pathname } = useLocation();
|
22 |
+
const { t } = useTranslation('translation', { keyPrefix: 'header' });
|
23 |
|
24 |
const tagsData = useMemo(
|
25 |
() => [
|
26 |
+
{ path: '/knowledge', name: t('knowledgeBase'), icon: KnowledgeBaseIcon },
|
27 |
+
{ path: '/chat', name: t('chat'), icon: StarIon },
|
28 |
// { path: '/file', name: 'File Management', icon: FileIcon },
|
29 |
],
|
30 |
+
[t],
|
31 |
);
|
32 |
|
33 |
const currentPath = useMemo(() => {
|
web/src/locales/en.json
CHANGED
@@ -1,12 +1,41 @@
|
|
1 |
{
|
2 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
"header": {
|
|
|
|
|
4 |
"register": "Register",
|
5 |
"signin": "Sign in",
|
6 |
"home": "Home",
|
7 |
"setting": "用户设置",
|
8 |
"logout": "登出"
|
9 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
"footer": {
|
11 |
"detail": "All rights reserved @ React"
|
12 |
},
|
|
|
1 |
{
|
2 |
+
"common": {
|
3 |
+
"delete": "Delete",
|
4 |
+
"deleteModalTitle": "Are you sure delete this item?"
|
5 |
+
},
|
6 |
+
"login": {
|
7 |
+
"login": "Sign in",
|
8 |
+
"signUp": "Sign up",
|
9 |
+
"loginDescription": "We’re so excited to see you again!",
|
10 |
+
"registerDescription": "Glad to have you on board!",
|
11 |
+
"emailLabel": "Email",
|
12 |
+
"emailPlaceholder": "Please input email",
|
13 |
+
"passwordLabel": "Password",
|
14 |
+
"passwordPlaceholder": "Please input password",
|
15 |
+
"rememberMe": "Remember me",
|
16 |
+
"signInTip": "Don’t have an account?",
|
17 |
+
"signUpTip": "Already have an account?",
|
18 |
+
"nicknameLabel": "Nickname",
|
19 |
+
"nicknamePlaceholder": "Please input nickname",
|
20 |
+
"register": "Create an account",
|
21 |
+
"continue": "Continue"
|
22 |
+
},
|
23 |
"header": {
|
24 |
+
"knowledgeBase": "Knowledge Base",
|
25 |
+
"chat": "Chat",
|
26 |
"register": "Register",
|
27 |
"signin": "Sign in",
|
28 |
"home": "Home",
|
29 |
"setting": "用户设置",
|
30 |
"logout": "登出"
|
31 |
},
|
32 |
+
"knowledgeList": {
|
33 |
+
"welcome": "Welcome back",
|
34 |
+
"description": "Which database are we going to use today?",
|
35 |
+
"createKnowledgeBase": "Create knowledge base",
|
36 |
+
"name": "Name",
|
37 |
+
"namePlaceholder": "Please input name!"
|
38 |
+
},
|
39 |
"footer": {
|
40 |
"detail": "All rights reserved @ React"
|
41 |
},
|
web/src/pages/add-knowledge/components/knowledge-file/model.ts
CHANGED
@@ -203,7 +203,6 @@ const model: DvaModel<KFModelState> = {
|
|
203 |
const documentId = payload;
|
204 |
try {
|
205 |
const ret = yield call(getDocumentFile, documentId);
|
206 |
-
console.info('fetch_document_file:', ret);
|
207 |
return ret;
|
208 |
} catch (error) {
|
209 |
console.warn(error);
|
@@ -238,7 +237,6 @@ const model: DvaModel<KFModelState> = {
|
|
238 |
payload: { current: 1, pageSize: 10 },
|
239 |
});
|
240 |
}
|
241 |
-
console.info(location);
|
242 |
});
|
243 |
},
|
244 |
},
|
|
|
203 |
const documentId = payload;
|
204 |
try {
|
205 |
const ret = yield call(getDocumentFile, documentId);
|
|
|
206 |
return ret;
|
207 |
} catch (error) {
|
208 |
console.warn(error);
|
|
|
237 |
payload: { current: 1, pageSize: 10 },
|
238 |
});
|
239 |
}
|
|
|
240 |
});
|
241 |
},
|
242 |
},
|
web/src/pages/add-knowledge/components/knowledge-file/parsing-action-cell/index.tsx
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import
|
2 |
import { useRemoveDocument } from '@/hooks/documentHooks';
|
3 |
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
4 |
import { api_host } from '@/utils/api';
|
@@ -31,6 +31,7 @@ const ParsingActionCell = ({
|
|
31 |
const isRunning = isParserRunning(record.run);
|
32 |
|
33 |
const removeDocument = useRemoveDocument(documentId);
|
|
|
34 |
|
35 |
const onRmDocument = () => {
|
36 |
if (!isRunning) {
|
|
|
1 |
+
import { useShowDeleteConfirm } from '@/hooks/commonHooks';
|
2 |
import { useRemoveDocument } from '@/hooks/documentHooks';
|
3 |
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
4 |
import { api_host } from '@/utils/api';
|
|
|
31 |
const isRunning = isParserRunning(record.run);
|
32 |
|
33 |
const removeDocument = useRemoveDocument(documentId);
|
34 |
+
const showDeleteConfirm = useShowDeleteConfirm();
|
35 |
|
36 |
const onRmDocument = () => {
|
37 |
if (!isRunning) {
|
web/src/pages/chat/hooks.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
-
import showDeleteConfirm from '@/components/deleting-confirm';
|
2 |
import { MessageType } from '@/constants/chat';
|
3 |
import { fileIconMap } from '@/constants/common';
|
4 |
-
import { useSetModalState } from '@/hooks/commonHooks';
|
5 |
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
6 |
import { IConversation, IDialog } from '@/interfaces/database/chat';
|
7 |
import { IChunk } from '@/interfaces/database/knowledge';
|
@@ -150,6 +149,7 @@ export const useSelectPromptConfigParameters = (): VariableTableDataType[] => {
|
|
150 |
|
151 |
export const useRemoveDialog = () => {
|
152 |
const dispatch = useDispatch();
|
|
|
153 |
|
154 |
const removeDocument = (dialogIds: Array<string>) => () => {
|
155 |
return dispatch({
|
@@ -668,6 +668,7 @@ export const useRemoveConversation = () => {
|
|
668 |
const dispatch = useDispatch();
|
669 |
const { dialogId } = useGetChatSearchParams();
|
670 |
const { handleClickConversation } = useClickConversationCard();
|
|
|
671 |
|
672 |
const removeConversation = (conversationIds: Array<string>) => async () => {
|
673 |
const ret = await dispatch<any>({
|
|
|
|
|
1 |
import { MessageType } from '@/constants/chat';
|
2 |
import { fileIconMap } from '@/constants/common';
|
3 |
+
import { useSetModalState, useShowDeleteConfirm } from '@/hooks/commonHooks';
|
4 |
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
5 |
import { IConversation, IDialog } from '@/interfaces/database/chat';
|
6 |
import { IChunk } from '@/interfaces/database/knowledge';
|
|
|
149 |
|
150 |
export const useRemoveDialog = () => {
|
151 |
const dispatch = useDispatch();
|
152 |
+
const showDeleteConfirm = useShowDeleteConfirm();
|
153 |
|
154 |
const removeDocument = (dialogIds: Array<string>) => () => {
|
155 |
return dispatch({
|
|
|
668 |
const dispatch = useDispatch();
|
669 |
const { dialogId } = useGetChatSearchParams();
|
670 |
const { handleClickConversation } = useClickConversationCard();
|
671 |
+
const showDeleteConfirm = useShowDeleteConfirm();
|
672 |
|
673 |
const removeConversation = (conversationIds: Array<string>) => async () => {
|
674 |
const ret = await dispatch<any>({
|
web/src/pages/knowledge/index.less
CHANGED
@@ -44,4 +44,7 @@
|
|
44 |
.knowledgeCardContainer {
|
45 |
padding: 0 60px;
|
46 |
overflow: auto;
|
|
|
|
|
|
|
47 |
}
|
|
|
44 |
.knowledgeCardContainer {
|
45 |
padding: 0 60px;
|
46 |
overflow: auto;
|
47 |
+
.knowledgeEmpty {
|
48 |
+
width: 100%;
|
49 |
+
}
|
50 |
}
|
web/src/pages/knowledge/index.tsx
CHANGED
@@ -6,22 +6,22 @@ import { Button, Empty, Flex, Space, Spin } from 'antd';
|
|
6 |
import KnowledgeCard from './knowledge-card';
|
7 |
import KnowledgeCreatingModal from './knowledge-creating-modal';
|
8 |
|
|
|
9 |
import styles from './index.less';
|
10 |
|
11 |
const Knowledge = () => {
|
12 |
const { list, loading } = useFetchKnowledgeList();
|
13 |
const userInfo = useSelectUserInfo();
|
|
|
14 |
|
15 |
return (
|
16 |
<Flex className={styles.knowledge} vertical flex={1}>
|
17 |
<div className={styles.topWrapper}>
|
18 |
<div>
|
19 |
<span className={styles.title}>
|
20 |
-
|
21 |
</span>
|
22 |
-
<p className={styles.description}>
|
23 |
-
Which database are we going to use today?
|
24 |
-
</p>
|
25 |
</div>
|
26 |
<Space size={'large'}>
|
27 |
{/* <Button icon={<FilterIcon />} className={styles.filterButton}>
|
@@ -38,7 +38,7 @@ const Knowledge = () => {
|
|
38 |
}}
|
39 |
className={styles.topButton}
|
40 |
>
|
41 |
-
|
42 |
</Button>
|
43 |
<KnowledgeCreatingModal
|
44 |
visible={visible}
|
@@ -62,7 +62,7 @@ const Knowledge = () => {
|
|
62 |
);
|
63 |
})
|
64 |
) : (
|
65 |
-
<Empty></Empty>
|
66 |
)}
|
67 |
</Flex>
|
68 |
</Spin>
|
|
|
6 |
import KnowledgeCard from './knowledge-card';
|
7 |
import KnowledgeCreatingModal from './knowledge-creating-modal';
|
8 |
|
9 |
+
import { useTranslation } from 'react-i18next';
|
10 |
import styles from './index.less';
|
11 |
|
12 |
const Knowledge = () => {
|
13 |
const { list, loading } = useFetchKnowledgeList();
|
14 |
const userInfo = useSelectUserInfo();
|
15 |
+
const { t } = useTranslation('translation', { keyPrefix: 'knowledgeList' });
|
16 |
|
17 |
return (
|
18 |
<Flex className={styles.knowledge} vertical flex={1}>
|
19 |
<div className={styles.topWrapper}>
|
20 |
<div>
|
21 |
<span className={styles.title}>
|
22 |
+
{t('welcome')}, {userInfo.nickname}
|
23 |
</span>
|
24 |
+
<p className={styles.description}>{t('description')}</p>
|
|
|
|
|
25 |
</div>
|
26 |
<Space size={'large'}>
|
27 |
{/* <Button icon={<FilterIcon />} className={styles.filterButton}>
|
|
|
38 |
}}
|
39 |
className={styles.topButton}
|
40 |
>
|
41 |
+
{t('createKnowledgeBase')}
|
42 |
</Button>
|
43 |
<KnowledgeCreatingModal
|
44 |
visible={visible}
|
|
|
62 |
);
|
63 |
})
|
64 |
) : (
|
65 |
+
<Empty className={styles.knowledgeEmpty}></Empty>
|
66 |
)}
|
67 |
</Flex>
|
68 |
</Spin>
|
web/src/pages/knowledge/knowledge-card/index.tsx
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import { ReactComponent as MoreIcon } from '@/assets/svg/more.svg';
|
2 |
import { KnowledgeRouteKey } from '@/constants/knowledge';
|
|
|
3 |
import { IKnowledge } from '@/interfaces/database/knowledge';
|
4 |
import { formatDate } from '@/utils/date';
|
5 |
import {
|
@@ -11,7 +12,6 @@ import {
|
|
11 |
import { Avatar, Card, Dropdown, MenuProps, Space } from 'antd';
|
12 |
import { useDispatch, useNavigate } from 'umi';
|
13 |
|
14 |
-
import showDeleteConfirm from '@/components/deleting-confirm';
|
15 |
import styles from './index.less';
|
16 |
|
17 |
interface IProps {
|
@@ -21,6 +21,7 @@ interface IProps {
|
|
21 |
const KnowledgeCard = ({ item }: IProps) => {
|
22 |
const navigate = useNavigate();
|
23 |
const dispatch = useDispatch();
|
|
|
24 |
|
25 |
const removeKnowledge = () => {
|
26 |
return dispatch({
|
|
|
1 |
import { ReactComponent as MoreIcon } from '@/assets/svg/more.svg';
|
2 |
import { KnowledgeRouteKey } from '@/constants/knowledge';
|
3 |
+
import { useShowDeleteConfirm } from '@/hooks/commonHooks';
|
4 |
import { IKnowledge } from '@/interfaces/database/knowledge';
|
5 |
import { formatDate } from '@/utils/date';
|
6 |
import {
|
|
|
12 |
import { Avatar, Card, Dropdown, MenuProps, Space } from 'antd';
|
13 |
import { useDispatch, useNavigate } from 'umi';
|
14 |
|
|
|
15 |
import styles from './index.less';
|
16 |
|
17 |
interface IProps {
|
|
|
21 |
const KnowledgeCard = ({ item }: IProps) => {
|
22 |
const navigate = useNavigate();
|
23 |
const dispatch = useDispatch();
|
24 |
+
const showDeleteConfirm = useShowDeleteConfirm();
|
25 |
|
26 |
const removeKnowledge = () => {
|
27 |
return dispatch({
|
web/src/pages/knowledge/knowledge-creating-modal/index.tsx
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
2 |
import { KnowledgeRouteKey } from '@/constants/knowledge';
|
3 |
import { Form, Input, Modal } from 'antd';
|
|
|
4 |
import { useDispatch, useNavigate, useSelector } from 'umi';
|
5 |
|
6 |
type FieldType = {
|
@@ -17,6 +18,7 @@ const KnowledgeCreatingModal = ({
|
|
17 |
(state: any) => state.loading.effects['kSModel/createKb'],
|
18 |
);
|
19 |
const navigate = useNavigate();
|
|
|
20 |
|
21 |
const handleOk = async () => {
|
22 |
const ret = await form.validateFields();
|
@@ -50,7 +52,7 @@ const KnowledgeCreatingModal = ({
|
|
50 |
|
51 |
return (
|
52 |
<Modal
|
53 |
-
title=
|
54 |
open={visible}
|
55 |
onOk={handleOk}
|
56 |
onCancel={handleCancel}
|
@@ -67,11 +69,11 @@ const KnowledgeCreatingModal = ({
|
|
67 |
form={form}
|
68 |
>
|
69 |
<Form.Item<FieldType>
|
70 |
-
label=
|
71 |
name="name"
|
72 |
-
rules={[{ required: true, message: '
|
73 |
>
|
74 |
-
<Input />
|
75 |
</Form.Item>
|
76 |
</Form>
|
77 |
</Modal>
|
|
|
1 |
import { IModalManagerChildrenProps } from '@/components/modal-manager';
|
2 |
import { KnowledgeRouteKey } from '@/constants/knowledge';
|
3 |
import { Form, Input, Modal } from 'antd';
|
4 |
+
import { useTranslation } from 'react-i18next';
|
5 |
import { useDispatch, useNavigate, useSelector } from 'umi';
|
6 |
|
7 |
type FieldType = {
|
|
|
18 |
(state: any) => state.loading.effects['kSModel/createKb'],
|
19 |
);
|
20 |
const navigate = useNavigate();
|
21 |
+
const { t } = useTranslation('translation', { keyPrefix: 'knowledgeList' });
|
22 |
|
23 |
const handleOk = async () => {
|
24 |
const ret = await form.validateFields();
|
|
|
52 |
|
53 |
return (
|
54 |
<Modal
|
55 |
+
title={t('createKnowledgeBase')}
|
56 |
open={visible}
|
57 |
onOk={handleOk}
|
58 |
onCancel={handleCancel}
|
|
|
69 |
form={form}
|
70 |
>
|
71 |
<Form.Item<FieldType>
|
72 |
+
label={t('name')}
|
73 |
name="name"
|
74 |
+
rules={[{ required: true, message: t('namePlaceholder') }]}
|
75 |
>
|
76 |
+
<Input placeholder={t('namePlaceholder')} />
|
77 |
</Form.Item>
|
78 |
</Form>
|
79 |
</Modal>
|
web/src/pages/login/index.tsx
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
2 |
import { rsaPsw } from '@/utils';
|
3 |
import { Button, Checkbox, Form, Input } from 'antd';
|
@@ -6,7 +7,6 @@ import { useTranslation } from 'react-i18next';
|
|
6 |
import { Icon, useNavigate } from 'umi';
|
7 |
import RightPanel from './right-panel';
|
8 |
|
9 |
-
import { useLogin, useRegister } from '@/hooks/loginHooks';
|
10 |
import styles from './index.less';
|
11 |
|
12 |
const Login = () => {
|
@@ -14,7 +14,7 @@ const Login = () => {
|
|
14 |
const navigate = useNavigate();
|
15 |
const login = useLogin();
|
16 |
const register = useRegister();
|
17 |
-
const { t } = useTranslation();
|
18 |
|
19 |
// TODO: When the server address request is not accessible, the value of dva-loading always remains true.
|
20 |
|
@@ -75,13 +75,11 @@ const Login = () => {
|
|
75 |
<div className={styles.loginLeft}>
|
76 |
<div className={styles.leftContainer}>
|
77 |
<div className={styles.loginTitle}>
|
78 |
-
<div>
|
79 |
-
{title === 'login' ? t('login.login') : 'Create an account'}
|
80 |
-
</div>
|
81 |
<span>
|
82 |
{title === 'login'
|
83 |
-
? '
|
84 |
-
: '
|
85 |
</span>
|
86 |
</div>
|
87 |
|
@@ -94,55 +92,52 @@ const Login = () => {
|
|
94 |
<Form.Item
|
95 |
{...formItemLayout}
|
96 |
name="email"
|
97 |
-
label=
|
98 |
-
rules={[{ required: true, message: '
|
99 |
>
|
100 |
-
<Input size="large" placeholder=
|
101 |
</Form.Item>
|
102 |
{title === 'register' && (
|
103 |
<Form.Item
|
104 |
{...formItemLayout}
|
105 |
name="nickname"
|
106 |
-
label=
|
107 |
-
rules={[
|
108 |
-
{ required: true, message: 'Please input your nickname' },
|
109 |
-
]}
|
110 |
>
|
111 |
-
<Input size="large" placeholder=
|
112 |
</Form.Item>
|
113 |
)}
|
114 |
<Form.Item
|
115 |
{...formItemLayout}
|
116 |
name="password"
|
117 |
-
label=
|
118 |
-
rules={[{ required: true, message: '
|
119 |
>
|
120 |
<Input.Password
|
121 |
size="large"
|
122 |
-
placeholder=
|
123 |
onPressEnter={onCheck}
|
124 |
/>
|
125 |
</Form.Item>
|
126 |
{title === 'login' && (
|
127 |
<Form.Item name="remember" valuePropName="checked">
|
128 |
-
<Checkbox>
|
129 |
</Form.Item>
|
130 |
)}
|
131 |
<div>
|
132 |
-
{' '}
|
133 |
{title === 'login' && (
|
134 |
<div>
|
135 |
-
|
136 |
<Button type="link" onClick={changeTitle}>
|
137 |
-
|
138 |
</Button>
|
139 |
</div>
|
140 |
)}
|
141 |
{title === 'register' && (
|
142 |
<div>
|
143 |
-
|
144 |
<Button type="link" onClick={changeTitle}>
|
145 |
-
|
146 |
</Button>
|
147 |
</div>
|
148 |
)}
|
@@ -154,7 +149,7 @@ const Login = () => {
|
|
154 |
onClick={onCheck}
|
155 |
loading={signLoading}
|
156 |
>
|
157 |
-
{title === 'login' ? '
|
158 |
</Button>
|
159 |
{title === 'login' && (
|
160 |
<>
|
|
|
1 |
+
import { useLogin, useRegister } from '@/hooks/loginHooks';
|
2 |
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
|
3 |
import { rsaPsw } from '@/utils';
|
4 |
import { Button, Checkbox, Form, Input } from 'antd';
|
|
|
7 |
import { Icon, useNavigate } from 'umi';
|
8 |
import RightPanel from './right-panel';
|
9 |
|
|
|
10 |
import styles from './index.less';
|
11 |
|
12 |
const Login = () => {
|
|
|
14 |
const navigate = useNavigate();
|
15 |
const login = useLogin();
|
16 |
const register = useRegister();
|
17 |
+
const { t } = useTranslation('translation', { keyPrefix: 'login' });
|
18 |
|
19 |
// TODO: When the server address request is not accessible, the value of dva-loading always remains true.
|
20 |
|
|
|
75 |
<div className={styles.loginLeft}>
|
76 |
<div className={styles.leftContainer}>
|
77 |
<div className={styles.loginTitle}>
|
78 |
+
<div>{title === 'login' ? t('login') : 'Create an account'}</div>
|
|
|
|
|
79 |
<span>
|
80 |
{title === 'login'
|
81 |
+
? t('loginDescription')
|
82 |
+
: t('registerDescription')}
|
83 |
</span>
|
84 |
</div>
|
85 |
|
|
|
92 |
<Form.Item
|
93 |
{...formItemLayout}
|
94 |
name="email"
|
95 |
+
label={t('emailLabel')}
|
96 |
+
rules={[{ required: true, message: t('emailPlaceholder') }]}
|
97 |
>
|
98 |
+
<Input size="large" placeholder={t('emailPlaceholder')} />
|
99 |
</Form.Item>
|
100 |
{title === 'register' && (
|
101 |
<Form.Item
|
102 |
{...formItemLayout}
|
103 |
name="nickname"
|
104 |
+
label={t('nicknameLabel')}
|
105 |
+
rules={[{ required: true, message: t('nicknamePlaceholder') }]}
|
|
|
|
|
106 |
>
|
107 |
+
<Input size="large" placeholder={t('nicknamePlaceholder')} />
|
108 |
</Form.Item>
|
109 |
)}
|
110 |
<Form.Item
|
111 |
{...formItemLayout}
|
112 |
name="password"
|
113 |
+
label={t('passwordLabel')}
|
114 |
+
rules={[{ required: true, message: t('passwordPlaceholder') }]}
|
115 |
>
|
116 |
<Input.Password
|
117 |
size="large"
|
118 |
+
placeholder={t('passwordPlaceholder')}
|
119 |
onPressEnter={onCheck}
|
120 |
/>
|
121 |
</Form.Item>
|
122 |
{title === 'login' && (
|
123 |
<Form.Item name="remember" valuePropName="checked">
|
124 |
+
<Checkbox> {t('rememberMe')}</Checkbox>
|
125 |
</Form.Item>
|
126 |
)}
|
127 |
<div>
|
|
|
128 |
{title === 'login' && (
|
129 |
<div>
|
130 |
+
{t('signInTip')}
|
131 |
<Button type="link" onClick={changeTitle}>
|
132 |
+
{t('signUp')}
|
133 |
</Button>
|
134 |
</div>
|
135 |
)}
|
136 |
{title === 'register' && (
|
137 |
<div>
|
138 |
+
{t('signUpTip')}
|
139 |
<Button type="link" onClick={changeTitle}>
|
140 |
+
{t('login')}
|
141 |
</Button>
|
142 |
</div>
|
143 |
)}
|
|
|
149 |
onClick={onCheck}
|
150 |
loading={signLoading}
|
151 |
>
|
152 |
+
{title === 'login' ? t('login') : t('continue')}
|
153 |
</Button>
|
154 |
{title === 'login' && (
|
155 |
<>
|