06ec0ee202
后端: - 新增 BGM 数据库模型、Schema、CRUD、API 路由 - BgmMusic 增加 url 字段存储七牛云地址 - Alembic 迁移: 创建 BGM 表 + 添加 url 字段 - import_bgm.py 导入时自动上传七牛云 (meijiaka-zy/bgm/...) 前端: - VideoCompose BGM 选择改为卡片弹窗 (系统BGM + 本地上传) - 去掉 BGM 硬编码本地路径, 直接使用云端 URL - CoverDesign 视觉重构: 绿色边框卡片、角标、hover 遮罩 - CoverDesign 去掉预选背景, 默认空白需手动选择 - 所有步骤按钮规范统一: 左=重新生成(主色), 右=导出/预览(次色) - 预览按钮状态统一: 文字变为'视频预览中...', 保持 btn-secondary - 去掉所有步骤按钮的 svg/emoji 图标 Rust: - mix_bgm_to_video 支持临时文件保护 (输入输出同路径时自动中转) - FFmpeg BGM 混合使用 aloop 循环 + amix 滤镜
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
"""
|
|
背景音乐 API
|
|
===========
|
|
|
|
提供装修行业场景化 BGM 列表查询。
|
|
"""
|
|
|
|
from fastapi import APIRouter, Depends, Query
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.api.deps import get_db
|
|
from app.crud.bgm_music import bgm_music
|
|
from app.schemas.bgm_music import BgmMusicItem, BgmMusicListResponse
|
|
from app.schemas.common import ApiResponse
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("/bgm-musics", response_model=ApiResponse[BgmMusicListResponse])
|
|
async def list_bgm_musics(
|
|
category: str | None = Query(None, description="场景分类筛选"),
|
|
db: AsyncSession = Depends(get_db),
|
|
) -> ApiResponse[BgmMusicListResponse]:
|
|
"""
|
|
获取背景音乐列表
|
|
|
|
按场景分类返回可用的背景音乐列表。
|
|
分类说明:
|
|
- knowledge: 知识科普(极简、低频)
|
|
- showcase: 案例展示(积极、有成就感)
|
|
- promotion: 促销活动(轻快、有能量)
|
|
- lifestyle: 家居生活(温馨、治愈)
|
|
- tech: 智能家居(科技感、高级感)
|
|
"""
|
|
items = await bgm_music.get_active_by_category(db, category=category)
|
|
return ApiResponse(
|
|
code=200,
|
|
message="success",
|
|
data=BgmMusicListResponse(
|
|
items=[BgmMusicItem.model_validate(item) for item in items],
|
|
total=len(items),
|
|
),
|
|
)
|