Files
mwy/backend/journal/readme.md
flowerstonezl 4ae691bfb4 story update
2026-05-18 20:59:00 +08:00

98 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 手账站开发与运行
## 访问地址
| 环境 | 手账站 | Django Admin |
|------|--------|----------------|
| 本地开发 | http://localhost:5173 | http://localhost:8000/admin/ |
| Docker | http://localhost:8080 | http://localhost:8000/admin/ |
---
## 本地开发(推荐)
前后端各开一个终端。前端 Vite 会把 `/api``/media` 代理到 `http://127.0.0.1:8000`,需先启动后端。
### 后端Django
在项目根目录 `mwy` 下:
```powershell
cd backend
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
python manage.py migrate
python manage.py runserver
```
首次使用 Admin 可创建超级用户:
```powershell
python manage.py createsuperuser
```
导入示例时间线数据(会清空现有 `Memory` 记录):
```powershell
python manage.py seed_nepal_story
```
### 前端Vue + Vite
另开终端,在项目根目录下:
```powershell
cd frontend
npm install
npm run dev
```
浏览器打开 Vite 提示的地址(默认 http://localhost:5173
可选:指定 API 地址(一般不必,默认走代理 `/api`
```powershell
# .env 或 .env.local
# VITE_API_BASE_URL=http://127.0.0.1:8000/api
```
### 生产构建预览(可选)
```powershell
cd frontend
npm run build
npm run preview
```
---
## Docker 一键启动
在项目根目录:
```powershell
docker compose up --build
```
- 手账站http://localhost:8080
- Adminhttp://localhost:8000/admin/
数据与媒体挂在 Docker 卷 `backend_data`SQLite、`media`)。
---
## 常用命令速查
```powershell
# 后端目录 backend/ 下,且已激活虚拟环境
python manage.py migrate
python manage.py runserver
python manage.py seed_nepal_story
python manage.py createsuperuser
# 前端目录 frontend/ 下
npm run dev
npm run build
```