diff --git a/alembic/versions/055_cover_templates.py b/alembic/versions/055_cover_templates.py index e1a9df1c2..f126c255a 100644 --- a/alembic/versions/055_cover_templates.py +++ b/alembic/versions/055_cover_templates.py @@ -22,14 +22,14 @@ branch_labels = None depends_on = None SYSTEM_TEMPLATES = [ - ("sys_default", "默认模板", {}), - ("sys_bold_red", "大胆红", {"background_color": "#ef4444"}), - ("sys_elegant_black", "优雅黑", {"background_color": "#111827"}), - ("sys_gradient_blue", "渐变蓝", {"background_color": "#3b82f6"}), - ("sys_gradient_purple", "渐变紫", {"background_color": "#8b5cf6"}), - ("sys_warm_orange", "暖橙", {"background_color": "#f97316"}), - ("sys_fresh_green", "清新绿", {"background_color": "#22c55e"}), - ("sys_tech_blue", "科技蓝", {"background_color": "#06b6d4"}), + ("a8b0120fd98e44788f5a6590f983d327", "默认模板", {}), + ("6d8c501b11424432b3df3a45ae89b1a9", "大胆红", {"background_color": "#ef4444"}), + ("04937fb57fea4bad95e7883e71a6b246", "优雅黑", {"background_color": "#111827"}), + ("3ff9cc821174437ca53931073e7f536e", "渐变蓝", {"background_color": "#3b82f6"}), + ("db51b3ea8f1a4f4caa94bf2d51f27d11", "渐变紫", {"background_color": "#8b5cf6"}), + ("5027d113432a4f798a3b4ee1644d66af", "暖橙", {"background_color": "#f97316"}), + ("0e10def2b5a148d686416494474726c2", "清新绿", {"background_color": "#22c55e"}), + ("38ea98ac00c04bada064006d880546f0", "科技蓝", {"background_color": "#06b6d4"}), ] diff --git a/apps/web/src/pages/generate/constants.ts b/apps/web/src/pages/generate/constants.ts index 703c3244d..74761b615 100644 --- a/apps/web/src/pages/generate/constants.ts +++ b/apps/web/src/pages/generate/constants.ts @@ -2,7 +2,7 @@ * 智能剪辑页面 — 常量定义 */ -import type { CoverConfig, CoverTemplate } from "../editing-planner/types" +import type { CoverConfig } from "../editing-planner/types" /* ── 克隆声音状态配置 ── */ export const CLONE_STATUS_CONFIG: Record = { @@ -199,39 +199,3 @@ export const DEFAULT_COVER_SETTINGS: CoverConfig = { thumbnail_url: "", } -/* ── Mock 封面模板数据 ── */ - -export const MOCK_COVER_TEMPLATES: CoverTemplate[] = [ - { id: "default", name: "默认模板", thumbnail_url: "", is_system: true, created_at: "2026-08-01" }, - { id: "bold-red", name: "大胆红", thumbnail_url: "", is_system: true, created_at: "2026-08-01" }, - { - id: "elegant-black", - name: "优雅黑", - thumbnail_url: "", - is_system: true, - created_at: "2026-08-01", - }, - { - id: "gradient-blue", - name: "渐变蓝", - thumbnail_url: "", - is_system: true, - created_at: "2026-08-01", - }, - { - id: "gradient-purple", - name: "渐变紫", - thumbnail_url: "", - is_system: true, - created_at: "2026-08-01", - }, - { id: "warm-orange", name: "暖橙", thumbnail_url: "", is_system: true, created_at: "2026-08-01" }, - { - id: "fresh-green", - name: "清新绿", - thumbnail_url: "", - is_system: true, - created_at: "2026-08-01", - }, - { id: "tech-blue", name: "科技蓝", thumbnail_url: "", is_system: true, created_at: "2026-08-01" }, -] diff --git a/packages/adapters/in_memory/cover_template_repository.py b/packages/adapters/in_memory/cover_template_repository.py index 793511c26..b42659886 100644 --- a/packages/adapters/in_memory/cover_template_repository.py +++ b/packages/adapters/in_memory/cover_template_repository.py @@ -19,7 +19,7 @@ class InMemoryCoverTemplateRepository: def list_for_user(self, user_id: str, skip: int = 0, limit: int = 100) -> list[CoverTemplate]: """列出系统模板 + 用户自己的模板。""" visible = [t for t in self._templates.values() if t.is_system or t.user_id == user_id] - visible.sort(key=lambda t: (not t.is_system, t.created_at), reverse=True) + visible.sort(key=lambda t: (t.is_system, t.created_at), reverse=True) return visible[skip : skip + limit] def count_for_user(self, user_id: str) -> int: diff --git a/tests/unit/test_cover_templates_crud.py b/tests/unit/test_cover_templates_crud.py index 2506ec8a2..c6a61c80c 100644 --- a/tests/unit/test_cover_templates_crud.py +++ b/tests/unit/test_cover_templates_crud.py @@ -170,7 +170,7 @@ class TestCoverTemplateAPIPermissions: mock_repo.get.return_value = tpl # 模拟 API 路由中的权限检查逻辑 - template = mock_repo.get("sys_default") + template = mock_repo.get("a8b0120fd98e44788f5a6590f983d327") assert template is not None assert template.is_system is True # 权限检查应该阻止删除 @@ -184,7 +184,7 @@ class TestCoverTemplateAPIPermissions: mock_repo = MagicMock() mock_repo.get.return_value = tpl - template = mock_repo.get("sys_default") + template = mock_repo.get("a8b0120fd98e44788f5a6590f983d327") assert template.is_system is True with pytest.raises(PermissionError): if template.is_system: