From f4b834840ac29de81b9eba6cca0cbc00efa473b5 Mon Sep 17 00:00:00 2001 From: Developer Date: Mon, 1 Jun 2026 17:21:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=EF=BC=9A=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E6=97=A7management=E7=9B=AE=E5=BD=95=EF=BC=88=E6=97=A7?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/apps/__init__.py | 1 - backend/apps/management/__init__.py | 1 - backend/apps/management/commands/__init__.py | 1 - .../apps/management/commands/init_system.py | 145 ------------------ 4 files changed, 148 deletions(-) delete mode 100644 backend/apps/__init__.py delete mode 100644 backend/apps/management/__init__.py delete mode 100644 backend/apps/management/commands/__init__.py delete mode 100644 backend/apps/management/commands/init_system.py diff --git a/backend/apps/__init__.py b/backend/apps/__init__.py deleted file mode 100644 index 8eac5c8..0000000 --- a/backend/apps/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# apps/__init__.py \ No newline at end of file diff --git a/backend/apps/management/__init__.py b/backend/apps/management/__init__.py deleted file mode 100644 index a693ec4..0000000 --- a/backend/apps/management/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# management/__init__.py \ No newline at end of file diff --git a/backend/apps/management/commands/__init__.py b/backend/apps/management/commands/__init__.py deleted file mode 100644 index 61f42e0..0000000 --- a/backend/apps/management/commands/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# management/commands/__init__.py \ No newline at end of file diff --git a/backend/apps/management/commands/init_system.py b/backend/apps/management/commands/init_system.py deleted file mode 100644 index c07b8ad..0000000 --- a/backend/apps/management/commands/init_system.py +++ /dev/null @@ -1,145 +0,0 @@ -import os -from django.core.management.base import BaseCommand -from django.core.files.storage import default_storage -from apps.projects.models import Project, Asset, CardLayer -from apps.templates.models import CardTemplate - - -class Command(BaseCommand): - help = 'Initialize cards design system with sample data' - - def handle(self, *args, **options): - self.stdout.write(self.style.SUCCESS('Starting initialization...')) - - # 创建模板和数据 - self.create_templates() - self.create_default_assets() - self.create_sample_project() - - self.stdout.write(self.style.SUCCESS('Initialization complete!')) - - def create_templates(self): - """创建示例模板""" - templates = [ - { - 'id': 'classic', - 'name': '经典风格', - 'description': '标准扑克牌设计,传统花色和字体', - 'color_spade': '#000000', - 'color_heart': '#FF0000', - 'color_club': '#000000', - 'color_diamond': '#FF0000', - 'color_background': '#FFFFFF', - }, - { - 'id': 'modern', - 'name': '现代简约', - 'description': '扁平化设计,简洁线条', - 'color_spade': '#333333', - 'color_heart': '#E53935', - 'color_club': '#333333', - 'color_diamond': '#E53935', - 'color_background': '#FAFAFA', - } - ] - - for template_data in templates: - try: - template = CardTemplate.objects.get(id=template_data['id']) - if not template.default_assets: - template.default_assets = template_data - template.save() - except CardTemplate.DoesNotExist: - template = CardTemplate.objects.create( - id=template_data['id'], - name=template_data['name'], - description=template_data['description'], - color_spade=template_data['color_spade'], - color_heart=template_data['color_heart'], - color_club=template_data['color_club'], - color_diamond=template_data['color_diamond'], - color_background=template_data['color_background'], - default_assets=template_data - ) - - def create_default_assets(self): - """创建默认花色素材""" - suits = { - 'spade': 0xE27B60, - 'heart': 0xE27B60, - 'club': 0xE27B60, - 'diamond': 0xE27B60 - } - - materials = 'backend/media/assets' - os.makedirs(materials, exist_ok=True) - - for suit_name, color_code in suits.items(): - # 创建简单SVG花色图案 - svg_path = os.path.join('backend/media/assets', f'{suit_name}.svg') - - storyboardSVG = ''' - - - - ^ -''' - - with open(svg_path, 'w', encoding='utf-8') as f: - f.write(storyboardSVG) - - # 创建Asset记录 - Asset.objects.create( - asset_type='suit_symbol', - asset_key=suit_name, - color=f'#{color_code:06X}' - ) - - def create_sample_project(self): - """创建示例项目""" - try: - project = Project.objects.get(name="示例项目") - self.stdout.write(self.style.WARNING('示例项目已存在,跳过创建')) - return - except Project.DoesNotExist: - project = Project.objects.create( - name="示例项目", - template_id='classic', - card_width=750, - card_height=1050, - export_resolution='standard', - export_include_back=True - ) - - # 创建示例素材 - suit_assets = [ - {'type': 'suit_symbol', 'key': 'spade'}, - {'type': 'suit_symbol', 'key': 'heart'}, - {'type': 'suit_symbol', 'key': 'club'}, - {'type': 'suit_symbol', 'key': 'diamond'}, - ] - - for asset_data in suit_assets: - Asset.objects.create( - asset_type=asset_data['type'], - asset_key=asset_data['key'], - width=60, - height=60 - ) - - # 创建JQK示例素材记录(临时) - face_cards = [ - {'type': 'face_card', 'key': 'spade-J'}, - {'type': 'face_card', 'key': 'spade-Q'}, - {'type': 'face_card', 'key': 'spade-K'}, - ] - - for face_card in face_cards: - Asset.objects.create( - asset_type=face_card['type'], - asset_key=face_card['key'], - width=300, - height=500 - ) - - self.stdout.write(self.style.SUCCESS(f'项目 "{project.name}" 已创建'))