yanleafadmin 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. yanleafadmin-2.0.0/LICENSE +21 -0
  2. yanleafadmin-2.0.0/MANIFEST.in +10 -0
  3. yanleafadmin-2.0.0/PKG-INFO +291 -0
  4. yanleafadmin-2.0.0/README.md +272 -0
  5. yanleafadmin-2.0.0/apps/__init__.py +0 -0
  6. yanleafadmin-2.0.0/apps/ai_assistant/__init__.py +0 -0
  7. yanleafadmin-2.0.0/apps/ai_assistant/apps.py +10 -0
  8. yanleafadmin-2.0.0/apps/ai_assistant/services.py +256 -0
  9. yanleafadmin-2.0.0/apps/ai_assistant/static/ai/ai-search.js +258 -0
  10. yanleafadmin-2.0.0/apps/ai_assistant/templates/ai/fullpage.html +143 -0
  11. yanleafadmin-2.0.0/apps/ai_assistant/urls.py +9 -0
  12. yanleafadmin-2.0.0/apps/ai_assistant/views.py +40 -0
  13. yanleafadmin-2.0.0/apps/dashboard_engine/__init__.py +0 -0
  14. yanleafadmin-2.0.0/apps/dashboard_engine/admin.py +3 -0
  15. yanleafadmin-2.0.0/apps/dashboard_engine/apps.py +212 -0
  16. yanleafadmin-2.0.0/apps/dashboard_engine/migrations/__init__.py +0 -0
  17. yanleafadmin-2.0.0/apps/dashboard_engine/models.py +3 -0
  18. yanleafadmin-2.0.0/apps/dashboard_engine/templates/admin/base_site.html +15 -0
  19. yanleafadmin-2.0.0/apps/dashboard_engine/templates/admin/dashboard_index.html +394 -0
  20. yanleafadmin-2.0.0/apps/dashboard_engine/tests.py +3 -0
  21. yanleafadmin-2.0.0/apps/dashboard_engine/views.py +34 -0
  22. yanleafadmin-2.0.0/apps/erd_engine/__init__.py +0 -0
  23. yanleafadmin-2.0.0/apps/erd_engine/apps.py +10 -0
  24. yanleafadmin-2.0.0/apps/erd_engine/sql_parser.py +386 -0
  25. yanleafadmin-2.0.0/apps/erd_engine/static/erd/er-diagram.js +597 -0
  26. yanleafadmin-2.0.0/apps/erd_engine/templates/erd/er_diagram.html +151 -0
  27. yanleafadmin-2.0.0/apps/erd_engine/urls.py +12 -0
  28. yanleafadmin-2.0.0/apps/erd_engine/views.py +212 -0
  29. yanleafadmin-2.0.0/apps/theme/__init__.py +0 -0
  30. yanleafadmin-2.0.0/apps/theme/admin.py +3 -0
  31. yanleafadmin-2.0.0/apps/theme/apps.py +117 -0
  32. yanleafadmin-2.0.0/apps/theme/components/__init__.py +0 -0
  33. yanleafadmin-2.0.0/apps/theme/components/actions.py +49 -0
  34. yanleafadmin-2.0.0/apps/theme/components/charts.py +107 -0
  35. yanleafadmin-2.0.0/apps/theme/context_processors.py +12 -0
  36. yanleafadmin-2.0.0/apps/theme/forms.py +13 -0
  37. yanleafadmin-2.0.0/apps/theme/migrations/__init__.py +0 -0
  38. yanleafadmin-2.0.0/apps/theme/models.py +3 -0
  39. yanleafadmin-2.0.0/apps/theme/settings.py +29 -0
  40. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/css/admin.css +1653 -0
  41. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/css/change-form.css +182 -0
  42. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/css/change-list.css +207 -0
  43. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/css/dashboard.css +57 -0
  44. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/css/login.css +75 -0
  45. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/css/password-form.css +95 -0
  46. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/css/user-change-form.css +24 -0
  47. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/js/components.js +14 -0
  48. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/js/core.js +293 -0
  49. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/js/filter-widget.js +298 -0
  50. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/js/i18n/datatables.en.json +29 -0
  51. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/js/i18n/datatables.zh-hans.json +29 -0
  52. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/js/login.js +76 -0
  53. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/js/password-check.js +21 -0
  54. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/js/smart-chart.js +55 -0
  55. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/js/user-password-field.js +23 -0
  56. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/bulma/bulma.min.css +3 -0
  57. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/bulma-calendar/bulma-calendar.min.css +1 -0
  58. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/bulma-calendar/bulma-calendar.min.js +1 -0
  59. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/datatables/css/buttons.bulma.min.css +1 -0
  60. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/datatables/css/dataTables.bulma.min.css +3 -0
  61. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/datatables/js/buttons.html5.min.js +8 -0
  62. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/datatables/js/buttons.print.min.js +5 -0
  63. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/datatables/js/dataTables.bulma.min.js +4 -0
  64. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/datatables/js/dataTables.buttons.min.js +4 -0
  65. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/datatables/js/jquery.dataTables.min.js +4 -0
  66. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/dropzone/dropzone-min.js +2 -0
  67. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/dropzone/dropzone.css +1 -0
  68. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/echarts/echarts.min.js +45 -0
  69. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/fontawesome/css/all.min.css +9 -0
  70. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/fontawesome/webfonts/fa-brands-400.woff2 +0 -0
  71. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/fontawesome/webfonts/fa-regular-400.woff2 +0 -0
  72. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/fontawesome/webfonts/fa-solid-900.woff2 +0 -0
  73. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/gojs/go.js +2210 -0
  74. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/jquery/jquery.min.js +2 -0
  75. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/jszip/jszip.min.js +13 -0
  76. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/mermaid/mermaid.min.js +3405 -0
  77. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/select2/css/select2.min.css +1 -0
  78. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/select2/js/select2.min.js +2 -0
  79. yanleafadmin-2.0.0/apps/theme/static/yanleafadmin/vendor/sweetalert2/sweetalert2.all.min.js +6 -0
  80. yanleafadmin-2.0.0/apps/theme/templates/admin/app_index.html +79 -0
  81. yanleafadmin-2.0.0/apps/theme/templates/admin/auth/user/add_form.html +18 -0
  82. yanleafadmin-2.0.0/apps/theme/templates/admin/auth/user/change_form.html +21 -0
  83. yanleafadmin-2.0.0/apps/theme/templates/admin/auth/user/change_password.html +105 -0
  84. yanleafadmin-2.0.0/apps/theme/templates/admin/base.html +268 -0
  85. yanleafadmin-2.0.0/apps/theme/templates/admin/change_form.html +221 -0
  86. yanleafadmin-2.0.0/apps/theme/templates/admin/change_list.html +202 -0
  87. yanleafadmin-2.0.0/apps/theme/templates/admin/change_list_results.html +74 -0
  88. yanleafadmin-2.0.0/apps/theme/templates/admin/edit_inline/tabular.html +121 -0
  89. yanleafadmin-2.0.0/apps/theme/templates/admin/login.html +94 -0
  90. yanleafadmin-2.0.0/apps/theme/templates/admin/pagination.html +52 -0
  91. yanleafadmin-2.0.0/apps/theme/templates/registration/password_change_done.html +29 -0
  92. yanleafadmin-2.0.0/apps/theme/templates/registration/password_change_form.html +90 -0
  93. yanleafadmin-2.0.0/apps/theme/templatetags/__init__.py +0 -0
  94. yanleafadmin-2.0.0/apps/theme/templatetags/yla_charts.py +23 -0
  95. yanleafadmin-2.0.0/apps/theme/templatetags/yla_components.py +95 -0
  96. yanleafadmin-2.0.0/apps/theme/tests.py +3 -0
  97. yanleafadmin-2.0.0/apps/theme/urls.py +15 -0
  98. yanleafadmin-2.0.0/apps/theme/views.py +3 -0
  99. yanleafadmin-2.0.0/apps/users/__init__.py +0 -0
  100. yanleafadmin-2.0.0/apps/users/admin.py +62 -0
  101. yanleafadmin-2.0.0/apps/users/apps.py +7 -0
  102. yanleafadmin-2.0.0/apps/users/management/__init__.py +0 -0
  103. yanleafadmin-2.0.0/apps/users/management/commands/__init__.py +0 -0
  104. yanleafadmin-2.0.0/apps/users/management/commands/seed_demo_data.py +60 -0
  105. yanleafadmin-2.0.0/apps/users/migrations/0001_initial.py +44 -0
  106. yanleafadmin-2.0.0/apps/users/migrations/__init__.py +0 -0
  107. yanleafadmin-2.0.0/apps/users/models.py +18 -0
  108. yanleafadmin-2.0.0/apps/users/tests.py +3 -0
  109. yanleafadmin-2.0.0/apps/users/views.py +3 -0
  110. yanleafadmin-2.0.0/requirements.txt +22 -0
  111. yanleafadmin-2.0.0/setup.cfg +4 -0
  112. yanleafadmin-2.0.0/setup.py +35 -0
  113. yanleafadmin-2.0.0/yanleafadmin/__init__.py +3 -0
  114. yanleafadmin-2.0.0/yanleafadmin/apps.py +10 -0
  115. yanleafadmin-2.0.0/yanleafadmin.egg-info/PKG-INFO +291 -0
  116. yanleafadmin-2.0.0/yanleafadmin.egg-info/SOURCES.txt +117 -0
  117. yanleafadmin-2.0.0/yanleafadmin.egg-info/dependency_links.txt +1 -0
  118. yanleafadmin-2.0.0/yanleafadmin.egg-info/requires.txt +11 -0
  119. yanleafadmin-2.0.0/yanleafadmin.egg-info/top_level.txt +2 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 zhouyanye
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,10 @@
1
+ recursive-include apps/theme/static *
2
+ recursive-include apps/theme/templates *
3
+ recursive-include apps/dashboard_engine/templates *
4
+ recursive-include apps/erd_engine/templates *
5
+ recursive-include apps/erd_engine/static *
6
+ recursive-include apps/ai_assistant/templates *
7
+ recursive-include apps/ai_assistant/static *
8
+ include README.md
9
+ include LICENSE
10
+ include requirements.txt
@@ -0,0 +1,291 @@
1
+ Metadata-Version: 2.1
2
+ Name: yanleafadmin
3
+ Version: 2.0.0
4
+ Summary: 极简白色现代 Django Admin 主题体系 — 基于 Django + Bulma CSS
5
+ Home-page: https://github.com/zhouyanye/yanleafadmin
6
+ Author: zhouyanye
7
+ Classifier: Framework :: Django
8
+ Classifier: Framework :: Django :: 5.0
9
+ Classifier: Programming Language :: Python :: 3.10
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ Provides-Extra: word
17
+ Provides-Extra: ai
18
+ License-File: LICENSE
19
+
20
+ # YanLeafAdmin
21
+
22
+ 极简白色现代 Django Admin 后台主题体系,基于 Django + Bulma CSS + ECharts + GoJS 构建。
23
+
24
+ ## 功能概览
25
+
26
+ ### 核心主题
27
+ - 白色极简 + 暗黑模式双模切换(localStorage 持久化)
28
+ - 中英文 i18n 国际化(zh-hans / en)
29
+ - 侧边栏导航 + 顶部面包屑 + 用户菜单
30
+ - 登录页验证码(django-simple-captcha)
31
+
32
+ ### 组件与交互
33
+ - **DataTables**:列表页一键导出 Excel / CSV / 打印
34
+ - **SweetAlert2**:编辑/删除确认弹窗,Toast 弱提示
35
+ - **Select2**:下拉搜索增强
36
+ - **Dropzone**:拖拽文件上传
37
+ - **穿梭框重写**:Bulma 卡片式左右选择器
38
+
39
+ ### 可视化引擎
40
+ - **SmartChart**:根据 Model 字段类型自动生成 ECharts 图表(趋势/饼图/柱状图)
41
+ - **仪表盘热力图**:近半年操作活跃度(类 GitHub 绿格子墙)
42
+ - **模块玫瑰图**:近 7 天模块活跃度分布
43
+ - **系统动态时间线**:10 条最新操作记录,Badge 四级颜色标记,展开变更 Diff
44
+
45
+ ### ER 图引擎
46
+ - **Django 模型直读**:一键生成当前项目所有表的实体关系图
47
+ - **SQL DDL 解析**:粘贴建表语句自动渲染 ER 图
48
+ - **GoJS 渲染**:黑白经典风格(矩形表+椭圆字段+菱形关联)
49
+ - **表选择 + 搜索过滤**
50
+ - **中英文切换**:中文优先 COMMENT 注释,英文用原名
51
+ - **导出 PNG** + **导出 Word 三线表 (.docx)**
52
+
53
+ ### AI 数据助手
54
+ - **右下角悬浮聊天机器人**,点击即可对话
55
+ - **自然语言查询**:基于 DeepSeek 驱动,自动转 Django ORM
56
+ - **SmartChart 渲染**:查询结果原地生成图表
57
+ - **多模型支持**:DeepSeek Chat / Reasoner / GPT-4o / 通义千问
58
+ - **配置保存在浏览器**:API Key 不上传服务器
59
+ - **聊天历史**:localStorage 持久化最近 50 条对话
60
+ - **全屏展开**:新标签页全屏对话
61
+
62
+ ### 开发者体验
63
+ - **pip install**:`pip install yanleafadmin`
64
+ - **YANLEAF_ADMIN 配置字典**:15+ 可配置项
65
+ - **模板标签**:`stat_card` / `status_badge` / `action_btn` / `empty_state` / `confirm_link` / `timeline` / `smart_chart`
66
+ - **无 CDN 依赖**:所有静态资源本地化(17 个 vendor 包),内网可用
67
+
68
+ ## 快速开始
69
+
70
+ ### 环境要求
71
+ - Python 3.10+
72
+ - Django 5.0+
73
+ - django-simple-captcha >= 0.5
74
+ - (可选) python-docx — Word 导出功能
75
+
76
+ ### 安装
77
+
78
+ ```bash
79
+ pip install yanleafadmin
80
+ ```
81
+
82
+ 或开发模式:
83
+
84
+ ```bash
85
+ git clone https://github.com/zhouyanye/yanleafadmin.git
86
+ cd yanleafadmin
87
+ pip install -e .
88
+ ```
89
+
90
+ ### 配置 settings.py
91
+
92
+ > 如果是 **pip install** 安装,直接跳到下方配置。
93
+ > 如果是 **git clone** 到本地作为项目使用,在 `settings.py` 顶部加一行:
94
+
95
+ ```python
96
+ import os, sys
97
+ sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
98
+ ```
99
+
100
+ #### 最少配置(只用主题 + 仪表盘)
101
+
102
+ ```python
103
+ INSTALLED_APPS = [
104
+ 'yanleafadmin', # 主题(必须在 admin 前面,一行搞定)
105
+ 'django.contrib.admin',
106
+ 'django.contrib.auth',
107
+ 'django.contrib.contenttypes',
108
+ 'django.contrib.sessions',
109
+ 'django.contrib.messages',
110
+ 'django.contrib.staticfiles',
111
+ 'captcha', # 登录验证码
112
+ 'apps.users.apps.UsersConfig',
113
+ 'apps.dashboard_engine.apps.DashboardEngineConfig',
114
+ ]
115
+
116
+ AUTH_USER_MODEL = 'users.User'
117
+ ```
118
+
119
+ #### 完整配置(含 ER 图 + AI 助手)
120
+
121
+ 在最少配置基础上追加:
122
+
123
+ ```python
124
+ INSTALLED_APPS += [
125
+ 'apps.erd_engine.apps.ErdEngineConfig',
126
+ 'apps.ai_assistant.apps.AiAssistantConfig',
127
+ ]
128
+ ```
129
+
130
+ #### 语言与主题配置
131
+
132
+ ```python
133
+ LANGUAGE_CODE = 'zh-hans'
134
+ TIME_ZONE = 'Asia/Shanghai'
135
+ USE_I18N = True
136
+
137
+ LANGUAGES = [
138
+ ('zh-hans', '简体中文'),
139
+ ('en', 'English'),
140
+ ]
141
+
142
+ # 所有配置项均可选,不写则使用默认值
143
+ YANLEAF_ADMIN = {
144
+ 'theme_color': '#485fc7',
145
+ 'show_credit': True,
146
+ 'dark_mode_default': 'auto',
147
+ 'datatables_page_length': 10,
148
+ 'login_captcha': True,
149
+ 'charts_enabled': True,
150
+ 'ai_assistant_enabled': True,
151
+ }
152
+
153
+ # AI 助手(Key 请在 .env 中设置,不要提交到 Git)
154
+ YANLEAF_AI = {
155
+ 'enabled': True,
156
+ 'model': 'deepseek-chat',
157
+ 'api_base': 'https://api.deepseek.com/v1',
158
+ }
159
+ ```
160
+
161
+ ### .env 文件(可选)
162
+
163
+ ```bash
164
+ YANLEAF_AI_API_KEY=sk-xxxxxxxxxxxxxxxx
165
+ YANLEAF_AI_API_BASE=https://api.deepseek.com/v1
166
+ YANLEAF_AI_MODEL=deepseek-chat
167
+ ```
168
+
169
+ ### 初始化
170
+
171
+ ```bash
172
+ python manage.py migrate
173
+ python manage.py createsuperuser
174
+ python manage.py seed_demo_data # 生成演示用户数据
175
+ python manage.py runserver
176
+ ```
177
+
178
+ 访问 `http://127.0.0.1:8000/admin/`
179
+
180
+ ## 项目结构
181
+
182
+ ```
183
+ yanleaf_admin_project/
184
+ ├── core/ # Django 项目配置
185
+ │ ├── settings.py
186
+ │ ├── urls.py
187
+ │ └── wsgi.py
188
+ ├── apps/
189
+ │ ├── theme/ # 主题核心(模板 + CSS + JS + 组件)
190
+ │ │ ├── components/ # actions.py(AJAX 视图)
191
+ │ │ ├── templatetags/ # yla_components.py / yla_charts.py
192
+ │ │ ├── static/yanleafadmin/
193
+ │ │ │ ├── css/ # admin.css + 各页面 CSS
194
+ │ │ │ ├── js/ # core.js + filter-widget.js + smart-chart.js
195
+ │ │ │ └── vendor/ # 本地化第三方库(17 个包)
196
+ │ │ └── templates/admin/ # base.html + login + change_list + change_form
197
+ │ ├── dashboard_engine/ # 仪表盘与可视化
198
+ │ │ ├── apps.py # 热力图/玫瑰图/系统动态数据构造
199
+ │ │ ├── views.py # 日志 Diff API
200
+ │ │ └── templates/admin/dashboard_index.html
201
+ │ ├── erd_engine/ # ER 图引擎
202
+ │ │ ├── sql_parser.py # SQL DDL 解析器
203
+ │ │ ├── views.py # ER 数据 API
204
+ │ │ ├── components/charts.py # SmartChart 构造器
205
+ │ │ ├── static/erd/er-diagram.js # GoJS ER 图渲染
206
+ │ │ └── templates/erd/er_diagram.html
207
+ │ ├── ai_assistant/ # AI 数据助手
208
+ │ │ ├── services.py # LLM Prompt + ORM 查询引擎
209
+ │ │ ├── views.py # /api/ai/query/ 接口
210
+ │ │ ├── static/ai/ai-search.js # 悬浮聊天机器人
211
+ │ │ └── templates/ai/fullpage.html # 全屏对话页
212
+ │ └── users/ # 用户模型 + 种子数据
213
+ ├── yanleafadmin/ # pip 入口包(代理 apps/theme)
214
+ │ ├── __init__.py
215
+ │ └── apps.py
216
+ ├── docs/ # 文档与设计规格
217
+ ├── setup.py # pip 安装包
218
+ ├── MANIFEST.in
219
+ └── README.md
220
+ ```
221
+
222
+ ## YANLEAF_ADMIN 完整配置项
223
+
224
+ | 配置项 | 类型 | 默认值 | 说明 |
225
+ |--------|------|--------|------|
226
+ | `site_title` | str | `YanleafAdmin` | 站点标题 |
227
+ | `theme_color` | str | `#485fc7` | 主题色 |
228
+ | `sidebar_width` | str | `250px` | 侧边栏宽度 |
229
+ | `show_credit` | bool | `True` | 侧边栏署名 |
230
+ | `dark_mode_default` | str | `auto` | 暗黑模式: auto / light / dark |
231
+ | `default_language` | str | `zh-hans` | 默认语言 |
232
+ | `datatables_page_length` | int | `10` | 列表每页条数 |
233
+ | `datatables_export` | bool | `True` | 启用导出按钮 |
234
+ | `charts_enabled` | bool | `True` | 启用 SmartChart |
235
+ | `charts_default_period` | str | `7d` | 默认图表周期 |
236
+ | `login_captcha` | bool | `True` | 登录验证码 |
237
+ | `captcha_length` | int | `4` | 验证码长度 |
238
+ | `captcha_image_size` | tuple | `(140, 45)` | 验证码图片尺寸 |
239
+ | `menu_icons` | dict | `{}` | 模型图标映射 |
240
+ | `ai_assistant_enabled` | bool | `True` | AI 助手开关 |
241
+
242
+ ## 模板标签
243
+
244
+ ```django
245
+ {% load yla_components %}
246
+ {% stat_card "今日新增" 128 "+12%" "fa-user-plus" "info" %}
247
+ {% status_badge True "启用" "禁用" %}
248
+ {% action_btn "审核通过" approve_url method="POST" %}
249
+ {% empty_state icon="fa-inbox" title="暂无数据" hint="点击上方按钮开始添加" %}
250
+ {% confirm_link delete_url "删除" "确定删除此用户?" %}
251
+
252
+ {% load yla_charts %}
253
+ {% smart_chart "users" "user" "date_joined" "trend" "7d" %}
254
+ ```
255
+
256
+ ## 技术栈
257
+
258
+ | 类别 | 技术 |
259
+ |------|------|
260
+ | 后端框架 | Django 5.2 |
261
+ | CSS 框架 | Bulma 1.0 |
262
+ | 表格 | DataTables 2.1 + Buttons 3.1 |
263
+ | 图表 | Apache ECharts 5.5 |
264
+ | ER 图 | GoJS |
265
+ | AI | DeepSeek / OpenAI 兼容 API |
266
+ | 弹窗 | SweetAlert2 11 |
267
+ | 下拉 | Select2 4.0 |
268
+ | 上传 | Dropzone 6.0 |
269
+ | 日期 | Bulma Calendar 6.1 |
270
+ | Word 导出 | python-docx 1.2 |
271
+ | SQL 解析 | sqlparse |
272
+
273
+ ## License
274
+
275
+ MIT License — 详见 [LICENSE](LICENSE)
276
+
277
+ ## 作者
278
+
279
+ **zhouyanye** — [github.com/zhouyanye](https://github.com/zhouyanye)
280
+
281
+
282
+
283
+ ## Star History
284
+
285
+ <a href="https://www.star-history.com/?repos=zhouyanye%2Fyanleafadmin&type=date&legend=top-left">
286
+ <picture>
287
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=zhouyanye/yanleafadmin&type=date&theme=dark&legend=top-left" />
288
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=zhouyanye/yanleafadmin&type=date&legend=top-left" />
289
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=zhouyanye/yanleafadmin&type=date&legend=top-left" />
290
+ </picture>
291
+ </a>
@@ -0,0 +1,272 @@
1
+ # YanLeafAdmin
2
+
3
+ 极简白色现代 Django Admin 后台主题体系,基于 Django + Bulma CSS + ECharts + GoJS 构建。
4
+
5
+ ## 功能概览
6
+
7
+ ### 核心主题
8
+ - 白色极简 + 暗黑模式双模切换(localStorage 持久化)
9
+ - 中英文 i18n 国际化(zh-hans / en)
10
+ - 侧边栏导航 + 顶部面包屑 + 用户菜单
11
+ - 登录页验证码(django-simple-captcha)
12
+
13
+ ### 组件与交互
14
+ - **DataTables**:列表页一键导出 Excel / CSV / 打印
15
+ - **SweetAlert2**:编辑/删除确认弹窗,Toast 弱提示
16
+ - **Select2**:下拉搜索增强
17
+ - **Dropzone**:拖拽文件上传
18
+ - **穿梭框重写**:Bulma 卡片式左右选择器
19
+
20
+ ### 可视化引擎
21
+ - **SmartChart**:根据 Model 字段类型自动生成 ECharts 图表(趋势/饼图/柱状图)
22
+ - **仪表盘热力图**:近半年操作活跃度(类 GitHub 绿格子墙)
23
+ - **模块玫瑰图**:近 7 天模块活跃度分布
24
+ - **系统动态时间线**:10 条最新操作记录,Badge 四级颜色标记,展开变更 Diff
25
+
26
+ ### ER 图引擎
27
+ - **Django 模型直读**:一键生成当前项目所有表的实体关系图
28
+ - **SQL DDL 解析**:粘贴建表语句自动渲染 ER 图
29
+ - **GoJS 渲染**:黑白经典风格(矩形表+椭圆字段+菱形关联)
30
+ - **表选择 + 搜索过滤**
31
+ - **中英文切换**:中文优先 COMMENT 注释,英文用原名
32
+ - **导出 PNG** + **导出 Word 三线表 (.docx)**
33
+
34
+ ### AI 数据助手
35
+ - **右下角悬浮聊天机器人**,点击即可对话
36
+ - **自然语言查询**:基于 DeepSeek 驱动,自动转 Django ORM
37
+ - **SmartChart 渲染**:查询结果原地生成图表
38
+ - **多模型支持**:DeepSeek Chat / Reasoner / GPT-4o / 通义千问
39
+ - **配置保存在浏览器**:API Key 不上传服务器
40
+ - **聊天历史**:localStorage 持久化最近 50 条对话
41
+ - **全屏展开**:新标签页全屏对话
42
+
43
+ ### 开发者体验
44
+ - **pip install**:`pip install yanleafadmin`
45
+ - **YANLEAF_ADMIN 配置字典**:15+ 可配置项
46
+ - **模板标签**:`stat_card` / `status_badge` / `action_btn` / `empty_state` / `confirm_link` / `timeline` / `smart_chart`
47
+ - **无 CDN 依赖**:所有静态资源本地化(17 个 vendor 包),内网可用
48
+
49
+ ## 快速开始
50
+
51
+ ### 环境要求
52
+ - Python 3.10+
53
+ - Django 5.0+
54
+ - django-simple-captcha >= 0.5
55
+ - (可选) python-docx — Word 导出功能
56
+
57
+ ### 安装
58
+
59
+ ```bash
60
+ pip install yanleafadmin
61
+ ```
62
+
63
+ 或开发模式:
64
+
65
+ ```bash
66
+ git clone https://github.com/zhouyanye/yanleafadmin.git
67
+ cd yanleafadmin
68
+ pip install -e .
69
+ ```
70
+
71
+ ### 配置 settings.py
72
+
73
+ > 如果是 **pip install** 安装,直接跳到下方配置。
74
+ > 如果是 **git clone** 到本地作为项目使用,在 `settings.py` 顶部加一行:
75
+
76
+ ```python
77
+ import os, sys
78
+ sys.path.insert(0, os.path.join(BASE_DIR, 'apps'))
79
+ ```
80
+
81
+ #### 最少配置(只用主题 + 仪表盘)
82
+
83
+ ```python
84
+ INSTALLED_APPS = [
85
+ 'yanleafadmin', # 主题(必须在 admin 前面,一行搞定)
86
+ 'django.contrib.admin',
87
+ 'django.contrib.auth',
88
+ 'django.contrib.contenttypes',
89
+ 'django.contrib.sessions',
90
+ 'django.contrib.messages',
91
+ 'django.contrib.staticfiles',
92
+ 'captcha', # 登录验证码
93
+ 'apps.users.apps.UsersConfig',
94
+ 'apps.dashboard_engine.apps.DashboardEngineConfig',
95
+ ]
96
+
97
+ AUTH_USER_MODEL = 'users.User'
98
+ ```
99
+
100
+ #### 完整配置(含 ER 图 + AI 助手)
101
+
102
+ 在最少配置基础上追加:
103
+
104
+ ```python
105
+ INSTALLED_APPS += [
106
+ 'apps.erd_engine.apps.ErdEngineConfig',
107
+ 'apps.ai_assistant.apps.AiAssistantConfig',
108
+ ]
109
+ ```
110
+
111
+ #### 语言与主题配置
112
+
113
+ ```python
114
+ LANGUAGE_CODE = 'zh-hans'
115
+ TIME_ZONE = 'Asia/Shanghai'
116
+ USE_I18N = True
117
+
118
+ LANGUAGES = [
119
+ ('zh-hans', '简体中文'),
120
+ ('en', 'English'),
121
+ ]
122
+
123
+ # 所有配置项均可选,不写则使用默认值
124
+ YANLEAF_ADMIN = {
125
+ 'theme_color': '#485fc7',
126
+ 'show_credit': True,
127
+ 'dark_mode_default': 'auto',
128
+ 'datatables_page_length': 10,
129
+ 'login_captcha': True,
130
+ 'charts_enabled': True,
131
+ 'ai_assistant_enabled': True,
132
+ }
133
+
134
+ # AI 助手(Key 请在 .env 中设置,不要提交到 Git)
135
+ YANLEAF_AI = {
136
+ 'enabled': True,
137
+ 'model': 'deepseek-chat',
138
+ 'api_base': 'https://api.deepseek.com/v1',
139
+ }
140
+ ```
141
+
142
+ ### .env 文件(可选)
143
+
144
+ ```bash
145
+ YANLEAF_AI_API_KEY=sk-xxxxxxxxxxxxxxxx
146
+ YANLEAF_AI_API_BASE=https://api.deepseek.com/v1
147
+ YANLEAF_AI_MODEL=deepseek-chat
148
+ ```
149
+
150
+ ### 初始化
151
+
152
+ ```bash
153
+ python manage.py migrate
154
+ python manage.py createsuperuser
155
+ python manage.py seed_demo_data # 生成演示用户数据
156
+ python manage.py runserver
157
+ ```
158
+
159
+ 访问 `http://127.0.0.1:8000/admin/`
160
+
161
+ ## 项目结构
162
+
163
+ ```
164
+ yanleaf_admin_project/
165
+ ├── core/ # Django 项目配置
166
+ │ ├── settings.py
167
+ │ ├── urls.py
168
+ │ └── wsgi.py
169
+ ├── apps/
170
+ │ ├── theme/ # 主题核心(模板 + CSS + JS + 组件)
171
+ │ │ ├── components/ # actions.py(AJAX 视图)
172
+ │ │ ├── templatetags/ # yla_components.py / yla_charts.py
173
+ │ │ ├── static/yanleafadmin/
174
+ │ │ │ ├── css/ # admin.css + 各页面 CSS
175
+ │ │ │ ├── js/ # core.js + filter-widget.js + smart-chart.js
176
+ │ │ │ └── vendor/ # 本地化第三方库(17 个包)
177
+ │ │ └── templates/admin/ # base.html + login + change_list + change_form
178
+ │ ├── dashboard_engine/ # 仪表盘与可视化
179
+ │ │ ├── apps.py # 热力图/玫瑰图/系统动态数据构造
180
+ │ │ ├── views.py # 日志 Diff API
181
+ │ │ └── templates/admin/dashboard_index.html
182
+ │ ├── erd_engine/ # ER 图引擎
183
+ │ │ ├── sql_parser.py # SQL DDL 解析器
184
+ │ │ ├── views.py # ER 数据 API
185
+ │ │ ├── components/charts.py # SmartChart 构造器
186
+ │ │ ├── static/erd/er-diagram.js # GoJS ER 图渲染
187
+ │ │ └── templates/erd/er_diagram.html
188
+ │ ├── ai_assistant/ # AI 数据助手
189
+ │ │ ├── services.py # LLM Prompt + ORM 查询引擎
190
+ │ │ ├── views.py # /api/ai/query/ 接口
191
+ │ │ ├── static/ai/ai-search.js # 悬浮聊天机器人
192
+ │ │ └── templates/ai/fullpage.html # 全屏对话页
193
+ │ └── users/ # 用户模型 + 种子数据
194
+ ├── yanleafadmin/ # pip 入口包(代理 apps/theme)
195
+ │ ├── __init__.py
196
+ │ └── apps.py
197
+ ├── docs/ # 文档与设计规格
198
+ ├── setup.py # pip 安装包
199
+ ├── MANIFEST.in
200
+ └── README.md
201
+ ```
202
+
203
+ ## YANLEAF_ADMIN 完整配置项
204
+
205
+ | 配置项 | 类型 | 默认值 | 说明 |
206
+ |--------|------|--------|------|
207
+ | `site_title` | str | `YanleafAdmin` | 站点标题 |
208
+ | `theme_color` | str | `#485fc7` | 主题色 |
209
+ | `sidebar_width` | str | `250px` | 侧边栏宽度 |
210
+ | `show_credit` | bool | `True` | 侧边栏署名 |
211
+ | `dark_mode_default` | str | `auto` | 暗黑模式: auto / light / dark |
212
+ | `default_language` | str | `zh-hans` | 默认语言 |
213
+ | `datatables_page_length` | int | `10` | 列表每页条数 |
214
+ | `datatables_export` | bool | `True` | 启用导出按钮 |
215
+ | `charts_enabled` | bool | `True` | 启用 SmartChart |
216
+ | `charts_default_period` | str | `7d` | 默认图表周期 |
217
+ | `login_captcha` | bool | `True` | 登录验证码 |
218
+ | `captcha_length` | int | `4` | 验证码长度 |
219
+ | `captcha_image_size` | tuple | `(140, 45)` | 验证码图片尺寸 |
220
+ | `menu_icons` | dict | `{}` | 模型图标映射 |
221
+ | `ai_assistant_enabled` | bool | `True` | AI 助手开关 |
222
+
223
+ ## 模板标签
224
+
225
+ ```django
226
+ {% load yla_components %}
227
+ {% stat_card "今日新增" 128 "+12%" "fa-user-plus" "info" %}
228
+ {% status_badge True "启用" "禁用" %}
229
+ {% action_btn "审核通过" approve_url method="POST" %}
230
+ {% empty_state icon="fa-inbox" title="暂无数据" hint="点击上方按钮开始添加" %}
231
+ {% confirm_link delete_url "删除" "确定删除此用户?" %}
232
+
233
+ {% load yla_charts %}
234
+ {% smart_chart "users" "user" "date_joined" "trend" "7d" %}
235
+ ```
236
+
237
+ ## 技术栈
238
+
239
+ | 类别 | 技术 |
240
+ |------|------|
241
+ | 后端框架 | Django 5.2 |
242
+ | CSS 框架 | Bulma 1.0 |
243
+ | 表格 | DataTables 2.1 + Buttons 3.1 |
244
+ | 图表 | Apache ECharts 5.5 |
245
+ | ER 图 | GoJS |
246
+ | AI | DeepSeek / OpenAI 兼容 API |
247
+ | 弹窗 | SweetAlert2 11 |
248
+ | 下拉 | Select2 4.0 |
249
+ | 上传 | Dropzone 6.0 |
250
+ | 日期 | Bulma Calendar 6.1 |
251
+ | Word 导出 | python-docx 1.2 |
252
+ | SQL 解析 | sqlparse |
253
+
254
+ ## License
255
+
256
+ MIT License — 详见 [LICENSE](LICENSE)
257
+
258
+ ## 作者
259
+
260
+ **zhouyanye** — [github.com/zhouyanye](https://github.com/zhouyanye)
261
+
262
+
263
+
264
+ ## Star History
265
+
266
+ <a href="https://www.star-history.com/?repos=zhouyanye%2Fyanleafadmin&type=date&legend=top-left">
267
+ <picture>
268
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=zhouyanye/yanleafadmin&type=date&theme=dark&legend=top-left" />
269
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=zhouyanye/yanleafadmin&type=date&legend=top-left" />
270
+ <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=zhouyanye/yanleafadmin&type=date&legend=top-left" />
271
+ </picture>
272
+ </a>
File without changes
File without changes
@@ -0,0 +1,10 @@
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class AiAssistantConfig(AppConfig):
5
+ default_auto_field = 'django.db.models.BigAutoField'
6
+ name = 'apps.ai_assistant'
7
+ verbose_name = 'AI 助手'
8
+
9
+ def ready(self):
10
+ pass