Skip to content

Commit 88911a2

Browse files
committed
refactor: 重构动态加载的页面入参,改用位置参数args和关键字参数kwargs接收传入的参数,不再指定具体的入参名称
1 parent 4bcd489 commit 88911a2

File tree

21 files changed

+38
-22
lines changed

21 files changed

+38
-22
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from dash.exceptions import PreventUpdate
44
import feffery_antd_components as fac
55
from jsonpath_ng import parse
6-
from flask import json
6+
from flask import json, session
77
from collections import OrderedDict
88

99
from server import app
@@ -53,10 +53,12 @@ def handle_tab_switch_and_create(currentKey, tabCloseCounts, latestDeletePane, o
5353
if currentKey == '个人资料':
5454
menu_title = '个人资料'
5555
button_perms = []
56+
role_perms = []
5657
menu_modules = 'system.user.profile'
5758
else:
5859
menu_title = find_title_by_key(menu_info.get('menu_info'), currentKey)
5960
button_perms = [item.get('perms') for item in menu_list.get('menu_list') if str(item.get('parent_id')) == currentKey]
61+
role_perms = [item.get('role_key') for item in session.get('role_info')]
6062
# 判断当前选中的菜单栏项是否存在module,如果有,则动态导入module,否则返回404页面
6163
menu_modules = find_modules_by_key(menu_info.get('menu_info'), currentKey)
6264

@@ -106,7 +108,7 @@ def handle_tab_switch_and_create(currentKey, tabCloseCounts, latestDeletePane, o
106108
{
107109
'label': menu_title,
108110
'key': currentKey,
109-
'children': eval('views.' + menu_modules + '.render(button_perms)'),
111+
'children': eval('views.' + menu_modules + '.render(button_perms=button_perms, role_perms=role_perms)'),
110112
'contextMenu': context_menu
111113
}
112114
)

dash-fastapi-frontend/views/monitor/cache/control/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from api.cache import get_cache_statistical_info_api
66

77

8-
def render(button_perms):
8+
def render(*args, **kwargs):
9+
button_perms = kwargs.get('button_perms')
910
command_stats = []
1011
db_size = ''
1112
info = {}

dash-fastapi-frontend/views/monitor/cache/list/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import callbacks.monitor_c.cache_c.list_c
66

77

8-
def render(button_perms):
8+
def render(*args, **kwargs):
99
cache_name_data = []
1010
cache_name_res = get_cache_name_list_api()
1111
if cache_name_res.get('code') == 200:

dash-fastapi-frontend/views/monitor/druid/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
import feffery_antd_components as fac
44

55

6-
def render(button_perms):
6+
def render(*args, **kwargs):
77

88
return html.Div('我是数据监控')

dash-fastapi-frontend/views/monitor/job/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
from api.dict import query_dict_data_list_api
99

1010

11-
def render(button_perms):
11+
def render(*args, **kwargs):
12+
button_perms = kwargs.get('button_perms')
1213

1314
option = []
1415
option_table = []

dash-fastapi-frontend/views/monitor/logininfor/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from api.log import get_login_log_list_api
66

77

8-
def render(button_perms):
8+
def render(*args, **kwargs):
9+
button_perms = kwargs.get('button_perms')
910

1011
login_log_params = dict(page_num=1, page_size=10)
1112
table_info = get_login_log_list_api(login_log_params)

dash-fastapi-frontend/views/monitor/online/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from api.online import get_online_list_api
66

77

8-
def render(button_perms):
8+
def render(*args, **kwargs):
9+
button_perms = kwargs.get('button_perms')
910

1011
online_params = dict(page_num=1, page_size=10)
1112
table_info = get_online_list_api(online_params)

dash-fastapi-frontend/views/monitor/operlog/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
from api.dict import query_dict_data_list_api
88

99

10-
def render(button_perms):
10+
def render(*args, **kwargs):
11+
button_perms = kwargs.get('button_perms')
1112

1213
option = []
1314
option_table = []

dash-fastapi-frontend/views/monitor/server/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
from api.server import get_server_statistical_info_api
55

66

7-
def render(button_perms):
7+
def render(*args, **kwargs):
8+
button_perms = kwargs.get('button_perms')
89
cpu = {}
910
mem = {}
1011
sys = {}

dash-fastapi-frontend/views/system/config/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from api.config import get_config_list_api
66

77

8-
def render(button_perms):
8+
def render(*args, **kwargs):
9+
button_perms = kwargs.get('button_perms')
910

1011
config_params = dict(page_num=1, page_size=10)
1112
table_info = get_config_list_api(config_params)

0 commit comments

Comments
 (0)