@@ -77,7 +77,12 @@ export function hasModelInput(node) {
7777 * @param {number } badgeOptions.iconOptions.uuid - 图标uuid 用于删除 自定义属性
7878 */
7979export function addCustomBadge ( node , badgeOptions ) {
80- const customBadge = new LGraphBadge ( badgeOptions ) ;
80+ const BadgeConstructor = globalThis . LGraphBadge ;
81+ if ( typeof BadgeConstructor !== "function" ) {
82+ throw new Error ( "LGraphBadge is not available" ) ;
83+ }
84+
85+ const customBadge = new BadgeConstructor ( badgeOptions ) ;
8186 // 每次添加badge 清空所有badge 因为badge没有一个唯一标识符,并且价格展示也就一个badge 所以直接全部清除
8287 node . badges = [ ] ;
8388 node . badges . push ( ( ) => customBadge ) ;
@@ -145,16 +150,20 @@ export function getBadgeConfigByCoinType(coinType, priceText) {
145150 } ;
146151}
147152
148- function getImagesLinkFlag ( node ) {
153+ function getLinkedInputFlags ( node ) {
149154 if ( ! node ?. inputs || ! Array . isArray ( node . inputs ) ) {
150- return "false" ;
155+ return { } ;
151156 }
152157
153- const imagesInput = node . inputs . find (
154- ( input ) => input ?. name === "images" || input ?. localized_name === "images"
155- ) ;
158+ return node . inputs . reduce ( ( flags , input ) => {
159+ const inputName = input ?. name || input ?. localized_name ;
160+ if ( ! inputName || input ?. widget !== undefined ) {
161+ return flags ;
162+ }
156163
157- return imagesInput ?. link != null ? "true" : "false" ;
164+ flags [ inputName ] = input ?. link != null ? "true" : "false" ;
165+ return flags ;
166+ } , { } ) ;
158167}
159168
160169/**
@@ -179,7 +188,7 @@ export async function addPriceBadgeToNode(node, modelName = "") {
179188 nodeInputs . model = modelName ;
180189 }
181190
182- nodeInputs . images = getImagesLinkFlag ( node ) ;
191+ Object . assign ( nodeInputs , getLinkedInputFlags ( node ) ) ;
183192
184193 // 获取价格信息
185194 const priceResult = await fetchNodePrice ( modelName , nodeInputs ) ;
0 commit comments