This commit is contained in:
flower_linux
2026-05-20 16:31:07 +08:00
parent a65cb05d5d
commit 6cc3fdf411
34 changed files with 126 additions and 125 deletions

View File

@@ -145,7 +145,6 @@ class ConfigAdmin(admin.ModelAdmin):
list_display = (
"site_title",
"together_since",
"bgm_enabled",
"unlock_at",
)
list_display_links = ("site_title",)
@@ -155,17 +154,13 @@ class ConfigAdmin(admin.ModelAdmin):
{"fields": ("site_title",)},
),
(
"时间与音乐",
"时间",
{
"fields": (
"together_since",
"bgm_enabled",
"unlock_at",
),
"description": (
"「在一起」时间用于首页计数。顶部网易云播放器在前端 .env 的 "
"VITE_NETEASE_PLAYER_SRC 配置。unlock_at 已不使用,可留空。"
),
"description": "「在一起」时间用于首页计数。unlock_at 已不使用,可留空。",
},
),
)

View File

@@ -0,0 +1,15 @@
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('journal', '0006_memory_photo'),
]
operations = [
migrations.RemoveField(
model_name='config',
name='bgm_enabled',
),
]

View File

@@ -123,10 +123,6 @@ class Config(models.Model):
null=True,
help_text="用于首页「我们在一起多少天多少秒」的起点(建议为正式在一起的时刻,含时区)。",
)
bgm_enabled = models.BooleanField(
default=True,
help_text="是否展示顶部音乐区(播放器地址在前端环境变量 VITE_NETEASE_PLAYER_SRC 配置)。",
)
site_title = models.CharField(
max_length=120,
default="Nepal Journey: Our Story",

View File

@@ -1,97 +0,0 @@
# 手账站开发与运行
## 访问地址
| 环境 | 手账站 | 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
```

View File

@@ -35,12 +35,10 @@ class StatusView(APIView):
config = Config.objects.filter(pk=1).first()
if config is None:
bgm_enabled = True
site_title = "Nepal Journey: Our Story"
together_since = default_together
unlock_at = None
else:
bgm_enabled = config.bgm_enabled
site_title = config.site_title or "Nepal Journey: Our Story"
ts = config.together_since
if ts is None:
@@ -63,7 +61,6 @@ class StatusView(APIView):
"unlocked": True,
"unlock_at": unlock_at,
"together_since": together_since,
"bgm_enabled": bgm_enabled,
"site_title": site_title,
}
)