feat: 代码格式化, 改进仪表盘, 新增多CSS支持

This commit is contained in:
2026-04-20 16:30:04 +08:00
parent 845a505ca1
commit 65fbdec0a9
43 changed files with 551 additions and 349 deletions
+35 -15
View File
@@ -3,27 +3,41 @@ from heurams.services.logger import get_logger
logger = get_logger(__name__)
def epath(dct, path: str = '', default=None, parents=False, enable_modify=False, new_value=None):
def epath(
dct,
path: str = "",
default=None,
parents=False,
enable_modify=False,
new_value=None,
):
if not path:
return dct
path = path.rstrip('.')
path = path.lstrip('.')
path = path.rstrip(".")
path = path.lstrip(".")
target = dct
keys = path.split('.')
keys = path.split(".")
logger.debug(f"处理 EPATH {path}, {new_value}")
for idx, i in enumerate(keys):
is_last = (idx == len(keys) - 1)
is_last = idx == len(keys) - 1
# 处理字典键
logger.debug(f'处理 {i}, {(isinstance(target, dict) or isinstance(target, ConfigDict))} {i in target}')
logger.debug(
f"处理 {i}, {(isinstance(target, dict) or isinstance(target, ConfigDict))} {i in target}"
)
if is_last and enable_modify:
# 最后一次循环执行修改
if (isinstance(target, dict) or isinstance(target, ConfigDict)):
if isinstance(target, dict) or isinstance(target, ConfigDict):
target[i] = new_value
return new_value
elif i.startswith('[') and i.endswith(']') and isinstance(target, (list, tuple)):
elif (
i.startswith("[")
and i.endswith("]")
and isinstance(target, (list, tuple))
):
idx_num = int(i[1:-1])
if 0 <= idx_num < len(target):
target[idx_num] = new_value
@@ -38,9 +52,15 @@ def epath(dct, path: str = '', default=None, parents=False, enable_modify=False,
else:
return default
else:
if (isinstance(target, dict) or isinstance(target, ConfigDict)) and i in target:
if (
isinstance(target, dict) or isinstance(target, ConfigDict)
) and i in target:
target = target[i]
elif i.startswith('[') and i.endswith(']') and isinstance(target, (list, tuple)):
elif (
i.startswith("[")
and i.endswith("]")
and isinstance(target, (list, tuple))
):
idx_num = int(i[1:-1])
if 0 <= idx_num < len(target):
target = target[idx_num]
@@ -56,5 +76,5 @@ def epath(dct, path: str = '', default=None, parents=False, enable_modify=False,
target = target[i]
else:
return default
return target
return target