- Django backend with projects, templates, exports apps - SQLite database models for Project, Asset, CardLayer - REST API endpoints for project management - Vue frontend with Vite, Element Plus, Fabric.js - Home page for project selection - Editor page with Fabric.js canvas integration
39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
from django.db import models
|
||
import uuid
|
||
|
||
class CardTemplate(models.Model):
|
||
"""扑克牌模板模型"""
|
||
id = models.CharField(max_length=50, primary_key=True) # 'classic', 'modern', etc.
|
||
name = models.CharField(max_length=100)
|
||
description = models.TextField()
|
||
preview_image = models.ImageField(upload_to='templates/previews/', null=True)
|
||
|
||
# 默认配色方案
|
||
color_spade = models.CharField(max_length=20, default='#000000')
|
||
color_heart = models.CharField(max_length=20, default='#FF0000')
|
||
color_club = models.CharField(max_length=20, default='#000000')
|
||
color_diamond = models.CharField(max_length=20, default='#FF0000')
|
||
color_background = models.CharField(max_length=20, default='#FFFFFF')
|
||
|
||
# 默认素材路径(JSON)
|
||
default_assets = models.JSONField(default=dict)
|
||
|
||
created_at = models.DateTimeField(auto_now_add=True)
|
||
|
||
def __str__(self):
|
||
return self.name
|
||
|
||
class Meta:
|
||
ordering = ['name']
|
||
|
||
|
||
class SuitSymbol(models.Model):
|
||
"""花色图案模板"""
|
||
template = models.ForeignKey(CardTemplate, on_delete=models.CASCADE, related_name='suit_symbols')
|
||
suit_name = models.CharField(max_length=20) # 'spade', 'heart', 'club', 'diamond'
|
||
svg_path = models.TextField() # SVG路径数据
|
||
color = models.CharField(max_length=20)
|
||
|
||
def __str__(self):
|
||
return f"{self.template.name} - {self.suit_name}"
|