Fix: Login page type error. (#14156)

### What problem does this PR solve?

Fix: Login page type error.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu
2026-04-16 18:46:52 +08:00
committed by GitHub
parent 901023a80a
commit 4cf4d444d2
7 changed files with 14 additions and 215 deletions

View File

@@ -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 };
};

View File

@@ -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<string[]>([]);
const { data, isFetching: loading } = useQuery<IMCPToolRecord>({
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<string, any>) => {
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<string, any>) => {
const { data = {} } = await mcpServerService.testTool(params);
return data;
},
});
return { data, loading, testMcpServerTool: mutateAsync };
};

View File

@@ -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<IModalProps<any>>) => {
const form = useForm({
defaultValues: values,
resolver: zodResolver(FormSchema),
});
const { parseDocument } = useParseDocument();
const { t } = useTranslation();
// useResetFormOnCloseModal({
// form,
// visible,
// });
async function onSubmit(values: z.infer<typeof FormSchema>) {
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 = (
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)}>
<FormField
control={form.control}
name={`url`}
render={({ field }) => (
<FormItem className="flex-1">
<FormControl>
<Input
{...field}
// onPressEnter={(e) => e.preventDefault()}
placeholder={t('flow.pasteFileLink')}
// suffix={
// <Button
// type="primary"
// onClick={onOk}
// size={'small'}
// loading={loading}
// >
// {t('common.submit')}
// </Button>
// }
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name={`result`}
render={() => <></>}
/>
</form>
</Form>
);
return (
<Popover open={visible} onOpenChange={switchVisible}>
{children}
<PopoverContent>{content}</PopoverContent>
</Popover>
);
};

View File

@@ -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<typeof useForm>;
form: UseFormReturn<any>;
loading: boolean;
onCheck: (params: any) => Promise<void>;
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 (
<div className="flex flex-col items-center justify-center w-full">
@@ -75,7 +74,7 @@ function LoginFormContent({
<Form {...form}>
<form
className="flex flex-col gap-8 text-text-primary "
data-testid={testId('form')}
data-testid="auth-form"
data-active={isActiveFace ? 'true' : undefined}
onSubmit={form.handleSubmit(onCheck)}
>
@@ -87,7 +86,7 @@ function LoginFormContent({
<FormLabel required>{t('emailLabel')}</FormLabel>
<FormControl>
<Input
data-testid={testId('email')}
data-testid="auth-email"
placeholder={t('emailPlaceholder')}
autoComplete="email"
{...field}
@@ -106,7 +105,7 @@ function LoginFormContent({
<FormLabel required>{t('nicknameLabel')}</FormLabel>
<FormControl>
<Input
data-testid={testId('nickname')}
data-testid="auth-nickname"
placeholder={t('nicknamePlaceholder')}
autoComplete="username"
{...field}
@@ -127,7 +126,7 @@ function LoginFormContent({
<FormControl>
<div className="relative">
<Input
data-testid={testId('password')}
data-testid="auth-password"
type={'password'}
placeholder={t('passwordPlaceholder')}
autoComplete={
@@ -174,7 +173,7 @@ function LoginFormContent({
/>
)}
<ButtonLoading
data-testid={testId('submit')}
data-testid="auth-submit"
type="submit"
loading={loading}
className="bg-metallic-gradient border-b-[#00BEB4] border-b-2 hover:bg-metallic-gradient hover:border-b-[#02bcdd] w-full my-8"
@@ -214,7 +213,7 @@ function LoginFormContent({
<p className="text-text-disabled text-sm">
{t('signInTip')}
<Button
data-testid={testId('toggle-register')}
data-testid="auth-toggle-register"
variant={'transparent'}
onClick={changeTitle}
className="text-accent-primary/90 hover:text-accent-primary hover:bg-transparent font-medium border-none transition-colors duration-200"
@@ -229,7 +228,7 @@ function LoginFormContent({
<p className="text-text-disabled text-sm">
{t('signUpTip')}
<Button
data-testid={testId('toggle-login')}
data-testid="auth-toggle-login"
variant={'transparent'}
onClick={changeTitle}
className="text-accent-primary/90 hover:text-accent-primary hover:bg-transparent font-medium border-none transition-colors duration-200"
@@ -304,18 +303,18 @@ const Login = () => {
});
}
});
const form = useForm({
type FormValues = z.infer<typeof FormSchema>;
const form = useForm<FormValues>({
defaultValues: {
nickname: '',
email: '',
password: '',
confirmPassword: '',
remember: false,
},
resolver: zodResolver(FormSchema),
});
const onCheck = async (params: z.infer<typeof FormSchema>) => {
const onCheck = async (params: FormValues) => {
try {
const rsaPassWord = rsaPsw(params.password) as string;

View File

@@ -11,9 +11,6 @@ const {
getMcpServer,
importMcpServer,
exportMcpServer,
listMcpServerTools,
testMcpServerTool,
cacheMcpServerTool,
testMcpServer,
} = api;
@@ -46,18 +43,6 @@ const methods = {
url: exportMcpServer,
method: 'post',
},
listTools: {
url: listMcpServerTools,
method: 'post',
},
testTool: {
url: testMcpServerTool,
method: 'post',
},
cacheTool: {
url: cacheMcpServerTool,
method: 'post',
},
test: {
url: testMcpServer,
method: 'post',

View File

@@ -124,7 +124,6 @@ export default {
webCrawl: `${webAPI}/document/web_crawl`,
documentInfos: `${webAPI}/document/infos`,
uploadAndParse: `${webAPI}/document/upload_info`,
parse: `${webAPI}/document/parse`,
setMeta: `${webAPI}/document/set_meta`,
getDatasetFilter: `${webAPI}/document/filter`,
@@ -224,9 +223,6 @@ export default {
deleteMcpServer: `${webAPI}/mcp_server/rm`,
importMcpServer: `${webAPI}/mcp_server/import`,
exportMcpServer: `${webAPI}/mcp_server/export`,
listMcpServerTools: `${webAPI}/mcp_server/list_tools`,
testMcpServerTool: `${webAPI}/mcp_server/test_tool`,
cacheMcpServerTool: `${webAPI}/mcp_server/cache_tools`,
testMcpServer: `${webAPI}/mcp_server/test_mcp`,
// next-search

View File

@@ -28,8 +28,7 @@
"@parent/*": ["../src/*"]
},
"types": ["vite/client", "node", "@testing-library/jest-dom"],
"ignoreDeprecations": "6.0"
"types": ["vite/client", "node", "@testing-library/jest-dom"]
},
"include": ["src"],
"exclude": ["node_modules", "dist"],