From 68cdf50cb638669ce8b856a588ba2d3dbce2dc63 Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Fri, 1 Sep 2023 10:13:57 +0800 Subject: [PATCH] perf: config home page --- client/.env.template | 7 ++- client/data/config.json | 3 +- client/public/imgs/home/icon_0.svg | 1 + client/public/locales/en/common.json | 4 +- client/public/locales/zh/common.json | 4 +- client/src/components/Layout/navbar.tsx | 26 +++++------ .../account/components/OpenAIAccountModal.tsx | 2 +- client/src/pages/components/Choice.tsx | 43 ++++++++++-------- client/src/pages/components/Navbar.tsx | 44 ++++++++++--------- client/src/pages/index.tsx | 29 ++++++++---- client/src/pages/login/index.tsx | 2 +- client/src/pages/tools/index.tsx | 14 +++--- .../src/service/moduleDispatch/chat/oneapi.ts | 2 +- client/src/types/index.d.ts | 3 +- files/deploy/fastgpt/config.json | 3 +- 15 files changed, 110 insertions(+), 77 deletions(-) create mode 100644 client/public/imgs/home/icon_0.svg diff --git a/client/.env.template b/client/.env.template index b84c0b916..d7717451a 100644 --- a/client/.env.template +++ b/client/.env.template @@ -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 @@ -18,4 +15,6 @@ OPENAI_BASE_URL=https://api.openai.com/v1 CHAT_API_KEY=sk-xxxx # db MONGODB_URI=mongodb://username:password@0.0.0.0:27017/fastgpt?authSource=admin -PG_URL=postgresql://username:password@host:port/postgres \ No newline at end of file +PG_URL=postgresql://username:password@host:port/postgres +# 首页路径 +HOME_URL=/ diff --git a/client/data/config.json b/client/data/config.json index 14b7aeb60..2b6b5cd6e 100644 --- a/client/data/config.json +++ b/client/data/config.json @@ -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": "", diff --git a/client/public/imgs/home/icon_0.svg b/client/public/imgs/home/icon_0.svg new file mode 100644 index 000000000..b3f10ddab --- /dev/null +++ b/client/public/imgs/home/icon_0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/client/public/locales/en/common.json b/client/public/locales/en/common.json index 2fe5b17ee..379c6df86 100644 --- a/client/public/locales/en/common.json +++ b/client/public/locales/en/common.json @@ -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!", @@ -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", diff --git a/client/public/locales/zh/common.json b/client/public/locales/zh/common.json index 1777839c7..96b3c3edb 100644 --- a/client/public/locales/zh/common.json +++ b/client/public/locales/zh/common.json @@ -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": "该应用可能为高级编排模式,保存后将会覆盖高级编排配置,请确认!", @@ -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": "更开放", diff --git a/client/src/components/Layout/navbar.tsx b/client/src/components/Layout/navbar.tsx index 45db932f1..50c2819cf 100644 --- a/client/src/components/Layout/navbar.tsx +++ b/client/src/components/Layout/navbar.tsx @@ -167,20 +167,20 @@ const Navbar = ({ unread }: { unread: number }) => { )} - - { - window.open(`https://doc.fastgpt.run/docs/intro`); - }} - > - + {feConfigs?.show_doc && ( + + { + window.open(`https://doc.fastgpt.run/docs/intro`); + }} + > - - - + + + )} {feConfigs?.show_git && ( diff --git a/client/src/pages/account/components/OpenAIAccountModal.tsx b/client/src/pages/account/components/OpenAIAccountModal.tsx index d74e2a018..ea2fbef51 100644 --- a/client/src/pages/account/components/OpenAIAccountModal.tsx +++ b/client/src/pages/account/components/OpenAIAccountModal.tsx @@ -43,7 +43,7 @@ const OpenAIAccountModal = ({ diff --git a/client/src/pages/components/Choice.tsx b/client/src/pages/components/Choice.tsx index e320b777e..c8f4c8ed0 100644 --- a/client/src/pages/components/Choice.tsx +++ b/client/src/pages/components/Choice.tsx @@ -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 })} {list.map((item) => ( @@ -72,7 +77,7 @@ const Choice = () => { _hover={{ bg: 'rgba(255,255,255,0.8)' }} - onClick={item.onClick} + onClick={() => item.onClick?.()} > { } = 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) { diff --git a/client/src/pages/index.tsx b/client/src/pages/index.tsx index dacbf07f4..ef45abbca 100644 --- a/client/src/pages/index.tsx +++ b/client/src/pages/index.tsx @@ -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 === '/' ? ( @@ -22,17 +30,22 @@ const Home = () => { - -