mirror of
https://git.datalinker.icu/ltdrdata/ComfyUI-Manager
synced 2025-12-09 22:24:23 +08:00
support preview method setting feature
This commit is contained in:
parent
93fa6187dd
commit
4da930814d
@ -32,6 +32,7 @@ You can execute ComfyUI by running either `./run_gpu.sh` or `./run_cpu.sh` depen
|
||||
|
||||
|
||||
# Changes
|
||||
* **0.17** Support preview method setting feature
|
||||
* **0.14** Support robust update
|
||||
* **0.13** Support additional 'pip' section for install spec
|
||||
* **0.12** Better installation support for Windows.
|
||||
@ -51,7 +52,7 @@ You can execute ComfyUI by running either `./run_gpu.sh` or `./run_cpu.sh` depen
|
||||
|
||||
|
||||
2. If you click on 'Install Custom Nodes' or 'Install Models', an installer dialog will open.
|
||||

|
||||

|
||||
|
||||
* When the 'Use local DB' feature is enabled, the application will utilize the data stored locally on your device, rather than retrieving node/model information over the internet
|
||||
|
||||
|
||||
79
__init__.py
79
__init__.py
@ -1,3 +1,4 @@
|
||||
import configparser
|
||||
import shutil
|
||||
import folder_paths
|
||||
import os, sys
|
||||
@ -32,7 +33,7 @@ sys.path.append('../..')
|
||||
from torchvision.datasets.utils import download_url
|
||||
|
||||
# ensure .js
|
||||
print("### Loading: ComfyUI-Manager (V0.16)")
|
||||
print("### Loading: ComfyUI-Manager (V0.17)")
|
||||
|
||||
comfy_ui_revision = "Unknown"
|
||||
|
||||
@ -48,6 +49,71 @@ local_db_extension_node_mappings = os.path.join(comfyui_manager_path, "extension
|
||||
git_script_path = os.path.join(os.path.dirname(__file__), "git_helper.py")
|
||||
|
||||
startup_script_path = os.path.join(comfyui_manager_path, "startup-scripts")
|
||||
config_path = os.path.join(os.path.dirname(__file__), "config.ini")
|
||||
cached_config = None
|
||||
|
||||
|
||||
from comfy.cli_args import args
|
||||
import latent_preview
|
||||
|
||||
|
||||
def write_config():
|
||||
config = configparser.ConfigParser()
|
||||
config['default'] = {
|
||||
'preview_method': get_current_preview_method(),
|
||||
}
|
||||
with open(config_path, 'w') as configfile:
|
||||
config.write(configfile)
|
||||
|
||||
|
||||
def read_config():
|
||||
try:
|
||||
config = configparser.ConfigParser()
|
||||
config.read(config_path)
|
||||
default_conf = config['default']
|
||||
|
||||
return {
|
||||
'preview_method': default_conf['preview_method']
|
||||
}
|
||||
|
||||
except Exception:
|
||||
return {'preview_method': get_current_preview_method()}
|
||||
|
||||
|
||||
def get_config():
|
||||
global cached_config
|
||||
|
||||
if cached_config is None:
|
||||
cached_config = read_config()
|
||||
|
||||
return cached_config
|
||||
|
||||
|
||||
def get_current_preview_method():
|
||||
if args.preview_method == latent_preview.LatentPreviewMethod.Auto:
|
||||
return "auto"
|
||||
elif args.preview_method == latent_preview.LatentPreviewMethod.Latent2RGB:
|
||||
return "latent2rgb"
|
||||
elif args.preview_method == latent_preview.LatentPreviewMethod.TAESD:
|
||||
return "taesd"
|
||||
else:
|
||||
return "none"
|
||||
|
||||
|
||||
def set_preview_method(method):
|
||||
if method == 'auto':
|
||||
args.preview_method = latent_preview.LatentPreviewMethod.Auto
|
||||
elif method == 'latent2rgb':
|
||||
args.preview_method = latent_preview.LatentPreviewMethod.Latent2RGB
|
||||
elif method == 'taesd':
|
||||
args.preview_method = latent_preview.LatentPreviewMethod.TAESD
|
||||
else:
|
||||
args.preview_method = latent_preview.LatentPreviewMethod.NoPreviews
|
||||
|
||||
get_config()['preview_method'] = args.preview_method
|
||||
|
||||
|
||||
set_preview_method(get_config()['preview_method'])
|
||||
|
||||
|
||||
def try_install_script(url, repo_path, install_cmd):
|
||||
@ -855,5 +921,16 @@ async def install_model(request):
|
||||
return web.Response(status=400)
|
||||
|
||||
|
||||
@server.PromptServer.instance.routes.get("/manager/preview_method")
|
||||
async def preview_method(request):
|
||||
if "value" in request.rel_url.query:
|
||||
set_preview_method(request.rel_url.query['value'])
|
||||
write_config()
|
||||
else:
|
||||
return web.Response(text=get_current_preview_method(), status=200)
|
||||
|
||||
return web.Response(status=200)
|
||||
|
||||
|
||||
NODE_CLASS_MAPPINGS = {}
|
||||
__all__ = ['NODE_CLASS_MAPPINGS']
|
||||
|
||||
@ -1338,6 +1338,20 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
() => fetchUpdates()
|
||||
});
|
||||
|
||||
let preview_combo = document.createElement("select");
|
||||
preview_combo.appendChild($el('option', {value:'auto', text:'Preview method: Auto'}, []));
|
||||
preview_combo.appendChild($el('option', {value:'taesd', text:'Preview method: TAESD'}, []));
|
||||
preview_combo.appendChild($el('option', {value:'latent2rgb', text:'Preview method: Latent2RGB'}, []));
|
||||
preview_combo.appendChild($el('option', {value:'none', text:'Preview method: None'}, []));
|
||||
|
||||
fetch('/manager/preview_method')
|
||||
.then(response => response.text())
|
||||
.then(data => { preview_combo.value = data; })
|
||||
|
||||
preview_combo.addEventListener('change', function(event) {
|
||||
fetch(`/manager/preview_method?value=${event.target.value}`);
|
||||
});
|
||||
|
||||
const res =
|
||||
[
|
||||
$el("tr.td", {width:"100%"}, [$el("font", {size:6, color:"white"}, [`ComfyUI Manager Menu`])]),
|
||||
@ -1400,7 +1414,12 @@ class ManagerMenuDialog extends ComfyDialog {
|
||||
onclick: () => { window.open("https://blenderneko.github.io/ComfyUI-docs/", "comfyui-community-manual"); }
|
||||
}),
|
||||
|
||||
$el("br", {}, []),
|
||||
$el("br", {}, []),
|
||||
$el("hr", {width: "100%"}, []),
|
||||
preview_combo,
|
||||
$el("hr", {width: "100%"}, []),
|
||||
$el("br", {}, []),
|
||||
|
||||
$el("button", {
|
||||
type: "button",
|
||||
textContent: "Close",
|
||||
|
||||
BIN
misc/menu.png
BIN
misc/menu.png
Binary file not shown.
|
Before Width: | Height: | Size: 38 KiB |
Loading…
x
Reference in New Issue
Block a user