balibabu
commited on
Commit
·
e08f767
1
Parent(s):
7fcb06c
fix: Set the default value of Self RAG to false #1220 (#1702)
Browse files### What problem does this PR solve?
fix: Set the default value of Self RAG to false #1220
fix: Change all tool file names to kebab format
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
- web/src/app.tsx +1 -1
- web/src/components/message-item/index.tsx +1 -1
- web/src/components/new-document-link.tsx +1 -1
- web/src/hooks/auth-hooks.ts +1 -1
- web/src/hooks/document-hooks.ts +1 -1
- web/src/hooks/llm-hooks.ts +1 -1
- web/src/hooks/logic-hooks.ts +1 -1
- web/src/hooks/login-hooks.ts +1 -1
- web/src/hooks/store-hooks.ts +1 -1
- web/src/pages/add-knowledge/components/knowledge-chunk/hooks.ts +1 -1
- web/src/pages/add-knowledge/components/knowledge-chunk/model.ts +1 -1
- web/src/pages/add-knowledge/components/knowledge-file/hooks.ts +1 -1
- web/src/pages/add-knowledge/components/knowledge-file/index.tsx +1 -1
- web/src/pages/add-knowledge/components/knowledge-file/parsing-action-cell/index.tsx +1 -1
- web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx +1 -1
- web/src/pages/add-knowledge/components/knowledge-setting/hooks.ts +1 -1
- web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx +1 -1
- web/src/pages/chat/chat-configuration-modal/index.tsx +1 -1
- web/src/pages/chat/markdown-content/index.tsx +1 -1
- web/src/pages/file-manager/action-cell/index.tsx +2 -2
- web/src/pages/file-manager/connect-to-knowledge-modal/index.tsx +1 -1
- web/src/pages/file-manager/index.tsx +2 -2
- web/src/pages/user-setting/setting-profile/index.tsx +1 -1
- web/src/pages/user-setting/setting-system/index.tsx +1 -1
- web/src/services/chat-service.ts +1 -1
- web/src/services/file-manager-service.ts +1 -1
- web/src/services/flow-service.ts +1 -1
- web/src/services/knowledge-service.ts +1 -1
- web/src/services/user-service.ts +1 -1
- web/src/utils/{authorizationUtil.ts → authorization-util.ts} +1 -1
- web/src/utils/{commonUtil.ts → common-util.ts} +0 -0
- web/src/utils/{documentUtils.ts → document-util.ts} +0 -0
- web/src/utils/{domUtils.ts → dom-util.ts} +0 -0
- web/src/utils/{fileUtil.ts → file-util.ts} +0 -0
- web/src/utils/hooks.ts +0 -14
- web/src/utils/{registerServer.ts → register-server.ts} +39 -39
- web/src/utils/request.ts +132 -130
- web/src/utils/{storeUtil.ts → store-util.ts} +0 -0
web/src/app.tsx
CHANGED
@@ -13,7 +13,7 @@ import weekOfYear from 'dayjs/plugin/weekOfYear';
|
|
13 |
import weekYear from 'dayjs/plugin/weekYear';
|
14 |
import weekday from 'dayjs/plugin/weekday';
|
15 |
import React, { ReactNode, useEffect, useState } from 'react';
|
16 |
-
import storage from './utils/
|
17 |
|
18 |
dayjs.extend(customParseFormat);
|
19 |
dayjs.extend(advancedFormat);
|
|
|
13 |
import weekYear from 'dayjs/plugin/weekYear';
|
14 |
import weekday from 'dayjs/plugin/weekday';
|
15 |
import React, { ReactNode, useEffect, useState } from 'react';
|
16 |
+
import storage from './utils/authorization-util';
|
17 |
|
18 |
dayjs.extend(customParseFormat);
|
19 |
dayjs.extend(advancedFormat);
|
web/src/components/message-item/index.tsx
CHANGED
@@ -8,7 +8,7 @@ import classNames from 'classnames';
|
|
8 |
import { useMemo } from 'react';
|
9 |
|
10 |
import MarkdownContent from '@/pages/chat/markdown-content';
|
11 |
-
import { getExtension } from '@/utils/
|
12 |
import { Avatar, Flex, List } from 'antd';
|
13 |
import NewDocumentLink from '../new-document-link';
|
14 |
import SvgIcon from '../svg-icon';
|
|
|
8 |
import { useMemo } from 'react';
|
9 |
|
10 |
import MarkdownContent from '@/pages/chat/markdown-content';
|
11 |
+
import { getExtension } from '@/utils/document-util';
|
12 |
import { Avatar, Flex, List } from 'antd';
|
13 |
import NewDocumentLink from '../new-document-link';
|
14 |
import SvgIcon from '../svg-icon';
|
web/src/components/new-document-link.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import {
|
2 |
getExtension,
|
3 |
isSupportedPreviewDocumentType,
|
4 |
-
} from '@/utils/
|
5 |
import React from 'react';
|
6 |
|
7 |
interface IProps extends React.PropsWithChildren {
|
|
|
1 |
import {
|
2 |
getExtension,
|
3 |
isSupportedPreviewDocumentType,
|
4 |
+
} from '@/utils/document-util';
|
5 |
import React from 'react';
|
6 |
|
7 |
interface IProps extends React.PropsWithChildren {
|
web/src/hooks/auth-hooks.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import authorizationUtil from '@/utils/
|
2 |
import { message } from 'antd';
|
3 |
import { useEffect, useMemo, useState } from 'react';
|
4 |
import { useNavigate, useSearchParams } from 'umi';
|
|
|
1 |
+
import authorizationUtil from '@/utils/authorization-util';
|
2 |
import { message } from 'antd';
|
3 |
import { useEffect, useMemo, useState } from 'react';
|
4 |
import { useNavigate, useSearchParams } from 'umi';
|
web/src/hooks/document-hooks.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import { IChunk, IKnowledgeFile } from '@/interfaces/database/knowledge';
|
2 |
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
3 |
import { api_host } from '@/utils/api';
|
4 |
-
import { buildChunkHighlights } from '@/utils/
|
5 |
import { UploadFile } from 'antd';
|
6 |
import { useCallback, useMemo, useState } from 'react';
|
7 |
import { IHighlight } from 'react-pdf-highlighter';
|
|
|
1 |
import { IChunk, IKnowledgeFile } from '@/interfaces/database/knowledge';
|
2 |
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
3 |
import { api_host } from '@/utils/api';
|
4 |
+
import { buildChunkHighlights } from '@/utils/document-util';
|
5 |
import { UploadFile } from 'antd';
|
6 |
import { useCallback, useMemo, useState } from 'react';
|
7 |
import { IHighlight } from 'react-pdf-highlighter';
|
web/src/hooks/llm-hooks.ts
CHANGED
@@ -8,7 +8,7 @@ import {
|
|
8 |
IAddLlmRequestBody,
|
9 |
IDeleteLlmRequestBody,
|
10 |
} from '@/interfaces/request/llm';
|
11 |
-
import { sortLLmFactoryListBySpecifiedOrder } from '@/utils/
|
12 |
import { useCallback, useEffect, useMemo } from 'react';
|
13 |
import { useDispatch, useSelector } from 'umi';
|
14 |
|
|
|
8 |
IAddLlmRequestBody,
|
9 |
IDeleteLlmRequestBody,
|
10 |
} from '@/interfaces/request/llm';
|
11 |
+
import { sortLLmFactoryListBySpecifiedOrder } from '@/utils/common-util';
|
12 |
import { useCallback, useEffect, useMemo } from 'react';
|
13 |
import { useDispatch, useSelector } from 'umi';
|
14 |
|
web/src/hooks/logic-hooks.ts
CHANGED
@@ -6,7 +6,7 @@ import { IAnswer } from '@/interfaces/database/chat';
|
|
6 |
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
7 |
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
8 |
import api from '@/utils/api';
|
9 |
-
import { getAuthorization } from '@/utils/
|
10 |
import { PaginationProps } from 'antd';
|
11 |
import axios from 'axios';
|
12 |
import { EventSourceParserStream } from 'eventsource-parser/stream';
|
|
|
6 |
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
7 |
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
8 |
import api from '@/utils/api';
|
9 |
+
import { getAuthorization } from '@/utils/authorization-util';
|
10 |
import { PaginationProps } from 'antd';
|
11 |
import axios from 'axios';
|
12 |
import { EventSourceParserStream } from 'eventsource-parser/stream';
|
web/src/hooks/login-hooks.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import { Authorization } from '@/constants/authorization';
|
2 |
import userService from '@/services/user-service';
|
3 |
-
import authorizationUtil from '@/utils/
|
4 |
import { useMutation } from '@tanstack/react-query';
|
5 |
import { message } from 'antd';
|
6 |
import { useTranslation } from 'react-i18next';
|
|
|
1 |
import { Authorization } from '@/constants/authorization';
|
2 |
import userService from '@/services/user-service';
|
3 |
+
import authorizationUtil from '@/utils/authorization-util';
|
4 |
import { useMutation } from '@tanstack/react-query';
|
5 |
import { message } from 'antd';
|
6 |
import { useTranslation } from 'react-i18next';
|
web/src/hooks/store-hooks.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import { getOneNamespaceEffectsLoading } from '@/utils/
|
2 |
import { useSelector } from 'umi';
|
3 |
|
4 |
// Get the loading status of given effects under a certain namespace
|
|
|
1 |
+
import { getOneNamespaceEffectsLoading } from '@/utils/store-util';
|
2 |
import { useSelector } from 'umi';
|
3 |
|
4 |
// Get the loading status of given effects under a certain namespace
|
web/src/pages/add-knowledge/components/knowledge-chunk/hooks.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import { useOneNamespaceEffectsLoading } from '@/hooks/store-hooks';
|
2 |
import { IChunk, IKnowledgeFile } from '@/interfaces/database/knowledge';
|
3 |
-
import { buildChunkHighlights } from '@/utils/
|
4 |
import { useCallback, useMemo, useState } from 'react';
|
5 |
import { IHighlight } from 'react-pdf-highlighter';
|
6 |
import { useSelector } from 'umi';
|
|
|
1 |
import { useOneNamespaceEffectsLoading } from '@/hooks/store-hooks';
|
2 |
import { IChunk, IKnowledgeFile } from '@/interfaces/database/knowledge';
|
3 |
+
import { buildChunkHighlights } from '@/utils/document-util';
|
4 |
import { useCallback, useMemo, useState } from 'react';
|
5 |
import { IHighlight } from 'react-pdf-highlighter';
|
6 |
import { useSelector } from 'umi';
|
web/src/pages/add-knowledge/components/knowledge-chunk/model.ts
CHANGED
@@ -3,7 +3,7 @@ import { IChunk, IKnowledgeFile } from '@/interfaces/database/knowledge';
|
|
3 |
import kbService from '@/services/knowledge-service';
|
4 |
import { message } from 'antd';
|
5 |
import { pick } from 'lodash';
|
6 |
-
// import { delay } from '@/utils/
|
7 |
import i18n from '@/locales/config';
|
8 |
import { DvaModel } from 'umi';
|
9 |
|
|
|
3 |
import kbService from '@/services/knowledge-service';
|
4 |
import { message } from 'antd';
|
5 |
import { pick } from 'lodash';
|
6 |
+
// import { delay } from '@/utils/store-util';
|
7 |
import i18n from '@/locales/config';
|
8 |
import { DvaModel } from 'umi';
|
9 |
|
web/src/pages/add-knowledge/components/knowledge-file/hooks.ts
CHANGED
@@ -14,7 +14,7 @@ import { useOneNamespaceEffectsLoading } from '@/hooks/store-hooks';
|
|
14 |
import { useFetchTenantInfo } from '@/hooks/user-setting-hooks';
|
15 |
import { Pagination } from '@/interfaces/common';
|
16 |
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
17 |
-
import { getUnSupportedFilesCount } from '@/utils/
|
18 |
import { PaginationProps, UploadFile } from 'antd';
|
19 |
import { useCallback, useEffect, useMemo, useState } from 'react';
|
20 |
import { useDispatch, useNavigate, useSelector } from 'umi';
|
|
|
14 |
import { useFetchTenantInfo } from '@/hooks/user-setting-hooks';
|
15 |
import { Pagination } from '@/interfaces/common';
|
16 |
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
|
17 |
+
import { getUnSupportedFilesCount } from '@/utils/document-util';
|
18 |
import { PaginationProps, UploadFile } from 'antd';
|
19 |
import { useCallback, useEffect, useMemo, useState } from 'react';
|
20 |
import { useDispatch, useNavigate, useSelector } from 'umi';
|
web/src/pages/add-knowledge/components/knowledge-file/index.tsx
CHANGED
@@ -7,7 +7,7 @@ import {
|
|
7 |
import { useSetSelectedRecord } from '@/hooks/logic-hooks';
|
8 |
import { useSelectParserList } from '@/hooks/user-setting-hooks';
|
9 |
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
10 |
-
import { getExtension } from '@/utils/
|
11 |
import { Divider, Flex, Switch, Table, Typography } from 'antd';
|
12 |
import type { ColumnsType } from 'antd/es/table';
|
13 |
import { useTranslation } from 'react-i18next';
|
|
|
7 |
import { useSetSelectedRecord } from '@/hooks/logic-hooks';
|
8 |
import { useSelectParserList } from '@/hooks/user-setting-hooks';
|
9 |
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
10 |
+
import { getExtension } from '@/utils/document-util';
|
11 |
import { Divider, Flex, Switch, Table, Typography } from 'antd';
|
12 |
import type { ColumnsType } from 'antd/es/table';
|
13 |
import { useTranslation } from 'react-i18next';
|
web/src/pages/add-knowledge/components/knowledge-file/parsing-action-cell/index.tsx
CHANGED
@@ -2,7 +2,7 @@ import { useShowDeleteConfirm, useTranslate } from '@/hooks/common-hooks';
|
|
2 |
import { useRemoveDocument } from '@/hooks/document-hooks';
|
3 |
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
4 |
import { api_host } from '@/utils/api';
|
5 |
-
import { downloadFile } from '@/utils/
|
6 |
import {
|
7 |
DeleteOutlined,
|
8 |
DownloadOutlined,
|
|
|
2 |
import { useRemoveDocument } from '@/hooks/document-hooks';
|
3 |
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
|
4 |
import { api_host } from '@/utils/api';
|
5 |
+
import { downloadFile } from '@/utils/file-util';
|
6 |
import {
|
7 |
DeleteOutlined,
|
8 |
DownloadOutlined,
|
web/src/pages/add-knowledge/components/knowledge-setting/configuration.tsx
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import { normFile } from '@/utils/
|
2 |
import { PlusOutlined } from '@ant-design/icons';
|
3 |
import { Button, Form, Input, Radio, Select, Space, Upload } from 'antd';
|
4 |
import {
|
|
|
1 |
+
import { normFile } from '@/utils/file-util';
|
2 |
import { PlusOutlined } from '@ant-design/icons';
|
3 |
import { Button, Form, Input, Radio, Select, Space, Upload } from 'antd';
|
4 |
import {
|
web/src/pages/add-knowledge/components/knowledge-setting/hooks.ts
CHANGED
@@ -11,7 +11,7 @@ import {
|
|
11 |
import {
|
12 |
getBase64FromUploadFileList,
|
13 |
getUploadFileListFromBase64,
|
14 |
-
} from '@/utils/
|
15 |
import { useIsFetching } from '@tanstack/react-query';
|
16 |
import { Form, UploadFile } from 'antd';
|
17 |
import { FormInstance } from 'antd/lib';
|
|
|
11 |
import {
|
12 |
getBase64FromUploadFileList,
|
13 |
getUploadFileListFromBase64,
|
14 |
+
} from '@/utils/file-util';
|
15 |
import { useIsFetching } from '@tanstack/react-query';
|
16 |
import { Form, UploadFile } from 'antd';
|
17 |
import { FormInstance } from 'antd/lib';
|
web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx
CHANGED
@@ -95,7 +95,7 @@ const AssistantSetting = ({ show }: ISegmentedContentProps) => {
|
|
95 |
valuePropName="checked"
|
96 |
name={['prompt_config', 'self_rag']}
|
97 |
tooltip={t('selfRagTip')}
|
98 |
-
initialValue={
|
99 |
>
|
100 |
<Switch />
|
101 |
</Form.Item>
|
|
|
95 |
valuePropName="checked"
|
96 |
name={['prompt_config', 'self_rag']}
|
97 |
tooltip={t('selfRagTip')}
|
98 |
+
initialValue={false}
|
99 |
>
|
100 |
<Switch />
|
101 |
</Form.Item>
|
web/src/pages/chat/chat-configuration-modal/index.tsx
CHANGED
@@ -19,7 +19,7 @@ import {
|
|
19 |
useFetchLlmModelOnVisible,
|
20 |
useFetchModelId,
|
21 |
} from '@/hooks/logic-hooks';
|
22 |
-
import { getBase64FromUploadFileList } from '@/utils/
|
23 |
import { removeUselessFieldsFromValues } from '@/utils/form';
|
24 |
import styles from './index.less';
|
25 |
|
|
|
19 |
useFetchLlmModelOnVisible,
|
20 |
useFetchModelId,
|
21 |
} from '@/hooks/logic-hooks';
|
22 |
+
import { getBase64FromUploadFileList } from '@/utils/file-util';
|
23 |
import { removeUselessFieldsFromValues } from '@/utils/form';
|
24 |
import styles from './index.less';
|
25 |
|
web/src/pages/chat/markdown-content/index.tsx
CHANGED
@@ -3,7 +3,7 @@ import SvgIcon from '@/components/svg-icon';
|
|
3 |
import { useSelectFileThumbnails } from '@/hooks/knowledge-hooks';
|
4 |
import { IReference } from '@/interfaces/database/chat';
|
5 |
import { IChunk } from '@/interfaces/database/knowledge';
|
6 |
-
import { getExtension } from '@/utils/
|
7 |
import { InfoCircleOutlined } from '@ant-design/icons';
|
8 |
import { Button, Flex, Popover, Space } from 'antd';
|
9 |
import DOMPurify from 'dompurify';
|
|
|
3 |
import { useSelectFileThumbnails } from '@/hooks/knowledge-hooks';
|
4 |
import { IReference } from '@/interfaces/database/chat';
|
5 |
import { IChunk } from '@/interfaces/database/knowledge';
|
6 |
+
import { getExtension } from '@/utils/document-util';
|
7 |
import { InfoCircleOutlined } from '@ant-design/icons';
|
8 |
import { Button, Flex, Popover, Space } from 'antd';
|
9 |
import DOMPurify from 'dompurify';
|
web/src/pages/file-manager/action-cell/index.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import { useTranslate } from '@/hooks/common-hooks';
|
2 |
import { IFile } from '@/interfaces/database/file-manager';
|
3 |
import { api_host } from '@/utils/api';
|
4 |
-
import { downloadFile } from '@/utils/
|
5 |
import {
|
6 |
DeleteOutlined,
|
7 |
DownloadOutlined,
|
@@ -16,7 +16,7 @@ import NewDocumentLink from '@/components/new-document-link';
|
|
16 |
import {
|
17 |
getExtension,
|
18 |
isSupportedPreviewDocumentType,
|
19 |
-
} from '@/utils/
|
20 |
import styles from './index.less';
|
21 |
|
22 |
interface IProps {
|
|
|
1 |
import { useTranslate } from '@/hooks/common-hooks';
|
2 |
import { IFile } from '@/interfaces/database/file-manager';
|
3 |
import { api_host } from '@/utils/api';
|
4 |
+
import { downloadFile } from '@/utils/file-util';
|
5 |
import {
|
6 |
DeleteOutlined,
|
7 |
DownloadOutlined,
|
|
|
16 |
import {
|
17 |
getExtension,
|
18 |
isSupportedPreviewDocumentType,
|
19 |
+
} from '@/utils/document-util';
|
20 |
import styles from './index.less';
|
21 |
|
22 |
interface IProps {
|
web/src/pages/file-manager/connect-to-knowledge-modal/index.tsx
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import { useTranslate } from '@/hooks/common-hooks';
|
2 |
import { useNextFetchKnowledgeList } from '@/hooks/knowledge-hooks';
|
3 |
import { IModalProps } from '@/interfaces/common';
|
4 |
-
import { filterOptionsByInput } from '@/utils/
|
5 |
import { Form, Modal, Select } from 'antd';
|
6 |
import { useEffect } from 'react';
|
7 |
|
|
|
1 |
import { useTranslate } from '@/hooks/common-hooks';
|
2 |
import { useNextFetchKnowledgeList } from '@/hooks/knowledge-hooks';
|
3 |
import { IModalProps } from '@/interfaces/common';
|
4 |
+
import { filterOptionsByInput } from '@/utils/common-util';
|
5 |
import { Form, Modal, Select } from 'antd';
|
6 |
import { useEffect } from 'react';
|
7 |
|
web/src/pages/file-manager/index.tsx
CHANGED
@@ -18,8 +18,8 @@ import FileUploadModal from '@/components/file-upload-modal';
|
|
18 |
import RenameModal from '@/components/rename-modal';
|
19 |
import SvgIcon from '@/components/svg-icon';
|
20 |
import { useTranslate } from '@/hooks/common-hooks';
|
21 |
-
import { formatNumberWithThousandsSeparator } from '@/utils/
|
22 |
-
import { getExtension } from '@/utils/
|
23 |
import ConnectToKnowledgeModal from './connect-to-knowledge-modal';
|
24 |
import FolderCreateModal from './folder-create-modal';
|
25 |
import styles from './index.less';
|
|
|
18 |
import RenameModal from '@/components/rename-modal';
|
19 |
import SvgIcon from '@/components/svg-icon';
|
20 |
import { useTranslate } from '@/hooks/common-hooks';
|
21 |
+
import { formatNumberWithThousandsSeparator } from '@/utils/common-util';
|
22 |
+
import { getExtension } from '@/utils/document-util';
|
23 |
import ConnectToKnowledgeModal from './connect-to-knowledge-modal';
|
24 |
import FolderCreateModal from './folder-create-modal';
|
25 |
import styles from './index.less';
|
web/src/pages/user-setting/setting-profile/index.tsx
CHANGED
@@ -7,7 +7,7 @@ import {
|
|
7 |
getBase64FromUploadFileList,
|
8 |
getUploadFileListFromBase64,
|
9 |
normFile,
|
10 |
-
} from '@/utils/
|
11 |
import { PlusOutlined } from '@ant-design/icons';
|
12 |
import {
|
13 |
Button,
|
|
|
7 |
getBase64FromUploadFileList,
|
8 |
getUploadFileListFromBase64,
|
9 |
normFile,
|
10 |
+
} from '@/utils/file-util';
|
11 |
import { PlusOutlined } from '@ant-design/icons';
|
12 |
import {
|
13 |
Button,
|
web/src/pages/user-setting/setting-system/index.tsx
CHANGED
@@ -7,7 +7,7 @@ import lowerCase from 'lodash/lowerCase';
|
|
7 |
import upperFirst from 'lodash/upperFirst';
|
8 |
import { useEffect } from 'react';
|
9 |
|
10 |
-
import { toFixed } from '@/utils/
|
11 |
import styles from './index.less';
|
12 |
|
13 |
const { Text } = Typography;
|
|
|
7 |
import upperFirst from 'lodash/upperFirst';
|
8 |
import { useEffect } from 'react';
|
9 |
|
10 |
+
import { toFixed } from '@/utils/common-util';
|
11 |
import styles from './index.less';
|
12 |
|
13 |
const { Text } = Typography;
|
web/src/services/chat-service.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import api from '@/utils/api';
|
2 |
-
import registerServer from '@/utils/
|
3 |
import request from '@/utils/request';
|
4 |
|
5 |
const {
|
|
|
1 |
import api from '@/utils/api';
|
2 |
+
import registerServer from '@/utils/register-server';
|
3 |
import request from '@/utils/request';
|
4 |
|
5 |
const {
|
web/src/services/file-manager-service.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import api from '@/utils/api';
|
2 |
-
import registerServer from '@/utils/
|
3 |
import request from '@/utils/request';
|
4 |
import pureRequest from 'axios';
|
5 |
|
|
|
1 |
import api from '@/utils/api';
|
2 |
+
import registerServer from '@/utils/register-server';
|
3 |
import request from '@/utils/request';
|
4 |
import pureRequest from 'axios';
|
5 |
|
web/src/services/flow-service.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import api from '@/utils/api';
|
2 |
-
import registerServer from '@/utils/
|
3 |
import request from '@/utils/request';
|
4 |
|
5 |
const {
|
|
|
1 |
import api from '@/utils/api';
|
2 |
+
import registerServer from '@/utils/register-server';
|
3 |
import request from '@/utils/request';
|
4 |
|
5 |
const {
|
web/src/services/knowledge-service.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import api from '@/utils/api';
|
2 |
-
import registerServer from '@/utils/
|
3 |
import request from '@/utils/request';
|
4 |
import pureRequest from 'umi-request';
|
5 |
|
|
|
1 |
import api from '@/utils/api';
|
2 |
+
import registerServer from '@/utils/register-server';
|
3 |
import request from '@/utils/request';
|
4 |
import pureRequest from 'umi-request';
|
5 |
|
web/src/services/user-service.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import api from '@/utils/api';
|
2 |
-
import registerServer from '@/utils/
|
3 |
import request from '@/utils/request';
|
4 |
|
5 |
const {
|
|
|
1 |
import api from '@/utils/api';
|
2 |
+
import registerServer from '@/utils/register-server';
|
3 |
import request from '@/utils/request';
|
4 |
|
5 |
const {
|
web/src/utils/{authorizationUtil.ts → authorization-util.ts}
RENAMED
@@ -1,5 +1,5 @@
|
|
1 |
import { Authorization, Token, UserInfo } from '@/constants/authorization';
|
2 |
-
import { getSearchValue } from './
|
3 |
const KeySet = [Authorization, Token, UserInfo];
|
4 |
|
5 |
const storage = {
|
|
|
1 |
import { Authorization, Token, UserInfo } from '@/constants/authorization';
|
2 |
+
import { getSearchValue } from './common-util';
|
3 |
const KeySet = [Authorization, Token, UserInfo];
|
4 |
|
5 |
const storage = {
|
web/src/utils/{commonUtil.ts → common-util.ts}
RENAMED
File without changes
|
web/src/utils/{documentUtils.ts → document-util.ts}
RENAMED
File without changes
|
web/src/utils/{domUtils.ts → dom-util.ts}
RENAMED
File without changes
|
web/src/utils/{fileUtil.ts → file-util.ts}
RENAMED
File without changes
|
web/src/utils/hooks.ts
DELETED
@@ -1,14 +0,0 @@
|
|
1 |
-
import { useState } from 'react';
|
2 |
-
|
3 |
-
export const usePagination = function (defaultPage: number, defaultPageSize: number, total: number) {
|
4 |
-
const [page = 1, setPage] = useState(defaultPage);
|
5 |
-
const [pageSize = 10, setPageSize] = useState(defaultPageSize);
|
6 |
-
return {
|
7 |
-
page,
|
8 |
-
pageSize,
|
9 |
-
count: total,
|
10 |
-
setPage,
|
11 |
-
setPageSize,
|
12 |
-
nextPage: () => setPage(page + 1)
|
13 |
-
};
|
14 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
web/src/utils/{registerServer.ts → register-server.ts}
RENAMED
@@ -1,39 +1,39 @@
|
|
1 |
-
import omit from 'lodash/omit';
|
2 |
-
import { RequestMethod } from 'umi-request';
|
3 |
-
|
4 |
-
type Service<T extends string> = Record<
|
5 |
-
T,
|
6 |
-
(params?: any, urlAppendix?: string) => any
|
7 |
-
>;
|
8 |
-
|
9 |
-
const registerServer = <T extends string>(
|
10 |
-
opt: Record<T, { url: string; method: string }>,
|
11 |
-
request: RequestMethod,
|
12 |
-
) => {
|
13 |
-
const server: Service<T> = {} as Service<T>;
|
14 |
-
for (let key in opt) {
|
15 |
-
server[key] = (params?: any, urlAppendix?: string) => {
|
16 |
-
let url = opt[key].url;
|
17 |
-
const requestOptions = opt[key];
|
18 |
-
if (urlAppendix) {
|
19 |
-
url = url + '/' + urlAppendix;
|
20 |
-
}
|
21 |
-
if (opt[key].method === 'post' || opt[key].method === 'POST') {
|
22 |
-
return request(url, {
|
23 |
-
method: opt[key].method,
|
24 |
-
data: params,
|
25 |
-
});
|
26 |
-
}
|
27 |
-
|
28 |
-
if (opt[key].method === 'get' || opt[key].method === 'GET') {
|
29 |
-
return request.get(url, {
|
30 |
-
...omit(requestOptions, ['method', 'url']),
|
31 |
-
params,
|
32 |
-
});
|
33 |
-
}
|
34 |
-
};
|
35 |
-
}
|
36 |
-
return server;
|
37 |
-
};
|
38 |
-
|
39 |
-
export default registerServer;
|
|
|
1 |
+
import omit from 'lodash/omit';
|
2 |
+
import { RequestMethod } from 'umi-request';
|
3 |
+
|
4 |
+
type Service<T extends string> = Record<
|
5 |
+
T,
|
6 |
+
(params?: any, urlAppendix?: string) => any
|
7 |
+
>;
|
8 |
+
|
9 |
+
const registerServer = <T extends string>(
|
10 |
+
opt: Record<T, { url: string; method: string }>,
|
11 |
+
request: RequestMethod,
|
12 |
+
) => {
|
13 |
+
const server: Service<T> = {} as Service<T>;
|
14 |
+
for (let key in opt) {
|
15 |
+
server[key] = (params?: any, urlAppendix?: string) => {
|
16 |
+
let url = opt[key].url;
|
17 |
+
const requestOptions = opt[key];
|
18 |
+
if (urlAppendix) {
|
19 |
+
url = url + '/' + urlAppendix;
|
20 |
+
}
|
21 |
+
if (opt[key].method === 'post' || opt[key].method === 'POST') {
|
22 |
+
return request(url, {
|
23 |
+
method: opt[key].method,
|
24 |
+
data: params,
|
25 |
+
});
|
26 |
+
}
|
27 |
+
|
28 |
+
if (opt[key].method === 'get' || opt[key].method === 'GET') {
|
29 |
+
return request.get(url, {
|
30 |
+
...omit(requestOptions, ['method', 'url']),
|
31 |
+
params,
|
32 |
+
});
|
33 |
+
}
|
34 |
+
};
|
35 |
+
}
|
36 |
+
return server;
|
37 |
+
};
|
38 |
+
|
39 |
+
export default registerServer;
|
web/src/utils/request.ts
CHANGED
@@ -1,130 +1,132 @@
|
|
1 |
-
import { Authorization } from '@/constants/authorization';
|
2 |
-
import { ResponseType } from '@/interfaces/database/base';
|
3 |
-
import i18n from '@/locales/config';
|
4 |
-
import authorizationUtil, {
|
5 |
-
|
6 |
-
|
7 |
-
import {
|
8 |
-
import {
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
const
|
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 |
-
const
|
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 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
return response;
|
127 |
-
}
|
128 |
-
|
129 |
-
|
130 |
-
|
|
|
|
|
|
1 |
+
import { Authorization } from '@/constants/authorization';
|
2 |
+
import { ResponseType } from '@/interfaces/database/base';
|
3 |
+
import i18n from '@/locales/config';
|
4 |
+
import authorizationUtil, {
|
5 |
+
getAuthorization,
|
6 |
+
} from '@/utils/authorization-util';
|
7 |
+
import { message, notification } from 'antd';
|
8 |
+
import { history } from 'umi';
|
9 |
+
import { RequestMethod, extend } from 'umi-request';
|
10 |
+
import { convertTheKeysOfTheObjectToSnake } from './common-util';
|
11 |
+
|
12 |
+
const ABORT_REQUEST_ERR_MESSAGE = 'The user aborted a request.';
|
13 |
+
|
14 |
+
const RetcodeMessage = {
|
15 |
+
200: i18n.t('message.200'),
|
16 |
+
201: i18n.t('message.201'),
|
17 |
+
202: i18n.t('message.202'),
|
18 |
+
204: i18n.t('message.204'),
|
19 |
+
400: i18n.t('message.400'),
|
20 |
+
401: i18n.t('message.401'),
|
21 |
+
403: i18n.t('message.403'),
|
22 |
+
404: i18n.t('message.404'),
|
23 |
+
406: i18n.t('message.406'),
|
24 |
+
410: i18n.t('message.410'),
|
25 |
+
422: i18n.t('message.422'),
|
26 |
+
500: i18n.t('message.500'),
|
27 |
+
502: i18n.t('message.502'),
|
28 |
+
503: i18n.t('message.503'),
|
29 |
+
504: i18n.t('message.504'),
|
30 |
+
};
|
31 |
+
type ResultCode =
|
32 |
+
| 200
|
33 |
+
| 201
|
34 |
+
| 202
|
35 |
+
| 204
|
36 |
+
| 400
|
37 |
+
| 401
|
38 |
+
| 403
|
39 |
+
| 404
|
40 |
+
| 406
|
41 |
+
| 410
|
42 |
+
| 422
|
43 |
+
| 500
|
44 |
+
| 502
|
45 |
+
| 503
|
46 |
+
| 504;
|
47 |
+
|
48 |
+
const errorHandler = (error: {
|
49 |
+
response: Response;
|
50 |
+
message: string;
|
51 |
+
}): Response => {
|
52 |
+
const { response } = error;
|
53 |
+
if (error.message === ABORT_REQUEST_ERR_MESSAGE) {
|
54 |
+
console.log('user abort request');
|
55 |
+
} else {
|
56 |
+
if (response && response.status) {
|
57 |
+
const errorText =
|
58 |
+
RetcodeMessage[response.status as ResultCode] || response.statusText;
|
59 |
+
const { status, url } = response;
|
60 |
+
notification.error({
|
61 |
+
message: `${i18n.t('message.requestError')} ${status}: ${url}`,
|
62 |
+
description: errorText,
|
63 |
+
});
|
64 |
+
} else if (!response) {
|
65 |
+
notification.error({
|
66 |
+
description: i18n.t('message.networkAnomalyDescription'),
|
67 |
+
message: i18n.t('message.networkAnomaly'),
|
68 |
+
});
|
69 |
+
}
|
70 |
+
}
|
71 |
+
return response;
|
72 |
+
};
|
73 |
+
|
74 |
+
const request: RequestMethod = extend({
|
75 |
+
errorHandler,
|
76 |
+
timeout: 300000,
|
77 |
+
getResponse: true,
|
78 |
+
});
|
79 |
+
|
80 |
+
request.interceptors.request.use((url: string, options: any) => {
|
81 |
+
const data = convertTheKeysOfTheObjectToSnake(options.data);
|
82 |
+
const params = convertTheKeysOfTheObjectToSnake(options.params);
|
83 |
+
|
84 |
+
return {
|
85 |
+
url,
|
86 |
+
options: {
|
87 |
+
...options,
|
88 |
+
data,
|
89 |
+
params,
|
90 |
+
headers: {
|
91 |
+
...(options.skipToken
|
92 |
+
? undefined
|
93 |
+
: { [Authorization]: getAuthorization() }),
|
94 |
+
...options.headers,
|
95 |
+
},
|
96 |
+
interceptors: true,
|
97 |
+
},
|
98 |
+
};
|
99 |
+
});
|
100 |
+
|
101 |
+
request.interceptors.response.use(async (response: any, options) => {
|
102 |
+
if (options.responseType === 'blob') {
|
103 |
+
return response;
|
104 |
+
}
|
105 |
+
const data: ResponseType = await response.clone().json();
|
106 |
+
|
107 |
+
if (data.retcode === 401 || data.retcode === 401) {
|
108 |
+
notification.error({
|
109 |
+
message: data.retmsg,
|
110 |
+
description: data.retmsg,
|
111 |
+
duration: 3,
|
112 |
+
});
|
113 |
+
authorizationUtil.removeAll();
|
114 |
+
history.push('/login'); // Will not jump to the login page
|
115 |
+
} else if (data.retcode !== 0) {
|
116 |
+
if (data.retcode === 100) {
|
117 |
+
message.error(data.retmsg);
|
118 |
+
} else {
|
119 |
+
notification.error({
|
120 |
+
message: `${i18n.t('message.hint')} : ${data.retcode}`,
|
121 |
+
description: data.retmsg,
|
122 |
+
duration: 3,
|
123 |
+
});
|
124 |
+
}
|
125 |
+
|
126 |
+
return response;
|
127 |
+
} else {
|
128 |
+
return response;
|
129 |
+
}
|
130 |
+
});
|
131 |
+
|
132 |
+
export default request;
|
web/src/utils/{storeUtil.ts → store-util.ts}
RENAMED
File without changes
|