### What problem does this PR solve? fix: remove unused libraries #1306 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)tags/v0.9.0
| "lodash": "^4.17.21", | "lodash": "^4.17.21", | ||||
| "mammoth": "^1.7.2", | "mammoth": "^1.7.2", | ||||
| "rc-tween-one": "^3.0.6", | "rc-tween-one": "^3.0.6", | ||||
| "react-chat-elements": "^12.0.13", | |||||
| "react-copy-to-clipboard": "^5.1.0", | "react-copy-to-clipboard": "^5.1.0", | ||||
| "react-i18next": "^14.0.0", | "react-i18next": "^14.0.0", | ||||
| "react-infinite-scroll-component": "^6.1.0", | |||||
| "react-markdown": "^9.0.1", | "react-markdown": "^9.0.1", | ||||
| "react-pdf-highlighter": "^6.1.0", | "react-pdf-highlighter": "^6.1.0", | ||||
| "react-string-replace": "^1.1.1", | "react-string-replace": "^1.1.1", | ||||
| "node": ">=8.9.0" | "node": ">=8.9.0" | ||||
| } | } | ||||
| }, | }, | ||||
| "node_modules/loaders.css": { | |||||
| "version": "0.1.2", | |||||
| "resolved": "https://registry.npmmirror.com/loaders.css/-/loaders.css-0.1.2.tgz", | |||||
| "integrity": "sha512-Rhowlq24ey1VOeor+3wYOt9+MjaxBOJm1u4KlQgNC3+0xJ0LS4wq4iG57D/BPzvuD/7HHDGQOWJ+81oR2EI9bQ==" | |||||
| }, | |||||
| "node_modules/local-pkg": { | "node_modules/local-pkg": { | ||||
| "version": "0.4.3", | "version": "0.4.3", | ||||
| "resolved": "https://registry.npmmirror.com/local-pkg/-/local-pkg-0.4.3.tgz", | "resolved": "https://registry.npmmirror.com/local-pkg/-/local-pkg-0.4.3.tgz", | ||||
| "resolved": "https://registry.npmmirror.com/process-warning/-/process-warning-1.0.0.tgz", | "resolved": "https://registry.npmmirror.com/process-warning/-/process-warning-1.0.0.tgz", | ||||
| "integrity": "sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q==" | "integrity": "sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q==" | ||||
| }, | }, | ||||
| "node_modules/progressbar.js": { | |||||
| "version": "1.1.1", | |||||
| "resolved": "https://registry.npmmirror.com/progressbar.js/-/progressbar.js-1.1.1.tgz", | |||||
| "integrity": "sha512-FBsw3BKsUbb+hNeYfiP3xzvAAQrPi4DnGDw66bCmfuRCDLcslxyxv2GyYUdBSKFGSIBa73CUP5WMcl6F8AAXlw==", | |||||
| "dependencies": { | |||||
| "lodash.merge": "^4.6.2", | |||||
| "shifty": "^2.8.3" | |||||
| } | |||||
| }, | |||||
| "node_modules/prompts": { | "node_modules/prompts": { | ||||
| "version": "2.4.2", | "version": "2.4.2", | ||||
| "resolved": "https://registry.npmmirror.com/prompts/-/prompts-2.4.2.tgz", | "resolved": "https://registry.npmmirror.com/prompts/-/prompts-2.4.2.tgz", | ||||
| "node": ">=0.10.0" | "node": ">=0.10.0" | ||||
| } | } | ||||
| }, | }, | ||||
| "node_modules/react-chat-elements": { | |||||
| "version": "12.0.13", | |||||
| "resolved": "https://registry.npmmirror.com/react-chat-elements/-/react-chat-elements-12.0.13.tgz", | |||||
| "integrity": "sha512-Vu5x8kW4LPu8onKfz5vsuDwZsDhoQmTBHJdqKAhVsi42PCQ8KOfzHiDp0fPUJlinJZ/MTJTm69UAchpys4iSTQ==", | |||||
| "dependencies": { | |||||
| "classnames": "^2.2.5", | |||||
| "progressbar.js": "^1.1.0", | |||||
| "react-icons": "^4.3.1", | |||||
| "react-spinkit": "^3.0.0", | |||||
| "timeago.js": "^4.0.2" | |||||
| }, | |||||
| "peerDependencies": { | |||||
| "react": "^18.2.0", | |||||
| "react-dom": "18.2.0" | |||||
| } | |||||
| }, | |||||
| "node_modules/react-copy-to-clipboard": { | "node_modules/react-copy-to-clipboard": { | ||||
| "version": "5.1.0", | "version": "5.1.0", | ||||
| "resolved": "https://registry.npmmirror.com/react-copy-to-clipboard/-/react-copy-to-clipboard-5.1.0.tgz", | "resolved": "https://registry.npmmirror.com/react-copy-to-clipboard/-/react-copy-to-clipboard-5.1.0.tgz", | ||||
| } | } | ||||
| } | } | ||||
| }, | }, | ||||
| "node_modules/react-icons": { | |||||
| "version": "4.12.0", | |||||
| "resolved": "https://registry.npmmirror.com/react-icons/-/react-icons-4.12.0.tgz", | |||||
| "integrity": "sha512-IBaDuHiShdZqmfc/TwHu6+d6k2ltNCf3AszxNmjJc1KUfXdEeRJOKyNvLmAHaarhzGmTSVygNdyu8/opXv2gaw==", | |||||
| "peerDependencies": { | |||||
| "react": "*" | |||||
| } | |||||
| }, | |||||
| "node_modules/react-infinite-scroll-component": { | |||||
| "version": "6.1.0", | |||||
| "resolved": "https://registry.npmmirror.com/react-infinite-scroll-component/-/react-infinite-scroll-component-6.1.0.tgz", | |||||
| "integrity": "sha512-SQu5nCqy8DxQWpnUVLx7V7b7LcA37aM7tvoWjTLZp1dk6EJibM5/4EJKzOnl07/BsM1Y40sKLuqjCwwH/xV0TQ==", | |||||
| "dependencies": { | |||||
| "throttle-debounce": "^2.1.0" | |||||
| }, | |||||
| "peerDependencies": { | |||||
| "react": ">=16.0.0" | |||||
| } | |||||
| }, | |||||
| "node_modules/react-infinite-scroll-component/node_modules/throttle-debounce": { | |||||
| "version": "2.3.0", | |||||
| "resolved": "https://registry.npmmirror.com/throttle-debounce/-/throttle-debounce-2.3.0.tgz", | |||||
| "integrity": "sha512-H7oLPV0P7+jgvrk+6mwwwBDmxTaxnu9HMXmloNLXwnNO0ZxZ31Orah2n8lU1eMPvsaowP2CX+USCgyovXfdOFQ==", | |||||
| "engines": { | |||||
| "node": ">=8" | |||||
| } | |||||
| }, | |||||
| "node_modules/react-is": { | "node_modules/react-is": { | ||||
| "version": "18.2.0", | "version": "18.2.0", | ||||
| "resolved": "https://registry.npmmirror.com/react-is/-/react-is-18.2.0.tgz", | "resolved": "https://registry.npmmirror.com/react-is/-/react-is-18.2.0.tgz", | ||||
| "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" | "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" | ||||
| } | } | ||||
| }, | }, | ||||
| "node_modules/react-spinkit": { | |||||
| "version": "3.0.0", | |||||
| "resolved": "https://registry.npmmirror.com/react-spinkit/-/react-spinkit-3.0.0.tgz", | |||||
| "integrity": "sha512-RrfGRPjqxHQiy7quPqhjPynTu0zobgQaZu1QYBMpJJ6pCSRRRK16EZMaxdE6fLVYFRJWpX/eGATWLMoVFFT5uQ==", | |||||
| "dependencies": { | |||||
| "classnames": "^2.2.3", | |||||
| "loaders.css": "^0.1.2", | |||||
| "object-assign": "^4.1.0", | |||||
| "prop-types": "^15.5.8" | |||||
| } | |||||
| }, | |||||
| "node_modules/react-string-replace": { | "node_modules/react-string-replace": { | ||||
| "version": "1.1.1", | "version": "1.1.1", | ||||
| "resolved": "https://registry.npmmirror.com/react-string-replace/-/react-string-replace-1.1.1.tgz", | "resolved": "https://registry.npmmirror.com/react-string-replace/-/react-string-replace-1.1.1.tgz", | ||||
| "integrity": "sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==", | "integrity": "sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA==", | ||||
| "dev": true | "dev": true | ||||
| }, | }, | ||||
| "node_modules/shifty": { | |||||
| "version": "2.20.4", | |||||
| "resolved": "https://registry.npmmirror.com/shifty/-/shifty-2.20.4.tgz", | |||||
| "integrity": "sha512-4Y0qRkg8ME5XN8yGNAwmFOmsIURGFKT9UQfNL6DDJQErYtN5HsjyoBuJn41ZQfTkuu2rIbRMn9qazjKsDpO2TA==", | |||||
| "optionalDependencies": { | |||||
| "fsevents": "^2.3.2" | |||||
| } | |||||
| }, | |||||
| "node_modules/side-channel": { | "node_modules/side-channel": { | ||||
| "version": "1.0.4", | "version": "1.0.4", | ||||
| "resolved": "https://registry.npmmirror.com/side-channel/-/side-channel-1.0.4.tgz", | "resolved": "https://registry.npmmirror.com/side-channel/-/side-channel-1.0.4.tgz", | ||||
| "node": ">=12.22" | "node": ">=12.22" | ||||
| } | } | ||||
| }, | }, | ||||
| "node_modules/timeago.js": { | |||||
| "version": "4.0.2", | |||||
| "resolved": "https://registry.npmmirror.com/timeago.js/-/timeago.js-4.0.2.tgz", | |||||
| "integrity": "sha512-a7wPxPdVlQL7lqvitHGGRsofhdwtkoSXPGATFuSOA2i1ZNQEPLrGnj68vOp2sOJTCFAQVXPeNMX/GctBaO9L2w==" | |||||
| }, | |||||
| "node_modules/timers-browserify": { | "node_modules/timers-browserify": { | ||||
| "version": "2.0.12", | "version": "2.0.12", | ||||
| "resolved": "https://registry.npmmirror.com/timers-browserify/-/timers-browserify-2.0.12.tgz", | "resolved": "https://registry.npmmirror.com/timers-browserify/-/timers-browserify-2.0.12.tgz", |
| "lodash": "^4.17.21", | "lodash": "^4.17.21", | ||||
| "mammoth": "^1.7.2", | "mammoth": "^1.7.2", | ||||
| "rc-tween-one": "^3.0.6", | "rc-tween-one": "^3.0.6", | ||||
| "react-chat-elements": "^12.0.13", | |||||
| "react-copy-to-clipboard": "^5.1.0", | "react-copy-to-clipboard": "^5.1.0", | ||||
| "react-i18next": "^14.0.0", | "react-i18next": "^14.0.0", | ||||
| "react-infinite-scroll-component": "^6.1.0", | |||||
| "react-markdown": "^9.0.1", | "react-markdown": "^9.0.1", | ||||
| "react-pdf-highlighter": "^6.1.0", | "react-pdf-highlighter": "^6.1.0", | ||||
| "react-string-replace": "^1.1.1", | "react-string-replace": "^1.1.1", |
| IFileListRequestBody, | IFileListRequestBody, | ||||
| } from '@/interfaces/request/file-manager'; | } from '@/interfaces/request/file-manager'; | ||||
| import fileManagerService from '@/services/file-manager-service'; | import fileManagerService from '@/services/file-manager-service'; | ||||
| import { useQuery } from '@tanstack/react-query'; | |||||
| import { useMutation, useQuery } from '@tanstack/react-query'; | |||||
| import { PaginationProps, UploadFile } from 'antd'; | import { PaginationProps, UploadFile } from 'antd'; | ||||
| import React, { useCallback } from 'react'; | import React, { useCallback } from 'react'; | ||||
| import { useDispatch, useSearchParams, useSelector } from 'umi'; | import { useDispatch, useSearchParams, useSelector } from 'umi'; | ||||
| import { useGetNextPagination, useHandleSearchChange } from './logic-hooks'; | import { useGetNextPagination, useHandleSearchChange } from './logic-hooks'; | ||||
| import { useSetPaginationParams } from './route-hook'; | |||||
| export const useGetFolderId = () => { | export const useGetFolderId = () => { | ||||
| const [searchParams] = useSearchParams(); | const [searchParams] = useSearchParams(); | ||||
| const { data } = useQuery({ | const { data } = useQuery({ | ||||
| queryKey: [ | queryKey: [ | ||||
| 'fetchFileList', | 'fetchFileList', | ||||
| id, | |||||
| pagination.current, | |||||
| pagination.pageSize, | |||||
| searchString, | |||||
| // pagination.current, | |||||
| // id, | |||||
| // pagination.pageSize, | |||||
| // searchString, | |||||
| { | |||||
| id, | |||||
| searchString, | |||||
| ...pagination, | |||||
| }, | |||||
| ], | ], | ||||
| initialData: {}, | initialData: {}, | ||||
| queryFn: async () => { | |||||
| queryFn: async (params: any) => { | |||||
| console.info(params); | |||||
| const { data } = await fileManagerService.listFile({ | const { data } = await fileManagerService.listFile({ | ||||
| parent_id: id, | parent_id: id, | ||||
| keywords: searchString, | keywords: searchString, | ||||
| return removeFile; | return removeFile; | ||||
| }; | }; | ||||
| export const useDeleteFile = () => { | |||||
| const { setPaginationParams } = useSetPaginationParams(); | |||||
| const { | |||||
| data, | |||||
| isPending: loading, | |||||
| mutateAsync, | |||||
| } = useMutation({ | |||||
| mutationKey: ['deleteFile'], | |||||
| mutationFn: async (params: { fileIds: string[]; parentId: string }) => { | |||||
| const { data } = await fileManagerService.removeFile(params); | |||||
| if (data.retcode === 0) { | |||||
| setPaginationParams(1); | |||||
| } | |||||
| return data?.data ?? {}; | |||||
| }, | |||||
| }); | |||||
| return { data, loading, deleteFile: mutateAsync }; | |||||
| }; | |||||
| export const useRenameFile = () => { | export const useRenameFile = () => { | ||||
| const dispatch = useDispatch(); | const dispatch = useDispatch(); | ||||
| import { useSetModalState, useTranslate } from './common-hooks'; | import { useSetModalState, useTranslate } from './common-hooks'; | ||||
| import { useSetDocumentParser } from './document-hooks'; | import { useSetDocumentParser } from './document-hooks'; | ||||
| import { useFetchLlmList } from './llm-hooks'; | import { useFetchLlmList } from './llm-hooks'; | ||||
| import { useSetPaginationParams } from './route-hook'; | |||||
| import { useOneNamespaceEffectsLoading } from './store-hooks'; | import { useOneNamespaceEffectsLoading } from './store-hooks'; | ||||
| import { | import { | ||||
| useFetchTenantInfo, | useFetchTenantInfo, | ||||
| export const useGetNextPagination = () => { | export const useGetNextPagination = () => { | ||||
| const { t } = useTranslate('common'); | const { t } = useTranslate('common'); | ||||
| const [{ page, pageSize }, setPagination] = useState({ | |||||
| page: 1, | |||||
| pageSize: 10, | |||||
| }); | |||||
| const { | |||||
| setPaginationParams, | |||||
| page, | |||||
| size: pageSize, | |||||
| } = useSetPaginationParams(); | |||||
| const onPageChange: PaginationProps['onChange'] = useCallback( | const onPageChange: PaginationProps['onChange'] = useCallback( | ||||
| (pageNumber: number, pageSize: number) => { | (pageNumber: number, pageSize: number) => { | ||||
| setPagination({ page: pageNumber, pageSize }); | |||||
| setPaginationParams(pageNumber, pageSize); | |||||
| }, | }, | ||||
| [setPagination], | |||||
| [setPaginationParams], | |||||
| ); | ); | ||||
| const setCurrentPagination = useCallback( | const setCurrentPagination = useCallback( | ||||
| (pagination: { page: number; pageSize?: number }) => { | (pagination: { page: number; pageSize?: number }) => { | ||||
| setPagination((p) => ({ ...p, ...pagination })); | |||||
| setPaginationParams(pagination.page, pagination.pageSize); | |||||
| }, | }, | ||||
| [setPagination], | |||||
| [setPaginationParams], | |||||
| ); | ); | ||||
| const pagination: PaginationProps = useMemo(() => { | const pagination: PaginationProps = useMemo(() => { |
| navigate(`/knowledge/${KnowledgeRouteKey.Dataset}?id=${knowledgeId}`); | navigate(`/knowledge/${KnowledgeRouteKey.Dataset}?id=${knowledgeId}`); | ||||
| }, [knowledgeId, navigate]); | }, [knowledgeId, navigate]); | ||||
| }; | }; | ||||
| export const useGetPaginationParams = () => { | |||||
| const [currentQueryParameters] = useSearchParams(); | |||||
| return { | |||||
| page: currentQueryParameters.get('page') || 1, | |||||
| size: currentQueryParameters.get('size') || 10, | |||||
| }; | |||||
| }; | |||||
| export const useSetPaginationParams = () => { | |||||
| const [queryParameters, setSearchParams] = useSearchParams(); | |||||
| // const newQueryParameters: URLSearchParams = useMemo( | |||||
| // () => new URLSearchParams(queryParameters.toString()), | |||||
| // [queryParameters], | |||||
| // ); | |||||
| const setPaginationParams = useCallback( | |||||
| (page: number = 1, pageSize?: number) => { | |||||
| queryParameters.set('page', page.toString()); | |||||
| if (pageSize) { | |||||
| queryParameters.set('size', pageSize.toString()); | |||||
| } | |||||
| setSearchParams(queryParameters); | |||||
| }, | |||||
| [setSearchParams, queryParameters], | |||||
| ); | |||||
| return { | |||||
| setPaginationParams, | |||||
| page: Number(queryParameters.get('page')) || 1, | |||||
| size: Number(queryParameters.get('size')) || 10, | |||||
| }; | |||||
| }; |
| // RCE CSS | |||||
| import { MessageList } from 'react-chat-elements'; | |||||
| import 'react-chat-elements/dist/main.css'; | |||||
| const ChatBox = () => { | |||||
| return ( | |||||
| <div style={{ width: 600 }}> | |||||
| {/* <MessageBox | |||||
| position={'left'} | |||||
| type={'photo'} | |||||
| text={'react.svg'} | |||||
| data={{ | |||||
| uri: 'https://facebook.github.io/react/img/logo.svg', | |||||
| status: { | |||||
| click: false, | |||||
| loading: 0, | |||||
| }, | |||||
| }} | |||||
| /> */} | |||||
| <MessageList | |||||
| // referance={messageListReferance} | |||||
| className="message-list" | |||||
| lockable={true} | |||||
| toBottomHeight={'100%'} | |||||
| dataSource={[ | |||||
| { | |||||
| position: 'right', | |||||
| type: 'text', | |||||
| text: 'Lorem ipsum dolor sit amet', | |||||
| date: new Date(), | |||||
| }, | |||||
| { | |||||
| position: 'left', | |||||
| type: 'text', | |||||
| text: 'Lorem ipsum dolor sit amet', | |||||
| date: new Date(), | |||||
| }, | |||||
| ]} | |||||
| /> | |||||
| </div> | |||||
| ); | |||||
| }; | |||||
| export default ChatBox; |
| import { | import { | ||||
| useConnectToKnowledge, | useConnectToKnowledge, | ||||
| useCreateFolder, | useCreateFolder, | ||||
| useDeleteFile, | |||||
| useFetchFileList, | useFetchFileList, | ||||
| useFetchParentFolderList, | useFetchParentFolderList, | ||||
| useRemoveFile, | |||||
| useRenameFile, | useRenameFile, | ||||
| useSelectFileList, | useSelectFileList, | ||||
| useSelectParentFolderList, | useSelectParentFolderList, | ||||
| fileIds: string[], | fileIds: string[], | ||||
| setSelectedRowKeys: (keys: string[]) => void, | setSelectedRowKeys: (keys: string[]) => void, | ||||
| ) => { | ) => { | ||||
| const removeDocument = useRemoveFile(); | |||||
| const { deleteFile: removeDocument } = useDeleteFile(); | |||||
| const showDeleteConfirm = useShowDeleteConfirm(); | const showDeleteConfirm = useShowDeleteConfirm(); | ||||
| const parentId = useGetFolderId(); | const parentId = useGetFolderId(); | ||||
| const handleRemoveFile = () => { | const handleRemoveFile = () => { | ||||
| showDeleteConfirm({ | showDeleteConfirm({ | ||||
| onOk: async () => { | onOk: async () => { | ||||
| const retcode = await removeDocument(fileIds, parentId); | |||||
| const retcode = await removeDocument({ fileIds, parentId }); | |||||
| if (retcode === 0) { | if (retcode === 0) { | ||||
| setSelectedRowKeys([]); | setSelectedRowKeys([]); | ||||
| } | } |