Update ComfyUI for private

This commit is contained in:
Loner 2024-03-13 14:55:45 +08:00 committed by GitHub
parent eda8704386
commit 49ea5435c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 68 additions and 28 deletions

View File

@ -1907,16 +1907,21 @@ 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:
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) 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 os.path.isfile(module_path) and os.path.splitext(module_path)[1] != ".py": continue
if module_path.endswith(".disabled"): continue if module_path.endswith(".disabled"): continue

View File

@ -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,6 +1497,13 @@ export class ComfyApp {
await this.registerNodes(); await this.registerNodes();
initWidgets(this); initWidgets(this);
// Load prebuilt workflow
const workflow = await getWorkflow();
if (workflow) {
await this.loadGraphData(workflow);
}
else {
// Load previous workflow // Load previous workflow
let restored = false; let restored = false;
try { try {
@ -1518,6 +1526,8 @@ export class ComfyApp {
if (!restored) { if (!restored) {
await this.loadGraphData(); await this.loadGraphData();
} }
}
// Save current workflow automatically // Save current workflow automatically
setInterval(() => { setInterval(() => {

View File

@ -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(),