feat: 现代化翻页组件 + 完整项目更新

- 新增 Pagination 通用组件:首页/上一页/页码/下一页/末页导航
- PickModal 和 SwapModal 集成分页功能,每页20项
- 搜索/筛选切换自动回到第1页
- 现代化CSS样式:hover浮起动效、主色高亮、移动端适配
- 新增 dashboard、admin 管理模板
- 菜系(cuisine)模型和迁移
- 构建脚本 build.py 支持 PyInstaller 打包
- 前端资源重新构建
This commit is contained in:
Chunyu
2026-08-28 13:44:21 +08:00
parent 65b52b052f
commit d7553520ce
51 changed files with 4318 additions and 441 deletions
+25 -31
View File
@@ -10,6 +10,7 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/6.0/ref/settings/
"""
import sys
from pathlib import Path
import os
@@ -76,54 +77,44 @@ WSGI_APPLICATION = 'config.wsgi.application'
# Database
# https://docs.djangoproject.com/en/6.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.environ.get('DJANGO_DB_PATH', str(BASE_DIR / 'db.sqlite3')),
'NAME': os.environ.get(
'DJANGO_DB_PATH',
str(os.path.join(os.path.dirname(sys.executable), 'db.sqlite3') if getattr(sys, 'frozen', False) else BASE_DIR / 'db.sqlite3')
),
}
}
# Password validation
# https://docs.djangoproject.com/en/6.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
{'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'},
{'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator'},
{'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator'},
{'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator'},
]
# Internationalization
# https://docs.djangoproject.com/en/6.0/topics/i18n/
LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'Asia/Shanghai'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/6.0/howto/static-files/
STATIC_URL = os.environ.get('DJANGO_STATIC_URL', '/xx/admin/')
STATIC_URL = os.environ.get('DJANGO_STATIC_URL', '/static/')
STATIC_ROOT = BASE_DIR / 'staticfiles'
STATICFILES_DIRS = [BASE_DIR / 'static']
# When frozen by PyInstaller, bundled files live in sys._MEIPASS
_frozen = getattr(sys, 'frozen', False)
if _frozen:
_bundled = sys._MEIPASS
# In frozen mode, static files are at _MEIPASS/backend/static
_be_static = os.path.join(_bundled, 'backend', 'static')
if os.path.isdir(_be_static) and _be_static not in [os.path.normpath(d) for d in STATICFILES_DIRS]:
STATICFILES_DIRS.append(_be_static)
CORS_ALLOWED_ORIGINS = [
'http://localhost:5173',
'http://127.0.0.1:5173',
@@ -149,8 +140,8 @@ JAZZMIN_SETTINGS = {
'site_title': '学校订餐菜单管理系统',
'site_header': '学校订餐菜单生成器',
'site_brand': '订餐菜单管理',
'site_icon': 'frontend/icon_512.png',
'welcome_sign': '欢迎使用学校订餐菜单管理系统',
'copyright': '上海外国语大学附属宝山双语学校',
'search_model': ['meals.Dish', 'auth.User'],
'show_sidebar': True,
'navigation_expanded': True,
@@ -169,7 +160,6 @@ JAZZMIN_SETTINGS = {
'custom_css': None,
'custom_js': None,
'theme': 'flatly',
'dark_mode_theme': 'darkly',
'header_classes': 'bg-primary',
'order_with_respect_to': ['meals', 'auth'],
}
@@ -195,6 +185,10 @@ JAZZMIN_UI_TWEAKS = {
'sidebar_nav_legacy_style': False,
'sidebar_nav_flat_style': False,
'theme': 'flatly',
'dark_mode_theme': 'darkly',
'button_classes': {'primary': 'btn-outline-primary', 'secondary': 'btn-outline-secondary', 'info': 'btn-outline-info', 'warning': 'btn-outline-warning', 'danger': 'btn-outline-danger', 'success': 'btn-outline-success'},
}
LOGIN_REDIRECT_URL = '/admin/'
LOGOUT_REDIRECT_URL = '/admin/login/'