From 5c7b74a0d6283e0b2a684fcc817a0127538bf0e3 Mon Sep 17 00:00:00 2001 From: Wang Zhiyu Date: Thu, 11 Dec 2025 17:42:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=8B=A5=E5=B9=B2=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.example/config.toml | 3 ++- src/heurams/interface/__main__.py | 3 +-- src/heurams/interface/screens/nucreator.py | 21 ++++++++++++++++----- src/heurams/kernel/particles/probe.py | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/config.example/config.toml b/config.example/config.toml index 22e17ec..9367cb6 100644 --- a/config.example/config.toml +++ b/config.example/config.toml @@ -27,6 +27,7 @@ nucleon_dir = "./data/nucleon" electron_dir = "./data/electron" orbital_dir = "./data/orbital" cache_dir = "./data/cache" +template_dir = "./data/template" [services] # 定义服务到提供者的映射 audio = "playsound" # 可选项: playsound(通用), termux(仅用于支持 Android Termux), mpg123(TODO) @@ -35,4 +36,4 @@ llm = "openai" # 可选项: openai [providers.llm.openai] # 与 OpenAI 相容的语言模型接口服务设置 url = "" -key = "" \ No newline at end of file +key = "" diff --git a/src/heurams/interface/__main__.py b/src/heurams/interface/__main__.py index e1891c6..3f53c3c 100644 --- a/src/heurams/interface/__main__.py +++ b/src/heurams/interface/__main__.py @@ -1,5 +1,3 @@ -from heurams.context import rootdir, workdir, config_var - from textual.app import App from textual.widgets import Button from .screens.dashboard import DashboardScreen @@ -48,6 +46,7 @@ def is_subdir(parent, child): return 0 # 开发模式 +from heurams.context import rootdir, workdir, config_var from pathlib import Path from heurams.context import rootdir import os diff --git a/src/heurams/interface/screens/nucreator.py b/src/heurams/interface/screens/nucreator.py index 0a31b84..427faf8 100644 --- a/src/heurams/interface/screens/nucreator.py +++ b/src/heurams/interface/screens/nucreator.py @@ -20,12 +20,23 @@ class NucleonCreatorScreen(Screen): def __init__(self) -> None: super().__init__(name=None, id=None, classes=None) - def search_templates(): - from heurams.context import - def search_templates(self): - with open('r','/template/t.timl'): - pass + from pathlib import Path + from heurams.context import config_var + template_dir = Path(config_var.get()['paths']['template_dir']) + templates = list() + for i in template_dir.iterdir(): + if i.name.endswith('.toml'): + try: + import toml + with open('r', i) as f: + dic = toml.load(f) + desc = dic['__metadata__']['attribution']['desc'] + templates.append(desc + ' (' + i.name + ')') + except: + templates.append(f'无描述模板 ({i.name})') + print(templates) + return templates def compose(self) -> ComposeResult: yield Header(show_clock=True) diff --git a/src/heurams/kernel/particles/probe.py b/src/heurams/kernel/particles/probe.py index 36cb22c..90657bc 100644 --- a/src/heurams/kernel/particles/probe.py +++ b/src/heurams/kernel/particles/probe.py @@ -38,4 +38,4 @@ def probe_all(is_stem = 1): if __name__ == "__main__": import os print(os.getcwd()) - print(probe_all()) \ No newline at end of file + print(probe_all())