From b37701418ed39135eb23b7ee3e99935e03954914 Mon Sep 17 00:00:00 2001 From: KimigaiiWuyi <444835641@qq.com> Date: Sun, 1 Jun 2025 02:52:43 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20=E4=B8=BA=E7=BD=91=E9=A1=B5?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=8F=B0=E8=AE=BE=E7=BD=AE=E9=A1=B9=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=AF=A6=E6=83=85=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gsuid_core/webconsole/create_base_panel.py | 80 +++++++++++++++++--- gsuid_core/webconsole/create_config_panel.py | 45 +++++++++-- 2 files changed, 110 insertions(+), 15 deletions(-) diff --git a/gsuid_core/webconsole/create_base_panel.py b/gsuid_core/webconsole/create_base_panel.py index 118c013..86f49b1 100644 --- a/gsuid_core/webconsole/create_base_panel.py +++ b/gsuid_core/webconsole/create_base_panel.py @@ -52,7 +52,12 @@ def get_service(body: List[Dict]): def get_input_number( - label: str, name: str, value: int, max_value: Optional[int] = None + label: str, + name: str, + value: int, + max_value: Optional[int] = None, + hint_title: Optional[str] = None, + hint_body: Optional[str] = None, ): data = { 'type': 'input-number', @@ -65,6 +70,9 @@ def get_input_number( } if max_value is not None: data['max'] = max_value + if hint_title is not None and hint_body is not None: + data['labelRemark'] = get_remark(hint_title, hint_body) + return data @@ -120,8 +128,14 @@ def get_button(title: str, api: Optional[Dict] = None): return data -def get_switch_panel(label: str, name: str, value: bool): - return { +def get_switch_panel( + label: str, + name: str, + value: bool, + hint_title: Optional[str] = None, + hint_body: Optional[str] = None, +): + data = { 'type': 'switch', 'label': label, 'option': '', @@ -132,9 +146,20 @@ def get_switch_panel(label: str, name: str, value: bool): 'value': value, } + if hint_title is not None and hint_body is not None: + data['labelRemark'] = get_remark(hint_title, hint_body) -def get_text_panel(label: str, name: str, value: str): - return { + return data + + +def get_text_panel( + label: str, + name: str, + value: str, + hint_title: Optional[str] = None, + hint_body: Optional[str] = None, +): + data: dict = { 'type': 'input-text', 'label': label, 'name': name, @@ -142,6 +167,22 @@ def get_text_panel(label: str, name: str, value: str): 'value': value, } + if hint_title is not None and hint_body is not None: + data['labelRemark'] = get_remark(hint_title, hint_body) + + return data + + +def get_remark(title: str, body: str): + return { + "icon": "fa fa-question-circle", + "trigger": ["hover"], + "className": "Remark--warning", + "placement": "top", + "title": title, + "content": body, + } + def get_alert( message: str, @@ -157,8 +198,15 @@ def get_alert( } -def get_select_panel(label: str, name: str, value: str, options: List[str]): - return { +def get_select_panel( + label: str, + name: str, + value: str, + options: List[str], + hint_title: Optional[str] = None, + hint_body: Optional[str] = None, +): + data = { 'type': 'input-text', 'label': label, 'name': name, @@ -166,9 +214,19 @@ def get_select_panel(label: str, name: str, value: str, options: List[str]): 'id': 'u:8050095a7c1d', 'value': value, } + if hint_title is not None and hint_body is not None: + data['labelRemark'] = get_remark(hint_title, hint_body) + return data -def get_input_tag(label: str, name: str, value: List[str], options: List[str]): +def get_input_tag( + label: str, + name: str, + value: List[str], + options: List[str], + hint_title: Optional[str] = None, + hint_body: Optional[str] = None, +): values = [] for i in value: if isinstance(i, int): @@ -176,7 +234,7 @@ def get_input_tag(label: str, name: str, value: List[str], options: List[str]): else: _data = i values.append(_data) - return { + data = { 'type': 'input-tag', 'label': label, 'name': name, @@ -186,6 +244,10 @@ def get_input_tag(label: str, name: str, value: List[str], options: List[str]): 'autoFill': {}, 'value': ','.join(values), } + if hint_title is not None and hint_body is not None: + data['labelRemark'] = get_remark(hint_title, hint_body) + + return data def get_divider(): diff --git a/gsuid_core/webconsole/create_config_panel.py b/gsuid_core/webconsole/create_config_panel.py index d0ab53e..97237a1 100644 --- a/gsuid_core/webconsole/create_config_panel.py +++ b/gsuid_core/webconsole/create_config_panel.py @@ -82,27 +82,60 @@ def get_config_page(): if isinstance(gsc, GsStrConfig): if gsc.options: _data = get_select_panel( - gsc.title, config, gsc.data, gsc.options + gsc.title, + config, + gsc.data, + gsc.options, + gsc.title, + gsc.desc, ) else: - _data = get_text_panel(gsc.title, config, gsc.data) + _data = get_text_panel( + gsc.title, + config, + gsc.data, + gsc.title, + gsc.desc, + ) solo_body.append(_data) elif isinstance(gsc, GsIntConfig): solo_body.append( get_input_number( - gsc.title, config, gsc.data, gsc.max_value + gsc.title, + config, + gsc.data, + gsc.max_value, + gsc.title, + gsc.desc, ) ) elif isinstance(gsc, GsBoolConfig): - solo_body.append(get_switch_panel(gsc.title, config, gsc.data)) + solo_body.append( + get_switch_panel( + gsc.title, + config, + gsc.data, + gsc.title, + gsc.desc, + ) + ) elif isinstance(gsc, GsListStrConfig): if not gsc.options: _data = get_text_panel( - gsc.title, config, ':'.join(gsc.data) + gsc.title, + config, + ':'.join(gsc.data), + gsc.title, + gsc.desc, ) else: _data = get_input_tag( - gsc.title, config, gsc.data, gsc.options + gsc.title, + config, + gsc.data, + gsc.options, + gsc.title, + gsc.desc, ) solo_body.append(_data) elif isinstance(gsc, GsImageConfig):