Skip to content

Commit

Permalink
🐛 修复Config add配置时显示问题 (#1835)
Browse files Browse the repository at this point in the history
  • Loading branch information
HibiKier authored Jan 16, 2025
1 parent 63145ff commit d0b1024
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions zhenxun/builtin_plugins/init/init_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def _generate_simple_config(exists_module: list[str]):
# 读取用户配置
_data = {}
_tmp_data = {}
exists_module += Config.add_module
if SIMPLE_CONFIG_FILE.exists():
_data = _yaml.load(SIMPLE_CONFIG_FILE.open(encoding="utf8"))
# 将简易配置文件的数据填充到配置文件
Expand Down
2 changes: 2 additions & 0 deletions zhenxun/configs/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ def __init__(self, file: Path):
self._data: dict[str, ConfigGroup] = {}
self._simple_data: dict = {}
self._simple_file = DATA_PATH / "config.yaml"
self.add_module = []
_yaml = YAML()
if file:
file.parent.mkdir(exist_ok=True, parents=True)
Expand Down Expand Up @@ -328,6 +329,7 @@ def add_plugin_config(

if not module or not key:
raise ValueError("add_plugin_config: module和key不能为为空")
self.add_module.append(f"{module}:{key}".lower())
if module in self._data and (config := self._data[module].configs.get(key)):
config.help = help
config.arg_parser = arg_parser
Expand Down

0 comments on commit d0b1024

Please sign in to comment.