From d645a7406bbe3621110a09a6e13303bd8c90142a Mon Sep 17 00:00:00 2001
From: Archer <545436317@qq.com>
Date: Mon, 1 Jan 2024 13:46:09 +0800
Subject: [PATCH] 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
---
.../content/docs/development/configuration.md | 2 +
docSite/content/docs/development/docker.md | 8 +-
docSite/content/docs/development/intro.md | 10 +-
.../common/vectorStore/pg/controller.ts | 2 +-
projects/app/public/locales/en/common.json | 3 +-
projects/app/public/locales/zh/common.json | 3 +-
projects/app/src/pages/components/Ability.tsx | 102 -----------
projects/app/src/pages/components/Choice.tsx | 108 ------------
projects/app/src/pages/components/Footer.tsx | 124 --------------
projects/app/src/pages/components/Hero.tsx | 116 -------------
projects/app/src/pages/components/Navbar.tsx | 159 ------------------
projects/app/src/pages/index.tsx | 59 -------
projects/app/src/pages/login/provider.tsx | 13 +-
13 files changed, 31 insertions(+), 678 deletions(-)
delete mode 100644 projects/app/src/pages/components/Ability.tsx
delete mode 100644 projects/app/src/pages/components/Choice.tsx
delete mode 100644 projects/app/src/pages/components/Footer.tsx
delete mode 100644 projects/app/src/pages/components/Hero.tsx
delete mode 100644 projects/app/src/pages/components/Navbar.tsx
delete mode 100644 projects/app/src/pages/index.tsx
diff --git a/docSite/content/docs/development/configuration.md b/docSite/content/docs/development/configuration.md
index b9fe9522b..c4af23116 100644
--- a/docSite/content/docs/development/configuration.md
+++ b/docSite/content/docs/development/configuration.md
@@ -16,6 +16,8 @@ weight: 708
## 旧版本配置文件
+以下配置适合 4.6.6-alpha 之前
+
```json
{
"SystemParams": {
diff --git a/docSite/content/docs/development/docker.md b/docSite/content/docs/development/docker.md
index b78442a49..4cc5c4b6d 100644
--- a/docSite/content/docs/development/docker.md
+++ b/docSite/content/docs/development/docker.md
@@ -7,9 +7,13 @@ toc: true
weight: 707
---
-## 准备条件
+## 推荐配置
-服务器要求:2C2G 起
+| 环境 | 推荐配置(单节点) |
+| ---- | ---- |
+| 测试 | 2c2g 起 |
+| 100w 组向量 | 4c16g起 |
+| 500w 组向量 | 16c64g起 |
### 1. 准备好代理环境(国外服务器可忽略)
diff --git a/docSite/content/docs/development/intro.md b/docSite/content/docs/development/intro.md
index 9c657d724..45a2e53ba 100644
--- a/docSite/content/docs/development/intro.md
+++ b/docSite/content/docs/development/intro.md
@@ -16,7 +16,7 @@ weight: 705
- [Git](http://git-scm.com/)
- [Docker](https://www.docker.com/)(构建镜像)
-- [Node.js v18.x (LTS)](http://nodejs.org)
+- [Node.js v18.x (不推荐最新的,可能有兼容问题)](http://nodejs.org)
- [pnpm](https://pnpm.io/) 版本 8.x.x
## 开始本地开发
@@ -24,7 +24,7 @@ weight: 705
**Tips**
1. 用户默认的时区为 `Asia/Shanghai`,非 linux 环境时候,获取系统时间会异常,本地开发时候,可以将用户的时区调整成 UTC(+0)。
-2. 建议先服务器装好数据库在进行本地开发。
+2. 建议先服务器装好**数据库**,再进行本地开发。
### 1. Fork 存储库
@@ -79,11 +79,13 @@ cd projects/app
pnpm dev
```
-### 6. 发布 - 镜像打包
+### 6. 部署打包
```bash
# 根目录下执行
-docker build -t dockername/fastgpt --build-arg name=app .
+docker build -t dockername/fastgpt:tag --build-arg name=app .
+# 使用代理
+docker build -t dockername/fastgpt:tag --build-arg name=app --build-arg proxy=taobao .
```
## 提交代码至开源仓库
diff --git a/packages/service/common/vectorStore/pg/controller.ts b/packages/service/common/vectorStore/pg/controller.ts
index d502b4389..018ee753f 100644
--- a/packages/service/common/vectorStore/pg/controller.ts
+++ b/packages/service/common/vectorStore/pg/controller.ts
@@ -22,7 +22,7 @@ export async function initPg() {
data_id VARCHAR(50) NOT NULL,
createTime TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
- CREATE INDEX IF NOT EXISTS vector_index ON ${PgDatasetTableName} USING hnsw (vector vector_ip_ops) WITH (m = 32, ef_construction = 64);
+ CREATE INDEX CONCURRENTLY IF NOT EXISTS vector_index ON ${PgDatasetTableName} USING hnsw (vector vector_ip_ops) WITH (m = 32, ef_construction = 64);
`);
console.log('init pg successful');
diff --git a/projects/app/public/locales/en/common.json b/projects/app/public/locales/en/common.json
index 55a5c31d1..6fc11e182 100644
--- a/projects/app/public/locales/en/common.json
+++ b/projects/app/public/locales/en/common.json
@@ -879,7 +879,8 @@
},
"login": {
"Github": "Github",
- "Google": "Google"
+ "Google": "Google",
+ "Provider error": "Login exception, please try again"
}
}
},
diff --git a/projects/app/public/locales/zh/common.json b/projects/app/public/locales/zh/common.json
index 4c9d2b3f7..4443d743c 100644
--- a/projects/app/public/locales/zh/common.json
+++ b/projects/app/public/locales/zh/common.json
@@ -879,7 +879,8 @@
},
"login": {
"Github": "Github 登录",
- "Google": "Google 登录"
+ "Google": "Google 登录",
+ "Provider error": "登录异常,请重试"
}
}
},
diff --git a/projects/app/src/pages/components/Ability.tsx b/projects/app/src/pages/components/Ability.tsx
deleted file mode 100644
index 35c4dfd49..000000000
--- a/projects/app/src/pages/components/Ability.tsx
+++ /dev/null
@@ -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 (
-
-
- {t('home.FastGPT Ability', { title: feConfigs.systemTitle })}
-
-
-
-
- {t('home.AI Assistant')}
-
-
- {t('home.AI Assistant Desc')}
-
-
-
-
-
- {t('home.Dateset')}
-
-
- {t('home.Dateset Desc')}
-
-
-
-
-
-
- {t('home.Advanced Settings')}
-
- {t('home.Advanced Settings Desc')}
-
-
-
-
- {t('home.OpenAPI')}
- {t('home.OpenAPI Desc')}
-
-
-
-
- );
-};
-
-export default Ability;
diff --git a/projects/app/src/pages/components/Choice.tsx b/projects/app/src/pages/components/Choice.tsx
deleted file mode 100644
index 0ec8759af..000000000
--- a/projects/app/src/pages/components/Choice.tsx
+++ /dev/null
@@ -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 (
-
-
- {t('home.Why FastGPT', { title: feConfigs?.systemTitle })}
-
-
- {list.map((item) => (
-
- item.onClick?.()}
- >
-
-
-
-
-
- {item.title}
-
-
- {item.desc}
-
-
-
-
- ))}
-
-
- );
-};
-
-export default Choice;
diff --git a/projects/app/src/pages/components/Footer.tsx b/projects/app/src/pages/components/Footer.tsx
deleted file mode 100644
index 8d49b8993..000000000
--- a/projects/app/src/pages/components/Footer.tsx
+++ /dev/null
@@ -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 (
-
-
-
-
-
- {feConfigs?.systemTitle}
-
-
-
- {t('home.FastGPT Desc', { title: feConfigs.systemTitle })}
-
-
- {list.map((item) => (
-
- {item.label}
- {item.child.map((child) => (
-
- {child.label}
-
- ))}
-
- ))}
- {isOpen && }
-
- );
-};
-
-export default Footer;
diff --git a/projects/app/src/pages/components/Hero.tsx b/projects/app/src/pages/components/Hero.tsx
deleted file mode 100644
index d735c9576..000000000
--- a/projects/app/src/pages/components/Hero.tsx
+++ /dev/null
@@ -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 (
-
-
- {t('home.slogan')}
-
-
- {t('home.desc')}
-
-
- {feConfigs?.show_git && (
- }
- onClick={() => window.open('https://github.com/labring/FastGPT', '_blank')}
- >
- Stars {(gitStar / 1000).toFixed(1)}k
-
- )}
-
-
-
-
- setShowVide(true)}
- />
-
- {showVideo && (
- setShowVide(false)}
- >
- e.preventDefault()}
- >
-
-
- )}
-
- );
-};
-
-export default Hero;
diff --git a/projects/app/src/pages/components/Navbar.tsx b/projects/app/src/pages/components/Navbar.tsx
deleted file mode 100644
index 1c36c6cc6..000000000
--- a/projects/app/src/pages/components/Navbar.tsx
+++ /dev/null
@@ -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 (
-
-
-
-
- {feConfigs?.systemTitle}
-
-
- {isPc ? (
- <>
- {menuList.map((item) => (
-
- {item.label}
-
- ))}
-
- |
-
- router.push('/login')}>
- {t('home.Login')}
-
-
- >
- ) : (
- (isOpenMenu ? onCloseMenu() : onOpenMenu())}
- />
- )}
-
- {isOpenMenu && !isPc && (
-
- {menuList.map((item) => (
-
- {item.label}
-
- ))}
-
- router.push('/login')}>
- {t('home.Login')}
-
-
-
- )}
- {isOpenCommunity && }
-
- );
-};
-
-export default Navbar;
diff --git a/projects/app/src/pages/index.tsx b/projects/app/src/pages/index.tsx
deleted file mode 100644
index 997ed7786..000000000
--- a/projects/app/src/pages/index.tsx
+++ /dev/null
@@ -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 (
- <>
-
-
-
-
-
-
-
-
-
-
-
- {feConfigs?.show_git && (
-
-
-
- )}
-
- {homeUrl !== '/' && }
- >
- );
-};
-
-export async function getServerSideProps(content: any) {
- return {
- props: {
- ...(await serviceSideProps(content)),
- homeUrl: process.env.HOME_URL || '/'
- }
- };
-}
-
-export default Home;
diff --git a/projects/app/src/pages/login/provider.tsx b/projects/app/src/pages/login/provider.tsx
index 108568351..f015ffccd 100644
--- a/projects/app/src/pages/login/provider.tsx
+++ b/projects/app/src/pages/login/provider.tsx
@@ -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))
}
};