diff --git a/web/src/hooks/use-document-request.ts b/web/src/hooks/use-document-request.ts index 8a5a72e5d8..8a8a436351 100644 --- a/web/src/hooks/use-document-request.ts +++ b/web/src/hooks/use-document-request.ts @@ -1,5 +1,4 @@ import { useHandleFilterSubmit } from '@/components/list-filter-bar/use-handle-filter-submit'; -import { post } from '@/utils/next-request'; import message from '@/components/ui/message'; import { RunningStatus } from '@/constants/knowledge'; @@ -21,7 +20,7 @@ import kbService, { renameDocument, uploadDocument, } from '@/services/knowledge-service'; -import api, { restAPIv1, webAPI } from '@/utils/api'; +import { restAPIv1, webAPI } from '@/utils/api'; import { getSearchValue } from '@/utils/common-util'; import { buildChunkHighlights } from '@/utils/document-util'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; @@ -564,26 +563,3 @@ export const useFetchDocumentThumbnailsByIds = () => { return { data, setDocumentIds }; }; - -export const useParseDocument = () => { - const { - data, - isPending: loading, - mutateAsync, - } = useMutation({ - mutationKey: [DocumentApiAction.ParseDocument], - mutationFn: async (url: string) => { - try { - const { data } = await post(api.parse, { url }); - if (data?.code === 0) { - message.success(i18n.t('message.uploaded')); - } - return data; - } catch (error) { - message.error('error'); - } - }, - }); - - return { parseDocument: mutateAsync, data, loading }; -}; diff --git a/web/src/hooks/use-mcp-request.ts b/web/src/hooks/use-mcp-request.ts index 64c25e5d69..f76811802d 100644 --- a/web/src/hooks/use-mcp-request.ts +++ b/web/src/hooks/use-mcp-request.ts @@ -5,7 +5,6 @@ import { IMcpServer, IMcpServerListResponse, IMCPTool, - IMCPToolRecord, } from '@/interfaces/database/mcp'; import { IImportMcpServersRequestBody, @@ -17,7 +16,6 @@ import mcpServerService, { } from '@/services/mcp-server-service'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; import { useDebounce } from 'ahooks'; -import { useState } from 'react'; import { useGetPaginationWithRouter, useHandleSearchChange, @@ -33,7 +31,6 @@ export const enum McpApiAction { ExportMcpServer = 'exportMcpServer', ListMcpServerTools = 'listMcpServerTools', TestMcpServerTool = 'testMcpServerTool', - CacheMcpServerTool = 'cacheMcpServerTool', TestMcpServer = 'testMcpServer', } @@ -202,22 +199,6 @@ export const useExportMcpServer = () => { return { data, loading, exportMcpServer: mutateAsync }; }; -export const useListMcpServerTools = () => { - const [ids, setIds] = useState([]); - const { data, isFetching: loading } = useQuery({ - queryKey: [McpApiAction.ListMcpServerTools], - initialData: {} as IMCPToolRecord, - gcTime: 0, - enabled: ids.length > 0, - queryFn: async () => { - const { data } = await mcpServerService.listTools({ mcp_ids: ids }); - return data?.data ?? {}; - }, - }); - - return { data, loading, setIds }; -}; - export const useTestMcpServer = () => { const { data, @@ -234,37 +215,3 @@ export const useTestMcpServer = () => { return { data, loading, testMcpServer: mutateAsync }; }; - -export const useCacheMcpServerTool = () => { - const { - data, - isPending: loading, - mutateAsync, - } = useMutation({ - mutationKey: [McpApiAction.CacheMcpServerTool], - mutationFn: async (params: Record) => { - const { data = {} } = await mcpServerService.cacheTool(params); - - return data; - }, - }); - - return { data, loading, cacheMcpServerTool: mutateAsync }; -}; - -export const useTestMcpServerTool = () => { - const { - data, - isPending: loading, - mutateAsync, - } = useMutation({ - mutationKey: [McpApiAction.TestMcpServerTool], - mutationFn: async (params: Record) => { - const { data = {} } = await mcpServerService.testTool(params); - - return data; - }, - }); - - return { data, loading, testMcpServerTool: mutateAsync }; -}; diff --git a/web/src/pages/agent/debug-content/popover-form.tsx b/web/src/pages/agent/debug-content/popover-form.tsx deleted file mode 100644 index 7cd0b89098..0000000000 --- a/web/src/pages/agent/debug-content/popover-form.tsx +++ /dev/null @@ -1,103 +0,0 @@ -import { - Form, - FormControl, - FormField, - FormItem, - FormMessage, -} from '@/components/ui/form'; -import { Input } from '@/components/ui/input'; -import { Popover, PopoverContent } from '@/components/ui/popover'; -import { useParseDocument } from '@/hooks/use-document-request'; -import { IModalProps } from '@/interfaces/common'; -import { zodResolver } from '@hookform/resolvers/zod'; -import { PropsWithChildren } from 'react'; -import { useForm } from 'react-hook-form'; -import { useTranslation } from 'react-i18next'; -import { z } from 'zod'; - -const reg = - /^(((ht|f)tps?):\/\/)?([^!@#$%^&*?.\s-]([^!@#$%^&*?.\s]{0,63}[^!@#$%^&*?.\s])?\.)+[a-z]{2,6}\/?/; - -const FormSchema = z.object({ - url: z.string(), - result: z.any(), -}); - -const values = { - url: '', - result: null, -}; - -export const PopoverForm = ({ - children, - visible, - switchVisible, -}: PropsWithChildren>) => { - const form = useForm({ - defaultValues: values, - resolver: zodResolver(FormSchema), - }); - const { parseDocument } = useParseDocument(); - const { t } = useTranslation(); - - // useResetFormOnCloseModal({ - // form, - // visible, - // }); - - async function onSubmit(values: z.infer) { - const val = values.url; - - if (reg.test(val)) { - const ret = await parseDocument(val); - if (ret?.data?.code === 0) { - form.setValue('result', ret?.data?.data); - } - } - } - - const content = ( -
- - ( - - - e.preventDefault()} - placeholder={t('flow.pasteFileLink')} - // suffix={ - // - // } - /> - - - - )} - /> - <>} - /> - - - ); - - return ( - - {children} - {content} - - ); -}; diff --git a/web/src/pages/login-next/index.tsx b/web/src/pages/login-next/index.tsx index a74afab5d0..908451330e 100644 --- a/web/src/pages/login-next/index.tsx +++ b/web/src/pages/login-next/index.tsx @@ -26,7 +26,7 @@ import { import { Input } from '@/components/ui/input'; import { cn } from '@/lib/utils'; import { zodResolver } from '@hookform/resolvers/zod'; -import { useForm } from 'react-hook-form'; +import { useForm, UseFormReturn } from 'react-hook-form'; import { z } from 'zod'; import { BgSvg } from './bg'; import FlipCard3D, { FlipFaceContext } from './card'; @@ -35,7 +35,7 @@ import './index.less'; type LoginFormContentProps = { isLoginPage: boolean; title: string; - form: ReturnType; + form: UseFormReturn; loading: boolean; onCheck: (params: any) => Promise; changeTitle: () => void; @@ -61,7 +61,6 @@ function LoginFormContent({ }: LoginFormContentProps) { const face = useContext(FlipFaceContext); const isActiveFace = isLoginPage ? face === 'front' : face === 'back'; - const testId = (id: string) => `${title}-auth-${id}`; return (
@@ -75,7 +74,7 @@ function LoginFormContent({
@@ -87,7 +86,7 @@ function LoginFormContent({ {t('emailLabel')} {t('nicknameLabel')}
)} {t('signInTip')}