Files
qhmes/web-dist/js/NodeContainer-D9PNfjwh-CawrgSrv.js
2026-06-16 18:19:57 +08:00

2 lines
6.8 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{e as Z,S as Q,w as q,h as M,o as X,b as ee,r as B,d as te,c as w,C as A,z as p,Q as n,H as b,L as I,f as d,y as _,G as N,A as u,R as oe,u as v,E as ae,J as $,T as ie,n as se}from"./vue-vendor-DNhG1Cve.js";import{l as ne}from"./runStore-Oe6fP2qb-CrdxkpS7.js";import{bo as le,T as re,x as y,aR as de,aS as ue,aE as ce,c1 as pe,b9 as he}from"./index-X7Y8jykP.js";import{addResizeListener as H,removeResizeListener as G}from"./index-C4wWpZeQ.js";import fe from"./NodeIcon-BiVm3xLp-DYMLCJV5.js";import"./index-CfNJyBRj.js";import{D as ge}from"./dropdown-jkliuVyN.js";var F=(o=>(o.START="start",o.END="end",o.LLM="llm",o.SWITCH="switch",o.CLASSIFIER="classifier",o.KNOWLEDGE="knowledge",o.KNOWLEDGE_WRITE="knowledgeWrite",o.CODE="code",o.SUBFLOW="subflow",o.ENHANCE_JAVA="enhanceJava",o.HTTP="http",o.TOOLS="tools",o.BRAVE_SEARCH="braveSearch",o.REPLY="reply",o.SQL="sql",o.LOOP="loop",o.LOOP_BREAK="loopBreak",o.LOOP_CONTINUE="loopContinue",o.LOOP_BODY="loopBody",o.SET_LOOP_VAR="setLoopVar",o.VAR_MERGE="varMerge",o.VAR_EXTRACT="varExtract",o.CHAT_VAR_GET="chatVarGet",o.CHAT_VAR_SET="chatVarSet",o.CHAT_MEMORY_GET="chatMemoryGet",o.CHAT_MEMORY_SET="chatMemorySet",o))(F||{});const Le=Symbol("no-setting-needed"),ve={class:"header"},ye=["title"],me={class:"text airag-node-label"},_e={class:"extra"},Se={class:"shortcut-keys-tip"},we={key:0,class:"content"},be=["title"],Ee=Z({__name:"NodeContainer",props:{node:{type:Object},graph:{type:Object},width:Number,height:Number,hideAction:{type:Boolean,default:!1},updateHeightImmediate:{type:Boolean,default:!0},disableResizeListener:{type:Boolean,default:!1},listenForeignObjectResize:{type:Boolean,default:!1},onUpdateNode:Function,onParentResize:Function,addNodeIsShow:Function,runGetStepFn:Function},setup(o,{expose:J}){const{prefixCls:U}=le("airag-base-node-container"),l=o,f=()=>({node:l.node,graph:l.graph}),g=B(),h=B(),a=ee({id:"",type:"",width:0,height:0,isSelected:!1,properties:{}}),k=Q("editConfigModel",{}),C=w(()=>k==null?void 0:k.isSilentMode),j=w(()=>/^chat[A-Z]/.test(a.type)),O=ne(),c=w(()=>{if(!(O.isRunning||O.isFinished))return["",""];let t;const{runGetStepFn:e}=l;return typeof e=="function"?t=e():t=O.nodeSteps.find(i=>i.node.id===a.id),t?[t.status,t.timeText]:["waiting",""]}),W=w(()=>{const t=[];if(c.value[0]){const e=`run-status-${c.value[0]}`;t.push(e)}return[U,{selected:a.isSelected},t]});q(()=>{const{graph:t,node:e}=f();t.$J.setEdgeRunStatus(e,c.value[0])});const Y=w(()=>{const t={width:`${(typeof l.width=="number"?l.width:a.width)-20}px`};return typeof l.height=="number"&&(t.height=`${l.height}px`),t});M(()=>a.isSelected,(t,e)=>{const{graph:i,node:s}=f(),r=i.$J.getAddNodeDrawerVisible();e&&!t&&r&&he(50,()=>x(!1)),s.type===F.LOOP_BODY&&s.zIndex>0&&s.setZIndex(-9999)}),M(()=>a.properties.remarks,()=>se(()=>E())),X(()=>{const{graph:t,node:e}=f();t.$J.register(e,{onNodeUpdated(){z()},onNodeClick(i){},onGraphUpdated(i){},onPropertiesChange(i){a.properties=i.properties},toggleAddNodeDrawer(i,s){let r=s.visible;r?r=s.triggerNodeId!==a.id:r=!r,x(r,i)},onAfterAddNode(i){e.draggable=!0}}),l.disableResizeListener||H(g.value,L),h.value=g.value.closest("foreignObject"),l.listenForeignObjectResize&&h.value&&typeof l.onParentResize=="function"&&H(h.value,T),l.updateHeightImmediate&&E()}),te(()=>{G(g.value,L),h.value&&G(h.value,T)});function T(){l.onParentResize({width:h.value.width.baseVal.value,height:h.value.height.baseVal.value,element:h.value})}function L(){E()}function x(t,e){const{node:i,graph:s}=f();i.draggable=!t,t&&(e=e||{},typeof l.addNodeIsShow=="function"&&(e.isShow=l.addNodeIsShow),e.prevData={node:i}),s.$J.setAddNodeDrawerVisible(t,e,a.id)}function E(t){if(!g.value)return;const{node:e,graph:i}=f();t==null&&(t=g.value.offsetHeight);const s=e.height;let r,S;s>t?(r=(s-t)/2,S=e.y-r):(r=(t-s)/2,S=e.y+r),e.setProperties({height:t}),e.moveTo(e.x,S);const R=e.getDefaultAnchor();for(const m of R){const D=m.type==="right"?["getAnchorOutgoingEdge","updateStartPoint"]:["getAnchorIncomingEdge","updateEndPoint"],P=i[D[0]](m.id),V=P==null?void 0:P[0];V&&V[D[1]]({x:m.x,y:m.y})}i.$J.$groupUtils.recalcGroupSizeByNode(e.id)}function z(){const{node:t}=f();a.id=t.id,a.type=t.type,a.width=t.width,a.height=t.height,a.isSelected=t.isSelected,a.properties=t.properties,typeof l.onUpdateNode=="function"&&l.onUpdateNode(a)}z();function K({key:t}){const{graph:e,node:i}=f();e.$J.doAction(t,{node:i})}return J({$node:a,runStatus:c,isSilentMode:C,updateHeight:E}),(t,e)=>{const i=re,s=ce,r=ue,S=pe,R=de,m=ge;return p(),A("div",{ref_key:"containerRef",ref:g,class:$(W.value),style:ie(Y.value)},[n("div",ve,[n("div",{class:"icon",title:a.id},[I(t.$slots,"icon",{},()=>[d(fe,{type:a.type},null,8,["type"])])],8,ye),n("div",me,[n("span",null,N(a.properties.text),1),j.value?(p(),_(i,{key:0,title:"该节点需要关联智能体应用才能使用"},{default:u(()=>[...e[1]||(e[1]=[n("span",{class:"need-app-tip"},"[应用]",-1)])]),_:1})):b("",!0)]),n("div",_e,[!C.value&&!o.hideAction?(p(),_(m,{key:0,trigger:["click"],placement:"bottomRight",overlayClassName:"airag-node-action-dropdown",getPopupContainer:()=>g.value},{overlay:u(()=>[d(R,{style:{width:"240px"},onClick:K},{default:u(()=>[d(r,{key:"copy"},{default:u(()=>[d(s,null,{default:u(()=>[d(v(y),{icon:"ant-design:copy",size:16}),e[2]||(e[2]=n("span",null,"复制",-1))]),_:1})]),_:1}),d(S),d(r,{key:"delete",class:"hover-red"},{default:u(()=>[d(s,null,{default:u(()=>[d(v(y),{icon:"ant-design:delete",size:16}),e[3]||(e[3]=n("span",null,"删除",-1))]),_:1}),n("div",Se,[d(i,{title:"选中节点时按下 Delete 键即可删除"},{default:u(()=>[...e[4]||(e[4]=[ae("Del",-1)])]),_:1})])]),_:1})]),_:1})]),default:u(()=>[n("div",{class:"action-item dropdown","data-is-node-action":"",onClick:e[0]||(e[0]=oe(()=>{},["stop"]))},[d(v(y),{icon:"ant-design:ellipsis",size:24})])]),_:1},8,["getPopupContainer"])):b("",!0)])]),t.$slots.default?(p(),A("div",we,[I(t.$slots,"default")])):b("",!0),c.value[0]?(p(),A("div",{key:1,class:$(["run-status",c.value[0]])},[c.value[0]==="waiting"?(p(),_(s,{key:0},{default:u(()=>[d(v(y),{icon:"tabler:clock",size:12}),e[5]||(e[5]=n("span",null,"等待中",-1))]),_:1})):c.value[0]==="running"?(p(),_(s,{key:1},{default:u(()=>[d(v(y),{icon:"eos-icons:bubble-loading",size:12}),e[6]||(e[6]=n("span",null,"运行中",-1))]),_:1})):c.value[0]==="success"?(p(),_(s,{key:2},{default:u(()=>[d(v(y),{icon:"ix:success",size:12}),e[7]||(e[7]=n("span",null,"运行成功",-1)),n("span",null,"耗时"+N(c.value[1]),1)]),_:1})):c.value[0]==="fail"?(p(),_(s,{key:3},{default:u(()=>[d(v(y),{icon:"ix:namur-failure-filled",size:12}),e[8]||(e[8]=n("span",null,"运行失败",-1)),n("span",null,"耗时"+N(c.value[1]),1)]),_:1})):b("",!0)],2)):a.properties.remarks?(p(),A("div",{key:2,class:"remarks",title:a.properties.remarks},[n("span",null,N(a.properties.remarks),1)],8,be)):b("",!0)],6)}}}),xe=Object.freeze(Object.defineProperty({__proto__:null,default:Ee},Symbol.toStringTag,{value:"Module"}));export{Le as D,Ee as L,xe as N,F as U};