Skip to content
This repository was archived by the owner on Nov 23, 2025. It is now read-only.

Commit 39ef610

Browse files
authored
Merge pull request #177 from AprilNEA/v3-dev
2 parents 5b402a0 + b38e561 commit 39ef610

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1057
-3554
lines changed

.npmrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
public-hoist-pattern[]=*prisma*
1+
public-hoist-pattern[]=*prisma*
2+
public-hoist-pattern[]=*@prisma/client*
3+
4+
strict-peer-dependencies=false

.pnpmfile.cjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function hookPrisma(pkg) {
2+
if (pkg.name === '@nest-http/prisma') {
3+
pkg.version = pkg.dependencies['@prisma/client'];
4+
}
5+
// if (pkg.name === 'nestjs-prisma') {
6+
// pkg.peerDependencies['@prisma/client'] = '*';
7+
// pkg.devDependencies['@prisma/client'] = undefined;
8+
// }
9+
// if (pkg.name === 'prisma-extension-pagination') {
10+
// pkg.peerDependencies['@prisma/client'] = '*';
11+
// }
12+
return pkg;
13+
}
14+
15+
module.exports = {
16+
hooks: {
17+
readPackage: hookPrisma,
18+
},
19+
};

docs/src/pages/_meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"index": "主页",
3-
"install": "安装",
3+
"quickstart": "快速开始",
44
"upgrade": {
55
"title": "升级"
66
},

docs/src/pages/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const Stars = () => {
4949
这是一个由 [ChatGPT-Next-Web](https://github.com/Yidadaa/ChatGPT-Next-Web) 二次开发的项目。
5050

5151
<Cards>
52-
<Card title="安装配置" href="/install" />
52+
<Card title="快速开始" href="/quickstart" />
5353
<Card title="更新日志" href="/upgrade/log" />
5454
</Cards>
5555

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import { Callout } from 'nextra/components'
2-
import { Steps } from 'nextra/components'
1+
import { Callout, Steps } from 'nextra/components'
32

4-
## 本地部署
3+
## 快速开始
54
<Callout type="info" emoji="ℹ️">
65
**Prerequisite** You should have installed Node.js (version 18.10.0 or
76
higher).
@@ -12,7 +11,6 @@ import { Steps } from 'nextra/components'
1211

1312
```bash
1413
git clone https://github.com/AprilNEA/ChatGPT-Admin-Web.git
15-
git checkout v3
1614
cd ChatGPT-Admin-Web
1715
pnpm install
1816
```
@@ -61,21 +59,73 @@ import { Steps } from 'nextra/components'
6159

6260
```
6361

64-
### 启动项目
62+
设置`REDIS_URL`环境变量,例如:
6563
```bash
66-
turbo run start
64+
export REDIS_URL=redis://localhost:6379/0
6765
```
66+
> 可通过 Docker 快速启动一个 Redis 数据库
67+
>
68+
> `docker run -p 6379:6379 -d redis/redis-stack:latest`
6869
69-
项目默认运行在 `http://localhost:3000`
70-
71-
首次打开应自动转跳`http://localhost:3000/install`设置管理员账户和密码,设置成功后即可登录。
7270

73-
</Steps>
71+
### 启动项目
72+
```bash
73+
pnpm run start
74+
```
7475

76+
项目默认运行在 `http://localhost:3000`
7577

78+
首次运行项目会自动生成`config.json`, 并导入`DATABASE_URL``REDIS_URL`环境变量,后续更改可直接修改`config.json`
7679

80+
<Callout type="warning" emoji="👷‍♀️">
81+
Dashboard is coming soon.
82+
</Callout>
7783

84+
~~首次打开应自动转跳`http://localhost:3000/install`设置管理员账户和密码,设置成功后即可登录。~~
7885

86+
</Steps>
7987

88+
## 配置
8089

90+
<Callout type="info" emoji="ℹ️">
91+
邮件服务仅 Resend 通过测试。
92+
短信服务仅 UniSMS 通过测试。
93+
支付服务仅 Xunhu 通过测试。
94+
</Callout>
8195

96+
```json
97+
{
98+
...// 自动生成部分
99+
100+
"openai": {
101+
"baseUrl": "https://api.openai.com/v1",
102+
"keys": [
103+
"fff"
104+
]
105+
},
106+
"email": {
107+
"use": "resend",
108+
"domain": "example.com",
109+
"resend": {
110+
"apiKey": "fff"
111+
}
112+
},
113+
"sms": {
114+
"use": "uni",
115+
"uni": {
116+
"signature": "XX科技",
117+
"apiKey": "ffffff"
118+
}
119+
},
120+
"payment": {
121+
"use": "xunhu",
122+
"xunhu": {
123+
"wapName": "XX科技",
124+
"appId": "ffffff",
125+
"appSecret": "ffffff",
126+
"notifyUrl": "https://example.com",
127+
"returnUrl": "https://example.com"
128+
}
129+
}
130+
}
131+
```

docs/theme.config.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default {
22
logo: <span>ChatGPT Admin Web</span>,
33
project: {
4-
link: 'https://github.com/ArilNEA/ChatGPT-Admin-Web',
4+
link: 'https://github.com/AprilNEA/ChatGPT-Admin-Web',
55
},
66
sidebar: {
77
defaultMenuCollapseLevel: 1,

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"scripts": {
1717
"build": "turbo run build",
1818
"dev": "turbo run dev --parallel",
19+
"start": "turbo run start",
1920
"lint": "turbo run lint",
2021
"prettier": "prettier --write .",
2122
"db:init": "prisma db push && prisma db seed",
@@ -28,7 +29,7 @@
2829
"ts-node": "latest",
2930
"turbo": "latest",
3031
"typescript": "latest",
31-
"prisma": "5.5.2"
32+
"prisma": "5.6.0"
3233
},
3334
"prisma": {
3435
"schema": "prisma/schema.prisma",
@@ -39,10 +40,12 @@
3940
},
4041
"pnpm": {
4142
"overrides": {
42-
"nestjs-prisma>@prisma/client": "workspace:@nest-http/prisma@*",
4343
"@liaoliaots/nestjs-redis>@nestjs/common": "^10.0.0",
4444
"@liaoliaots/nestjs-redis>@nestjs/core": "^10.0.0",
4545
"@liaoliaots/nestjs-redis>@nestjs/terminus": "^10.0.0"
46+
},
47+
"allowedDeprecatedVersions": {
48+
"sourcemap-codec": "1.4.8"
4649
}
4750
},
4851
"packageManager": "[email protected]"

packages/backend/src/app.module.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { CustomPrismaModule } from 'nestjs-prisma';
22

3-
import { RedisModule } from '@liaoliaots/nestjs-redis';
3+
import { RedisModule, RedisModuleOptions } from '@liaoliaots/nestjs-redis';
44
import { Module } from '@nestjs/common';
55
import { APP_GUARD } from '@nestjs/core';
66

7-
import { ConfigModule } from '@/common/config';
7+
import { ConfigModule, ConfigService } from '@/common/config';
88
import { AuthGuard } from '@/common/guards/auth.guard';
99
import { JwtModule } from '@/libs/jwt/jwt.module';
1010
import { AuthModule } from '@/modules/auth/auth.module';
@@ -26,9 +26,18 @@ import { AppService } from './app.service';
2626
useClass: ExtendedPrismaConfigService,
2727
isGlobal: true,
2828
}),
29-
RedisModule.forRoot({
30-
config: {
31-
url: process.env.REDIS_URL,
29+
RedisModule.forRootAsync({
30+
imports: [ConfigModule],
31+
inject: [ConfigService],
32+
useFactory: async (
33+
configService: ConfigService,
34+
): Promise<RedisModuleOptions> => {
35+
return {
36+
readyLog: true,
37+
config: {
38+
url: configService.get('redis')?.url ?? process.env.REDIS_URL,
39+
},
40+
};
3241
},
3342
}),
3443
AuthModule,

packages/backend/src/common/config/config.service.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,7 @@ import { join } from 'path';
33

44
import { Injectable } from '@nestjs/common';
55

6-
import { BizException } from '@/common/exceptions/biz.exception';
7-
86
import { ConfigType, ISettingSchema } from 'shared';
9-
import { ErrorCodeEnum } from 'shared/dist/error-code';
10-
11-
const DEFAULT_CONFIG = {
12-
mode: 'nginx',
13-
title: 'ChatGPT Admin Web',
14-
port: {
15-
frontend: 3000,
16-
backend: 3001,
17-
},
18-
jwt: {
19-
algorithm: 'HS256',
20-
},
21-
};
227

238
const CONFIG_SCHEMA: ISettingSchema[] = [
249
{
@@ -82,15 +67,18 @@ const CONFIG_SCHEMA: ISettingSchema[] = [
8267
@Injectable()
8368
export class ConfigService {
8469
private config: ConfigType;
85-
private readonly defaultConfig = DEFAULT_CONFIG;
8670
private readonly configFilePath = join(__dirname, '../../../config.json');
8771

8872
constructor() {
8973
this.loadConfig();
9074
}
9175

9276
private loadConfig(): void {
93-
this.config = JSON.parse(fs.readFileSync(this.configFilePath, 'utf8'));
77+
if (fs.existsSync(this.configFilePath)) {
78+
this.config = JSON.parse(fs.readFileSync(this.configFilePath, 'utf8'));
79+
} else {
80+
console.error('配置文件缺失。\nConfiguration file is missing.');
81+
}
9482
}
9583

9684
/* 获取配置文件结构 */

packages/backend/src/common/exceptions/biz.exception.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { HttpException } from '@nestjs/common';
22

3-
import { ErrorCodeEnum } from 'shared/dist/error-code';
3+
import { ErrorCodeEnum } from 'shared';
44

55
export const ErrorCode = Object.freeze<
66
Record<ErrorCodeEnum, [string, string, number]>
@@ -84,7 +84,9 @@ export const ErrorCode = Object.freeze<
8484
[ErrorCodeEnum.DatabaseError]: ['Database error', '数据库错误', 500],
8585
[ErrorCodeEnum.RedisError]: ['Redis error', 'Redis错误', 500],
8686
[ErrorCodeEnum.EmailError]: ['Email error', '邮件错误', 500],
87+
[ErrorCodeEnum.EmailNotSetup]: ['Email not setup', '邮件未设置', 500],
8788
[ErrorCodeEnum.SmsError]: ['Sms error', '短信错误', 500],
89+
[ErrorCodeEnum.SmsNotSetup]: ['Sms not setup', '短信未设置', 500],
8890
[ErrorCodeEnum.WechatError]: ['Wechat error', '微信错误', 500],
8991
[ErrorCodeEnum.UnknownError]: ['Unknown error', '未知错误', 500],
9092
});

0 commit comments

Comments
 (0)