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_register": false,
"show_appStore": false,
"show_promotion": false,
"show_userDetail": false,
"show_git": false,
"authorText": "Made by FastGpt Team."
"show_emptyChat": true,
"show_register": true,
"show_appStore": true,
"show_userDetail": true,
"show_git": true,
"systemTitle": "FastAI",
"authorText": "Made by FastAI Team."
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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