mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-13 23:12:35 +08:00
Allow extensions to add custom css
This commit is contained in:
parent
213976f8c3
commit
b06527ba23
@ -142,6 +142,11 @@ class PromptServer():
|
|||||||
name) + "/" + os.path.relpath(f, dir).replace("\\", "/"), files)))
|
name) + "/" + os.path.relpath(f, dir).replace("\\", "/"), files)))
|
||||||
|
|
||||||
return web.json_response(extensions)
|
return web.json_response(extensions)
|
||||||
|
|
||||||
|
@routes.get("/extensions/styles")
|
||||||
|
async def get_extensions_styles(request):
|
||||||
|
files = glob.glob(os.path.join(self.web_root, 'extensions/**/*.css'), recursive=True)
|
||||||
|
return web.json_response(list(map(lambda f: "/" + os.path.relpath(f, self.web_root).replace("\\", "/"), files)))
|
||||||
|
|
||||||
def get_dir_by_type(dir_type):
|
def get_dir_by_type(dir_type):
|
||||||
if dir_type is None:
|
if dir_type is None:
|
||||||
|
|||||||
@ -163,6 +163,15 @@ class ComfyApi extends EventTarget {
|
|||||||
return await resp.json();
|
return await resp.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list of extension's CSS style urls
|
||||||
|
* @returns An array of CSS urls to include
|
||||||
|
*/
|
||||||
|
async getExtensionsStyles() {
|
||||||
|
const resp = await this.fetchApi("/extensions/styles", { cache: "no-store" });
|
||||||
|
return await resp.json();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a list of embedding names
|
* Gets a list of embedding names
|
||||||
* @returns An array of script urls to import
|
* @returns An array of script urls to import
|
||||||
|
|||||||
@ -1130,6 +1130,15 @@ export class ComfyApp {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await Promise.all(extensionPromises);
|
await Promise.all(extensionPromises);
|
||||||
|
|
||||||
|
const styles = await api.getExtensionsStyles();
|
||||||
|
function loadCSS(url) {
|
||||||
|
var link = document.createElement('link');
|
||||||
|
link.rel = 'stylesheet';
|
||||||
|
link.href = url;
|
||||||
|
document.head.appendChild(link);
|
||||||
|
}
|
||||||
|
styles.forEach(loadCSS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user