g# This is a combination of 6 commits. (#675)

perf: node render

perf: react flow performance

config

perf: pg index

perf: oauth login

doc

doc
This commit is contained in:
Archer
2024-01-01 13:46:09 +08:00
committed by GitHub
parent 9ccfda47b7
commit d645a7406b
13 changed files with 31 additions and 678 deletions

View File

@@ -879,7 +879,8 @@
},
"login": {
"Github": "Github",
"Google": "Google"
"Google": "Google",
"Provider error": "Login exception, please try again"
}
}
},

View File

@@ -879,7 +879,8 @@
},
"login": {
"Github": "Github 登录",
"Google": "Google 登录"
"Google": "Google 登录",
"Provider error": "登录异常,请重试"
}
}
},

View File

@@ -1,102 +0,0 @@
import { Box, Image, BoxProps, Grid, useTheme } from '@chakra-ui/react';
import React from 'react';
import { useTranslation } from 'next-i18next';
import { feConfigs } from '@/web/common/system/staticData';
import { MyImage } from '@/components/MyImage';
const Ability = () => {
const theme = useTheme();
const { t } = useTranslation();
const CardStyles: BoxProps = {
pt: 4,
borderRadius: 'xl',
overflow: 'hidden',
border: theme.borders.base
};
const TitleStyles: BoxProps = {
px: 4,
fontSize: ['xl', '28px'],
fontWeight: 'bold'
};
const DescStyles: BoxProps = {
px: 4,
mt: 2,
mb: 5,
fontSize: ['sm', 'md'],
whiteSpace: 'pre-wrap'
};
return (
<Box>
<Box
className="textlg"
py={['30px', '60px']}
textAlign={'center'}
fontSize={['22px', '30px']}
fontWeight={'bold'}
>
{t('home.FastGPT Ability', { title: feConfigs.systemTitle })}
</Box>
<Grid px={[5, 0]} minH={'400px'} gridTemplateColumns={['1fr', `500px 1fr`]} gridGap={6}>
<Box
{...CardStyles}
backgroundImage={'linear-gradient(to bottom right, #00A9A6 0%, #33BABB 100%)'}
>
<Box {...TitleStyles} color={'white'}>
{t('home.AI Assistant')}
</Box>
<Box {...DescStyles} color={'rgba(255,255,255,0.9)'}>
{t('home.AI Assistant Desc')}
</Box>
<MyImage src="/imgs/home/ai_assiatant.png" alt={''} transform={'translateX(20px)'} />
</Box>
<Box
{...CardStyles}
pb={4}
backgroundImage={'linear-gradient(120deg, #3370ff 0%, #4e83fd 100%)'}
>
<Box {...TitleStyles} color={'white'}>
{t('home.Dateset')}
</Box>
<Box {...DescStyles} color={'rgba(255,255,255,0.9)'}>
{t('home.Dateset Desc')}
</Box>
<MyImage src="/imgs/home/dataset_import.png" w={'90%'} mx={'auto'} borderRadius={'lg'} />
</Box>
</Grid>
<Grid
mt={6}
px={[5, 0]}
minH={'400px'}
gridTemplateColumns={['1fr', `1fr 500px`]}
gridGap={6}
>
<Box {...CardStyles} backgroundImage={'linear-gradient(to top, #6a85b6 0%, #bac8e0 100%)'}>
<Box {...TitleStyles}>{t('home.Advanced Settings')}</Box>
<Box {...DescStyles} fontSize={['sm', 'md']}>
{t('home.Advanced Settings Desc')}
</Box>
<MyImage src="/imgs/home/advanced_settings.png" alt={''} w={'100%'} />
</Box>
<Box
{...CardStyles}
pb={4}
backgroundImage={'linear-gradient(to right, #FDCBB1 0%, #FEE5D8 100%)'}
>
<Box {...TitleStyles}>{t('home.OpenAPI')}</Box>
<Box {...DescStyles}>{t('home.OpenAPI Desc')}</Box>
<MyImage
src="/imgs/home/openapi.png"
alt={''}
w={'90%'}
mx={'auto'}
borderRadius={'lg'}
/>
</Box>
</Grid>
</Box>
);
};
export default Ability;

View File

@@ -1,108 +0,0 @@
import { Box, Image, Flex, Grid, useTheme } from '@chakra-ui/react';
import React from 'react';
import { useTranslation } from 'next-i18next';
import MyTooltip from '@/components/MyTooltip';
import { feConfigs } from '@/web/common/system/staticData';
const Choice = () => {
const theme = useTheme();
const { t } = useTranslation();
const list = [
...(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')
},
{
icon: '/imgs/home/icon_3.svg',
title: t('home.Choice Visual'),
desc: t('home.Choice Visual Desc')
},
{
icon: '/imgs/home/icon_4.svg',
title: t('home.Choice Extension'),
desc: t('home.Choice Extension Desc')
},
{
icon: '/imgs/home/icon_5.svg',
title: t('home.Choice Debug'),
desc: t('home.Choice Debug Desc')
},
{
icon: '/imgs/home/icon_6.svg',
title: t('home.Choice Models'),
desc: t('home.Choice Models Desc')
}
];
return (
<Box>
<Box
className="textlg"
py={['30px', '60px']}
textAlign={'center'}
fontSize={['22px', '30px']}
fontWeight={'bold'}
>
{t('home.Why FastGPT', { title: feConfigs?.systemTitle })}
</Box>
<Grid px={[5, 0]} gridTemplateColumns={['1fr', `1fr 1fr`, 'repeat(3,1fr)']} gridGap={6}>
{list.map((item) => (
<MyTooltip key={item.title} label={item.tooltip}>
<Flex
alignItems={'flex-start'}
border={theme.borders.md}
borderRadius={'lg'}
p={'40px'}
transition={'0.1s'}
cursor={'default'}
_hover={{
bg: 'rgba(255,255,255,0.8)'
}}
onClick={() => item.onClick?.()}
>
<Flex
flex={'0 0 48px'}
h={'48px'}
alignItems={'center'}
justifyContent={'center'}
boxShadow={theme.shadows.base}
borderRadius={'14px'}
>
<Image src={item.icon} w={'28px'} alt={''} loading={'lazy'} />
</Flex>
<Box ml={5}>
<Box fontSize={['lg', 'xl']} fontWeight={'bold'} color={'myGray.900'}>
{item.title}
</Box>
<Box mt={1} fontSize={'md'}>
{item.desc}
</Box>
</Box>
</Flex>
</MyTooltip>
))}
</Grid>
</Box>
);
};
export default Choice;

View File

@@ -1,124 +0,0 @@
import React, { useMemo } from 'react';
import { Box, Flex, useDisclosure } from '@chakra-ui/react';
import { feConfigs } from '@/web/common/system/staticData';
import { useTranslation } from 'next-i18next';
import Avatar from '@/components/Avatar';
import { useRouter } from 'next/router';
import CommunityModal from '@/components/CommunityModal';
import { getDocPath } from '@/web/common/system/doc';
const Footer = () => {
const { t } = useTranslation();
const router = useRouter();
const { isOpen, onOpen, onClose } = useDisclosure();
const list = useMemo(
() => [
{
label: t('home.Footer Product'),
child: [
{
label: t('home.Footer FastGPT Cloud', { title: feConfigs.systemTitle }),
onClick: () => {
router.push('/app/list');
}
},
{
label: 'Sealos',
onClick: () => {
window.open('https://github.com/labring/sealos', '_blank');
}
},
{
label: 'Laf',
onClick: () => {
window.open('https://github.com/labring/laf', '_blank');
}
}
]
},
{
label: t('home.Footer Developer'),
child: [
{
label: t('home.Footer Git'),
onClick: () => {
window.open('https://github.com/labring/FastGPT', '_blank');
}
},
{
label: t('home.Footer Docs'),
onClick: () => {
window.open(getDocPath('/docs/intro'), '_blank');
}
}
]
},
{
label: t('home.Footer Support'),
child: [
{
label: t('home.Footer Feedback'),
onClick: () => {
window.open('https://github.com/labring/FastGPT/issues', '_blank');
}
},
{
label: t('home.Community'),
onClick: () => {
onOpen();
}
}
]
}
],
[onOpen, router, t]
);
return (
<Box
display={['block', 'flex']}
px={[5, 0]}
maxW={'1200px'}
m={'auto'}
py={['30px', '60px']}
flexWrap={'wrap'}
>
<Box flex={1}>
<Flex alignItems={'center'}>
<Avatar src="/icon/logo.svg" w={['24px', '30px']} />
<Box
className="textlg"
fontSize={['xl', '2xl']}
fontWeight={'bold'}
ml={3}
fontStyle={'italic'}
>
{feConfigs?.systemTitle}
</Box>
</Flex>
<Box mt={5} fontSize={'sm'} color={'myGray.600'} maxW={'380px'} textAlign={'justify'}>
{t('home.FastGPT Desc', { title: feConfigs.systemTitle })}
</Box>
</Box>
{list.map((item) => (
<Box key={item.label} w={'200px'} mt={[5, 0]}>
<Box color={'myGray.500'}>{item.label}</Box>
{item.child.map((child) => (
<Box
key={child.label}
mt={[2, 3]}
cursor={'pointer'}
_hover={{ textDecoration: 'underline' }}
onClick={child.onClick}
>
{child.label}
</Box>
))}
</Box>
))}
{isOpen && <CommunityModal onClose={onClose} />}
</Box>
);
};
export default Footer;

View File

@@ -1,116 +0,0 @@
import { Box, Flex, Button, Image } from '@chakra-ui/react';
import React, { useState } from 'react';
import { useTranslation } from 'next-i18next';
import { feConfigs } from '@/web/common/system/staticData';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import MyIcon from '@/components/Icon';
import { useRouter } from 'next/router';
const Hero = () => {
const router = useRouter();
const { t } = useTranslation();
const { isPc, gitStar } = useSystemStore();
const [showVideo, setShowVide] = useState(false);
return (
<Flex flexDirection={'column'} pt={['24px', '50px']} alignItems={'center'} userSelect={'none'}>
<Box fontSize={['38px', '54px']} fontWeight={'bold'}>
{t('home.slogan')}
</Box>
<Box fontSize={['xl', '2xl']} py={5} color={'myGray.600'} textAlign={'center'} maxW={'400px'}>
{t('home.desc')}
</Box>
<Flex zIndex={1} flexDirection={['column', 'row']} mt={[5, 8]}>
{feConfigs?.show_git && (
<Button
mr={[0, 5]}
mb={[5, 0]}
fontSize={['xl', '2xl']}
h={'auto'}
py={[2, 3]}
variant={'whitePrimary'}
border={'2px solid'}
borderColor={'myGray.800'}
transition={'0.3s'}
borderRadius={'xl'}
_hover={{
bg: 'myGray.800',
color: 'white'
}}
leftIcon={<MyIcon name={'git'} w={'20px'} />}
onClick={() => window.open('https://github.com/labring/FastGPT', '_blank')}
>
Stars {(gitStar / 1000).toFixed(1)}k
</Button>
)}
<Button
fontSize={['xl', '2xl']}
h={['38px', 'auto']}
borderRadius={'xl'}
py={[2, 3]}
w={'150px'}
onClick={() => router.push(`/app/list`)}
>
{t('home.Start Now')}
</Button>
</Flex>
<Box mt={['', '-50px']} position={'relative'}>
<Image
minH={['auto', '400px']}
src={isPc ? '/imgs/home/videobgpc.png' : '/imgs/home/videobgphone.png'}
mx={['-10%', 'auto']}
maxW={['120%', '1000px']}
alt=""
draggable={false}
loading={'lazy'}
/>
<MyIcon
name={'common/playFill'}
position={'absolute'}
w={['30px', '40px']}
cursor={'pointer'}
left={'50%'}
top={'50%'}
color={'#363c42b8'}
transform={['translate(-50%,5px)', 'translate(-50%,40px)']}
onClick={() => setShowVide(true)}
/>
</Box>
{showVideo && (
<Flex
position={'fixed'}
zIndex={99}
top={0}
left={0}
right={0}
bottom={0}
alignItems={'center'}
justifyContent={'center'}
bg={'rgba(255,255,255,0.4)'}
onClick={() => setShowVide(false)}
>
<Box
w={['100vw', '50%']}
borderRadius={'lg'}
overflow={'hidden'}
onClick={(e) => e.preventDefault()}
>
<video
style={{
margin: 'auto'
}}
onClick={(e) => {
e.stopPropagation();
}}
src={'https://otnvvf-imgs.oss.laf.run/fastgpt.mp4'}
controls
autoPlay
/>
</Box>
</Flex>
)}
</Flex>
);
};
export default Hero;

View File

@@ -1,159 +0,0 @@
import React, { useEffect, useMemo, useState } from 'react';
import { Flex, Box, type BoxProps, Button, useDisclosure } from '@chakra-ui/react';
import { feConfigs } from '@/web/common/system/staticData';
import { useTranslation } from 'next-i18next';
import { useRouter } from 'next/router';
import Avatar from '@/components/Avatar';
import CommunityModal from '@/components/CommunityModal';
import { useSystemStore } from '@/web/common/system/useSystemStore';
import MyIcon from '@/components/Icon';
import { getDocPath } from '@/web/common/system/doc';
const Navbar = () => {
const router = useRouter();
const { t } = useTranslation();
const [scrollTop, setScrollTop] = useState(0);
const {
isOpen: isOpenCommunity,
onOpen: onOpenCommunity,
onClose: onCloseCommunity
} = useDisclosure();
const { isOpen: isOpenMenu, onOpen: onOpenMenu, onClose: onCloseMenu } = useDisclosure();
const { isPc } = useSystemStore();
const menuList = [
...(feConfigs?.concatMd
? [
{
label: t('home.Commercial'),
key: 'Commercial',
onClick: () => {
window.open(
'https://fael3z0zfze.feishu.cn/share/base/form/shrcnRxj3utrzjywsom96Px4sud',
'_blank'
);
}
},
{
label: t('home.Community'),
key: 'community',
onClick: () => {
onOpenCommunity();
}
}
]
: []),
...(feConfigs?.docUrl
? [
{
label: t('home.Docs'),
key: 'docs',
onClick: () => {
window.open(getDocPath('/docs/intro'));
}
}
]
: [])
];
const bgOpacity = useMemo(() => {
const rate = scrollTop / 120;
if (rate > 0.7) {
return 0.7;
}
return rate;
}, [scrollTop]);
const menuStyles: BoxProps = {
mr: 4,
px: 5,
py: 2,
cursor: 'pointer',
transition: '0.5s',
borderRadius: 'xl',
fontSize: 'lg',
_hover: {
bg: 'myGray.200'
}
};
useEffect(() => {
const scrollListen = (e: any) => {
setScrollTop(e?.target?.scrollTop);
};
const dom = document.getElementById('home');
if (!dom) return;
dom.addEventListener('scroll', scrollListen);
return () => {
dom.removeEventListener('scroll', scrollListen);
};
}, []);
return (
<Box
bg={`rgba(255,255,255,${bgOpacity})`}
backdropFilter={'blur(24px)'}
py={[3, 5]}
px={5}
transition={'0.4s ease'}
h={isOpenMenu ? '100vh' : 'auto'}
>
<Flex maxW={'1300px'} m={'auto'} alignItems={'center'}>
<Avatar src="/icon/logo.svg" w={['30px', '38px']} />
<Box
className="textlg"
fontSize={['3xl', '4xl']}
fontWeight={'bold'}
ml={3}
fontStyle={'italic'}
>
{feConfigs?.systemTitle}
</Box>
<Box flex={1} />
{isPc ? (
<>
{menuList.map((item) => (
<Box key={item.key} {...menuStyles} onClick={item.onClick}>
{item.label}
</Box>
))}
<Box px={4} color={'myGray.500'}>
|
</Box>
<Box {...menuStyles} onClick={() => router.push('/login')}>
{t('home.Login')}
</Box>
<Button ml={4} h={'36px'} borderRadius={'3xl'} onClick={() => router.push('/app/list')}>
{t('home.Start Now')}
</Button>
</>
) : (
<MyIcon
name={isOpenMenu ? 'closeLight' : 'menu'}
w={'20px'}
onClick={() => (isOpenMenu ? onCloseMenu() : onOpenMenu())}
/>
)}
</Flex>
{isOpenMenu && !isPc && (
<Box mt={'15vh'} ml={'10vw'}>
{menuList.map((item) => (
<Box key={item.key} mb={8} onClick={item.onClick}>
{item.label}
</Box>
))}
<Box bg={'myGray.500'} h={'1.5px'} w={'20px'} mb={8} />
<Box mb={10} onClick={() => router.push('/login')}>
{t('home.Login')}
</Box>
<Button h={'36px'} borderRadius={'3xl'} onClick={() => router.push('/app/list')}>
{t('home.Start Now')}
</Button>
</Box>
)}
{isOpenCommunity && <CommunityModal onClose={onCloseCommunity} />}
</Box>
);
};
export default Navbar;

View File

@@ -1,59 +0,0 @@
import React, { useEffect } from 'react';
import { Box } from '@chakra-ui/react';
import { feConfigs } from '@/web/common/system/staticData';
import { serviceSideProps } from '@/web/common/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 = ({ homeUrl = '/' }: { homeUrl: string }) => {
const router = useRouter();
if (homeUrl !== '/') {
router.replace(homeUrl);
}
useEffect(() => {
router.prefetch('/app/list');
router.prefetch('/login');
}, [router]);
return (
<>
<Box id="home" bg={'myWhite.600'} h={'100vh'} overflowY={'auto'} overflowX={'hidden'}>
<Box position={'fixed'} zIndex={10} top={0} left={0} right={0}>
<Navbar />
</Box>
<Box maxW={'1200px'} pt={'70px'} m={'auto'}>
<Hero />
<Ability />
<Box my={[4, 6]}>
<Choice />
</Box>
</Box>
{feConfigs?.show_git && (
<Box bg={'white'}>
<Footer />
</Box>
)}
</Box>
{homeUrl !== '/' && <Loading bg={'white'} />}
</>
);
};
export async function getServerSideProps(content: any) {
return {
props: {
...(await serviceSideProps(content)),
homeUrl: process.env.HOME_URL || '/'
}
};
}
export default Home;

View File

@@ -10,8 +10,10 @@ import { useToast } from '@/web/common/hooks/useToast';
import Loading from '@/components/Loading';
import { serviceSideProps } from '@/web/common/utils/i18n';
import { getErrText } from '@fastgpt/global/common/error/utils';
import { useTranslation } from 'next-i18next';
const provider = ({ code, state }: { code: string; state: string }) => {
const provider = ({ code, state, error }: { code: string; state: string; error?: string }) => {
const { t } = useTranslation();
const { loginStore } = useSystemStore();
const { setLastChatId, setLastChatAppId } = useChatStore();
const { setUserInfo } = useUserStore();
@@ -75,6 +77,14 @@ const provider = ({ code, state }: { code: string; state: string }) => {
useEffect(() => {
clearToken();
router.prefetch('/app/list');
if (error) {
toast({
status: 'warning',
title: t('support.user.login.Provider error')
});
router.replace('/login');
return;
}
if (!code) return;
if (state !== loginStore?.state) {
@@ -98,6 +108,7 @@ export async function getServerSideProps(content: any) {
props: {
code: content?.query?.code,
state: content?.query?.state,
error: content?.query?.error,
...(await serviceSideProps(content))
}
};