bizydraft 0.2.31__py3-none-any.whl → 0.2.78.dev20251117024007__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.
@@ -0,0 +1,65 @@
1
+ // 保存原始的 WebSocket 构造函数
2
+ const OriginalWebSocket = window.WebSocket;
3
+
4
+ // 保存原始的 fetch 函数
5
+ const OriginalFetch = window.fetch;
6
+
7
+ // 需要跳过的 URL 数组
8
+ const skipFetchUrls = [
9
+ 'manager/badge_mode',
10
+ 'pysssss/autocomplete'
11
+ ];
12
+
13
+ class FakeWebSocket {
14
+ constructor(url) {
15
+ this.url = url;
16
+ this.readyState = WebSocket.CONNECTING; // 核心:保持 CONNECTING 状态
17
+ console.warn('[BizyDraft] 已阻止 WebSocket 连接:', url);
18
+ }
19
+ send() {}
20
+ close() {}
21
+ addEventListener() {}
22
+ removeEventListener() {}
23
+ }
24
+
25
+ window.WebSocket = function(url, protocols) {
26
+ //精确拦截/ws请求
27
+ if (typeof url === 'string' && /^wss?:\/\/[^/]+\/ws(\?.*)?$/.test(url)) {
28
+ return new FakeWebSocket(url);
29
+ }
30
+ // 其他连接正常创建,不影响
31
+ return new OriginalWebSocket(url, protocols);
32
+ };
33
+
34
+ // 保留 WebSocket 的静态属性和原型
35
+ Object.setPrototypeOf(window.WebSocket, OriginalWebSocket);
36
+ window.WebSocket.prototype = OriginalWebSocket.prototype;
37
+
38
+ // 复制静态常量(使用 defineProperty 避免只读属性错误)
39
+ ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'].forEach(prop => {
40
+ Object.defineProperty(window.WebSocket, prop, {
41
+ value: OriginalWebSocket[prop],
42
+ writable: false,
43
+ enumerable: true,
44
+ configurable: true
45
+ });
46
+ });
47
+
48
+ // 拦截 fetch 请求
49
+ window.fetch = function(url) {
50
+ // 将 URL 转换为字符串进行比较
51
+ const urlString = typeof url === 'string' ? url : url.toString();
52
+ // 检查 URL 是否在跳过列表中
53
+ if (skipFetchUrls.some(skipUrl => urlString.includes(skipUrl))) {
54
+ console.warn('[BizyDraft] 已阻止 fetch 请求:', urlString);
55
+ // 返回一个模拟的 Response 对象,状态为 200
56
+ return Promise.resolve(new Response(null, {
57
+ status: 200,
58
+ statusText: 'OK',
59
+ headers: new Headers({ 'Content-Type': 'application/json' })
60
+ }));
61
+ }
62
+
63
+ // 其他请求正常发送
64
+ return OriginalFetch.apply(this, arguments);
65
+ };
@@ -39,6 +39,9 @@ function freezeWorkflow(isworkflow = false) {
39
39
 
40
40
  // 阻止拖拽上传文件
41
41
  blockDragDropEvents(true);
42
+
43
+ // 关闭并禁用最小地图按钮
44
+ setMiniMapButtonDisabled(true, true);
42
45
  }
43
46
 
44
47
  // 解冻工作流,移除遮罩层
@@ -70,6 +73,9 @@ function unfreezeWorkflow() {
70
73
 
71
74
  // 恢复拖拽上传文件
72
75
  blockDragDropEvents(false);
76
+
77
+ // 恢复最小地图按钮可用
78
+ setMiniMapButtonDisabled(false);
73
79
  }
74
80
 
75
81
  // 显示提示信息
@@ -450,6 +456,23 @@ function updateHighlightedNodes() {
450
456
  }
451
457
  }
452
458
  }
459
+ //关闭并禁用小地图按钮
460
+ function setMiniMapButtonDisabled(disabled, clickIfActive = false) {
461
+ const miniMapBtn = document.querySelector('button[data-testid="toggle-minimap-button"]');
462
+ if (!miniMapBtn) return;
463
+
464
+ if (disabled) {
465
+ const isActive = miniMapBtn.classList.contains('minimap-active') ||
466
+ miniMapBtn.hasAttribute('minimap-active') ||
467
+ miniMapBtn.getAttribute('aria-pressed') === 'true';
468
+ if (clickIfActive && isActive) {
469
+ miniMapBtn.click();
470
+ }
471
+ miniMapBtn.disabled = true;
472
+ } else {
473
+ miniMapBtn.disabled = false;
474
+ }
475
+ }
453
476
 
454
477
  // 处理遮罩层上的鼠标按下事件
455
478
  function handleOverlayMouseDown(e) {
@@ -44,6 +44,22 @@ const styleMenus = `
44
44
  .p-dialog-mask.p-overlay-mask.p-overlay-mask-enter[data-pc-name="dialog"]{
45
45
  display: none !important;
46
46
  }
47
+ .p-button.p-component.p-button-icon-only.p-button-text.templates-tab-button.side-bar-button.p-button-secondary{
48
+ display: none;
49
+ }
50
+ .p-button.p-component.p-button-icon-only.p-button-text.queue-tab-button.side-bar-button.p-button-secondary{
51
+ display: none;
52
+ }
53
+ .w-full.flex.content-end{
54
+ display: none;
55
+ }
56
+ .side-tool-bar-container.small-sidebar .side-bar-button-label{
57
+ display: none;
58
+ }
59
+ body .comfy-img-preview video{
60
+ width: 100%;
61
+ height: 100%;
62
+ }
47
63
  `;
48
64
  app.registerExtension({
49
65
  name: "comfy.BizyAir.Style",
@@ -52,5 +68,62 @@ app.registerExtension({
52
68
  textContent: styleMenus,
53
69
  parent: document.head,
54
70
  });
71
+ const getCloseBtn = () => {
72
+ // let temp = null
73
+ // document.querySelectorAll('h2').forEach(e => {
74
+ // if (e.innerHTML == "<span>模板</span>") {
75
+ // const dialogContent = e.closest('.p-dialog-content')
76
+ // if (dialogContent) {
77
+ // temp = dialogContent.querySelector('i.pi.pi-times.text-sm')
78
+ // }
79
+ // }
80
+ // })
81
+ return document.querySelector('i.pi.pi-times.text-sm')
82
+ }
83
+ const getFengrossmentBtn = () => {
84
+ let temp = null
85
+ document.querySelectorAll('button').forEach(e => {
86
+ if (e.getAttribute('aria-label') == "专注模式 (F)") {
87
+ temp = e
88
+ }
89
+ })
90
+ return temp
91
+ }
92
+ let indexCloseLayout = 0;
93
+ let indexAddSmlBar = 0;
94
+ let indexFengrossment = 0;
95
+ let iTimer = setInterval(() => {
96
+ indexCloseLayout++
97
+ if (indexCloseLayout > 10) {
98
+ clearInterval(iTimer)
99
+ return
100
+ }
101
+ if (getCloseBtn()) {
102
+ getCloseBtn().click()
103
+ clearInterval(iTimer)
104
+ }
105
+ }, 300)
106
+ let iTimerSmlBar = setInterval(() => {
107
+ indexAddSmlBar++
108
+ if (indexAddSmlBar > 10) {
109
+ clearInterval(iTimerSmlBar)
110
+ return
111
+ }
112
+ if (document.querySelector('.side-tool-bar-container')) {
113
+ document.querySelector('.side-tool-bar-container').classList.add('small-sidebar')
114
+ clearInterval(iTimerSmlBar)
115
+ }
116
+ }, 300)
117
+ let iTimerFengrossment = setInterval(() => {
118
+ indexFengrossment++
119
+ if (indexFengrossment > 10) {
120
+ clearInterval(iTimerFengrossment)
121
+ return
122
+ }
123
+ if (getFengrossmentBtn()) {
124
+ getFengrossmentBtn().style.display = 'none'
125
+ clearInterval(iTimerFengrossment)
126
+ }
127
+ }, 300)
55
128
  }
56
129
  });
@@ -0,0 +1,68 @@
1
+ // 统一的配置加载器 - 合并 model.js 和 media.js 的配置请求
2
+ // 只发送一次 API 请求,同时获取 weight_load_nodes 和 media_load_nodes
3
+
4
+ // 统一的配置缓存
5
+ let fullConfigCache = null;
6
+ let configLoadPromise = null;
7
+
8
+ // API配置(统一使用一个域名,根据实际需要调整)
9
+ const CONFIG_API_URL = 'https://bizyair.cn/api/special/comfyagent_node_config?t=' + Math.floor(Date.now() / 60000);
10
+
11
+ // 获取完整配置的API函数(返回包含 weight_load_nodes 和 media_load_nodes 的完整对象)
12
+ export async function fetchFullConfig() {
13
+ if (fullConfigCache) {
14
+ return fullConfigCache;
15
+ }
16
+
17
+ if (configLoadPromise) {
18
+ return configLoadPromise;
19
+ }
20
+
21
+ configLoadPromise = (async () => {
22
+ try {
23
+ console.log('正在从API获取完整节点配置...');
24
+ const response = await fetch(CONFIG_API_URL, { credentials: 'include' });
25
+
26
+ if (!response.ok) {
27
+ throw new Error(`HTTP error! status: ${response.status}`);
28
+ }
29
+
30
+ const result = await response.json();
31
+
32
+ if (result.code === 20000 && result.data) {
33
+ fullConfigCache = {
34
+ weight_load_nodes: result.data.weight_load_nodes || {},
35
+ media_load_nodes: result.data.media_load_nodes || {}
36
+ };
37
+ console.log('完整配置加载成功:', {
38
+ weight_nodes: Object.keys(fullConfigCache.weight_load_nodes).length,
39
+ media_nodes: Object.keys(fullConfigCache.media_load_nodes).length
40
+ });
41
+ return fullConfigCache;
42
+ } else {
43
+ throw new Error('API返回数据格式不正确');
44
+ }
45
+ } catch (error) {
46
+ console.error('获取完整配置失败:', error);
47
+ fullConfigCache = null;
48
+ return null;
49
+ }
50
+ })();
51
+
52
+ return configLoadPromise;
53
+ }
54
+
55
+ // 获取模型节点配置(从完整配置中提取 weight_load_nodes)
56
+ export async function fetchNodeConfig() {
57
+ const fullConfig = await fetchFullConfig();
58
+ return fullConfig ? fullConfig.weight_load_nodes : null;
59
+ }
60
+
61
+ // 获取媒体节点配置(从完整配置中提取 media_load_nodes)
62
+ export async function fetchMediaConfig() {
63
+ const fullConfig = await fetchFullConfig();
64
+ return fullConfig ? fullConfig.media_load_nodes : null;
65
+ }
66
+
67
+ // 启动时后台预取(不阻塞后续逻辑)
68
+ try { void fetchFullConfig(); } catch (e) { /* noop */ }