perf: config home page

This commit is contained in:
archer
2023-09-01 10:13:57 +08:00
parent 2ae8d43216
commit 68cdf50cb6
15 changed files with 110 additions and 77 deletions

View File

@@ -167,20 +167,20 @@ const Navbar = ({ unread }: { unread: number }) => {
</Link>
</Box>
)}
<MyTooltip label={t('home.Docs')} placement={'right-end'}>
<Box
{...itemStyles}
mb={0}
color={'#9096a5'}
onClick={() => {
window.open(`https://doc.fastgpt.run/docs/intro`);
}}
>
<Badge count={unread}>
{feConfigs?.show_doc && (
<MyTooltip label={t('home.Docs')} placement={'right-end'}>
<Box
{...itemStyles}
mb={0}
color={'#9096a5'}
onClick={() => {
window.open(`https://doc.fastgpt.run/docs/intro`);
}}
>
<MyIcon name={'courseLight'} width={'26px'} height={'26px'} />
</Badge>
</Box>
</MyTooltip>
</Box>
</MyTooltip>
)}
<Language {...itemStyles} />
{feConfigs?.show_git && (
<MyTooltip label={`Git Star: ${gitStar}`} placement={'right-end'}>

View File

@@ -43,7 +43,7 @@ const OpenAIAccountModal = ({
<Input
flex={1}
{...register('baseUrl')}
placeholder={'中转地址,未自动补全 "v1"'}
placeholder={'请求地址,默认为 openai 官方。可填中转地址,未自动补全 "v1"'}
></Input>
</Flex>
</ModalBody>

View File

@@ -9,42 +9,47 @@ const Choice = () => {
const { t } = useTranslation();
const list = [
{
icon: '/imgs/home/icon_1.svg',
title: t('home.Choice Open'),
desc: t('home.Choice Open Desc', { title: feConfigs.systemTitle }),
tooltip: '前往 GitHub',
onClick: () => window.open('https://github.com/labring/FastGPT', '_blank')
},
...(feConfigs?.show_git
? [
{
icon: '/imgs/home/icon_1.svg',
title: t('home.Choice Open'),
desc: t('home.Choice Open Desc', { title: feConfigs?.systemTitle }),
tooltip: '前往 GitHub',
onClick: () => window.open('https://github.com/labring/FastGPT', '_blank')
}
]
: [
{
icon: '/imgs/home/icon_0.svg',
title: t('home.Choice Fast'),
desc: t('home.Choice Fast Desc', { title: feConfigs?.systemTitle })
}
]),
{
icon: '/imgs/home/icon_2.svg',
title: t('home.Choice QA'),
desc: t('home.Choice QA Desc'),
onClick: () => {}
desc: t('home.Choice QA Desc')
},
{
icon: '/imgs/home/icon_3.svg',
title: t('home.Choice Visual'),
desc: t('home.Choice Visual Desc'),
onClick: () => {}
desc: t('home.Choice Visual Desc')
},
{
icon: '/imgs/home/icon_4.svg',
title: t('home.Choice Extension'),
desc: t('home.Choice Extension Desc'),
onClick: () => {}
desc: t('home.Choice Extension Desc')
},
{
icon: '/imgs/home/icon_5.svg',
title: t('home.Choice Debug'),
desc: t('home.Choice Debug Desc'),
onClick: () => {}
desc: t('home.Choice Debug Desc')
},
{
icon: '/imgs/home/icon_6.svg',
title: t('home.Choice Models'),
desc: t('home.Choice Models Desc'),
onClick: () => {}
desc: t('home.Choice Models Desc')
}
];
@@ -57,7 +62,7 @@ const Choice = () => {
fontSize={['22px', '30px']}
fontWeight={'bold'}
>
{t('home.Why FastGPT', { title: feConfigs.systemTitle })}
{t('home.Why FastGPT', { title: feConfigs?.systemTitle })}
</Box>
<Grid px={[5, 0]} gridTemplateColumns={['1fr', `1fr 1fr`, 'repeat(3,1fr)']} gridGap={6}>
{list.map((item) => (
@@ -72,7 +77,7 @@ const Choice = () => {
_hover={{
bg: 'rgba(255,255,255,0.8)'
}}
onClick={item.onClick}
onClick={() => item.onClick?.()}
>
<Flex
flex={'0 0 48px'}

View File

@@ -19,26 +19,30 @@ const Navbar = () => {
} = useDisclosure();
const { isOpen: isOpenMenu, onOpen: onOpenMenu, onClose: onCloseMenu } = useDisclosure();
const { isPc } = useGlobalStore();
const menuList = useMemo(
() => [
// { label: t('home.Features'), key: 'features', onClick: () => {} },
{
label: t('home.Community'),
key: 'community',
onClick: () => {
onOpenCommunity();
}
},
{
label: t('home.Docs'),
key: 'docs',
onClick: () => {
window.open('https://doc.fastgpt.run/docs/intro');
}
}
],
[onOpenCommunity, t]
);
const menuList = [
...(feConfigs?.show_contact
? [
{
label: t('home.Community'),
key: 'community',
onClick: () => {
onOpenCommunity();
}
}
]
: []),
...(feConfigs?.show_doc
? [
{
label: t('home.Docs'),
key: 'docs',
onClick: () => {
window.open('https://doc.fastgpt.run/docs/intro');
}
}
]
: [])
];
const bgOpacity = useMemo(() => {
const rate = scrollTop / 120;
if (rate > 0.7) {

View File

@@ -1,16 +1,24 @@
import React, { useEffect } from 'react';
import React from 'react';
import { Box } from '@chakra-ui/react';
import { feConfigs } from '@/store/static';
import { serviceSideProps } from '@/utils/i18n';
import { useRouter } from 'next/router';
import Navbar from './components/Navbar';
import Hero from './components/Hero';
import Ability from './components/Ability';
import Choice from './components/Choice';
import Footer from './components/Footer';
import Loading from '@/components/Loading';
const Home = () => {
return (
const Home = ({ homeUrl = '/' }: { homeUrl: string }) => {
const router = useRouter();
if (homeUrl !== '/') {
router.replace(homeUrl);
}
return homeUrl === '/' ? (
<Box id="home" bg={'myWhite.600'} h={'100vh'} overflowY={'auto'} overflowX={'hidden'}>
<Box position={'fixed'} zIndex={10} top={0} left={0} right={0}>
<Navbar />
@@ -22,17 +30,22 @@ const Home = () => {
<Choice />
</Box>
</Box>
<Box bg={'white'}>
<Footer />
</Box>
{feConfigs?.show_git && (
<Box bg={'white'}>
<Footer />
</Box>
)}
</Box>
) : (
<Loading />
);
};
export async function getServerSideProps(content: any) {
return {
props: {
...(await serviceSideProps(content))
...(await serviceSideProps(content)),
homeUrl: process.env.HOME_URL || '/'
}
};
}

View File

@@ -99,7 +99,7 @@ const Login = () => {
>
<DynamicComponent type={pageType} />
{feConfigs?.show_loginTip && (
{feConfigs?.show_contact && (
<Box
fontSize={'sm'}
color={'myGray.600'}

View File

@@ -34,11 +34,15 @@ const Tools = () => {
}
]
: []),
{
icon: 'courseLight',
label: '使用文档',
link: 'https://doc.fastgpt.run/docs/intro'
}
...(feConfigs?.show_doc
? [
{
icon: 'courseLight',
label: '使用文档',
link: 'https://doc.fastgpt.run/docs/intro'
}
]
: [])
];
return (

View File

@@ -124,7 +124,7 @@ export const dispatchChatCompletion = async (props: Record<string, any>): Promis
stream
},
{
timeout: stream ? 60000 : 480000,
timeout: stream ? 120000 : 480000,
responseType: stream ? 'stream' : 'json',
...axiosConfig(userOpenaiAccount)
}

View File

@@ -19,8 +19,9 @@ export type FeConfigsType = {
show_register?: boolean;
show_appStore?: boolean;
show_userDetail?: boolean;
show_loginTip?: boolean;
show_contact?: boolean;
show_git?: boolean;
show_doc?: boolean;
systemTitle?: string;
authorText?: string;
beianText?: string;