bizydraft 0.1.30__py3-none-any.whl → 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of bizydraft might be problematic. Click here for more details.
- bizydraft/block_nodes.py +35 -0
- bizydraft/env.py +11 -0
- bizydraft/hijack_nodes.py +66 -6
- bizydraft/hijack_routes.py +87 -184
- bizydraft/oss_utils.py +227 -0
- bizydraft/patch_handlers.py +150 -0
- bizydraft/postload.py +26 -8
- bizydraft/static/js/aiAppHandler.js +540 -0
- bizydraft/static/js/freezeModeHandler.js +490 -0
- bizydraft/static/js/handleStyle.js +6 -0
- bizydraft/static/js/hookLoadImage.js +121 -81
- bizydraft/static/js/hookLoadModel.js +152 -0
- bizydraft/static/js/main.js +0 -1
- bizydraft/static/js/nodeFocusHandler.js +153 -0
- bizydraft/static/js/nodeParamsFilter.js +136 -0
- bizydraft/static/js/postEvent.js +291 -61
- bizydraft/static/js/tool.js +60 -0
- bizydraft/workflow_io.py +2 -2
- {bizydraft-0.1.30.dist-info → bizydraft-0.2.0.dist-info}/METADATA +1 -1
- bizydraft-0.2.0.dist-info/RECORD +28 -0
- bizydraft-0.1.30.dist-info/RECORD +0 -19
- {bizydraft-0.1.30.dist-info → bizydraft-0.2.0.dist-info}/WHEEL +0 -0
- {bizydraft-0.1.30.dist-info → bizydraft-0.2.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
import { app } from "../../scripts/app.js";
|
|
2
|
+
|
|
3
|
+
// 冻结模式相关的状态变量
|
|
4
|
+
let freezeOverlay = null;
|
|
5
|
+
let highlightedNodes = new Set();
|
|
6
|
+
let mouseTrackingEnabled = false;
|
|
7
|
+
let mouseMoveListener = null;
|
|
8
|
+
let globalEventBlocked = false; // 全局事件是否被阻止
|
|
9
|
+
let keyboardListener = null; // 键盘事件监听器
|
|
10
|
+
let contextMenuListener = null; // 右键菜单监听器
|
|
11
|
+
let originalMethods = null; // 存储原始方法
|
|
12
|
+
let nodeSearchStyleElement = null; // 用于存储禁用节点搜索的样式元素
|
|
13
|
+
let bottomTipElement = null; // 用于存储底部提示元素
|
|
14
|
+
let dragDropBlocker = null;
|
|
15
|
+
|
|
16
|
+
// 冻结工作流,添加遮罩层
|
|
17
|
+
function freezeWorkflow(isworkflow = false) {
|
|
18
|
+
// 禁用全局快捷键和鼠标事件
|
|
19
|
+
blockGlobalEvents(true);
|
|
20
|
+
|
|
21
|
+
// 创建遮罩层
|
|
22
|
+
createOverlay();
|
|
23
|
+
|
|
24
|
+
// 更新高亮节点列表
|
|
25
|
+
updateHighlightedNodes();
|
|
26
|
+
|
|
27
|
+
// 启用鼠标追踪
|
|
28
|
+
enableMouseTracking();
|
|
29
|
+
|
|
30
|
+
// 禁用节点搜索容器
|
|
31
|
+
disableNodeSearch(true);
|
|
32
|
+
|
|
33
|
+
// 显示底部提示
|
|
34
|
+
showBottomTip(isworkflow);
|
|
35
|
+
|
|
36
|
+
// 阻止拖拽上传文件
|
|
37
|
+
blockDragDropEvents(true);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 解冻工作流,移除遮罩层
|
|
41
|
+
function unfreezeWorkflow() {
|
|
42
|
+
// 恢复全局快捷键和鼠标事件
|
|
43
|
+
blockGlobalEvents(false);
|
|
44
|
+
|
|
45
|
+
// 移除遮罩层
|
|
46
|
+
removeOverlay();
|
|
47
|
+
|
|
48
|
+
// 清空高亮节点列表
|
|
49
|
+
highlightedNodes.clear();
|
|
50
|
+
|
|
51
|
+
// 禁用鼠标追踪
|
|
52
|
+
disableMouseTracking();
|
|
53
|
+
|
|
54
|
+
// 恢复节点搜索容器
|
|
55
|
+
disableNodeSearch(false);
|
|
56
|
+
|
|
57
|
+
// 隐藏底部提示
|
|
58
|
+
hideBottomTip();
|
|
59
|
+
|
|
60
|
+
// 恢复拖拽上传文件
|
|
61
|
+
blockDragDropEvents(false);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 显示提示信息
|
|
65
|
+
function showBottomTip(isworkflow = false) {
|
|
66
|
+
// 如果已经存在提示元素,先移除
|
|
67
|
+
if (bottomTipElement) {
|
|
68
|
+
bottomTipElement.remove();
|
|
69
|
+
bottomTipElement = null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// 创建提示元素
|
|
73
|
+
bottomTipElement = document.createElement('div');
|
|
74
|
+
bottomTipElement.id = 'aiapp-bottom-tip';
|
|
75
|
+
|
|
76
|
+
// 设置样式
|
|
77
|
+
bottomTipElement.style.position = 'fixed';
|
|
78
|
+
bottomTipElement.style.left = '64%';
|
|
79
|
+
bottomTipElement.style.top = '89%';
|
|
80
|
+
bottomTipElement.style.transform = 'translate(-50%, -50%)';
|
|
81
|
+
bottomTipElement.style.backgroundColor = 'white'; // 白色背景
|
|
82
|
+
bottomTipElement.style.color = 'black'; // 黑色文字
|
|
83
|
+
bottomTipElement.style.padding = '10px 20px';
|
|
84
|
+
bottomTipElement.style.textAlign = 'center';
|
|
85
|
+
bottomTipElement.style.fontSize = '14px';
|
|
86
|
+
bottomTipElement.style.zIndex = '10000';
|
|
87
|
+
bottomTipElement.style.borderRadius = '4px';
|
|
88
|
+
bottomTipElement.style.boxShadow = '0 2px 8px rgba(0, 0, 0, 0.15)';
|
|
89
|
+
bottomTipElement.style.border = '1px solid #e0e0e0';
|
|
90
|
+
|
|
91
|
+
// 根据模式设置不同的提示文本
|
|
92
|
+
if (isworkflow) {
|
|
93
|
+
bottomTipElement.textContent = '发布工作流时不可编辑原工作流';
|
|
94
|
+
} else {
|
|
95
|
+
bottomTipElement.textContent = '编辑AI应用参数时不可编辑原工作流';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// 添加到DOM
|
|
99
|
+
document.body.appendChild(bottomTipElement);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// 隐藏底部提示信息
|
|
103
|
+
function hideBottomTip() {
|
|
104
|
+
if (bottomTipElement) {
|
|
105
|
+
bottomTipElement.remove();
|
|
106
|
+
bottomTipElement = null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// 禁用或启用节点搜索功能
|
|
111
|
+
function disableNodeSearch(disable) {
|
|
112
|
+
// 如果已经有样式元素,先移除它
|
|
113
|
+
if (nodeSearchStyleElement) {
|
|
114
|
+
nodeSearchStyleElement.remove();
|
|
115
|
+
nodeSearchStyleElement = null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (disable) {
|
|
119
|
+
// 创建样式元素
|
|
120
|
+
nodeSearchStyleElement = document.createElement('style');
|
|
121
|
+
nodeSearchStyleElement.id = 'aiapp-disable-node-search-style';
|
|
122
|
+
|
|
123
|
+
// 添加CSS规则来禁用节点搜索容器和相关元素
|
|
124
|
+
nodeSearchStyleElement.textContent = `
|
|
125
|
+
/* 禁用节点搜索容器 */
|
|
126
|
+
.comfy-vue-node-search-container,
|
|
127
|
+
.litegraph-dialog,
|
|
128
|
+
.litecontextmenu,
|
|
129
|
+
.litesearchbox,
|
|
130
|
+
#node-panel,
|
|
131
|
+
#dialog_node_panel,
|
|
132
|
+
#dialog_search_panel {
|
|
133
|
+
display: none !important;
|
|
134
|
+
visibility: hidden !important;
|
|
135
|
+
pointer-events: none !important;
|
|
136
|
+
opacity: 0 !important;
|
|
137
|
+
}
|
|
138
|
+
`;
|
|
139
|
+
|
|
140
|
+
// 添加到文档头部
|
|
141
|
+
document.head.appendChild(nodeSearchStyleElement);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// 阻止全局快捷键和鼠标事件
|
|
146
|
+
function blockGlobalEvents(block) {
|
|
147
|
+
if (block && !globalEventBlocked) {
|
|
148
|
+
// 启用拦截
|
|
149
|
+
globalEventBlocked = true;
|
|
150
|
+
|
|
151
|
+
// 阻止键盘快捷键
|
|
152
|
+
keyboardListener = function(e) {
|
|
153
|
+
// 检查是否是需要阻止的按键
|
|
154
|
+
// 阻止: 退格键(8), Delete(46), Ctrl+C(67), Ctrl+V(86), Ctrl+Z(90), Ctrl+Y(89)
|
|
155
|
+
const key = e.keyCode || e.which;
|
|
156
|
+
const isCtrl = e.ctrlKey || e.metaKey;
|
|
157
|
+
|
|
158
|
+
// 检查节点附近的鼠标位置 - 如果在节点附近则不阻止
|
|
159
|
+
const isNearHighlightedNode = isMouseNearHighlightedNode(e);
|
|
160
|
+
|
|
161
|
+
if (!isNearHighlightedNode && (
|
|
162
|
+
key === 8 || // Backspace
|
|
163
|
+
key === 46 || // Delete
|
|
164
|
+
(isCtrl && (
|
|
165
|
+
key === 67 || // C
|
|
166
|
+
key === 86 || // V
|
|
167
|
+
key === 90 || // Z
|
|
168
|
+
key === 89 // Y
|
|
169
|
+
))
|
|
170
|
+
)) {
|
|
171
|
+
console.log('阻止键盘快捷键:', e.key, key);
|
|
172
|
+
e.preventDefault();
|
|
173
|
+
e.stopPropagation();
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// 阻止右键菜单
|
|
179
|
+
contextMenuListener = function(e) {
|
|
180
|
+
// 检查鼠标是否在高亮节点附近
|
|
181
|
+
const isNearHighlightedNode = isMouseNearHighlightedNode(e);
|
|
182
|
+
|
|
183
|
+
// 如果不在高亮节点附近,阻止右键菜单
|
|
184
|
+
if (!isNearHighlightedNode) {
|
|
185
|
+
e.preventDefault();
|
|
186
|
+
e.stopPropagation();
|
|
187
|
+
return false;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// 添加事件监听器
|
|
192
|
+
document.addEventListener('keydown', keyboardListener, true);
|
|
193
|
+
document.addEventListener('contextmenu', contextMenuListener, true);
|
|
194
|
+
|
|
195
|
+
// 保存并替换LiteGraph的双击相关方法
|
|
196
|
+
if (window.LGraphCanvas) {
|
|
197
|
+
// 保存原始方法
|
|
198
|
+
originalMethods = {
|
|
199
|
+
showNodePanel: LGraphCanvas.prototype.showNodePanel,
|
|
200
|
+
processNodeDblClicked: LGraphCanvas.prototype.processNodeDblClicked,
|
|
201
|
+
processContextMenu: LGraphCanvas.prototype.processContextMenu
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
// 禁用节点面板(双击弹出的)
|
|
205
|
+
LGraphCanvas.prototype.showNodePanel = function() {
|
|
206
|
+
return false;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
// 禁用节点双击
|
|
210
|
+
LGraphCanvas.prototype.processNodeDblClicked = function() {
|
|
211
|
+
return false;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
// 禁用右键菜单
|
|
215
|
+
LGraphCanvas.prototype.processContextMenu = function(node, event) {
|
|
216
|
+
// 检查是否在高亮节点附近
|
|
217
|
+
if (node && highlightedNodes.has(node.id)) {
|
|
218
|
+
// 在高亮节点上,允许菜单
|
|
219
|
+
if (originalMethods.processContextMenu) {
|
|
220
|
+
return originalMethods.processContextMenu.call(this, node, event);
|
|
221
|
+
}
|
|
222
|
+
} else {
|
|
223
|
+
// 检查鼠标是否在节点附近(即使不是该节点本身)
|
|
224
|
+
if (event && isMouseNearHighlightedNode(event)) {
|
|
225
|
+
return false; // 在节点附近但不允许菜单
|
|
226
|
+
}
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
} else if (!block && globalEventBlocked) {
|
|
233
|
+
// 禁用拦截
|
|
234
|
+
globalEventBlocked = false;
|
|
235
|
+
|
|
236
|
+
// 移除事件监听器
|
|
237
|
+
document.removeEventListener('keydown', keyboardListener, true);
|
|
238
|
+
document.removeEventListener('contextmenu', contextMenuListener, true);
|
|
239
|
+
|
|
240
|
+
// 恢复LiteGraph的方法
|
|
241
|
+
if (window.LGraphCanvas && originalMethods) {
|
|
242
|
+
if (originalMethods.showNodePanel) {
|
|
243
|
+
LGraphCanvas.prototype.showNodePanel = originalMethods.showNodePanel;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (originalMethods.processNodeDblClicked) {
|
|
247
|
+
LGraphCanvas.prototype.processNodeDblClicked = originalMethods.processNodeDblClicked;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (originalMethods.processContextMenu) {
|
|
251
|
+
LGraphCanvas.prototype.processContextMenu = originalMethods.processContextMenu;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
originalMethods = null;
|
|
256
|
+
keyboardListener = null;
|
|
257
|
+
contextMenuListener = null;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// 检查鼠标是否在高亮节点附近(包括扩展范围)
|
|
262
|
+
function isMouseNearHighlightedNode(e) {
|
|
263
|
+
if (!app || !app.graph) return false;
|
|
264
|
+
|
|
265
|
+
// 转换为图形坐标
|
|
266
|
+
const pos = app.canvas.convertEventToCanvasOffset(e);
|
|
267
|
+
|
|
268
|
+
// 检查所有高亮节点
|
|
269
|
+
for (const node of app.graph._nodes) {
|
|
270
|
+
if (node && node._aiAppHighlighted) {
|
|
271
|
+
// 使用正确的属性名:_pos 和 _posSize
|
|
272
|
+
const nodeX = node._pos[0];
|
|
273
|
+
const nodeY = node._pos[1];
|
|
274
|
+
const nodeWidth = node._posSize[2];
|
|
275
|
+
const nodeHeight = node._posSize[3];
|
|
276
|
+
|
|
277
|
+
const nodeBounds = {
|
|
278
|
+
left: nodeX - 10,
|
|
279
|
+
top: nodeY - 50,
|
|
280
|
+
right: nodeX + nodeWidth + 2,
|
|
281
|
+
bottom: nodeY + nodeHeight + 2
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// 检查鼠标是否在扩展边界内
|
|
285
|
+
if (pos[0] >= nodeBounds.left && pos[0] <= nodeBounds.right &&
|
|
286
|
+
pos[1] >= nodeBounds.top && pos[1] <= nodeBounds.bottom) {
|
|
287
|
+
return true;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// 创建遮罩层
|
|
296
|
+
function createOverlay() {
|
|
297
|
+
// 如果已存在,先移除
|
|
298
|
+
removeOverlay();
|
|
299
|
+
|
|
300
|
+
// 创建新的遮罩层
|
|
301
|
+
freezeOverlay = document.createElement('div');
|
|
302
|
+
freezeOverlay.id = 'aiapp-freeze-overlay';
|
|
303
|
+
|
|
304
|
+
// 设置样式
|
|
305
|
+
freezeOverlay.style.position = 'absolute';
|
|
306
|
+
freezeOverlay.style.top = '0';
|
|
307
|
+
freezeOverlay.style.left = '0';
|
|
308
|
+
freezeOverlay.style.width = '100%';
|
|
309
|
+
freezeOverlay.style.height = '100%';
|
|
310
|
+
freezeOverlay.style.backgroundColor = 'transparent';
|
|
311
|
+
freezeOverlay.style.zIndex = '9999';
|
|
312
|
+
freezeOverlay.style.pointerEvents = 'none'; // 默认不拦截事件,让画布可移动
|
|
313
|
+
freezeOverlay.style.cursor = 'move'; // 默认指示可拖动
|
|
314
|
+
|
|
315
|
+
// 添加事件监听
|
|
316
|
+
freezeOverlay.addEventListener('mousedown', handleOverlayMouseDown);
|
|
317
|
+
|
|
318
|
+
// 添加到DOM
|
|
319
|
+
const container = document.querySelector('#graph-canvas')?.parentElement || document.body;
|
|
320
|
+
container.appendChild(freezeOverlay);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// 移除遮罩层
|
|
324
|
+
function removeOverlay() {
|
|
325
|
+
if (freezeOverlay) {
|
|
326
|
+
freezeOverlay.removeEventListener('mousedown', handleOverlayMouseDown);
|
|
327
|
+
freezeOverlay.remove();
|
|
328
|
+
freezeOverlay = null;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// 启用鼠标追踪
|
|
333
|
+
function enableMouseTracking() {
|
|
334
|
+
if (!mouseTrackingEnabled) {
|
|
335
|
+
mouseMoveListener = handleMouseMove.bind(this);
|
|
336
|
+
document.addEventListener('mousemove', mouseMoveListener);
|
|
337
|
+
mouseTrackingEnabled = true;
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// 禁用鼠标追踪
|
|
342
|
+
function disableMouseTracking() {
|
|
343
|
+
if (mouseTrackingEnabled) {
|
|
344
|
+
document.removeEventListener('mousemove', mouseMoveListener);
|
|
345
|
+
mouseMoveListener = null;
|
|
346
|
+
mouseTrackingEnabled = false;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// 处理鼠标移动事件
|
|
351
|
+
function handleMouseMove(e) {
|
|
352
|
+
if (!freezeOverlay || !app || !app.graph) return;
|
|
353
|
+
|
|
354
|
+
// 转换为图形坐标
|
|
355
|
+
const pos = app.canvas.convertEventToCanvasOffset(e);
|
|
356
|
+
|
|
357
|
+
// 检查鼠标是否在高亮节点附近
|
|
358
|
+
let isNearHighlightedNode = false;
|
|
359
|
+
for (const node of app.graph._nodes) {
|
|
360
|
+
if (node && node._aiAppHighlighted) {
|
|
361
|
+
// 使用正确的属性名:_pos 和 _posSize
|
|
362
|
+
const nodeX = node._pos[0];
|
|
363
|
+
const nodeY = node._pos[1];
|
|
364
|
+
const nodeWidth = node._posSize[2];
|
|
365
|
+
const nodeHeight = node._posSize[3];
|
|
366
|
+
|
|
367
|
+
const nodeBounds = {
|
|
368
|
+
left: nodeX - 10,
|
|
369
|
+
top: nodeY - 50,
|
|
370
|
+
right: nodeX + nodeWidth + 2,
|
|
371
|
+
bottom: nodeY + nodeHeight + 2
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
if (pos[0] >= nodeBounds.left && pos[0] <= nodeBounds.right &&
|
|
375
|
+
pos[1] >= nodeBounds.top && pos[1] <= nodeBounds.bottom) {
|
|
376
|
+
isNearHighlightedNode = true;
|
|
377
|
+
break;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// 根据鼠标位置控制遮罩层
|
|
383
|
+
if (isNearHighlightedNode) {
|
|
384
|
+
// 鼠标在高亮节点附近,打开遮罩层
|
|
385
|
+
showOverlay();
|
|
386
|
+
} else {
|
|
387
|
+
// 鼠标在空白区域,隐藏遮罩层
|
|
388
|
+
hideOverlay();
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// 显示遮罩层
|
|
393
|
+
function showOverlay() {
|
|
394
|
+
if (freezeOverlay) {
|
|
395
|
+
freezeOverlay.style.pointerEvents = 'all';
|
|
396
|
+
freezeOverlay.style.cursor = 'pointer';
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// 隐藏遮罩层
|
|
401
|
+
function hideOverlay() {
|
|
402
|
+
if (freezeOverlay) {
|
|
403
|
+
freezeOverlay.style.pointerEvents = 'none';
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// 更新高亮节点列表
|
|
408
|
+
function updateHighlightedNodes() {
|
|
409
|
+
highlightedNodes.clear();
|
|
410
|
+
|
|
411
|
+
if (!app || !app.graph || !app.graph._nodes) return;
|
|
412
|
+
|
|
413
|
+
for (const node of app.graph._nodes) {
|
|
414
|
+
if (node && node._aiAppHighlighted) {
|
|
415
|
+
highlightedNodes.add(node.id);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// 处理遮罩层上的鼠标按下事件
|
|
421
|
+
function handleOverlayMouseDown(e) {
|
|
422
|
+
// 检查是否点击了高亮节点附近
|
|
423
|
+
const isNearHighlightedNode = isMouseNearHighlightedNode(e);
|
|
424
|
+
|
|
425
|
+
if (isNearHighlightedNode) {
|
|
426
|
+
// 获取实际点击的节点(用于发送消息)
|
|
427
|
+
const nodeUnderMouse = getNodeUnderMouse(e);
|
|
428
|
+
|
|
429
|
+
if (nodeUnderMouse) {
|
|
430
|
+
// 发送消息到前端,通知节点被点击
|
|
431
|
+
window.parent.postMessage({
|
|
432
|
+
type: 'CANVAS_NODE_CLICKED',
|
|
433
|
+
nodeId: nodeUnderMouse.id,
|
|
434
|
+
nodeTitle: nodeUnderMouse.title,
|
|
435
|
+
nodeType: nodeUnderMouse.type
|
|
436
|
+
}, '*');
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
// 阻止事件冒泡,避免触发其他处理
|
|
440
|
+
e.preventDefault();
|
|
441
|
+
e.stopPropagation();
|
|
442
|
+
return false;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
// 让事件传递给画布 - 允许画布正常处理点击事件
|
|
446
|
+
return true;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// 获取鼠标下方的节点
|
|
450
|
+
function getNodeUnderMouse(e) {
|
|
451
|
+
if (!app || !app.graph) return null;
|
|
452
|
+
|
|
453
|
+
// 获取画布位置
|
|
454
|
+
const canvas = document.querySelector('canvas');
|
|
455
|
+
if (!canvas) return null;
|
|
456
|
+
|
|
457
|
+
// 转换为图形坐标
|
|
458
|
+
const pos = app.canvas.convertEventToCanvasOffset(e);
|
|
459
|
+
|
|
460
|
+
// 检查点击位置是否在某个节点上
|
|
461
|
+
const node = app.graph.getNodeOnPos(pos[0], pos[1]);
|
|
462
|
+
return node;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// 阻止拖拽上传文件
|
|
466
|
+
function blockDragDropEvents(enable) {
|
|
467
|
+
if (enable) {
|
|
468
|
+
if (dragDropBlocker) return; // 已经阻止过了
|
|
469
|
+
dragDropBlocker = function(e) {
|
|
470
|
+
e.preventDefault();
|
|
471
|
+
e.stopPropagation();
|
|
472
|
+
return false;
|
|
473
|
+
};
|
|
474
|
+
document.addEventListener('dragover', dragDropBlocker, true);
|
|
475
|
+
document.addEventListener('drop', dragDropBlocker, true);
|
|
476
|
+
} else {
|
|
477
|
+
if (!dragDropBlocker) return;
|
|
478
|
+
document.removeEventListener('dragover', dragDropBlocker, true);
|
|
479
|
+
document.removeEventListener('drop', dragDropBlocker, true);
|
|
480
|
+
dragDropBlocker = null;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
export {
|
|
485
|
+
freezeWorkflow,
|
|
486
|
+
unfreezeWorkflow,
|
|
487
|
+
isMouseNearHighlightedNode,
|
|
488
|
+
getNodeUnderMouse,
|
|
489
|
+
updateHighlightedNodes
|
|
490
|
+
};
|
|
@@ -43,6 +43,12 @@ const styleMenus = `
|
|
|
43
43
|
body div.side-tool-bar-end{
|
|
44
44
|
display: none;
|
|
45
45
|
}
|
|
46
|
+
body .tydev-utils-log-console-container{
|
|
47
|
+
display: none;
|
|
48
|
+
}
|
|
49
|
+
.p-dialog-mask.p-overlay-mask.p-overlay-mask-enter{
|
|
50
|
+
display: none !important;
|
|
51
|
+
}
|
|
46
52
|
`
|
|
47
53
|
app.registerExtension({
|
|
48
54
|
name: "comfy.BizyAir.Style",
|