Skip to content

Commit 848a0b7

Browse files
添加可切换API节点显示 (#165)
* 添加可切换API节点显示 * 更改版本号
1 parent 1b0ed06 commit 848a0b7

2 files changed

Lines changed: 28 additions & 4 deletions

File tree

bizyui/js/handle_load_nodes.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,33 @@ import { addPriceBadgeToNode, hasModelInput } from "./model_price.js";
44
// 用于存储模型类型的属性名(会被序列化保存到工作流中)
55
const BIZYAIR_MODEL_TYPE_KEY = "bizyair_model_type";
66

7+
/**
8+
* 检查是否应该显示 API 节点价格徽章
9+
* @returns {boolean} 如果设置开启则返回 true,否则返回 false
10+
*/
11+
function shouldShowApiPricingBadge() {
12+
try {
13+
const app = document.querySelector("#vue-app").__vue_app__;
14+
const pinia = app.config.globalProperties.$pinia;
15+
const settingStore = pinia._s.get("setting");
16+
const showApiPricing = settingStore.get("Comfy.NodeBadge.ShowApiPricing");
17+
return showApiPricing !== false;
18+
} catch (error) {
19+
// 如果无法获取 store 或出错,默认返回 true(保持原有行为)
20+
return true;
21+
}
22+
}
23+
724
// 获取node 的模型配置input
825
export async function applyBadgeToNode(_this, forceRefresh = false) {
26+
const shouldShowBadge = shouldShowApiPricingBadge();
27+
928
// 如果不是强制刷新,优先从节点属性中恢复模型类型(用于工作流加载场景)
1029
if (!forceRefresh && _this.properties && _this.properties[BIZYAIR_MODEL_TYPE_KEY]) {
1130
const modelType = _this.properties[BIZYAIR_MODEL_TYPE_KEY];
12-
await addPriceBadgeToNode(_this, modelType);
31+
if (shouldShowBadge) {
32+
await addPriceBadgeToNode(_this, modelType);
33+
}
1334
return;
1435
}
1536

@@ -38,9 +59,12 @@ export async function applyBadgeToNode(_this, forceRefresh = false) {
3859
}
3960
_this.properties[BIZYAIR_MODEL_TYPE_KEY] = modelType;
4061

41-
await addPriceBadgeToNode(_this, modelType);
62+
// 只有在设置开启时才添加badge
63+
if (shouldShowBadge) {
64+
await addPriceBadgeToNode(_this, modelType);
65+
}
4266

43-
// 删除无用的outputs
67+
// 无论是否添加badge,都要删除无用的outputs
4468
_this.outputs = _this.outputs.filter(
4569
(output) => output.name !== hiddenOutput.name
4670
);

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.2.92
1+
1.2.93

0 commit comments

Comments
 (0)