feat: 现代化翻页组件 + 完整项目更新
- 新增 Pagination 通用组件:首页/上一页/页码/下一页/末页导航 - PickModal 和 SwapModal 集成分页功能,每页20项 - 搜索/筛选切换自动回到第1页 - 现代化CSS样式:hover浮起动效、主色高亮、移动端适配 - 新增 dashboard、admin 管理模板 - 菜系(cuisine)模型和迁移 - 构建脚本 build.py 支持 PyInstaller 打包 - 前端资源重新构建
This commit is contained in:
+54
-16
@@ -1,23 +1,61 @@
|
||||
"""
|
||||
URL configuration for config project.
|
||||
import os
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/6.0/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import include, path
|
||||
from django.http import HttpResponseNotFound
|
||||
from django.urls import include, path, re_path
|
||||
from django.views.generic import RedirectView, TemplateView
|
||||
from django.views.static import serve as static_serve
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from meals.views_spa import spa_serve
|
||||
from meals.views_dashboard import dashboard_api
|
||||
from meals.views_spa import _get_frontend_dir
|
||||
|
||||
|
||||
def _serve_fe_assets(request, path=''):
|
||||
"""Serve built React assets (JS/CSS) from the frontend directory."""
|
||||
fdir = _get_frontend_dir()
|
||||
rel = os.path.join('assets', path)
|
||||
target = os.path.normpath(os.path.join(fdir, rel))
|
||||
if target.startswith(os.path.normpath(fdir)) and os.path.isfile(target):
|
||||
return static_serve(request, rel, document_root=fdir)
|
||||
return HttpResponseNotFound('Not found')
|
||||
|
||||
urlpatterns = [
|
||||
path('', TemplateView.as_view(template_name='index.html'), name='index'),
|
||||
path('app/', spa_serve, name='spa_serve'),
|
||||
path('app/<path:path>', spa_serve, name='spa_serve_path'),
|
||||
re_path(r'^assets/(?P<path>.+)$', _serve_fe_assets, name='fe_assets'),
|
||||
path('admin/', admin.site.urls),
|
||||
path('api/', include('meals.urls')),
|
||||
path('api/dashboard/', dashboard_api, name='dashboard_api'),
|
||||
path('dashboard/', RedirectView.as_view(url='/admin/', permanent=False), name='dashboard_redirect'),
|
||||
]
|
||||
|
||||
# When DEBUG is off (e.g. desktop.py / EXE mode), serve static files directly
|
||||
# so the Django admin and Jazzmin theme load correctly.
|
||||
if not settings.DEBUG:
|
||||
from django.contrib.staticfiles import finders as _sf_finders
|
||||
|
||||
def _serve_static(request, path=''):
|
||||
"""Search all static file roots for the requested path."""
|
||||
for root in _static_roots:
|
||||
target = os.path.normpath(os.path.join(root, path))
|
||||
if target.startswith(root) and os.path.isfile(target):
|
||||
return static_serve(request, path, document_root=root)
|
||||
from django.http import Http404
|
||||
raise Http404
|
||||
|
||||
_static_roots = []
|
||||
for _d in settings.STATICFILES_DIRS:
|
||||
if os.path.isdir(_d):
|
||||
_static_roots.append(os.path.normpath(_d))
|
||||
for _finder in _sf_finders.get_finders():
|
||||
for _path, _storage in _finder.list([]):
|
||||
_loc = getattr(_storage, 'location', None)
|
||||
if _loc and os.path.isdir(_loc):
|
||||
_static_roots.append(os.path.normpath(_loc))
|
||||
urlpatterns += [
|
||||
re_path(r'^static/(?P<path>.+)$', _serve_static),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user