jingrow/apps/jingrow/frontend/dist/assets/FlowBuilderContainer-001ad899.js

2 lines
3.2 KiB
JavaScript

import{ag as N,r as A,d as x,u as E,c as p,M as j,e as R,f as g,g as h,h as s,w as i,j as o,k as z,l as O,n as B,$ as I,p as F,t as l,I as M}from"./index-7b482730.js";import{I as b}from"./iconify-30ae5ba5.js";import T from"./AIAgentFlowBuilder-dceed8dc.js";import{useFlowBuilderStore as $}from"./flowBuilder-41625347.js";import{getRecord as L,updateRecord as P}from"./common-a0065b74.js";import{_ as q}from"./_plugin-vue_export-helper-c27b6911.js";const G=async e=>{try{const r=await L("Local Ai Agent",e);if(!r.success)throw new Error(r.message||"获取AI Agent详情失败");return r.data}catch(r){throw new Error(r.message||"获取AI Agent详情失败")}},H=async(e,r)=>{try{const t=await P("Local Ai Agent",e,r);if(!t.success)throw new Error(t.message||"更新AI Agent失败");return t.data}catch(t){throw console.error("Error in updateAgentApi:",t),new Error(t.message||"更新AI Agent失败")}},J=N("agent",()=>{const e=A(null);return{currentAgent:e,fetchAgent:async u=>{try{const n=await G(u);e.value=n}catch(n){throw console.error("获取AI Agent详情失败:",n),n}},updateAgent:async(u,n)=>{try{return await H(u,n),e.value&&e.value.name===u&&(e.value={...e.value,...n}),{success:!0}}catch(c){throw console.error("更新AI Agent失败:",c),c}}}}),K={class:"flow-builder"},Q={class:"flow-builder-header"},U={class:"header-left"},W={class:"title"},X={class:"header-right"},Y={class:"flow-builder-content"},Z=x({__name:"FlowBuilderContainer",props:{initialValue:{},agentId:{}},emits:["save"],setup(e,{emit:r}){const t=e,u=r,n=z(),c=E(),f=J(),w=$(),d=A(""),k=p(()=>{if(t.initialValue&&Object.keys(t.initialValue).length>0)return t.initialValue;const a=w.getFlowData();return a&&Object.keys(a).length>0?a:{}}),v=A(),_=p(()=>t.agentId||w.getAgentId()),S=p(()=>d.value?`${d.value}`:l("Flow Builder"));j(_,async a=>{var m,y;if(a)try{await f.fetchAgent(a),d.value=((m=f.currentAgent)==null?void 0:m.agent_name)||((y=f.currentAgent)==null?void 0:y.name)||""}catch(D){console.error("获取智能体信息失败:",D),d.value=""}else d.value=""},{immediate:!0});const C=async()=>{try{if(!v.value){c.error(l("Flow Builder is not initialized"));return}const a=v.value.getFlowData();_.value?(await f.updateAgent(_.value,{agent_flow:a}),c.success(l("Flow saved successfully"))):(u("save",a),c.success(l("Flow saved successfully")))}catch(a){c.error(l("Save failed")+": "+(a.message||l("An error occurred during save")))}},V=()=>{w.deactivateFlowBuilder(),n.back()};return(a,m)=>(O(),R("div",K,[g("div",Q,[g("div",U,[g("h2",W,h(S.value),1)]),g("div",X,[s(o(M),null,{default:i(()=>[s(o(B),{size:"small",onClick:V},{icon:i(()=>[s(o(I),null,{default:i(()=>[s(o(b),{icon:"tabler:arrow-left"})]),_:1})]),default:i(()=>[F(" "+h(o(l)("Back")),1)]),_:1}),s(o(B),{size:"small",type:"primary",onClick:C,class:"save-btn-brand"},{icon:i(()=>[s(o(I),null,{default:i(()=>[s(o(b),{icon:"tabler:check"})]),_:1})]),default:i(()=>[F(" "+h(o(l)("Save")),1)]),_:1})]),_:1})])]),g("div",Y,[s(T,{ref_key:"flowBuilderRef",ref:v,"initial-value":k.value,"agent-id":_.value},null,8,["initial-value","agent-id"])])]))}});const ee=q(Z,[["__scopeId","data-v-c0f6c106"]]),le=Object.freeze(Object.defineProperty({__proto__:null,default:ee},Symbol.toStringTag,{value:"Module"}));export{ee as F,le as a,J as u};