mirror of
https://github.com/labring/FastGPT.git
synced 2026-05-05 01:02:59 +08:00
update shell (#6830)
This commit is contained in:
@@ -19,7 +19,7 @@ endif
|
||||
filePath=$(projectDir)/Dockerfile
|
||||
|
||||
dev:
|
||||
pnpm --prefix $(projectDir) dev
|
||||
pnpm --filter=@fastgpt/$(name) dev
|
||||
|
||||
build:
|
||||
ifeq ($(proxy), taobao)
|
||||
|
||||
@@ -60,20 +60,6 @@ docker compose up -d
|
||||
- **商业版**
|
||||
如果你需要更完整的功能,或深度的服务支持,可以选择我们的[商业版](https://doc.fastgpt.io/introduction/commercial)。我们除了提供完整的软件外,还提供相应的场景落地辅导,具体可提交[商业咨询](https://fael3z0zfze.feishu.cn/share/base/form/shrcnjJWtKqjOI9NbQTzhNyzljc)
|
||||
|
||||
## 📁 仓库结构
|
||||
|
||||
- `projects/app`: 开源主应用
|
||||
- `pro/admin`: 商业版后台
|
||||
- `pro/sso`: 商业版 SSO 服务
|
||||
|
||||
统一在仓库根目录执行 `pnpm i`,开发时使用:
|
||||
|
||||
```bash
|
||||
make dev name=app
|
||||
make dev name=admin
|
||||
make dev name=sso
|
||||
```
|
||||
|
||||
## 💡 核心功能
|
||||
|
||||
| | |
|
||||
|
||||
@@ -1,131 +1,58 @@
|
||||
## Premise
|
||||
# FastGPT 开发文档
|
||||
|
||||
Since FastGPT is managed in the same way as monorepo, it is recommended to install ‘make’ first during development.
|
||||
FastGPT 采用 monorepo 方式管理。
|
||||
|
||||
monorepo Project Name:
|
||||
|
||||
- app: main project
|
||||
- admin: pro admin project
|
||||
- sso: pro sso service
|
||||
-......
|
||||
## 📁 仓库结构
|
||||
|
||||
## Dev
|
||||
- `projects/app`: 开源主应用
|
||||
- `projects/code-sandbox`: 代码沙盒
|
||||
- `pro/admin`: 商业版后台
|
||||
|
||||
## 启用开发
|
||||
|
||||
```sh
|
||||
# Give automatic script code execution permission (on non-Linux systems, you can manually execute the postinstall.sh file content)
|
||||
# 赋予脚本自动执行权限(非 Linux 系统可以手动执行 postinstall.sh 文件中的内容)
|
||||
chmod -R +x ./scripts/
|
||||
# Executing under the code root directory installs all dependencies within the root package, projects, and packages
|
||||
# 在代码根目录下执行,会安装根 package、projects 和 packages 中的所有依赖
|
||||
pnpm i
|
||||
# 如果没有自动触发构建依赖,可以手动执行
|
||||
pnpm build:sdks
|
||||
|
||||
# Not make cmd
|
||||
cd projects/app
|
||||
pnpm dev
|
||||
|
||||
# Make cmd
|
||||
make dev name=app
|
||||
make dev name=admin
|
||||
make dev name=sso
|
||||
```
|
||||
# 不使用 make 命令启动
|
||||
cd projects/app
|
||||
pnpm dev
|
||||
|
||||
Note: If the Node version is >= 20, you need to pass the `--no-node-snapshot` parameter to Node when running `pnpm i`
|
||||
# 使用 make 命令
|
||||
make dev name=app
|
||||
make dev name=admin
|
||||
```
|
||||
|
||||
|
||||
## 插件安装
|
||||
|
||||
### 安装 i18n-ally 插件
|
||||
|
||||
安装 `i18n Ally` 插件,用于自动生成国际化文件。
|
||||
|
||||
## 构建
|
||||
|
||||
```sh
|
||||
NODE_OPTIONS=--no-node-snapshot pnpm i
|
||||
```
|
||||
|
||||
### Jest
|
||||
|
||||
https://fael3z0zfze.feishu.cn/docx/ZOI1dABpxoGhS7xzhkXcKPxZnDL
|
||||
|
||||
## I18N
|
||||
|
||||
### Install i18n-ally Plugin
|
||||
|
||||
1. Open the Extensions Marketplace in VSCode, search for and install the `i18n Ally` plugin.
|
||||
|
||||
### Code Optimization Examples
|
||||
|
||||
#### Fetch Specific Namespace Translations in `getServerSideProps`
|
||||
|
||||
```typescript
|
||||
// pages/yourPage.tsx
|
||||
export async function getServerSideProps(context: any) {
|
||||
return {
|
||||
props: {
|
||||
currentTab: context?.query?.currentTab || TabEnum.info,
|
||||
...(await serverSideTranslations(context.locale, ['publish', 'user']))
|
||||
}
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
#### Use useTranslation Hook in Page
|
||||
|
||||
```typescript
|
||||
// pages/yourPage.tsx
|
||||
import { useTranslation } from 'next-i18next';
|
||||
|
||||
const YourComponent = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
mr={2}
|
||||
onClick={() => setShowSelected(false)}
|
||||
>
|
||||
{t('common:close')}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
export default YourComponent;
|
||||
```
|
||||
|
||||
#### Handle Static File Translations
|
||||
|
||||
```typescript
|
||||
// utils/i18n.ts
|
||||
import { i18nT } from '@fastgpt/web/i18n/utils';
|
||||
|
||||
const staticContent = {
|
||||
id: 'simpleChat',
|
||||
avatar: 'core/workflow/template/aiChat',
|
||||
name: i18nT('app:template.simple_robot'),
|
||||
};
|
||||
|
||||
export default staticContent;
|
||||
```
|
||||
|
||||
### Standardize Translation Format
|
||||
|
||||
- Use the t(namespace:key) format to ensure consistent naming.
|
||||
- Translation keys should use lowercase letters and underscores, e.g., common.close.
|
||||
|
||||
## audit
|
||||
|
||||
Please fill the AuditEventEnum and audit function is added to the ts, and on the corresponding position to fill i18n, at the same time to add the location of the log using addOpearationLog function add function
|
||||
|
||||
## Build
|
||||
|
||||
```sh
|
||||
# Docker cmd: Build image, not proxy
|
||||
docker build -f ./projects/app/Dockerfile -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1 . --build-arg name=app
|
||||
# Docker cmd: Build pro admin image, not proxy
|
||||
docker build -f ./pro/admin/Dockerfile -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-admin:v4.8.1 . --build-arg name=admin
|
||||
# Docker cmd: Build pro sso image, not proxy
|
||||
docker build -f ./pro/sso/Dockerfile -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sso-service:v4.8.1 . --build-arg name=sso
|
||||
# Make cmd: Build image, not proxy
|
||||
make build name=app image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1
|
||||
make build name=admin image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-admin:v4.8.1
|
||||
make build name=sso image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sso-service:v4.8.1
|
||||
|
||||
# Docker cmd: Build image with proxy
|
||||
docker build -f ./projects/app/Dockerfile -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1 . --build-arg name=app --build-arg proxy=taobao
|
||||
# Docker cmd: Build pro admin image with proxy
|
||||
docker build -f ./pro/admin/Dockerfile -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-admin:v4.8.1 . --build-arg name=admin --build-arg proxy=taobao
|
||||
# Make cmd: Build image with proxy
|
||||
make build name=app image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1 proxy=taobao
|
||||
make build name=admin image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-admin:v4.8.1 proxy=taobao
|
||||
# Docker 命令:构建镜像,不使用代理
|
||||
docker build -f ./projects/app/Dockerfile -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1 . --build-arg name=app
|
||||
# Docker 命令:构建商业版 admin 镜像,不使用代理
|
||||
docker build -f ./pro/admin/Dockerfile -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-admin:v4.8.1 . --build-arg name=admin
|
||||
# Docker 命令:构建商业版 sso 镜像,不使用代理
|
||||
docker build -f ./pro/sso/Dockerfile -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sso-service:v4.8.1 . --build-arg name=sso
|
||||
# Make 命令:构建镜像,不使用代理
|
||||
make build name=app image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1
|
||||
make build name=admin image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-admin:v4.8.1
|
||||
make build name=sso image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-sso-service:v4.8.1
|
||||
|
||||
# Docker 命令:使用代理构建镜像
|
||||
docker build -f ./projects/app/Dockerfile -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1 . --build-arg name=app --build-arg proxy=taobao
|
||||
# Docker 命令:使用代理构建商业版 admin 镜像
|
||||
docker build -f ./pro/admin/Dockerfile -t registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-admin:v4.8.1 . --build-arg name=admin --build-arg proxy=taobao
|
||||
# Make 命令:使用代理构建镜像
|
||||
make build name=app image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt:v4.8.1 proxy=taobao
|
||||
make build name=admin image=registry.cn-hangzhou.aliyuncs.com/fastgpt/fastgpt-admin:v4.8.1 proxy=taobao
|
||||
```
|
||||
|
||||
+4
-8
@@ -3,19 +3,16 @@
|
||||
"version": "4.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev:app": "turbo run dev --filter=@fastgpt/app",
|
||||
"dev:admin": "turbo run dev --filter=@fastgpt/admin",
|
||||
"dev": "turbo run dev --filter=@fastgpt/app",
|
||||
"proDev": "turbo run dev --filter=@fastgpt/app",
|
||||
"prepare": "husky install",
|
||||
"gen:theme-typings": "chakra-cli tokens packages/web/styles/theme.ts --out node_modules/.pnpm/node_modules/@chakra-ui/styled-system/dist/theming.types.d.ts",
|
||||
"gen:deploy": "node deploy/init.mjs",
|
||||
"postinstall": "pnpm gen:theme-typings",
|
||||
"postinstall": "pnpm gen:theme-typings && pnpm run build:sdks",
|
||||
"initIcon": "node ./scripts/icon/init.js && prettier --config \"./.prettierrc.js\" --write \"packages/web/components/common/Icon/constants.ts\"",
|
||||
"previewIcon": "node ./scripts/icon/index.js",
|
||||
"lint": "eslint \"**/*.{ts,tsx}\" --fix --ignore-path .eslintignore",
|
||||
"create:i18n": "node ./scripts/i18n/index.js",
|
||||
"clean:unused:pro": "node --experimental-strip-types ./pro/scripts/cleanup-unused.ts",
|
||||
"clean:unused:pro:write": "node --experimental-strip-types ./pro/scripts/cleanup-unused.ts --write",
|
||||
"lint": "eslint \"**/*.{ts,tsx}\" --fix --ignore-path .eslintignore",
|
||||
"test": "pnpm test:workspace",
|
||||
"test:all": "pnpm test:workspace && pnpm test:vector",
|
||||
"test:repo": "vitest run --config vitest.config.mts --coverage --passWithNoTests",
|
||||
@@ -26,8 +23,7 @@
|
||||
"test:service": "turbo run test --filter=@fastgpt/service",
|
||||
"test:service:integration": "turbo run test:integration --filter=@fastgpt/service",
|
||||
"test:vector": "turbo run test:integration --filter=@fastgpt/service",
|
||||
"build:sdks": "pnpm -r --filter @fastgpt-sdk/storage --filter @fastgpt-sdk/logger --filter @fastgpt-sdk/otel build",
|
||||
"predev": "pnpm run build:sdks"
|
||||
"build:sdks": "pnpm -r --filter @fastgpt-sdk/storage --filter @fastgpt-sdk/logger --filter @fastgpt-sdk/otel build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@chakra-ui/cli": "^2.4.1",
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
"ui": "tui",
|
||||
"tasks": {
|
||||
"dev": {
|
||||
"with": ["@fastgpt/admin#dev"],
|
||||
"cache": false,
|
||||
"persistent": true
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user