Skip to content

Commit 6301420

Browse files
insistencegitee-org
authored andcommitted
!10 Dash-FastAPI-Admin v1.0.5
Merge pull request !10 from insistence/develop
2 parents 8f87d80 + 93f8982 commit 6301420

File tree

43 files changed

+4133
-2634
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4133
-2634
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<p align="center">
22
<img alt="logo" src="https://oscimg.oschina.net/oscnet/up-d3d0a9303e11d522a06cd263f3079027715.png">
33
</p>
4-
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">Dash-FastAPI-Admin v1.0.4</h1>
4+
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">Dash-FastAPI-Admin v1.0.5</h1>
55
<h4 align="center">基于Dash+FastAPI前后端分离的纯Python快速开发框架</h4>
66
<p align="center">
77
<a href="https://gitee.com/insistence2022/dash-fastapi-admin/stargazers"><img src="https://gitee.com/insistence2022/dash-fastapi-admin/badge/star.svg?theme=dark"></a>
8-
<a href="https://gitee.com/insistence2022/dash-fastapi-admin"><img src="https://img.shields.io/badge/DashFastAPIAdmin-v1.0.4-brightgreen.svg"></a>
8+
<a href="https://gitee.com/insistence2022/dash-fastapi-admin"><img src="https://img.shields.io/badge/DashFastAPIAdmin-v1.0.5-brightgreen.svg"></a>
99
<a href="https://gitee.com/insistence2022/dash-fastapi-admin/blob/master/LICENSE"><img src="https://img.shields.io/github/license/mashape/apistatus.svg"></a>
1010
<img src="https://img.shields.io/badge/python-≥3.8-blue">
1111
<img src="https://img.shields.io/badge/MySQL-≥5.7-blue">
@@ -130,10 +130,14 @@ python3 app.py
130130
```
131131

132132
## 交流与赞助
133-
如果有对本项目及FastAPI感兴趣的朋友,欢迎加入知识星球一起交流学习,让我们一起变得更强。如果你觉得这个项目帮助到了你,你可以请作者喝杯咖啡表示鼓励☕。
133+
如果有对本项目及FastAPI感兴趣的朋友,欢迎加入知识星球一起交流学习,让我们一起变得更强。如果你觉得这个项目帮助到了你,你可以请作者喝杯咖啡表示鼓励☕。扫描下面微信二维码添加微信备注DF-Admin即可进群,也欢迎大家加入dash大神费弗里的知识星球学习更多dash开发知识。
134134
<table>
135135
<tr>
136136
<td><img alt="zsxq" src="https://gitee.com/insistence2022/dash-fastapi-admin/raw/master/demo-pictures/zsxq.jpg"></td>
137137
<td><img alt="zanzhu" src="https://gitee.com/insistence2022/dash-fastapi-admin/raw/master/demo-pictures/zanzhu.jpg"></td>
138138
</tr>
139+
<tr>
140+
<td><img alt="wxcode" src="https://gitee.com/insistence2022/dash-fastapi-admin/raw/master/demo-pictures/wxcode.jpg"></td>
141+
<td><img alt="dashzsxq" src="https://gitee.com/insistence2022/dash-fastapi-admin/raw/master/demo-pictures/dashzsxq.jpg"></td>
142+
</tr>
139143
</table>

dash-fastapi-backend/module_admin/dao/dept_dao.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def add_dept_dao(cls, db: Session, dept: DeptModel):
197197
"""
198198
db_dept = SysDept(**dept.dict())
199199
db.add(db_dept)
200-
db.refresh(db_dept) # 刷新
200+
db.flush()
201201

202202
return db_dept
203203

dash-fastapi-backend/module_admin/service/job_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ async def export_job_list_services(request: Request, job_list: List):
167167

168168
data = [JobModel(**vars(row)).dict() for row in job_list]
169169
job_group_list = await DictDataService.query_dict_data_list_from_cache_services(request.app.state.redis, dict_type='sys_job_group')
170-
job_group_option = [dict(label=item.dict_label, value=item.dict_value) for item in job_group_list]
170+
job_group_option = [dict(label=item.get('dict_label'), value=item.get('dict_value')) for item in job_group_list]
171171
job_group_option_dict = {item.get('value'): item for item in job_group_option}
172172

173173
for item in data:

dash-fastapi-frontend/app.py

Lines changed: 120 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,27 @@
7676

7777

7878
@app.callback(
79-
[Output('app-mount', 'children'),
80-
Output('redirect-container', 'children', allow_duplicate=True),
81-
Output('global-message-container', 'children', allow_duplicate=True),
82-
Output('api-check-token', 'data', allow_duplicate=True),
83-
Output('current-key-container', 'data'),
84-
Output('menu-info-store-container', 'data'),
85-
Output('menu-list-store-container', 'data'),
86-
Output('search-panel', 'data')],
87-
Input('url-container', 'pathname'),
88-
[State('url-container', 'trigger'),
89-
State('token-container', 'data')],
79+
output=dict(
80+
app_mount=Output('app-mount', 'children'),
81+
redirect_container=Output('redirect-container', 'children', allow_duplicate=True),
82+
global_message_container=Output('global-message-container', 'children', allow_duplicate=True),
83+
api_check_token_trigger=Output('api-check-token', 'data', allow_duplicate=True),
84+
menu_current_key=Output('current-key-container', 'data'),
85+
menu_info=Output('menu-info-store-container', 'data'),
86+
menu_list=Output('menu-list-store-container', 'data'),
87+
search_panel_data=Output('search-panel', 'data')
88+
),
89+
inputs=dict(pathname=Input('url-container', 'pathname')),
90+
state=dict(
91+
url_trigger=State('url-container', 'trigger'),
92+
session_token=State('token-container', 'data')
93+
),
9094
prevent_initial_call=True
9195
)
92-
def router(pathname, trigger, session_token):
96+
def router(pathname, url_trigger, session_token):
97+
"""
98+
全局路由回调
99+
"""
93100
# 检查当前会话是否已经登录
94101
token_result = session.get('Authorization')
95102
# 若已登录
@@ -115,142 +122,136 @@ def router(pathname, trigger, session_token):
115122
current_key = '首页'
116123
if pathname == '/user/profile':
117124
current_key = '个人资料'
118-
if trigger == 'load':
125+
if url_trigger == 'load':
119126

120127
# 根据pathname控制渲染行为
121128
if pathname == '/login' or pathname == '/forget':
122129
# 重定向到主页面
123-
return [
124-
dash.no_update,
125-
dcc.Location(
126-
pathname='/',
127-
id='router-redirect'
128-
),
129-
None,
130-
{'timestamp': time.time()},
131-
{'current_key': current_key},
132-
{'menu_info': menu_info},
133-
{'menu_list': menu_list},
134-
search_panel_data
135-
]
130+
return dict(
131+
app_mount=dash.no_update,
132+
redirect_container=dcc.Location(pathname='/', id='router-redirect'),
133+
global_message_container=None,
134+
api_check_token_trigger={'timestamp': time.time()},
135+
menu_current_key={'current_key': current_key},
136+
menu_info={'menu_info': menu_info},
137+
menu_list={'menu_list': menu_list},
138+
search_panel_data=search_panel_data
139+
)
136140

137141
# 否则正常渲染主页面
138-
return [
139-
views.layout.render_content(user_menu_info),
140-
None,
141-
fuc.FefferyFancyNotification('进入主页面', type='success', autoClose=2000),
142-
{'timestamp': time.time()},
143-
{'current_key': current_key},
144-
{'menu_info': menu_info},
145-
{'menu_list': menu_list},
146-
search_panel_data
147-
]
142+
return dict(
143+
app_mount=views.layout.render_content(user_menu_info),
144+
redirect_container=None,
145+
global_message_container=None,
146+
api_check_token_trigger={'timestamp': time.time()},
147+
menu_current_key={'current_key': current_key},
148+
menu_info={'menu_info': menu_info},
149+
menu_list={'menu_list': menu_list},
150+
search_panel_data=search_panel_data
151+
)
148152

149153
else:
150-
return [
151-
dash.no_update,
152-
None,
153-
None,
154-
{'timestamp': time.time()},
155-
{'current_key': current_key},
156-
{'menu_info': menu_info},
157-
{'menu_list': menu_list},
158-
search_panel_data
159-
]
154+
return dict(
155+
app_mount=dash.no_update,
156+
redirect_container=None,
157+
global_message_container=None,
158+
api_check_token_trigger={'timestamp': time.time()},
159+
menu_current_key={'current_key': current_key},
160+
menu_info={'menu_info': menu_info},
161+
menu_list={'menu_list': menu_list},
162+
search_panel_data=search_panel_data
163+
)
160164

161165
else:
162166
# 渲染404状态页
163-
return [
164-
views.page_404.render_content(),
165-
None,
166-
None,
167-
{'timestamp': time.time()},
168-
dash.no_update,
169-
dash.no_update,
170-
dash.no_update,
171-
dash.no_update
172-
]
167+
return dict(
168+
app_mount=views.page_404.render_content(),
169+
redirect_container=None,
170+
global_message_container=None,
171+
api_check_token_trigger={'timestamp': time.time()},
172+
menu_current_key=dash.no_update,
173+
menu_info=dash.no_update,
174+
menu_list=dash.no_update,
175+
search_panel_data=dash.no_update
176+
)
173177

174178
else:
175-
return [
176-
dash.no_update,
177-
dash.no_update,
178-
dash.no_update,
179-
{'timestamp': time.time()},
180-
dash.no_update,
181-
dash.no_update,
182-
dash.no_update,
183-
dash.no_update
184-
]
179+
return dict(
180+
app_mount=dash.no_update,
181+
redirect_container=dash.no_update,
182+
global_message_container=dash.no_update,
183+
api_check_token_trigger={'timestamp': time.time()},
184+
menu_current_key=dash.no_update,
185+
menu_info=dash.no_update,
186+
menu_list=dash.no_update,
187+
search_panel_data=dash.no_update
188+
)
185189

186190
except Exception as e:
187191
print(e)
188192

189-
return [
190-
dash.no_update,
191-
None,
192-
fuc.FefferyFancyNotification('接口异常', type='error', autoClose=2000),
193-
{'timestamp': time.time()},
194-
dash.no_update,
195-
dash.no_update,
196-
dash.no_update,
197-
dash.no_update
198-
]
193+
return dict(
194+
app_mount=dash.no_update,
195+
redirect_container=None,
196+
global_message_container=fuc.FefferyFancyNotification('接口异常', type='error', autoClose=2000),
197+
api_check_token_trigger={'timestamp': time.time()},
198+
menu_current_key=dash.no_update,
199+
menu_info=dash.no_update,
200+
menu_list=dash.no_update,
201+
search_panel_data=dash.no_update
202+
)
199203
else:
200204
# 若未登录
201205
# 根据pathname控制渲染行为
202206
# 检验pathname合法性
203207
if pathname not in RouterConfig.BASIC_VALID_PATHNAME:
204208
# 渲染404状态页
205-
return [
206-
views.page_404.render_content(),
207-
None,
208-
None,
209-
{'timestamp': time.time()},
210-
dash.no_update,
211-
dash.no_update,
212-
dash.no_update,
213-
dash.no_update
214-
]
209+
return dict(
210+
app_mount=views.page_404.render_content(),
211+
redirect_container=None,
212+
global_message_container=None,
213+
api_check_token_trigger={'timestamp': time.time()},
214+
menu_current_key=dash.no_update,
215+
menu_info=dash.no_update,
216+
menu_list=dash.no_update,
217+
search_panel_data=dash.no_update
218+
)
215219

216220
if pathname == '/login':
217-
return [
218-
views.login.render_content(),
219-
None,
220-
None,
221-
{'timestamp': time.time()},
222-
dash.no_update,
223-
dash.no_update,
224-
dash.no_update,
225-
dash.no_update
226-
]
221+
return dict(
222+
app_mount=views.login.render_content(),
223+
redirect_container=None,
224+
global_message_container=None,
225+
api_check_token_trigger={'timestamp': time.time()},
226+
menu_current_key=dash.no_update,
227+
menu_info=dash.no_update,
228+
menu_list=dash.no_update,
229+
search_panel_data=dash.no_update
230+
)
227231

228232
if pathname == '/forget':
229-
return [
230-
views.forget.render_forget_content(),
231-
None,
232-
None,
233-
{'timestamp': time.time()},
234-
dash.no_update,
235-
dash.no_update,
236-
dash.no_update,
237-
dash.no_update
238-
]
233+
return dict(
234+
app_mount=views.forget.render_forget_content(),
235+
redirect_container=None,
236+
global_message_container=None,
237+
api_check_token_trigger={'timestamp': time.time()},
238+
menu_current_key=dash.no_update,
239+
menu_info=dash.no_update,
240+
menu_list=dash.no_update,
241+
search_panel_data=dash.no_update
242+
)
239243

240244
# 否则重定向到登录页
241-
return [
242-
dash.no_update,
243-
dcc.Location(
244-
pathname='/login',
245-
id='router-redirect'
246-
),
247-
None,
248-
{'timestamp': time.time()},
249-
dash.no_update,
250-
dash.no_update,
251-
dash.no_update,
252-
dash.no_update
253-
]
245+
return dict(
246+
app_mount=dash.no_update,
247+
redirect_container=dcc.Location(pathname='/login', id='router-redirect'),
248+
global_message_container=None,
249+
api_check_token_trigger={'timestamp': time.time()},
250+
menu_current_key=dash.no_update,
251+
menu_info=dash.no_update,
252+
menu_list=dash.no_update,
253+
search_panel_data=dash.no_update
254+
)
254255

255256

256257
if __name__ == '__main__':

0 commit comments

Comments
 (0)