From eec90ab513ba42596aaec1f8e732a613fb0e90a8 Mon Sep 17 00:00:00 2001 From: LAOGOU-666 <441059767@qq.com> Date: Mon, 17 Nov 2025 00:45:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8A=E4=B8=AA=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E9=83=A8=E5=88=86=E6=8F=92=E4=BB=B6=E7=9A=84=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 20 +++++++++++++++----- pyproject.toml | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/__init__.py b/__init__.py index 35e38a7..1f9732f 100644 --- a/__init__.py +++ b/__init__.py @@ -74,16 +74,26 @@ async def dynamic_extensions_handler(request): """处理动态加载的插件的WEB_DIRECTORY文件访问""" module_name = request.match_info['module_name'] file_path = request.match_info['path'] - - # 从当前的EXTENSION_WEB_DIRS中查找 + + # 优先从 EXTENSION_WEB_DIRS 中查找(自定义节点,支持热更新) if module_name in nodes.EXTENSION_WEB_DIRS: web_dir = nodes.EXTENSION_WEB_DIRS[module_name] full_path = os.path.join(web_dir, file_path) - + if os.path.isfile(full_path): return web.FileResponse(full_path) - - # 如果找不到,返回404 + + # 如果不在 EXTENSION_WEB_DIRS 中,尝试从 ComfyUI 前端包的 extensions 目录查找(系统扩展如 core) + # PromptServer.instance.web_root 指向前端包的静态文件目录 + # 例如:E:\python3.11\Lib\site-packages\comfyui_frontend_package\static + if hasattr(PromptServer.instance, 'web_root') and PromptServer.instance.web_root: + web_root = PromptServer.instance.web_root + full_path = os.path.join(web_root, "extensions", module_name, file_path) + + if os.path.isfile(full_path): + return web.FileResponse(full_path) + + # 如果都找不到,返回404 raise web.HTTPNotFound() # 存储动态路由映射 diff --git a/pyproject.toml b/pyproject.toml index 4b40432..854e7ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui_lg_hotreload" description = "An extension for ComfyUI that allows hot reloading. Once installed, you can preview changes in real-time while developing custom nodes or installing plugins without restarting ComfyUI." -version = "1.8.0" +version = "1.8.1" dependencies = ["watchdog"] [project.urls]