mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-11-12 03:20:03 +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}")
|
logging.warning(f"Cannot import {module_path} module for custom nodes: {e}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def load_custom_nodes():
|
def load_custom_nodes(public_mark: str = '_public/'):
|
||||||
base_node_names = set(NODE_CLASS_MAPPINGS.keys())
|
base_node_names = set(NODE_CLASS_MAPPINGS.keys())
|
||||||
node_paths = folder_paths.get_folder_paths("custom_nodes")
|
node_paths = folder_paths.get_folder_paths("custom_nodes")
|
||||||
node_import_times = []
|
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))
|
possible_modules = os.listdir(os.path.realpath(custom_node_path))
|
||||||
if "__pycache__" in possible_modules:
|
if "__pycache__" in possible_modules:
|
||||||
possible_modules.remove("__pycache__")
|
possible_modules.remove("__pycache__")
|
||||||
|
|
||||||
for possible_module in possible_modules:
|
for possible_module in possible_modules:
|
||||||
module_path = os.path.join(custom_node_path, possible_module)
|
to_install_possible_modules[possible_module] = (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
|
for custom_node_path, possible_module in to_install_possible_modules.values():
|
||||||
time_before = time.perf_counter()
|
module_path = os.path.join(custom_node_path, possible_module)
|
||||||
success = load_custom_node(module_path, base_node_names)
|
if os.path.isfile(module_path) and os.path.splitext(module_path)[1] != ".py": continue
|
||||||
node_import_times.append((time.perf_counter() - time_before, module_path, success))
|
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:
|
if len(node_import_times) > 0:
|
||||||
logging.info("\nImport times for custom nodes:")
|
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 { getPngMetadata, getWebpMetadata, importA1111, getLatentMetadata } from "./pnginfo.js";
|
||||||
import { addDomClippingSetting } from "./domWidget.js";
|
import { addDomClippingSetting } from "./domWidget.js";
|
||||||
import { createImageHost, calculateImageGrid } from "./ui/imagePreview.js"
|
import { createImageHost, calculateImageGrid } from "./ui/imagePreview.js"
|
||||||
|
import { getWorkflow } from "./utils.js";
|
||||||
|
|
||||||
export const ANIM_PREVIEW_WIDGET = "$$comfy_animation_preview"
|
export const ANIM_PREVIEW_WIDGET = "$$comfy_animation_preview"
|
||||||
|
|
||||||
@ -1496,28 +1497,37 @@ export class ComfyApp {
|
|||||||
await this.registerNodes();
|
await this.registerNodes();
|
||||||
initWidgets(this);
|
initWidgets(this);
|
||||||
|
|
||||||
// Load previous workflow
|
// Load prebuilt workflow
|
||||||
let restored = false;
|
const workflow = await getWorkflow();
|
||||||
try {
|
|
||||||
const loadWorkflow = async (json) => {
|
if (workflow) {
|
||||||
if (json) {
|
await this.loadGraphData(workflow);
|
||||||
const workflow = JSON.parse(json);
|
}
|
||||||
await this.loadGraphData(workflow);
|
else {
|
||||||
return true;
|
// Load previous workflow
|
||||||
}
|
let restored = false;
|
||||||
};
|
try {
|
||||||
const clientId = api.initialClientId ?? api.clientId;
|
const loadWorkflow = async (json) => {
|
||||||
restored =
|
if (json) {
|
||||||
(clientId && (await loadWorkflow(sessionStorage.getItem(`workflow:${clientId}`)))) ||
|
const workflow = JSON.parse(json);
|
||||||
(await loadWorkflow(localStorage.getItem("workflow")));
|
await this.loadGraphData(workflow);
|
||||||
} catch (err) {
|
return true;
|
||||||
console.error("Error loading previous workflow", err);
|
}
|
||||||
|
};
|
||||||
|
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
|
// Save current workflow automatically
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
|
|||||||
@ -1,5 +1,30 @@
|
|||||||
import { $el } from "./ui.js";
|
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
|
// Simple date formatter
|
||||||
const parts = {
|
const parts = {
|
||||||
d: (d) => d.getDate(),
|
d: (d) => d.getDate(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user