mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-13 12:17:08 +08:00
Merge e93d5f9edabcd7879500a2135693d5394e920610 into bf2650a80e5a7a888da206eab45c53dbb22940f7
This commit is contained in:
commit
45f4595d80
6
nodes.py
6
nodes.py
@ -1984,6 +1984,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EXTENSION_WEB_DIRS = {}
|
EXTENSION_WEB_DIRS = {}
|
||||||
|
EXTENSION_STYLE_DIRS = {}
|
||||||
|
|
||||||
|
|
||||||
def get_module_name(module_path: str) -> str:
|
def get_module_name(module_path: str) -> str:
|
||||||
@ -2026,6 +2027,11 @@ def load_custom_node(module_path: str, ignore=set(), module_parent="custom_nodes
|
|||||||
sys.modules[module_name] = module
|
sys.modules[module_name] = module
|
||||||
module_spec.loader.exec_module(module)
|
module_spec.loader.exec_module(module)
|
||||||
|
|
||||||
|
if hasattr(module, "STYLE_DIRECTORY") and getattr(module, "STYLE_DIRECTORY") is not None:
|
||||||
|
style_dir = os.path.abspath(os.path.join(module_dir, getattr(module, "STYLE_DIRECTORY")))
|
||||||
|
if os.path.isdir(style_dir):
|
||||||
|
EXTENSION_STYLE_DIRS[module_name] = style_dir
|
||||||
|
|
||||||
if hasattr(module, "WEB_DIRECTORY") and getattr(module, "WEB_DIRECTORY") is not None:
|
if hasattr(module, "WEB_DIRECTORY") and getattr(module, "WEB_DIRECTORY") is not None:
|
||||||
web_dir = os.path.abspath(os.path.join(module_dir, getattr(module, "WEB_DIRECTORY")))
|
web_dir = os.path.abspath(os.path.join(module_dir, getattr(module, "WEB_DIRECTORY")))
|
||||||
if os.path.isdir(web_dir):
|
if os.path.isdir(web_dir):
|
||||||
|
|||||||
15
server.py
15
server.py
@ -235,6 +235,16 @@ class PromptServer():
|
|||||||
files = folder_paths.get_filename_list(folder)
|
files = folder_paths.get_filename_list(folder)
|
||||||
return web.json_response(files)
|
return web.json_response(files)
|
||||||
|
|
||||||
|
@routes.get("/styles")
|
||||||
|
async def get_styles(request):
|
||||||
|
styles = list()
|
||||||
|
for name, dir in nodes.EXTENSION_STYLE_DIRS.items():
|
||||||
|
files = glob.glob(os.path.join(glob.escape(dir), '**/*.css'), recursive=True)
|
||||||
|
styles.extend(list(map(lambda f: "/styles/" + urllib.parse.quote(
|
||||||
|
name) + "/" + os.path.relpath(f, dir).replace("\\", "/"), files)))
|
||||||
|
|
||||||
|
return web.json_response(styles)
|
||||||
|
|
||||||
@routes.get("/extensions")
|
@routes.get("/extensions")
|
||||||
async def get_extensions(request):
|
async def get_extensions(request):
|
||||||
files = glob.glob(os.path.join(
|
files = glob.glob(os.path.join(
|
||||||
@ -698,6 +708,11 @@ class PromptServer():
|
|||||||
self.app.add_routes(api_routes)
|
self.app.add_routes(api_routes)
|
||||||
self.app.add_routes(self.routes)
|
self.app.add_routes(self.routes)
|
||||||
|
|
||||||
|
for name, dir in nodes.EXTENSION_STYLE_DIRS.items():
|
||||||
|
self.app.add_routes([
|
||||||
|
web.static('/styles/' + urllib.parse.quote(name), dir, follow_symlinks=True),
|
||||||
|
])
|
||||||
|
|
||||||
for name, dir in nodes.EXTENSION_WEB_DIRS.items():
|
for name, dir in nodes.EXTENSION_WEB_DIRS.items():
|
||||||
self.app.add_routes([
|
self.app.add_routes([
|
||||||
web.static('/extensions/' + urllib.parse.quote(name), dir),
|
web.static('/extensions/' + urllib.parse.quote(name), dir),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user