mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-11 18:53:35 +08:00
Update ComfyUI for private
This commit is contained in:
parent
eda8704386
commit
49ea5435c7
21
nodes.py
21
nodes.py
@ -1907,22 +1907,27 @@ def load_custom_node(module_path, ignore=set()):
|
||||
logging.warning(f"Cannot import {module_path} module for custom nodes: {e}")
|
||||
return False
|
||||
|
||||
def load_custom_nodes():
|
||||
def load_custom_nodes(public_mark: str = '_public/'):
|
||||
base_node_names = set(NODE_CLASS_MAPPINGS.keys())
|
||||
node_paths = folder_paths.get_folder_paths("custom_nodes")
|
||||
node_import_times = []
|
||||
for custom_node_path in node_paths:
|
||||
to_install_possible_modules = {}
|
||||
|
||||
for custom_node_path in sorted(node_paths, key=lambda x: public_mark in x, reverse=True):
|
||||
possible_modules = os.listdir(os.path.realpath(custom_node_path))
|
||||
if "__pycache__" in possible_modules:
|
||||
possible_modules.remove("__pycache__")
|
||||
|
||||
for possible_module in possible_modules:
|
||||
module_path = os.path.join(custom_node_path, possible_module)
|
||||
if os.path.isfile(module_path) and os.path.splitext(module_path)[1] != ".py": continue
|
||||
if module_path.endswith(".disabled"): continue
|
||||
time_before = time.perf_counter()
|
||||
success = load_custom_node(module_path, base_node_names)
|
||||
node_import_times.append((time.perf_counter() - time_before, module_path, success))
|
||||
to_install_possible_modules[possible_module] = (custom_node_path, possible_module)
|
||||
|
||||
for custom_node_path, possible_module in to_install_possible_modules.values():
|
||||
module_path = os.path.join(custom_node_path, possible_module)
|
||||
if os.path.isfile(module_path) and os.path.splitext(module_path)[1] != ".py": continue
|
||||
if module_path.endswith(".disabled"): continue
|
||||
time_before = time.perf_counter()
|
||||
success = load_custom_node(module_path, base_node_names)
|
||||
node_import_times.append((time.perf_counter() - time_before, module_path, success))
|
||||
|
||||
if len(node_import_times) > 0:
|
||||
logging.info("\nImport times for custom nodes:")
|
||||
|
||||
@ -6,6 +6,7 @@ import { defaultGraph } from "./defaultGraph.js";
|
||||
import { getPngMetadata, getWebpMetadata, importA1111, getLatentMetadata } from "./pnginfo.js";
|
||||
import { addDomClippingSetting } from "./domWidget.js";
|
||||
import { createImageHost, calculateImageGrid } from "./ui/imagePreview.js"
|
||||
import { getWorkflow } from "./utils.js";
|
||||
|
||||
export const ANIM_PREVIEW_WIDGET = "$$comfy_animation_preview"
|
||||
|
||||
@ -1496,28 +1497,37 @@ export class ComfyApp {
|
||||
await this.registerNodes();
|
||||
initWidgets(this);
|
||||
|
||||
// Load previous workflow
|
||||
let restored = false;
|
||||
try {
|
||||
const loadWorkflow = async (json) => {
|
||||
if (json) {
|
||||
const workflow = JSON.parse(json);
|
||||
await this.loadGraphData(workflow);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
const clientId = api.initialClientId ?? api.clientId;
|
||||
restored =
|
||||
(clientId && (await loadWorkflow(sessionStorage.getItem(`workflow:${clientId}`)))) ||
|
||||
(await loadWorkflow(localStorage.getItem("workflow")));
|
||||
} catch (err) {
|
||||
console.error("Error loading previous workflow", err);
|
||||
// Load prebuilt workflow
|
||||
const workflow = await getWorkflow();
|
||||
|
||||
if (workflow) {
|
||||
await this.loadGraphData(workflow);
|
||||
}
|
||||
else {
|
||||
// Load previous workflow
|
||||
let restored = false;
|
||||
try {
|
||||
const loadWorkflow = async (json) => {
|
||||
if (json) {
|
||||
const workflow = JSON.parse(json);
|
||||
await this.loadGraphData(workflow);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
const clientId = api.initialClientId ?? api.clientId;
|
||||
restored =
|
||||
(clientId && (await loadWorkflow(sessionStorage.getItem(`workflow:${clientId}`)))) ||
|
||||
(await loadWorkflow(localStorage.getItem("workflow")));
|
||||
} catch (err) {
|
||||
console.error("Error loading previous workflow", err);
|
||||
}
|
||||
|
||||
// We failed to restore a workflow so load the default
|
||||
if (!restored) {
|
||||
await this.loadGraphData();
|
||||
}
|
||||
}
|
||||
|
||||
// We failed to restore a workflow so load the default
|
||||
if (!restored) {
|
||||
await this.loadGraphData();
|
||||
}
|
||||
|
||||
// Save current workflow automatically
|
||||
setInterval(() => {
|
||||
|
||||
@ -1,5 +1,30 @@
|
||||
import { $el } from "./ui.js";
|
||||
|
||||
export function needLoadPrebuiltWorkflow(workflowId) {
|
||||
var loaded = localStorage.getItem('PrebuiltWorkflowId' + workflowId);
|
||||
if (loaded) {
|
||||
return false
|
||||
} else {
|
||||
localStorage.setItem('PrebuiltWorkflowId' + workflowId, true);
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
export async function getWorkflow() {
|
||||
let flow_json = null;
|
||||
const queryString = window.location.search;
|
||||
const urlParams = new URLSearchParams(queryString);
|
||||
const workflowId = urlParams.get('workflow');
|
||||
if (workflowId && needLoadPrebuiltWorkflow(workflowId)) {
|
||||
await fetch('../workflows/' + workflowId + '/' + workflowId + '.json').then(
|
||||
response => {
|
||||
flow_json = response.json()
|
||||
}
|
||||
)
|
||||
}
|
||||
return flow_json;
|
||||
}
|
||||
|
||||
// Simple date formatter
|
||||
const parts = {
|
||||
d: (d) => d.getDate(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user