Skip to content

Commit

Permalink
perf: ui
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu committed May 11, 2023
1 parent 451f234 commit 3e4b165
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 15 deletions.
3 changes: 3 additions & 0 deletions src/api/system.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { GET, POST, PUT } from './request';

export const getFilling = () => GET<{ beianText: string }>('/system/getFiling');
11 changes: 11 additions & 0 deletions src/pages/api/system/getFiling.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import type { NextApiRequest, NextApiResponse } from 'next';
import { jsonRes } from '@/service/response';

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
jsonRes(res, {
data: {
beianText: process.env.SAFE_BEIAN_TEXT || ''
}
});
}
11 changes: 8 additions & 3 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Card, Box, Link } from '@chakra-ui/react';
import Markdown from '@/components/Markdown';
import { useMarkdown } from '@/hooks/useMarkdown';
import { useRouter } from 'next/router';
import { getFilling } from '@/api/system';
import { useQuery } from '@tanstack/react-query';

const Home = () => {
const { inviterId } = useRouter().query as { inviterId: string };
Expand All @@ -14,18 +16,21 @@ const Home = () => {
}
}, [inviterId]);

const { data: { beianText = '' } = {} } = useQuery(['init'], getFilling);

return (
<Box p={[5, 10]}>
<Card p={5} lineHeight={2}>
<Markdown source={data} isChatting={false} />
</Card>

<Card p={5} mt={4} textAlign={'center'}>
<Box>
{beianText && (
<Link href="https://beian.miit.gov.cn/" target="_blank">
浙ICP备2023011255号-1
{beianText}
</Link>
</Box>
)}

<Box>Made by FastGpt Team.</Box>
</Card>
</Box>
Expand Down
6 changes: 3 additions & 3 deletions src/pages/login/components/ForgetPasswordForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
{!!errors.username && errors.username.message}
</FormErrorMessage>
</FormControl>
<FormControl mt={5} isInvalid={!!errors.username}>
<FormControl mt={8} isInvalid={!!errors.username}>
<Flex>
<Input
flex={1}
Expand All @@ -121,7 +121,7 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
{!!errors.code && errors.code.message}
</FormErrorMessage>
</FormControl>
<FormControl mt={5} isInvalid={!!errors.password}>
<FormControl mt={8} isInvalid={!!errors.password}>
<Input
type={'password'}
placeholder="新密码"
Expand All @@ -142,7 +142,7 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
{!!errors.password && errors.password.message}
</FormErrorMessage>
</FormControl>
<FormControl mt={5} isInvalid={!!errors.password2}>
<FormControl mt={8} isInvalid={!!errors.password2}>
<Input
type={'password'}
placeholder="确认密码"
Expand Down
6 changes: 3 additions & 3 deletions src/pages/login/components/RegisterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
{!!errors.username && errors.username.message}
</FormErrorMessage>
</FormControl>
<FormControl mt={5} isInvalid={!!errors.username}>
<FormControl mt={8} isInvalid={!!errors.username}>
<Flex>
<Input
flex={1}
Expand All @@ -129,7 +129,7 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
{!!errors.code && errors.code.message}
</FormErrorMessage>
</FormControl>
<FormControl mt={5} isInvalid={!!errors.password}>
<FormControl mt={8} isInvalid={!!errors.password}>
<Input
type={'password'}
placeholder="密码"
Expand All @@ -150,7 +150,7 @@ const RegisterForm = ({ setPageType, loginSuccess }: Props) => {
{!!errors.password && errors.password.message}
</FormErrorMessage>
</FormControl>
<FormControl mt={5} isInvalid={!!errors.password2}>
<FormControl mt={8} isInvalid={!!errors.password2}>
<Input
type={'password'}
placeholder="确认密码"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const Login = ({ isPcDevice }: { isPcDevice: boolean }) => {
height="100%"
w={'100%'}
maxW={'1240px'}
maxH={['auto', '660px']}
maxH={['auto', 'max(660px,80vh)']}
backgroundColor={'#fff'}
alignItems={'center'}
justifyContent={'center'}
Expand Down
21 changes: 16 additions & 5 deletions src/pages/model/components/detail/components/InputDataModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ const InputDataModal = ({
*/
const sureImportData = useCallback(
async (e: FormData) => {
if (e.a.length + e.q.length >= 3000) {
toast({
title: '总长度超长了',
status: 'warning'
});
return;
}
setImporting(true);

try {
Expand All @@ -66,7 +73,11 @@ const InputDataModal = ({
q: ''
});
onSuccess();
} catch (err) {
} catch (err: any) {
toast({
title: err?.message || '出现了点意外~',
status: 'error'
});
console.log(err);
}
setImporting(false);
Expand Down Expand Up @@ -121,8 +132,8 @@ const InputDataModal = ({
<Box flex={1} mr={[0, 4]} mb={[4, 0]} h={['230px', '100%']}>
<Box h={'30px'}>{'匹配的知识点'}</Box>
<Textarea
placeholder={'匹配的知识点。这部分内容会被搜索,请把控内容的质量。最多 1500 字。'}
maxLength={1500}
placeholder={'匹配的知识点。这部分内容会被搜索,请把控内容的质量。总和最多 3000 字。'}
maxLength={3000}
resize={'none'}
h={'calc(100% - 30px)'}
{...register(`q`, {
Expand All @@ -134,9 +145,9 @@ const InputDataModal = ({
<Box h={'30px'}>补充知识</Box>
<Textarea
placeholder={
'补充知识。这部分内容不会被搜索,但会作为"匹配的知识点"的内容补充,你可以讲一些细节的内容填写在这里。最多 1500 字。'
'补充知识。这部分内容不会被搜索,但会作为"匹配的知识点"的内容补充,你可以讲一些细节的内容填写在这里。总和最多 3000 字。'
}
maxLength={1500}
maxLength={3000}
resize={'none'}
h={'calc(100% - 30px)'}
{...register('a')}
Expand Down

0 comments on commit 3e4b165

Please sign in to comment.