Skip to content

Commit

Permalink
perf: config home page
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu committed Sep 1, 2023
1 parent 2ae8d43 commit 68cdf50
Show file tree
Hide file tree
Showing 15 changed files with 110 additions and 77 deletions.
7 changes: 3 additions & 4 deletions client/.env.template
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# 默认用户密码,用户名为 root,每次重启时会自动更新。
DEFAULT_ROOT_PSW=123456
# 代理
# AXIOS_PROXY_HOST=127.0.0.1
# AXIOS_PROXY_PORT=7890
# 数据库最大连接数
DB_MAX_LINK=5
# token
Expand All @@ -18,4 +15,6 @@ OPENAI_BASE_URL=https://api.openai.com/v1
CHAT_API_KEY=sk-xxxx
# db
MONGODB_URI=mongodb://username:[email protected]:27017/fastgpt?authSource=admin
PG_URL=postgresql://username:password@host:port/postgres
PG_URL=postgresql://username:password@host:port/postgres
# 首页路径
HOME_URL=/
3 changes: 2 additions & 1 deletion client/data/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
"show_register": false,
"show_appStore": false,
"show_userDetail": false,
"show_loginTip": false,
"show_contact": true,
"show_git": true,
"show_doc": true,
"systemTitle": "FastGPT",
"authorText": "Made by FastGPT Team.",
"gitLoginKey": "",
Expand Down
1 change: 1 addition & 0 deletions client/public/imgs/home/icon_0.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion client/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"app": {
"Advance App TestTip": "The current application is advanced editing mode \n. If you need to switch to [simple mode], please click the save button on the left",
"App Detail": "App Detail",
"Chat Logs Tips": "Logs record the app's online, shared, and API conversations",
"Chat Logs Tips": "Logs record the app's online, shared, and API(chatId is existing) conversations",
"Chat logs": "Chat Logs",
"Confirm Del App Tip": "Confirm to delete the app and all its chats",
"Confirm Save App Tip": "The application may be in advanced orchestration mode, and the advanced orchestration configuration will be overwritten after saving, please confirm!",
Expand Down Expand Up @@ -110,6 +110,8 @@
"Choice Desc": "FastGPT follows the Apache License 2.0 open source protocol",
"Choice Extension": "Infinite Extension",
"Choice Extension Desc": "HTTP based extension, easy to achieve custom functions",
"Choice Fast": "Fast",
"Choice Fast Desc": "{{title}} provides out-of-the-box visual actions to build AI applications point-by-point",
"Choice Models": "Multiple Models",
"Choice Models Desc": "Supports multiple models such as GPT, Claude, Spark, and ChatGLM",
"Choice Open": "Open",
Expand Down
4 changes: 3 additions & 1 deletion client/public/locales/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"app": {
"Advance App TestTip": "当前应用为高级编排模式\n如需切换为【简易模式】请点击左侧保存按键",
"App Detail": "应用详情",
"Chat Logs Tips": "日志会记录该应用的在线、分享和 API 对话记录",
"Chat Logs Tips": "日志会记录该应用的在线、分享和 API(需填写 chatId) 对话记录",
"Chat logs": "对话日志",
"Confirm Del App Tip": "确认删除该应用及其所有聊天记录?",
"Confirm Save App Tip": "该应用可能为高级编排模式,保存后将会覆盖高级编排配置,请确认!",
Expand Down Expand Up @@ -110,6 +110,8 @@
"Choice Desc": "",
"Choice Extension": "无限扩展",
"Choice Extension Desc": "基于 HTTP 实现扩展,轻松实现定制功能",
"Choice Fast": "开箱即用",
"Choice Fast Desc": "{{title}} 提供开箱即用的可视化操作,点点点即可构建 AI 应用",
"Choice Models": "支持多种模型",
"Choice Models Desc": "支持 GPT、Claude、Spark、ChatGLM等多模型",
"Choice Open": "更开放",
Expand Down
26 changes: 13 additions & 13 deletions client/src/components/Layout/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'}>
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/account/components/OpenAIAccountModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const OpenAIAccountModal = ({
<Input
flex={1}
{...register('baseUrl')}
placeholder={'中转地址,未自动补全 "v1"'}
placeholder={'请求地址,默认为 openai 官方。可填中转地址,未自动补全 "v1"'}
></Input>
</Flex>
</ModalBody>
Expand Down
43 changes: 24 additions & 19 deletions client/src/pages/components/Choice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
];

Expand All @@ -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) => (
Expand All @@ -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'}
Expand Down
44 changes: 24 additions & 20 deletions client/src/pages/components/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
29 changes: 21 additions & 8 deletions client/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -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 = ({ homeUrl = '/' }: { homeUrl: string }) => {
const router = useRouter();

if (homeUrl !== '/') {
router.replace(homeUrl);
}

const Home = () => {
return (
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 />
Expand All @@ -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 || '/'
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const Login = () => {
>
<DynamicComponent type={pageType} />

{feConfigs?.show_loginTip && (
{feConfigs?.show_contact && (
<Box
fontSize={'sm'}
color={'myGray.600'}
Expand Down
14 changes: 9 additions & 5 deletions client/src/pages/tools/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion client/src/service/moduleDispatch/chat/oneapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
3 changes: 2 additions & 1 deletion client/src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion files/deploy/fastgpt/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"show_register": false,
"show_appStore": false,
"show_userDetail": false,
"show_contact": true,
"show_git": true,
"show_doc": true,
"systemTitle": "FastGPT",
"authorText": "Made by FastGPT Team.",
"gitLoginKey": "",
Expand All @@ -15,7 +17,6 @@
"qaMaxProcess": 15,
"pgIvfflatProbe": 20
},
"plugins": {},
"ChatModels": [
{
"model": "gpt-3.5-turbo",
Expand Down

0 comments on commit 68cdf50

Please sign in to comment.