perf: 性能与资源优化 - 提取内联资源、数据库查询优化、限流与缓存增强
主要优化: - templates/index.html: 220KB → 28KB,内联CSS/JS提取为静态文件 - menu/serializers.py: 修复 Order.ingredients_summary N+1 查询问题 - menu/services/dish_service.py: 移除多余查询,添加 only() 限制字段 - menu/views.py: 上传接口添加每分钟20次限流 - static/js/api.js: 统一API错误处理 - zhangmenu/settings.py: 添加Whitenoise压缩、Redis缓存支持、环境变量配置 - static/css/app.css, static/js/app.js: 提取的内联资源文件 - 新增 migrations, requirements.txt, .env.example Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
f1994c869d
commit
94647e2b4b
@@ -0,0 +1,39 @@
|
||||
# Generated by Django 5.2.11 on 2026-03-19 05:59
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('menu', '0006_order_images'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='order',
|
||||
name='party_date',
|
||||
field=models.DateTimeField(blank=True, db_index=True, null=True, verbose_name='聚会时间'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='order',
|
||||
name='status',
|
||||
field=models.CharField(choices=[('in_progress', '进行中'), ('completed', '已完成')], db_index=True, default='in_progress', max_length=20, verbose_name='状态'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='dish',
|
||||
index=models.Index(fields=['name'], name='menu_dish_name_6ad09b_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='dish',
|
||||
index=models.Index(fields=['-created_at'], name='menu_dish_created_8b2b23_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='order',
|
||||
index=models.Index(fields=['status', '-created_at'], name='menu_order_status_7e2ff4_idx'),
|
||||
),
|
||||
migrations.AddIndex(
|
||||
model_name='order',
|
||||
index=models.Index(fields=['party_date'], name='menu_order_party_d_e06c2c_idx'),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.2.11 on 2026-03-19 06:04
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('menu', '0007_add_indexes'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='order',
|
||||
name='status',
|
||||
field=models.CharField(choices=[('in_progress', '进行中'), ('completed', '已完成')], default='in_progress', max_length=20, verbose_name='状态'),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user