Skip to content

Commit d6be55a

Browse files
committed
perf:优化登录信息失效时自动移除sessionStorage的token信息
1 parent 5d26b33 commit d6be55a

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

dash-fastapi-frontend/callbacks/app_c.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def check_api_response(data):
2828

2929
# api拦截器——退出登录二次确认
3030
@app.callback(
31-
Output('redirect-container', 'children', allow_duplicate=True),
31+
[Output('redirect-container', 'children', allow_duplicate=True),
32+
Output('token-container', 'data', allow_duplicate=True)],
3233
Input('token-invalid-modal', 'okCounts'),
3334
prevent_initial_call=True
3435
)
@@ -41,10 +42,11 @@ def redirect_page(okCounts):
4142
dcc.Location(
4243
pathname='/login',
4344
id='index-redirect'
44-
)
45+
),
46+
None
4547
]
4648

47-
return dash.no_update
49+
return [dash.no_update] * 2
4850

4951

5052
# 应用初始化主题颜色

dash-fastapi-frontend/callbacks/layout_c/head_c.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545

4646
# 退出登录回调
4747
@app.callback(
48-
Output('redirect-container', 'children', allow_duplicate=True),
48+
[Output('redirect-container', 'children', allow_duplicate=True),
49+
Output('token-container', 'data', allow_duplicate=True)],
4950
Input('logout-modal', 'okCounts'),
5051
prevent_initial_call=True
5152
)
@@ -60,9 +61,10 @@ def logout_confirm(okCounts):
6061
pathname='/login',
6162
id='index-redirect'
6263
),
64+
None
6365
]
6466

65-
return dash.no_update
67+
return [dash.no_update] * 2
6668

6769

6870
# 全局页面重载回调

0 commit comments

Comments
 (0)