perf: config fe

This commit is contained in:
archer
2023-07-19 11:17:08 +08:00
parent 47af8d1c3d
commit c46a37541c
10 changed files with 52 additions and 50 deletions

View File

@@ -1,9 +1,9 @@
{ {
"show_emptyChat": false, "show_emptyChat": true,
"show_register": false, "show_register": true,
"show_appStore": false, "show_appStore": true,
"show_promotion": false, "show_userDetail": true,
"show_userDetail": false, "show_git": true,
"show_git": false, "systemTitle": "FastAI",
"authorText": "Made by FastGpt Team." "authorText": "Made by FastAI Team."
} }

View File

@@ -394,7 +394,7 @@ const ChatBox = (
const showEmpty = useMemo( const showEmpty = useMemo(
() => () =>
feConfigs.show_emptyChat && feConfigs?.show_emptyChat &&
showEmptyIntro && showEmptyIntro &&
chatHistory.length === 0 && chatHistory.length === 0 &&
!variableModules?.length && !variableModules?.length &&

View File

@@ -42,7 +42,7 @@ const Navbar = ({ unread }: { unread: number }) => {
link: `/kb/list`, link: `/kb/list`,
activeLink: ['/kb/list', '/kb/detail'] activeLink: ['/kb/list', '/kb/detail']
}, },
...(feConfigs.show_appStore ...(feConfigs?.show_appStore
? [ ? [
{ {
label: '市场', label: '市场',
@@ -143,7 +143,7 @@ const Navbar = ({ unread }: { unread: number }) => {
</Link> </Link>
</Box> </Box>
)} )}
{feConfigs.show_git && ( {feConfigs?.show_git && (
<Box> <Box>
<Link <Link
as={NextLink} as={NextLink}

View File

@@ -10,10 +10,9 @@ import NProgress from 'nprogress'; //nprogress module
import Router from 'next/router'; import Router from 'next/router';
import 'nprogress/nprogress.css'; import 'nprogress/nprogress.css';
import '@/styles/reset.scss'; import '@/styles/reset.scss';
import { clientInitData } from '@/store/static'; import { clientInitData, feConfigs } from '@/store/static';
import { NextPageContext } from 'next'; import { NextPageContext } from 'next';
import { useGlobalStore } from '@/store/global'; import { useGlobalStore } from '@/store/global';
import { GET } from '@/service/api/axios';
//Binding events. //Binding events.
Router.events.on('routeChangeStart', () => NProgress.start()); Router.events.on('routeChangeStart', () => NProgress.start());
@@ -51,7 +50,7 @@ function App({ Component, pageProps, isPc }: AppProps & { isPc?: boolean; respon
return ( return (
<> <>
<Head> <Head>
<title>Fast GPT</title> <title>{feConfigs?.systemTitle || 'FastAI'}</title>
<meta name="description" content="Embedding + LLM, Build AI knowledge base" /> <meta name="description" content="Embedding + LLM, Build AI knowledge base" />
<meta <meta
name="viewport" name="viewport"

View File

@@ -33,7 +33,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
await connectToDatabase(); await connectToDatabase();
// register switch // register switch
if (type === UserAuthTypeEnum.register && !global.feConfigs.show_register) { if (type === UserAuthTypeEnum.register && !global.feConfigs?.show_register) {
throw new Error('Register is closed'); throw new Error('Register is closed');
} }

View File

@@ -1,7 +1,5 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Card, Box, Link, Flex, Image, Button } from '@chakra-ui/react'; import { Card, Box, Link, Flex, Image, Button } from '@chakra-ui/react';
import Markdown from '@/components/Markdown';
import { useMarkdown } from '@/hooks/useMarkdown';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { useGlobalStore } from '@/store/global'; import { useGlobalStore } from '@/store/global';
import { beianText } from '@/store/static'; import { beianText } from '@/store/static';
@@ -170,7 +168,7 @@ const Home = () => {
fontSize={['40px', '70px']} fontSize={['40px', '70px']}
letterSpacing={'5px'} letterSpacing={'5px'}
> >
FastAI {feConfigs?.systemTitle || 'FastAI'}
</Box> </Box>
<Box className={styles.textlg} fontWeight={'bold'} fontSize={['30px', '50px']}> <Box className={styles.textlg} fontWeight={'bold'} fontSize={['30px', '50px']}>
AI AI
@@ -180,25 +178,27 @@ const Home = () => {
</Box> </Box>
<Flex flexDirection={['column', 'row']} my={5}> <Flex flexDirection={['column', 'row']} my={5}>
<Button {feConfigs?.show_git && (
mr={[0, 5]} <Button
mb={[5, 0]} mr={[0, 5]}
fontSize={['xl', '3xl']} mb={[5, 0]}
h={'auto'} fontSize={['xl', '3xl']}
py={[2, 3]} h={'auto'}
variant={'base'} py={[2, 3]}
border={'2px solid'} variant={'base'}
borderColor={'myGray.800'} border={'2px solid'}
transition={'0.3s'} borderColor={'myGray.800'}
_hover={{ transition={'0.3s'}
bg: 'myGray.800', _hover={{
color: 'white' bg: 'myGray.800',
}} color: 'white'
leftIcon={<MyIcon name={'git'} w={'20px'} />} }}
onClick={() => window.open('https://github.com/labring/FastGPT', '_blank')} leftIcon={<MyIcon name={'git'} w={'20px'} />}
> onClick={() => window.open('https://github.com/labring/FastGPT', '_blank')}
Stars {(star / 1000).toFixed(1)}k >
</Button> Stars {(star / 1000).toFixed(1)}k
</Button>
)}
<Button <Button
fontSize={['xl', '3xl']} fontSize={['xl', '3xl']}
h={'auto'} h={'auto'}

View File

@@ -5,6 +5,7 @@ import { PageTypeEnum } from '@/constants/user';
import { postLogin } from '@/api/user'; import { postLogin } from '@/api/user';
import type { ResLogin } from '@/api/response/user'; import type { ResLogin } from '@/api/response/user';
import { useToast } from '@/hooks/useToast'; import { useToast } from '@/hooks/useToast';
import { feConfigs } from '@/store/static';
interface Props { interface Props {
setPageType: Dispatch<`${PageTypeEnum}`>; setPageType: Dispatch<`${PageTypeEnum}`>;
@@ -104,14 +105,16 @@ const LoginForm = ({ setPageType, loginSuccess }: Props) => {
> >
? ?
</Box> </Box>
<Box {feConfigs?.show_register && (
cursor={'pointer'} <Box
_hover={{ textDecoration: 'underline' }} cursor={'pointer'}
onClick={() => setPageType('register')} _hover={{ textDecoration: 'underline' }}
fontSize="sm" onClick={() => setPageType('register')}
> fontSize="sm"
>
</Box>
</Box>
)}
</Flex> </Flex>
<Button <Button
type="submit" type="submit"

View File

@@ -174,7 +174,7 @@ const NumberSetting = ({ tableType }: { tableType: `${TableEnum}` }) => {
<Box flex={'0 0 50px'}>:</Box> <Box flex={'0 0 50px'}>:</Box>
<Box>{userInfo?.username}</Box> <Box>{userInfo?.username}</Box>
</Flex> </Flex>
{feConfigs.show_userDetail && ( {feConfigs?.show_userDetail && (
<Box mt={6}> <Box mt={6}>
<Flex alignItems={'center'}> <Flex alignItems={'center'}>
<Box flex={'0 0 50px'}>:</Box> <Box flex={'0 0 50px'}>:</Box>
@@ -188,7 +188,7 @@ const NumberSetting = ({ tableType }: { tableType: `${TableEnum}` }) => {
</Box> </Box>
)} )}
</Card> </Card>
{feConfigs.show_userDetail && ( {feConfigs?.show_userDetail && (
<Card px={6} py={4}> <Card px={6} py={4}>
<Box fontSize={'xl'} fontWeight={'bold'}> <Box fontSize={'xl'} fontWeight={'bold'}>
@@ -234,7 +234,7 @@ const NumberSetting = ({ tableType }: { tableType: `${TableEnum}` }) => {
)} )}
</Grid> </Grid>
{feConfigs.show_userDetail && ( {feConfigs?.show_userDetail && (
<Card mt={4} px={[3, 6]} py={4}> <Card mt={4} px={[3, 6]} py={4}>
<Tabs <Tabs
m={'auto'} m={'auto'}

View File

@@ -11,7 +11,7 @@ const list = [
label: '我的知识库', label: '我的知识库',
link: '/kb/list' link: '/kb/list'
}, },
...(feConfigs.show_appStore ...(feConfigs?.show_appStore
? [ ? [
{ {
icon: 'appStoreLight', icon: 'appStoreLight',
@@ -20,7 +20,7 @@ const list = [
} }
] ]
: []), : []),
...(feConfigs.show_git ...(feConfigs?.show_git
? [ ? [
{ {
icon: 'git', icon: 'git',

View File

@@ -17,9 +17,9 @@ export type FeConfigsType = {
show_emptyChat?: boolean; show_emptyChat?: boolean;
show_register?: boolean; show_register?: boolean;
show_appStore?: boolean; show_appStore?: boolean;
show_promotion?: boolean;
show_userDetail?: boolean; show_userDetail?: boolean;
show_git?: false; show_git?: false;
systemTitle?: string;
authorText?: string; authorText?: string;
}; };