File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { app } from "../../scripts/app.js" ;
22import { applyBadgeToNode } from "./handle_load_nodes.js" ;
33import { hasModelInput } from "./model_price.js" ;
4+
5+ // 链式callback实现,保留原始callback并添加新callback
6+ function chainCallback ( originalCallback , newCallback ) {
7+ return async function ( ...args ) {
8+ // 先执行原始callback
9+ if ( originalCallback ) {
10+ const result = originalCallback . apply ( this , args ) ;
11+ // 如果原始callback返回Promise,等待它完成
12+ if ( result && typeof result . then === 'function' ) {
13+ await result ;
14+ }
15+ }
16+ // 然后执行新callback
17+ await newCallback . apply ( this , args ) ;
18+ } ;
19+ }
20+
421app . registerExtension ( {
522 name : "bizyair.handle.node.configure" ,
623 nodeCreated ( node , app ) {
@@ -11,10 +28,12 @@ app.registerExtension({
1128 }
1229 // 不仅仅是切换model才会修改模型定价,比如切换输入参数也会修改模型定价
1330 node . widgets . forEach ( ( widget ) => {
14- widget . callback = async function ( ) {
31+ // 保存原始callback,使用链式callback保留原始功能
32+ const originalCallback = widget . callback ;
33+ widget . callback = chainCallback ( originalCallback , async function ( ) {
1534 // 用户手动修改widget时,强制刷新badge(不使用缓存的模型类型)
1635 await applyBadgeToNode ( node , true ) ;
17- } ;
36+ } ) ;
1837 } ) ;
1938 }
2039 } ,
Original file line number Diff line number Diff line change 1- 1.2.90
1+ 1.2.91
You can’t perform that action at this time.
0 commit comments