mirror of
https://github.com/handsomezhuzhu/QQuiz.git
synced 2026-04-18 22:42:53 +00:00
refactor: remove legacy frontend code and implement new Next.js structure
- Deleted the old Register page and utility functions. - Removed Tailwind CSS configuration and Vite configuration files. - Added a new script for starting a single container with FastAPI and Next.js. - Updated README to reflect the current status of the Next.js frontend. - Implemented new login and registration API routes with improved error handling. - Refactored frontend API calls to use the new proxy structure. - Enhanced error handling in API response processing. - Updated components to align with the new API endpoints and structure.
This commit is contained in:
94
README.md
94
README.md
@@ -16,7 +16,9 @@ QQuiz 是一个用于题库导入、刷题训练和错题管理的全栈应用
|
||||
|
||||
## 快速开始
|
||||
|
||||
### 方式一:直接运行 GitHub Actions 构建好的镜像
|
||||
QQuiz 默认以单容器形式发布和部署。GitHub Actions 只构建根目录 `Dockerfile` 生成的单容器镜像,README 也以这个路径为主。
|
||||
|
||||
### 方式一:直接运行 GitHub Actions 构建好的单容器镜像
|
||||
|
||||
适合只想快速启动,不想先克隆仓库。
|
||||
|
||||
@@ -58,58 +60,61 @@ GEMINI_API_KEY=your-real-gemini-api-key
|
||||
#### 3. 拉取镜像
|
||||
|
||||
```bash
|
||||
docker pull ghcr.io/handsomezhuzhu/qquiz-backend:latest
|
||||
docker pull ghcr.io/handsomezhuzhu/qquiz-frontend:latest
|
||||
docker pull ghcr.io/handsomezhuzhu/qquiz:latest
|
||||
```
|
||||
|
||||
#### 4. 创建网络和数据卷
|
||||
#### 4. 创建数据卷
|
||||
|
||||
```bash
|
||||
docker network create qquiz_net
|
||||
docker volume create qquiz_sqlite_data
|
||||
docker volume create qquiz_upload_files
|
||||
docker volume create qquiz_data
|
||||
docker volume create qquiz_uploads
|
||||
```
|
||||
|
||||
#### 5. 启动后端
|
||||
#### 5. 启动容器
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
--name qquiz_backend \
|
||||
--network qquiz_net \
|
||||
--name qquiz \
|
||||
--env-file .env \
|
||||
-e DATABASE_URL=sqlite+aiosqlite:////app/data/qquiz.db \
|
||||
-e UPLOAD_DIR=/app/uploads \
|
||||
-v qquiz_sqlite_data:/app/data \
|
||||
-v qquiz_upload_files:/app/uploads \
|
||||
-v qquiz_data:/app/data \
|
||||
-v qquiz_uploads:/app/uploads \
|
||||
-p 8000:8000 \
|
||||
ghcr.io/handsomezhuzhu/qquiz-backend:latest
|
||||
```
|
||||
|
||||
#### 6. 启动前端
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
--name qquiz_frontend \
|
||||
--network qquiz_net \
|
||||
-e API_BASE_URL=http://qquiz_backend:8000 \
|
||||
-p 3000:3000 \
|
||||
ghcr.io/handsomezhuzhu/qquiz-frontend:latest
|
||||
--restart unless-stopped \
|
||||
ghcr.io/handsomezhuzhu/qquiz:latest
|
||||
```
|
||||
|
||||
访问:
|
||||
|
||||
- 前端:`http://localhost:3000`
|
||||
- 后端:`http://localhost:8000`
|
||||
- 应用:`http://localhost:8000`
|
||||
- API 文档:`http://localhost:8000/docs`
|
||||
|
||||
停止:
|
||||
|
||||
```bash
|
||||
docker rm -f qquiz_frontend qquiz_backend
|
||||
docker rm -f qquiz
|
||||
```
|
||||
|
||||
### 方式二:从源码用 Docker Compose 启动
|
||||
### 方式二:从源码启动单容器
|
||||
|
||||
#### 前后端分离,推荐
|
||||
适合需要自行构建镜像或修改代码后再部署。
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
docker compose -f docker-compose-single.yml up -d --build
|
||||
```
|
||||
|
||||
访问:
|
||||
|
||||
- 应用:`http://localhost:8000`
|
||||
- API 文档:`http://localhost:8000/docs`
|
||||
|
||||
### 可选:开发或兼容性部署
|
||||
|
||||
以下方式保留用于开发调试或兼容场景,不再作为默认部署方案:
|
||||
|
||||
#### 前后端分离开发栈
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
@@ -121,24 +126,14 @@ docker compose up -d --build
|
||||
- 前端:`http://localhost:3000`
|
||||
- 后端:`http://localhost:8000`
|
||||
|
||||
#### 使用 MySQL
|
||||
#### 分离栈叠加 MySQL
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
docker compose -f docker-compose.yml -f docker-compose.mysql.yml up -d --build
|
||||
```
|
||||
|
||||
#### 单容器模式
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
docker compose -f docker-compose-single.yml up -d --build
|
||||
```
|
||||
|
||||
访问:
|
||||
|
||||
- 应用:`http://localhost:8000`
|
||||
- API 文档:`http://localhost:8000/docs`
|
||||
MySQL 相关说明见 [docs/MYSQL_SETUP.md](docs/MYSQL_SETUP.md)。
|
||||
|
||||
## 本地开发
|
||||
|
||||
@@ -163,8 +158,8 @@ npm run dev
|
||||
|
||||
说明:
|
||||
|
||||
- `web/` 是当前主前端,基于 Next.js
|
||||
- `frontend/` 是保留中的旧 Vite 前端,主要用于单容器兼容路径
|
||||
- `web/` 是唯一前端工程,基于 Next.js
|
||||
- 单容器镜像会在同一个容器里运行 FastAPI 和 Next.js,并由 FastAPI 代理前端请求
|
||||
|
||||
## 关键环境变量
|
||||
|
||||
@@ -191,14 +186,13 @@ npm run dev
|
||||
```text
|
||||
QQuiz/
|
||||
├─ backend/ FastAPI 后端
|
||||
├─ web/ Next.js 前端
|
||||
├─ frontend/ Legacy Vite 前端
|
||||
├─ web/ Next.js 前端工程
|
||||
├─ docs/ 文档与截图
|
||||
├─ test_data/ 示例题库文件
|
||||
├─ docker-compose.yml 前后端分离部署
|
||||
├─ docker-compose.mysql.yml MySQL overlay
|
||||
├─ docker-compose-single.yml 单容器部署
|
||||
└─ Dockerfile 单容器镜像构建
|
||||
├─ docker-compose-single.yml 单容器部署(默认)
|
||||
├─ Dockerfile 单容器镜像构建(默认)
|
||||
├─ docker-compose.yml 前后端分离开发/兼容部署
|
||||
└─ docker-compose.mysql.yml MySQL overlay(可选)
|
||||
```
|
||||
|
||||
## 技术栈
|
||||
@@ -210,7 +204,7 @@ QQuiz/
|
||||
|
||||
```bash
|
||||
cd web && npm run build
|
||||
docker compose build backend frontend
|
||||
docker compose -f docker-compose-single.yml build
|
||||
```
|
||||
|
||||
建议至少手动验证:
|
||||
|
||||
Reference in New Issue
Block a user