@yuku123/z-agent-frontend-component 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -216,4 +216,4 @@ components:
216
216
  0%, 100% { opacity: 1; }
217
217
  50% { opacity: 0; }
218
218
  }
219
- `})]})},yl=()=>e.jsx(l.RobotOutlined,{}),{TextArea:rs}=t.Input,{Option:de}=t.Select,{TabPane:yt}=t.Tabs,jl=()=>{const[o,i]=s.useState("list");return e.jsx(t.Card,{style:{minHeight:"calc(100vh - 140px)"},children:e.jsxs(t.Tabs,{activeKey:o,onChange:i,children:[e.jsx(yt,{tab:e.jsxs("span",{children:[e.jsx(l.NodeIndexOutlined,{})," 场景管理"]}),children:e.jsx(bl,{})},"list"),e.jsx(yt,{tab:e.jsxs("span",{children:[e.jsx(l.SettingOutlined,{})," 节点配置"]}),children:e.jsx(Sl,{})},"nodes"),e.jsx(yt,{tab:e.jsxs("span",{children:[e.jsx(l.ApiOutlined,{})," 场景编排"]}),children:e.jsx(Cl,{})},"canvas")]})})},bl=()=>{const[o,i]=s.useState([]),[a,n]=s.useState(!1),[T,d]=s.useState(""),[b,f]=s.useState(""),[j,w]=s.useState(1),[h]=s.useState(12),[m,z]=s.useState(0),[F,N]=s.useState(!1),[u]=t.Form.useForm(),[v,S]=s.useState(null),[x,D]=s.useState(!1),[G,g]=s.useState(!1),[C,P]=s.useState(null),[K,O]=s.useState([]);s.useEffect(()=>{Se.page({id:1,pageSize:100}).then(r=>{var L;O(((L=r.data)==null?void 0:L.records)||[])})},[]),s.useEffect(()=>{V()},[j,T,b]);const V=async()=>{n(!0);try{const r=await ue.page({sceneName:T,status:b,id:j});r.data&&(i(r.data.records||[]),z(r.data.total||0))}catch(r){t.message.error("加载失败: "+(r.message||""))}n(!1)},U=()=>{S(null),u.resetFields(),u.setFieldsValue({status:"DRAFT",sceneType:"CONVERSATION"}),N(!0)},A=r=>{S(r),u.setFieldsValue({sceneCode:r.sceneCode,sceneName:r.sceneName,description:r.description,productCode:r.productCode,sceneType:r.sceneType||"CONVERSATION",version:r.version||"1.0.0",status:r.status,iconUrl:r.iconUrl}),N(!0)},k=async()=>{try{const r=await u.validateFields();D(!0),v?(await ue.update({id:v.id,...r}),t.message.success("更新成功")):(await ue.create(r),t.message.success("创建成功")),N(!1),V()}catch(r){r.errorFields||t.message.error("操作失败")}finally{D(!1)}},_=async r=>{try{await ue.delete(r),t.message.success("删除成功"),V()}catch{t.message.error("删除失败")}},p=async r=>{try{await ue.publish(r),t.message.success("发布成功"),V()}catch{t.message.error("发布失败")}},y=async r=>{try{await ue.offline(r),t.message.success("下架成功"),V()}catch{t.message.error("下架失败")}},M=r=>{P(r),g(!0)},E=async r=>{try{await ue.duplicate(r.id),t.message.success("复制成功"),V()}catch{t.message.error("复制失败")}},Q=r=>{navigator.clipboard.writeText(r).then(()=>t.message.success("场景编码已复制")).catch(()=>{})},c=[{title:"场景",key:"scene",width:280,render:(r,L)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:8,background:"linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(l.NodeIndexOutlined,{style:{fontSize:18,color:"#fff"}})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500},children:L.sceneName}),e.jsxs("div",{style:{fontSize:12,color:"#999"},children:[e.jsx("span",{style:{fontFamily:"monospace"},children:L.sceneCode}),e.jsx(t.Tooltip,{title:"复制编码",children:e.jsx(t.Button,{size:"small",type:"text",icon:e.jsx(l.CopyOutlined,{}),onClick:()=>Q(L.sceneCode),style:{marginLeft:4,padding:0}})})]})]})]})},{title:"所属产品",dataIndex:"productCode",width:160,render:r=>r?e.jsx(t.Tag,{color:"blue",children:r}):e.jsx("span",{style:{color:"#ccc"},children:"未关联"})},{title:"类型",dataIndex:"sceneType",width:100,render:r=>{const L={CONVERSATION:"对话",TASK:"任务",WORKFLOW:"工作流"};return e.jsx(t.Tag,{icon:e.jsx(l.NodeOutlined,{}),children:L[r]||r})}},{title:"状态",dataIndex:"status",width:100,render:r=>{const L={PUBLISHED:"success",DRAFT:"warning",OFFLINE:"error",ARCHIVED:"default"},$={PUBLISHED:"已发布",DRAFT:"草稿",OFFLINE:"已下架",ARCHIVED:"已归档"};return e.jsx(t.Badge,{status:L[r]||"default",text:$[r]||r})}},{title:"版本",dataIndex:"version",width:90,render:r=>e.jsxs("span",{style:{fontFamily:"monospace"},children:["v",r||"1.0.0"]})},{title:"描述",dataIndex:"description",ellipsis:!0},{title:"操作",width:340,render:(r,L)=>e.jsxs(t.Space,{size:"small",wrap:!0,children:[e.jsx(t.Tooltip,{title:"查看详情",children:e.jsx(t.Button,{size:"small",icon:e.jsx(l.EyeOutlined,{}),onClick:()=>M(L),children:"详情"})}),e.jsx(t.Tooltip,{title:"编辑配置",children:e.jsx(t.Button,{size:"small",icon:e.jsx(l.EditOutlined,{}),onClick:()=>A(L),children:"编辑"})}),e.jsx(t.Tooltip,{title:"复制场景",children:e.jsx(t.Button,{size:"small",icon:e.jsx(l.CopyOutlined,{}),onClick:()=>E(L),children:"复制"})}),L.status==="DRAFT"&&e.jsx(t.Tooltip,{title:"发布场景",children:e.jsx(t.Button,{size:"small",type:"primary",icon:e.jsx(l.CheckCircleOutlined,{}),onClick:()=>p(L.sceneCode),children:"发布"})}),L.status==="PUBLISHED"&&e.jsx(t.Tooltip,{title:"下架场景",children:e.jsx(t.Button,{size:"small",danger:!0,icon:e.jsx(l.StopOutlined,{}),onClick:()=>y(L.sceneCode),children:"下架"})}),e.jsx(t.Tooltip,{title:"执行场景",children:e.jsx(t.Button,{size:"small",type:"primary",icon:e.jsx(l.PlayCircleOutlined,{}),onClick:()=>window.open(`/ai/product/execute?sceneCode=${L.sceneCode}`,"_blank"),children:"执行"})}),e.jsx(t.Popconfirm,{title:"确定删除此场景?",onConfirm:()=>_(L.id),okText:"删除",okButtonProps:{danger:!0},children:e.jsx(t.Button,{size:"small",danger:!0,icon:e.jsx(l.DeleteOutlined,{})})})]})}];return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:16,gap:12,flexWrap:"wrap"},children:[e.jsxs(t.Space,{children:[e.jsx(t.Input.Search,{placeholder:"搜索场景名称/编码",onSearch:r=>{d(r),w(1)},style:{width:220},allowClear:!0}),e.jsxs(t.Select,{placeholder:"状态筛选",allowClear:!0,style:{width:120},onChange:r=>{f(r),w(1)},children:[e.jsx(de,{value:"DRAFT",children:"草稿"}),e.jsx(de,{value:"PUBLISHED",children:"已发布"}),e.jsx(de,{value:"OFFLINE",children:"已下架"})]}),e.jsxs(t.Select,{placeholder:"类型筛选",allowClear:!0,style:{width:120},onChange:r=>{f(r),w(1)},children:[e.jsx(de,{value:"CONVERSATION",children:"对话"}),e.jsx(de,{value:"TASK",children:"任务"}),e.jsx(de,{value:"WORKFLOW",children:"工作流"})]})]}),e.jsx(t.Button,{type:"primary",icon:e.jsx(l.PlusOutlined,{}),onClick:U,children:"新建场景"})]}),e.jsx(t.Table,{dataSource:o,columns:c,loading:a,rowKey:"id",pagination:{current:j,pageSize:h,total:m,showSizeChanger:!1,showTotal:r=>`共 ${r} 个场景`,onChange:r=>w(r)},locale:{emptyText:e.jsx(t.Empty,{image:t.Empty.PRESENTED_IMAGE_SIMPLE,description:"还没有场景,点击新建开始创建"})}}),e.jsx(t.Modal,{title:v?`编辑场景: ${v.sceneName}`:"新建场景",open:F,onOk:k,onCancel:()=>N(!1),width:640,confirmLoading:x,okText:v?"保存":"创建",children:e.jsxs(t.Form,{form:u,layout:"vertical",size:"middle",children:[e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"sceneName",label:"场景名称",rules:[{required:!0,message:"请输入场景名称"}],children:e.jsx(t.Input,{placeholder:"如 智能问答助手"})})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"sceneCode",label:"场景编码",rules:[{required:!0,message:"请输入场景编码"}],children:e.jsx(t.Input,{placeholder:"如 chat_scene",disabled:!!v})})})]}),e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"sceneType",label:"场景类型",initialValue:"CONVERSATION",children:e.jsxs(t.Select,{children:[e.jsx(de,{value:"CONVERSATION",children:"对话场景"}),e.jsx(de,{value:"TASK",children:"任务场景"}),e.jsx(de,{value:"WORKFLOW",children:"工作流场景"})]})})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"productCode",label:"所属产品",children:e.jsx(t.Select,{allowClear:!0,placeholder:"选择产品",children:K.map(r=>e.jsx(de,{value:r.productCode,children:r.productName},r.productCode))})})})]}),e.jsx(t.Form.Item,{name:"description",label:"场景描述",children:e.jsx(rs,{rows:2,placeholder:"简短描述这个场景的能力和使用方式"})}),e.jsx(t.Form.Item,{name:"version",label:"版本号",initialValue:"1.0.0",children:e.jsx(t.Input,{placeholder:"1.0.0"})}),!v&&e.jsx(t.Form.Item,{name:"status",label:"创建后状态",initialValue:"DRAFT",children:e.jsxs(t.Select,{children:[e.jsx(de,{value:"DRAFT",children:"草稿"}),e.jsx(de,{value:"PUBLISHED",children:"直接发布"})]})})]})}),e.jsx(t.Drawer,{title:"场景详情",open:G,onClose:()=>g(!1),width:560,children:C&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:48,height:48,borderRadius:10,background:"linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(l.NodeIndexOutlined,{style:{fontSize:22,color:"#fff"}})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:600},children:C.sceneName}),e.jsx("div",{style:{fontSize:12,color:"#999"},children:C.sceneCode})]})]}),e.jsx(t.Divider,{style:{margin:"8px 0"}}),e.jsxs(t.Row,{gutter:16,children:[e.jsxs(t.Col,{span:12,children:[e.jsx("div",{style:{fontSize:12,color:"#999",marginBottom:4},children:"类型"}),e.jsx(t.Tag,{children:C.sceneType==="CONVERSATION"?"对话":C.sceneType==="TASK"?"任务":"工作流"})]}),e.jsxs(t.Col,{span:12,children:[e.jsx("div",{style:{fontSize:12,color:"#999",marginBottom:4},children:"版本"}),e.jsx("span",{style:{fontFamily:"monospace"},children:C.version||"1.0.0"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,color:"#999",marginBottom:4},children:"状态"}),e.jsx(t.Badge,{status:C.status==="PUBLISHED"?"success":C.status==="DRAFT"?"warning":"error",text:C.status==="PUBLISHED"?"已发布":C.status==="DRAFT"?"草稿":C.status==="OFFLINE"?"已下架":"已归档"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,color:"#999",marginBottom:4},children:"描述"}),e.jsx("div",{style:{color:"#333",lineHeight:1.6},children:C.description||"暂无描述"})]})]})})]})},Sl=()=>{const[o,i]=s.useState([]),[a,n]=s.useState(null),[T,d]=s.useState([]),[b,f]=s.useState(!1),[j,w]=s.useState(!1),[h]=t.Form.useForm();s.useEffect(()=>{ue.page({id:1,pageSize:100}).then(S=>{var x;i(((x=S.data)==null?void 0:x.records)||[])})},[]),s.useEffect(()=>{a&&m(a.sceneCode)},[a]);const m=async S=>{f(!0);try{const x=await ue.nodes(S);d(x.data||[])}catch{d([])}f(!1)},z=()=>{h.resetFields(),h.setFieldsValue({nodeType:"LLM",isEnabled:!0}),w(!0)},F=async()=>{try{const S=await h.validateFields();d(x=>[...x||[],{...S,id:Date.now()}]),w(!1),t.message.success("节点已添加")}catch{}},N=S=>{d(x=>(x||[]).filter(D=>D.id!==S))},u=S=>{d(x=>x.map(D=>D.id===S?{...D,isEnabled:!D.isEnabled}:D))},v=[{title:"节点名称",dataIndex:"nodeName",key:"nodeName"},{title:"节点类型",dataIndex:"nodeType",key:"nodeType",render:S=>e.jsx(t.Tag,{color:"blue",children:S})},{title:"配置",dataIndex:"config",key:"config",ellipsis:!0},{title:"启用",dataIndex:"isEnabled",key:"isEnabled",render:(S,x)=>e.jsx(t.Switch,{checked:S,onChange:()=>u(x.id)})},{title:"操作",width:100,render:(S,x)=>e.jsx(t.Button,{size:"small",danger:!0,icon:e.jsx(l.DeleteOutlined,{}),onClick:()=>N(x.id)})}];return e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsxs(t.Card,{size:"small",title:e.jsxs("span",{style:{fontWeight:600},children:[e.jsx(l.NodeIndexOutlined,{style:{color:"#4facfe",marginRight:6}}),"选择场景"]}),style:{width:260,flexShrink:0,borderRadius:10},styles:{header:{borderBottom:"1px solid #f0f0f0",padding:"12px 16px"},body:{padding:8}},children:[(o||[]).map(S=>e.jsxs("div",{onClick:()=>n(S),style:{padding:"10px 12px",borderRadius:8,cursor:"pointer",marginBottom:4,background:(a==null?void 0:a.id)===S.id?"linear-gradient(135deg, #4facfe22, #00f2fe22)":"transparent",border:(a==null?void 0:a.id)===S.id?"1px solid #4facfe44":"1px solid transparent"},children:[e.jsx("div",{style:{fontSize:13,fontWeight:500},children:S.sceneName}),e.jsx("div",{style:{fontSize:11,color:"#999"},children:S.sceneCode})]},S.id)),o.length===0&&e.jsx(t.Empty,{description:"暂无场景",style:{padding:20}})]}),e.jsx(t.Card,{title:e.jsxs("span",{style:{fontWeight:600},children:["节点配置 ",a?`- ${a.sceneName}`:""]}),extra:e.jsx(t.Button,{size:"small",icon:e.jsx(l.PlusOutlined,{}),onClick:z,disabled:!a,children:"添加节点"}),style:{flex:1,borderRadius:10},children:a?e.jsx(t.Table,{dataSource:T,columns:v,rowKey:"id",pagination:!1,locale:{emptyText:e.jsx(t.Empty,{description:"暂无节点,点击添加开始配置",image:t.Empty.PRESENTED_IMAGE_SIMPLE})}}):e.jsx(t.Empty,{description:"请先选择场景",style:{padding:60},image:t.Empty.PRESENTED_IMAGE_SIMPLE})}),e.jsx(t.Modal,{title:"添加节点",open:j,onOk:F,onCancel:()=>w(!1),okText:"添加",children:e.jsxs(t.Form,{form:h,layout:"vertical",children:[e.jsx(t.Form.Item,{name:"nodeName",label:"节点名称",rules:[{required:!0,message:"请输入节点名称"}],children:e.jsx(t.Input,{placeholder:"如 LLM调用节点"})}),e.jsx(t.Form.Item,{name:"nodeType",label:"节点类型",initialValue:"LLM",children:e.jsxs(t.Select,{children:[e.jsx(de,{value:"LLM",children:"LLM调用"}),e.jsx(de,{value:"TOOL",children:"工具调用"}),e.jsx(de,{value:"CONDITION",children:"条件分支"}),e.jsx(de,{value:"TRANSFORM",children:"数据转换"}),e.jsx(de,{value:"HTTP",children:"HTTP请求"})]})}),e.jsx(t.Form.Item,{name:"config",label:"节点配置",children:e.jsx(rs,{rows:3,placeholder:'JSON格式配置,如 {"model":"gpt-4"}'})})]})})]})},Cl=()=>{const[o,i]=s.useState([]),[a,n]=s.useState(null),[T,d]=s.useState([]),[b,f]=s.useState([]);s.useEffect(()=>{ue.page({id:1,pageSize:100}).then(h=>{var m;i(((m=h.data)==null?void 0:m.records)||[])})},[]);const j=async h=>{n(h);try{const m=await ue.canvasGet(h.sceneCode);m.data&&(d(m.data.nodes||[]),f(m.data.edges||[]))}catch{d([]),f([])}},w=[{title:"节点",dataIndex:"label",key:"label",width:200},{title:"类型",dataIndex:"type",key:"type",render:h=>e.jsx(t.Tag,{color:"purple",children:h})},{title:"位置",dataIndex:"position",key:"position",render:h=>e.jsxs("span",{style:{fontSize:11,color:"#999"},children:["x:",(h==null?void 0:h.x)||0," y:",(h==null?void 0:h.y)||0]})}];return e.jsxs("div",{style:{display:"flex",gap:16,minHeight:500},children:[e.jsx(t.Card,{size:"small",title:e.jsxs("span",{style:{fontWeight:600},children:[e.jsx(l.NodeIndexOutlined,{style:{color:"#4facfe",marginRight:6}}),"场景列表"]}),style:{width:240,flexShrink:0,borderRadius:10},styles:{header:{borderBottom:"1px solid #f0f0f0",padding:"12px 16px"},body:{padding:8}},children:(o||[]).map(h=>e.jsxs("div",{onClick:()=>j(h),style:{padding:"10px 12px",borderRadius:8,cursor:"pointer",marginBottom:4,background:(a==null?void 0:a.id)===h.id?"linear-gradient(135deg, #4facfe22, #00f2fe22)":"transparent",border:(a==null?void 0:a.id)===h.id?"1px solid #4facfe44":"1px solid transparent"},children:[e.jsx("div",{style:{fontSize:13,fontWeight:500},children:h.sceneName}),e.jsx(t.Tag,{style:{fontSize:10,marginTop:2},children:h.sceneType})]},h.id))}),e.jsx(t.Card,{title:e.jsxs("span",{style:{fontWeight:600},children:["场景编排画布 ",a?`- ${a.sceneName}`:""]}),style:{flex:1,borderRadius:10},styles:{body:{padding:16,display:"flex",flexDirection:"column",gap:12}},children:a?T.length===0?e.jsx(t.Empty,{description:"暂无节点配置,请先在节点配置中添加节点",style:{padding:40},image:t.Empty.PRESENTED_IMAGE_SIMPLE}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 0",borderBottom:"1px solid #f0f0f0"},children:[e.jsx(l.ThunderboltOutlined,{style:{color:"#4facfe"}}),e.jsxs("span",{style:{fontSize:13,color:"#666"},children:["编排节点 ",T.length," 个,连接 ",b.length," 条"]})]}),e.jsx(t.Table,{dataSource:T,columns:w,rowKey:"id",pagination:!1,size:"small"}),b.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginTop:8},children:"连线"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:b.map((h,m)=>e.jsx(t.Card,{size:"small",style:{background:"#fafafa",border:"none"},children:e.jsxs("span",{style:{fontFamily:"monospace",fontSize:12},children:[h.source," → ",h.target]})},m))})]})]}):e.jsx(t.Empty,{description:"请选择场景进行编排",style:{padding:60},image:t.Empty.PRESENTED_IMAGE_SIMPLE})})]})},{Text:jt}=t.Typography,{TabPane:Qe}=t.Tabs,vl=()=>{const[o,i]=s.useState(null),[a,n]=s.useState([]),[T,d]=s.useState([]),[b,f]=s.useState([]),[j,w]=s.useState([]),[h,m]=s.useState(!1),[z,F]=s.useState(null),[N,u]=s.useState(null),[v,S]=s.useState(null),[x,D]=s.useState([]),[G,g]=s.useState([]),[C,P]=s.useState([]);s.useEffect(()=>{te("/llm-center/provider/list").then(c=>{const r=Array.isArray(c)?c:(c==null?void 0:c.data)||[];D(r)}).catch(()=>{}),K(null),te("/agent/app/page",{method:"POST",body:JSON.stringify({current:1,size:100})}).then(c=>{const r=Array.isArray(c)?c:(c==null?void 0:c.records)||(c==null?void 0:c.data)||[];P(r)}).catch(()=>{})},[]);const K=c=>{te("/llm-center/model/list",{params:{providerCode:c}}).then(r=>{const L=Array.isArray(r)?r:(r==null?void 0:r.data)||[];g(L)}).catch(()=>{})},O=c=>{u(c),S(null),K(c)},V=()=>({appCode:z,providerCode:N,modelCode:v}),U=async()=>{try{const c=await te("/llm-gateway/usage/overview",{method:"GET",params:V()});i((c==null?void 0:c.data)||c||null)}catch(c){console.warn("Usage overview API unavailable:",c==null?void 0:c.message),i(null)}},A=async()=>{try{const c=await te("/llm-gateway/usage/by-app",{method:"GET"});n(Array.isArray(c)?c:(c==null?void 0:c.data)||[])}catch(c){console.warn("Usage by-app API unavailable:",c==null?void 0:c.message),n([])}},k=async()=>{try{const c=await te("/llm-gateway/usage/by-user",{method:"GET",params:V()});d(Array.isArray(c)?c:(c==null?void 0:c.data)||[])}catch(c){console.warn("Usage by-user API unavailable:",c==null?void 0:c.message),d([])}},_=async()=>{try{const c=await te("/llm-gateway/usage/trend",{method:"GET",params:{...V(),days:7}});f(Array.isArray(c)?c:(c==null?void 0:c.data)||[])}catch(c){console.warn("Usage trend API unavailable:",c==null?void 0:c.message),f([])}},p=async()=>{m(!0);try{const c=await te("/llm-gateway/usage/records",{method:"GET",params:{...V(),page:1,size:20}}),r=Array.isArray(c)?c:(c==null?void 0:c.records)||(c==null?void 0:c.data)||[];w(r)}catch(c){console.warn("Usage records API unavailable:",c==null?void 0:c.message),w([])}finally{m(!1)}};s.useEffect(()=>{U(),A(),k(),_(),p()},[z,N,v]);const y={tooltip:{trigger:"axis"},legend:{data:["Token消耗","调用次数"]},xAxis:{type:"category",data:b.map(c=>c.date)},yAxis:[{type:"value",name:"Tokens",position:"left"},{type:"value",name:"调用次数",position:"right"}],series:[{name:"Token消耗",type:"bar",data:b.map(c=>c.dailyTokens)},{name:"调用次数",type:"line",yAxisIndex:1,data:b.map(c=>c.dailyCalls)}]},M=[{title:"应用编码",dataIndex:"appCode"},{title:"调用次数",dataIndex:"totalCalls",render:c=>c==null?void 0:c.toLocaleString()},{title:"输入Token",dataIndex:"inputTokens",render:c=>c==null?void 0:c.toLocaleString()},{title:"输出Token",dataIndex:"outputTokens",render:c=>c==null?void 0:c.toLocaleString()},{title:"总Token",dataIndex:"totalTokens",render:c=>c==null?void 0:c.toLocaleString()},{title:"费用",dataIndex:"totalCost",render:c=>e.jsxs(jt,{style:{color:"#faad14"},children:["¥",(c==null?void 0:c.toFixed(4))||"0"]})}],E=[{title:"用户ID",dataIndex:"userId"},{title:"调用次数",dataIndex:"totalCalls",render:c=>c==null?void 0:c.toLocaleString()},{title:"总Token",dataIndex:"totalTokens",render:c=>c==null?void 0:c.toLocaleString()},{title:"费用",dataIndex:"totalCost",render:c=>e.jsxs(jt,{style:{color:"#faad14"},children:["¥",(c==null?void 0:c.toFixed(4))||"0"]})}],Q=[{title:"时间",dataIndex:"gmtCreate",width:160},{title:"应用",dataIndex:"appCode",render:c=>e.jsx(t.Tag,{color:"blue",children:c||"-"})},{title:"用户",dataIndex:"userName"},{title:"供应商",dataIndex:"providerCode",render:c=>e.jsx(t.Tag,{color:"purple",children:c||"-"})},{title:"模型",dataIndex:"modelCode",render:c=>e.jsx(t.Tag,{children:c||"-"})},{title:"输入Token",dataIndex:"inputTokens",render:c=>c==null?void 0:c.toLocaleString()},{title:"输出Token",dataIndex:"outputTokens",render:c=>c==null?void 0:c.toLocaleString()},{title:"延迟",dataIndex:"latencyMs",render:c=>c?`${c}ms`:"-"},{title:"状态",dataIndex:"status",render:c=>e.jsx(t.Tag,{color:c==="SUCCESS"?"green":"red",children:c||"-"})},{title:"费用",dataIndex:"totalCost",render:c=>e.jsxs(jt,{style:{color:"#faad14"},children:["¥",c||0]})}];return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center",flexWrap:"wrap",background:"#fff",padding:"12px 16px",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)",marginBottom:16},children:[e.jsx("span",{style:{fontWeight:600,color:"#333",marginRight:4},children:"维度筛选:"}),e.jsx(t.Select,{placeholder:"筛选应用",allowClear:!0,style:{width:180},value:z,onChange:F,options:C.map(c=>({value:c.appCode,label:c.appName||c.appCode}))}),e.jsx(t.Select,{placeholder:"筛选供应商",allowClear:!0,style:{width:180},value:N,onChange:O,options:x.map(c=>({value:c.providerCode,label:c.providerName}))}),e.jsx(t.Select,{placeholder:"筛选模型",allowClear:!0,style:{width:180},value:v,onChange:S,options:G.map(c=>({value:c.modelCode,label:c.modelName}))}),(z||N||v)&&e.jsx("a",{onClick:()=>{F(null),u(null),S(null)},style:{fontSize:12},children:"清空筛选"})]}),e.jsxs(t.Row,{gutter:16,style:{marginBottom:16},children:[e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Statistic,{title:e.jsx("span",{style:{color:"#666",fontSize:13},children:"累计 Token"}),value:(o==null?void 0:o.totalTokens)||0,prefix:e.jsx(l.RocketOutlined,{style:{color:"#667eea"}}),formatter:c=>c==null?void 0:c.toLocaleString(),valueStyle:{color:"#333",fontSize:22,fontWeight:700}})})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Statistic,{title:e.jsx("span",{style:{color:"#666",fontSize:13},children:"累计费用"}),value:(o==null?void 0:o.totalCost)||0,prefix:e.jsx(l.DollarOutlined,{style:{color:"#faad14"}}),valueStyle:{color:"#333",fontSize:22,fontWeight:700}})})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Statistic,{title:e.jsx("span",{style:{color:"#666",fontSize:13},children:"今日 Token"}),value:(o==null?void 0:o.todayTokens)||0,prefix:e.jsx(l.BarChartOutlined,{style:{color:"#52c41a"}}),formatter:c=>c==null?void 0:c.toLocaleString(),valueStyle:{color:"#333",fontSize:22,fontWeight:700}})})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Statistic,{title:e.jsx("span",{style:{color:"#666",fontSize:13},children:"今日费用"}),value:(o==null?void 0:o.todayCost)||0,prefix:e.jsx(l.DollarOutlined,{style:{color:"#faad14"}}),precision:4,suffix:"元",valueStyle:{color:"#333",fontSize:22,fontWeight:700}})})})]}),e.jsxs(t.Tabs,{defaultActiveKey:"trend",children:[e.jsx(Qe,{tab:"用量趋势",children:e.jsx(t.Card,{style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(Pt,{option:y,style:{height:300}})})},"trend"),e.jsx(Qe,{tab:"按应用统计",children:e.jsx(t.Card,{style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Table,{columns:M,dataSource:a,rowKey:"appCode",pagination:!1,locale:{emptyText:"暂无数据"}})})},"byApp"),e.jsx(Qe,{tab:"按用户统计",children:e.jsx(t.Card,{style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Table,{columns:E,dataSource:T,rowKey:"userId",pagination:!1,locale:{emptyText:"暂无数据"}})})},"byUser"),e.jsx(Qe,{tab:"调用明细",children:e.jsx(t.Card,{style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Table,{columns:Q,dataSource:j,loading:h,rowKey:"id",pagination:{pageSize:20,showSizeChanger:!1},locale:{emptyText:"暂无数据"}})})},"records")]})]})};Z.AgentAppEditor=Mt,Z.AgentAppList=_t,Z.AgentAppPage=_t,Z.AgentSharePage=Ns,Z.AkManage=Gs,Z.AkUsageDrawer=Vt,Z.ApiBridgeEditor=Zt,Z.BucketList=Js,Z.CurlImportModal=Yt,Z.FieldMappingEditor=xt,Z.LlmModel=Vs,Z.LlmProvider=Us,Z.McpPage=Hs,Z.ModelManage=Ms,Z.ObjectBrowser=Qs,Z.OpenApiImportModal=Qt,Z.ProductExecute=fl,Z.ProductList=ul,Z.ProductScene=jl,Z.ScriptCenterPage=il,Z.SkillMarket=pl,Z.UsageDashboard=vl,Z.WorkflowEditor=Nt,Z.agentApi=ae,Z.authRequest=qe,Z.ctcRequest=$e,Z.flowApi=De,Z.llmApi=Ae,Z.mcpApi=Ie,Z.ossApi=me,Z.productApi=Se,Z.request=te,Z.sceneApi=ue,Z.scriptApi=be,Z.skillApi=ge,Object.defineProperty(Z,Symbol.toStringTag,{value:"Module"})}));
219
+ `})]})},yl=()=>e.jsx(l.RobotOutlined,{}),{TextArea:rs}=t.Input,{Option:de}=t.Select,{TabPane:yt}=t.Tabs,jl=()=>{const[o,i]=s.useState("list");return e.jsx(t.Card,{style:{minHeight:"calc(100vh - 140px)"},children:e.jsxs(t.Tabs,{activeKey:o,onChange:i,children:[e.jsx(yt,{tab:e.jsxs("span",{children:[e.jsx(l.NodeIndexOutlined,{})," 场景管理"]}),children:e.jsx(bl,{})},"list"),e.jsx(yt,{tab:e.jsxs("span",{children:[e.jsx(l.SettingOutlined,{})," 节点配置"]}),children:e.jsx(Sl,{})},"nodes"),e.jsx(yt,{tab:e.jsxs("span",{children:[e.jsx(l.ApiOutlined,{})," 场景编排"]}),children:e.jsx(Cl,{})},"canvas")]})})},bl=()=>{const[o,i]=s.useState([]),[a,n]=s.useState(!1),[T,d]=s.useState(""),[b,f]=s.useState(""),[j,w]=s.useState(1),[h]=s.useState(12),[m,z]=s.useState(0),[F,N]=s.useState(!1),[u]=t.Form.useForm(),[v,S]=s.useState(null),[x,D]=s.useState(!1),[G,g]=s.useState(!1),[C,P]=s.useState(null),[K,O]=s.useState([]);s.useEffect(()=>{Se.page({id:1,pageSize:100}).then(r=>{var L;O(((L=r.data)==null?void 0:L.records)||[])})},[]),s.useEffect(()=>{V()},[j,T,b]);const V=async()=>{n(!0);try{const r=await ue.page({sceneName:T,status:b,id:j});r.data&&(i(r.data.records||[]),z(r.data.total||0))}catch(r){t.message.error("加载失败: "+(r.message||""))}n(!1)},U=()=>{S(null),u.resetFields(),u.setFieldsValue({status:"DRAFT",sceneType:"CONVERSATION"}),N(!0)},A=r=>{S(r),u.setFieldsValue({sceneCode:r.sceneCode,sceneName:r.sceneName,description:r.description,productCode:r.productCode,sceneType:r.sceneType||"CONVERSATION",version:r.version||"1.0.0",status:r.status,iconUrl:r.iconUrl}),N(!0)},k=async()=>{try{const r=await u.validateFields();D(!0),v?(await ue.update({id:v.id,...r}),t.message.success("更新成功")):(await ue.create(r),t.message.success("创建成功")),N(!1),V()}catch(r){r.errorFields||t.message.error("操作失败")}finally{D(!1)}},_=async r=>{try{await ue.delete(r),t.message.success("删除成功"),V()}catch{t.message.error("删除失败")}},p=async r=>{try{await ue.publish(r),t.message.success("发布成功"),V()}catch{t.message.error("发布失败")}},y=async r=>{try{await ue.offline(r),t.message.success("下架成功"),V()}catch{t.message.error("下架失败")}},M=r=>{P(r),g(!0)},E=async r=>{try{await ue.duplicate(r.id),t.message.success("复制成功"),V()}catch{t.message.error("复制失败")}},Q=r=>{navigator.clipboard.writeText(r).then(()=>t.message.success("场景编码已复制")).catch(()=>{})},c=[{title:"场景",key:"scene",width:280,render:(r,L)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:8,background:"linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(l.NodeIndexOutlined,{style:{fontSize:18,color:"#fff"}})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500},children:L.sceneName}),e.jsxs("div",{style:{fontSize:12,color:"#999"},children:[e.jsx("span",{style:{fontFamily:"monospace"},children:L.sceneCode}),e.jsx(t.Tooltip,{title:"复制编码",children:e.jsx(t.Button,{size:"small",type:"text",icon:e.jsx(l.CopyOutlined,{}),onClick:()=>Q(L.sceneCode),style:{marginLeft:4,padding:0}})})]})]})]})},{title:"所属产品",dataIndex:"productCode",width:160,render:r=>r?e.jsx(t.Tag,{color:"blue",children:r}):e.jsx("span",{style:{color:"#ccc"},children:"未关联"})},{title:"类型",dataIndex:"sceneType",width:100,render:r=>{const L={CONVERSATION:"对话",TASK:"任务",WORKFLOW:"工作流"};return e.jsx(t.Tag,{icon:e.jsx(l.NodeIndexOutlined,{}),children:L[r]||r})}},{title:"状态",dataIndex:"status",width:100,render:r=>{const L={PUBLISHED:"success",DRAFT:"warning",OFFLINE:"error",ARCHIVED:"default"},$={PUBLISHED:"已发布",DRAFT:"草稿",OFFLINE:"已下架",ARCHIVED:"已归档"};return e.jsx(t.Badge,{status:L[r]||"default",text:$[r]||r})}},{title:"版本",dataIndex:"version",width:90,render:r=>e.jsxs("span",{style:{fontFamily:"monospace"},children:["v",r||"1.0.0"]})},{title:"描述",dataIndex:"description",ellipsis:!0},{title:"操作",width:340,render:(r,L)=>e.jsxs(t.Space,{size:"small",wrap:!0,children:[e.jsx(t.Tooltip,{title:"查看详情",children:e.jsx(t.Button,{size:"small",icon:e.jsx(l.EyeOutlined,{}),onClick:()=>M(L),children:"详情"})}),e.jsx(t.Tooltip,{title:"编辑配置",children:e.jsx(t.Button,{size:"small",icon:e.jsx(l.EditOutlined,{}),onClick:()=>A(L),children:"编辑"})}),e.jsx(t.Tooltip,{title:"复制场景",children:e.jsx(t.Button,{size:"small",icon:e.jsx(l.CopyOutlined,{}),onClick:()=>E(L),children:"复制"})}),L.status==="DRAFT"&&e.jsx(t.Tooltip,{title:"发布场景",children:e.jsx(t.Button,{size:"small",type:"primary",icon:e.jsx(l.CheckCircleOutlined,{}),onClick:()=>p(L.sceneCode),children:"发布"})}),L.status==="PUBLISHED"&&e.jsx(t.Tooltip,{title:"下架场景",children:e.jsx(t.Button,{size:"small",danger:!0,icon:e.jsx(l.StopOutlined,{}),onClick:()=>y(L.sceneCode),children:"下架"})}),e.jsx(t.Tooltip,{title:"执行场景",children:e.jsx(t.Button,{size:"small",type:"primary",icon:e.jsx(l.PlayCircleOutlined,{}),onClick:()=>window.open(`/ai/product/execute?sceneCode=${L.sceneCode}`,"_blank"),children:"执行"})}),e.jsx(t.Popconfirm,{title:"确定删除此场景?",onConfirm:()=>_(L.id),okText:"删除",okButtonProps:{danger:!0},children:e.jsx(t.Button,{size:"small",danger:!0,icon:e.jsx(l.DeleteOutlined,{})})})]})}];return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:16,gap:12,flexWrap:"wrap"},children:[e.jsxs(t.Space,{children:[e.jsx(t.Input.Search,{placeholder:"搜索场景名称/编码",onSearch:r=>{d(r),w(1)},style:{width:220},allowClear:!0}),e.jsxs(t.Select,{placeholder:"状态筛选",allowClear:!0,style:{width:120},onChange:r=>{f(r),w(1)},children:[e.jsx(de,{value:"DRAFT",children:"草稿"}),e.jsx(de,{value:"PUBLISHED",children:"已发布"}),e.jsx(de,{value:"OFFLINE",children:"已下架"})]}),e.jsxs(t.Select,{placeholder:"类型筛选",allowClear:!0,style:{width:120},onChange:r=>{f(r),w(1)},children:[e.jsx(de,{value:"CONVERSATION",children:"对话"}),e.jsx(de,{value:"TASK",children:"任务"}),e.jsx(de,{value:"WORKFLOW",children:"工作流"})]})]}),e.jsx(t.Button,{type:"primary",icon:e.jsx(l.PlusOutlined,{}),onClick:U,children:"新建场景"})]}),e.jsx(t.Table,{dataSource:o,columns:c,loading:a,rowKey:"id",pagination:{current:j,pageSize:h,total:m,showSizeChanger:!1,showTotal:r=>`共 ${r} 个场景`,onChange:r=>w(r)},locale:{emptyText:e.jsx(t.Empty,{image:t.Empty.PRESENTED_IMAGE_SIMPLE,description:"还没有场景,点击新建开始创建"})}}),e.jsx(t.Modal,{title:v?`编辑场景: ${v.sceneName}`:"新建场景",open:F,onOk:k,onCancel:()=>N(!1),width:640,confirmLoading:x,okText:v?"保存":"创建",children:e.jsxs(t.Form,{form:u,layout:"vertical",size:"middle",children:[e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"sceneName",label:"场景名称",rules:[{required:!0,message:"请输入场景名称"}],children:e.jsx(t.Input,{placeholder:"如 智能问答助手"})})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"sceneCode",label:"场景编码",rules:[{required:!0,message:"请输入场景编码"}],children:e.jsx(t.Input,{placeholder:"如 chat_scene",disabled:!!v})})})]}),e.jsxs(t.Row,{gutter:16,children:[e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"sceneType",label:"场景类型",initialValue:"CONVERSATION",children:e.jsxs(t.Select,{children:[e.jsx(de,{value:"CONVERSATION",children:"对话场景"}),e.jsx(de,{value:"TASK",children:"任务场景"}),e.jsx(de,{value:"WORKFLOW",children:"工作流场景"})]})})}),e.jsx(t.Col,{span:12,children:e.jsx(t.Form.Item,{name:"productCode",label:"所属产品",children:e.jsx(t.Select,{allowClear:!0,placeholder:"选择产品",children:K.map(r=>e.jsx(de,{value:r.productCode,children:r.productName},r.productCode))})})})]}),e.jsx(t.Form.Item,{name:"description",label:"场景描述",children:e.jsx(rs,{rows:2,placeholder:"简短描述这个场景的能力和使用方式"})}),e.jsx(t.Form.Item,{name:"version",label:"版本号",initialValue:"1.0.0",children:e.jsx(t.Input,{placeholder:"1.0.0"})}),!v&&e.jsx(t.Form.Item,{name:"status",label:"创建后状态",initialValue:"DRAFT",children:e.jsxs(t.Select,{children:[e.jsx(de,{value:"DRAFT",children:"草稿"}),e.jsx(de,{value:"PUBLISHED",children:"直接发布"})]})})]})}),e.jsx(t.Drawer,{title:"场景详情",open:G,onClose:()=>g(!1),width:560,children:C&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:48,height:48,borderRadius:10,background:"linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(l.NodeIndexOutlined,{style:{fontSize:22,color:"#fff"}})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:600},children:C.sceneName}),e.jsx("div",{style:{fontSize:12,color:"#999"},children:C.sceneCode})]})]}),e.jsx(t.Divider,{style:{margin:"8px 0"}}),e.jsxs(t.Row,{gutter:16,children:[e.jsxs(t.Col,{span:12,children:[e.jsx("div",{style:{fontSize:12,color:"#999",marginBottom:4},children:"类型"}),e.jsx(t.Tag,{children:C.sceneType==="CONVERSATION"?"对话":C.sceneType==="TASK"?"任务":"工作流"})]}),e.jsxs(t.Col,{span:12,children:[e.jsx("div",{style:{fontSize:12,color:"#999",marginBottom:4},children:"版本"}),e.jsx("span",{style:{fontFamily:"monospace"},children:C.version||"1.0.0"})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,color:"#999",marginBottom:4},children:"状态"}),e.jsx(t.Badge,{status:C.status==="PUBLISHED"?"success":C.status==="DRAFT"?"warning":"error",text:C.status==="PUBLISHED"?"已发布":C.status==="DRAFT"?"草稿":C.status==="OFFLINE"?"已下架":"已归档"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,color:"#999",marginBottom:4},children:"描述"}),e.jsx("div",{style:{color:"#333",lineHeight:1.6},children:C.description||"暂无描述"})]})]})})]})},Sl=()=>{const[o,i]=s.useState([]),[a,n]=s.useState(null),[T,d]=s.useState([]),[b,f]=s.useState(!1),[j,w]=s.useState(!1),[h]=t.Form.useForm();s.useEffect(()=>{ue.page({id:1,pageSize:100}).then(S=>{var x;i(((x=S.data)==null?void 0:x.records)||[])})},[]),s.useEffect(()=>{a&&m(a.sceneCode)},[a]);const m=async S=>{f(!0);try{const x=await ue.nodes(S);d(x.data||[])}catch{d([])}f(!1)},z=()=>{h.resetFields(),h.setFieldsValue({nodeType:"LLM",isEnabled:!0}),w(!0)},F=async()=>{try{const S=await h.validateFields();d(x=>[...x||[],{...S,id:Date.now()}]),w(!1),t.message.success("节点已添加")}catch{}},N=S=>{d(x=>(x||[]).filter(D=>D.id!==S))},u=S=>{d(x=>x.map(D=>D.id===S?{...D,isEnabled:!D.isEnabled}:D))},v=[{title:"节点名称",dataIndex:"nodeName",key:"nodeName"},{title:"节点类型",dataIndex:"nodeType",key:"nodeType",render:S=>e.jsx(t.Tag,{color:"blue",children:S})},{title:"配置",dataIndex:"config",key:"config",ellipsis:!0},{title:"启用",dataIndex:"isEnabled",key:"isEnabled",render:(S,x)=>e.jsx(t.Switch,{checked:S,onChange:()=>u(x.id)})},{title:"操作",width:100,render:(S,x)=>e.jsx(t.Button,{size:"small",danger:!0,icon:e.jsx(l.DeleteOutlined,{}),onClick:()=>N(x.id)})}];return e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsxs(t.Card,{size:"small",title:e.jsxs("span",{style:{fontWeight:600},children:[e.jsx(l.NodeIndexOutlined,{style:{color:"#4facfe",marginRight:6}}),"选择场景"]}),style:{width:260,flexShrink:0,borderRadius:10},styles:{header:{borderBottom:"1px solid #f0f0f0",padding:"12px 16px"},body:{padding:8}},children:[(o||[]).map(S=>e.jsxs("div",{onClick:()=>n(S),style:{padding:"10px 12px",borderRadius:8,cursor:"pointer",marginBottom:4,background:(a==null?void 0:a.id)===S.id?"linear-gradient(135deg, #4facfe22, #00f2fe22)":"transparent",border:(a==null?void 0:a.id)===S.id?"1px solid #4facfe44":"1px solid transparent"},children:[e.jsx("div",{style:{fontSize:13,fontWeight:500},children:S.sceneName}),e.jsx("div",{style:{fontSize:11,color:"#999"},children:S.sceneCode})]},S.id)),o.length===0&&e.jsx(t.Empty,{description:"暂无场景",style:{padding:20}})]}),e.jsx(t.Card,{title:e.jsxs("span",{style:{fontWeight:600},children:["节点配置 ",a?`- ${a.sceneName}`:""]}),extra:e.jsx(t.Button,{size:"small",icon:e.jsx(l.PlusOutlined,{}),onClick:z,disabled:!a,children:"添加节点"}),style:{flex:1,borderRadius:10},children:a?e.jsx(t.Table,{dataSource:T,columns:v,rowKey:"id",pagination:!1,locale:{emptyText:e.jsx(t.Empty,{description:"暂无节点,点击添加开始配置",image:t.Empty.PRESENTED_IMAGE_SIMPLE})}}):e.jsx(t.Empty,{description:"请先选择场景",style:{padding:60},image:t.Empty.PRESENTED_IMAGE_SIMPLE})}),e.jsx(t.Modal,{title:"添加节点",open:j,onOk:F,onCancel:()=>w(!1),okText:"添加",children:e.jsxs(t.Form,{form:h,layout:"vertical",children:[e.jsx(t.Form.Item,{name:"nodeName",label:"节点名称",rules:[{required:!0,message:"请输入节点名称"}],children:e.jsx(t.Input,{placeholder:"如 LLM调用节点"})}),e.jsx(t.Form.Item,{name:"nodeType",label:"节点类型",initialValue:"LLM",children:e.jsxs(t.Select,{children:[e.jsx(de,{value:"LLM",children:"LLM调用"}),e.jsx(de,{value:"TOOL",children:"工具调用"}),e.jsx(de,{value:"CONDITION",children:"条件分支"}),e.jsx(de,{value:"TRANSFORM",children:"数据转换"}),e.jsx(de,{value:"HTTP",children:"HTTP请求"})]})}),e.jsx(t.Form.Item,{name:"config",label:"节点配置",children:e.jsx(rs,{rows:3,placeholder:'JSON格式配置,如 {"model":"gpt-4"}'})})]})})]})},Cl=()=>{const[o,i]=s.useState([]),[a,n]=s.useState(null),[T,d]=s.useState([]),[b,f]=s.useState([]);s.useEffect(()=>{ue.page({id:1,pageSize:100}).then(h=>{var m;i(((m=h.data)==null?void 0:m.records)||[])})},[]);const j=async h=>{n(h);try{const m=await ue.canvasGet(h.sceneCode);m.data&&(d(m.data.nodes||[]),f(m.data.edges||[]))}catch{d([]),f([])}},w=[{title:"节点",dataIndex:"label",key:"label",width:200},{title:"类型",dataIndex:"type",key:"type",render:h=>e.jsx(t.Tag,{color:"purple",children:h})},{title:"位置",dataIndex:"position",key:"position",render:h=>e.jsxs("span",{style:{fontSize:11,color:"#999"},children:["x:",(h==null?void 0:h.x)||0," y:",(h==null?void 0:h.y)||0]})}];return e.jsxs("div",{style:{display:"flex",gap:16,minHeight:500},children:[e.jsx(t.Card,{size:"small",title:e.jsxs("span",{style:{fontWeight:600},children:[e.jsx(l.NodeIndexOutlined,{style:{color:"#4facfe",marginRight:6}}),"场景列表"]}),style:{width:240,flexShrink:0,borderRadius:10},styles:{header:{borderBottom:"1px solid #f0f0f0",padding:"12px 16px"},body:{padding:8}},children:(o||[]).map(h=>e.jsxs("div",{onClick:()=>j(h),style:{padding:"10px 12px",borderRadius:8,cursor:"pointer",marginBottom:4,background:(a==null?void 0:a.id)===h.id?"linear-gradient(135deg, #4facfe22, #00f2fe22)":"transparent",border:(a==null?void 0:a.id)===h.id?"1px solid #4facfe44":"1px solid transparent"},children:[e.jsx("div",{style:{fontSize:13,fontWeight:500},children:h.sceneName}),e.jsx(t.Tag,{style:{fontSize:10,marginTop:2},children:h.sceneType})]},h.id))}),e.jsx(t.Card,{title:e.jsxs("span",{style:{fontWeight:600},children:["场景编排画布 ",a?`- ${a.sceneName}`:""]}),style:{flex:1,borderRadius:10},styles:{body:{padding:16,display:"flex",flexDirection:"column",gap:12}},children:a?T.length===0?e.jsx(t.Empty,{description:"暂无节点配置,请先在节点配置中添加节点",style:{padding:40},image:t.Empty.PRESENTED_IMAGE_SIMPLE}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 0",borderBottom:"1px solid #f0f0f0"},children:[e.jsx(l.ThunderboltOutlined,{style:{color:"#4facfe"}}),e.jsxs("span",{style:{fontSize:13,color:"#666"},children:["编排节点 ",T.length," 个,连接 ",b.length," 条"]})]}),e.jsx(t.Table,{dataSource:T,columns:w,rowKey:"id",pagination:!1,size:"small"}),b.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontSize:13,fontWeight:500,marginTop:8},children:"连线"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:b.map((h,m)=>e.jsx(t.Card,{size:"small",style:{background:"#fafafa",border:"none"},children:e.jsxs("span",{style:{fontFamily:"monospace",fontSize:12},children:[h.source," → ",h.target]})},m))})]})]}):e.jsx(t.Empty,{description:"请选择场景进行编排",style:{padding:60},image:t.Empty.PRESENTED_IMAGE_SIMPLE})})]})},{Text:jt}=t.Typography,{TabPane:Qe}=t.Tabs,vl=()=>{const[o,i]=s.useState(null),[a,n]=s.useState([]),[T,d]=s.useState([]),[b,f]=s.useState([]),[j,w]=s.useState([]),[h,m]=s.useState(!1),[z,F]=s.useState(null),[N,u]=s.useState(null),[v,S]=s.useState(null),[x,D]=s.useState([]),[G,g]=s.useState([]),[C,P]=s.useState([]);s.useEffect(()=>{te("/llm-center/provider/list").then(c=>{const r=Array.isArray(c)?c:(c==null?void 0:c.data)||[];D(r)}).catch(()=>{}),K(null),te("/agent/app/page",{method:"POST",body:JSON.stringify({current:1,size:100})}).then(c=>{const r=Array.isArray(c)?c:(c==null?void 0:c.records)||(c==null?void 0:c.data)||[];P(r)}).catch(()=>{})},[]);const K=c=>{te("/llm-center/model/list",{params:{providerCode:c}}).then(r=>{const L=Array.isArray(r)?r:(r==null?void 0:r.data)||[];g(L)}).catch(()=>{})},O=c=>{u(c),S(null),K(c)},V=()=>({appCode:z,providerCode:N,modelCode:v}),U=async()=>{try{const c=await te("/llm-gateway/usage/overview",{method:"GET",params:V()});i((c==null?void 0:c.data)||c||null)}catch(c){console.warn("Usage overview API unavailable:",c==null?void 0:c.message),i(null)}},A=async()=>{try{const c=await te("/llm-gateway/usage/by-app",{method:"GET"});n(Array.isArray(c)?c:(c==null?void 0:c.data)||[])}catch(c){console.warn("Usage by-app API unavailable:",c==null?void 0:c.message),n([])}},k=async()=>{try{const c=await te("/llm-gateway/usage/by-user",{method:"GET",params:V()});d(Array.isArray(c)?c:(c==null?void 0:c.data)||[])}catch(c){console.warn("Usage by-user API unavailable:",c==null?void 0:c.message),d([])}},_=async()=>{try{const c=await te("/llm-gateway/usage/trend",{method:"GET",params:{...V(),days:7}});f(Array.isArray(c)?c:(c==null?void 0:c.data)||[])}catch(c){console.warn("Usage trend API unavailable:",c==null?void 0:c.message),f([])}},p=async()=>{m(!0);try{const c=await te("/llm-gateway/usage/records",{method:"GET",params:{...V(),page:1,size:20}}),r=Array.isArray(c)?c:(c==null?void 0:c.records)||(c==null?void 0:c.data)||[];w(r)}catch(c){console.warn("Usage records API unavailable:",c==null?void 0:c.message),w([])}finally{m(!1)}};s.useEffect(()=>{U(),A(),k(),_(),p()},[z,N,v]);const y={tooltip:{trigger:"axis"},legend:{data:["Token消耗","调用次数"]},xAxis:{type:"category",data:b.map(c=>c.date)},yAxis:[{type:"value",name:"Tokens",position:"left"},{type:"value",name:"调用次数",position:"right"}],series:[{name:"Token消耗",type:"bar",data:b.map(c=>c.dailyTokens)},{name:"调用次数",type:"line",yAxisIndex:1,data:b.map(c=>c.dailyCalls)}]},M=[{title:"应用编码",dataIndex:"appCode"},{title:"调用次数",dataIndex:"totalCalls",render:c=>c==null?void 0:c.toLocaleString()},{title:"输入Token",dataIndex:"inputTokens",render:c=>c==null?void 0:c.toLocaleString()},{title:"输出Token",dataIndex:"outputTokens",render:c=>c==null?void 0:c.toLocaleString()},{title:"总Token",dataIndex:"totalTokens",render:c=>c==null?void 0:c.toLocaleString()},{title:"费用",dataIndex:"totalCost",render:c=>e.jsxs(jt,{style:{color:"#faad14"},children:["¥",(c==null?void 0:c.toFixed(4))||"0"]})}],E=[{title:"用户ID",dataIndex:"userId"},{title:"调用次数",dataIndex:"totalCalls",render:c=>c==null?void 0:c.toLocaleString()},{title:"总Token",dataIndex:"totalTokens",render:c=>c==null?void 0:c.toLocaleString()},{title:"费用",dataIndex:"totalCost",render:c=>e.jsxs(jt,{style:{color:"#faad14"},children:["¥",(c==null?void 0:c.toFixed(4))||"0"]})}],Q=[{title:"时间",dataIndex:"gmtCreate",width:160},{title:"应用",dataIndex:"appCode",render:c=>e.jsx(t.Tag,{color:"blue",children:c||"-"})},{title:"用户",dataIndex:"userName"},{title:"供应商",dataIndex:"providerCode",render:c=>e.jsx(t.Tag,{color:"purple",children:c||"-"})},{title:"模型",dataIndex:"modelCode",render:c=>e.jsx(t.Tag,{children:c||"-"})},{title:"输入Token",dataIndex:"inputTokens",render:c=>c==null?void 0:c.toLocaleString()},{title:"输出Token",dataIndex:"outputTokens",render:c=>c==null?void 0:c.toLocaleString()},{title:"延迟",dataIndex:"latencyMs",render:c=>c?`${c}ms`:"-"},{title:"状态",dataIndex:"status",render:c=>e.jsx(t.Tag,{color:c==="SUCCESS"?"green":"red",children:c||"-"})},{title:"费用",dataIndex:"totalCost",render:c=>e.jsxs(jt,{style:{color:"#faad14"},children:["¥",c||0]})}];return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center",flexWrap:"wrap",background:"#fff",padding:"12px 16px",borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)",marginBottom:16},children:[e.jsx("span",{style:{fontWeight:600,color:"#333",marginRight:4},children:"维度筛选:"}),e.jsx(t.Select,{placeholder:"筛选应用",allowClear:!0,style:{width:180},value:z,onChange:F,options:C.map(c=>({value:c.appCode,label:c.appName||c.appCode}))}),e.jsx(t.Select,{placeholder:"筛选供应商",allowClear:!0,style:{width:180},value:N,onChange:O,options:x.map(c=>({value:c.providerCode,label:c.providerName}))}),e.jsx(t.Select,{placeholder:"筛选模型",allowClear:!0,style:{width:180},value:v,onChange:S,options:G.map(c=>({value:c.modelCode,label:c.modelName}))}),(z||N||v)&&e.jsx("a",{onClick:()=>{F(null),u(null),S(null)},style:{fontSize:12},children:"清空筛选"})]}),e.jsxs(t.Row,{gutter:16,style:{marginBottom:16},children:[e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Statistic,{title:e.jsx("span",{style:{color:"#666",fontSize:13},children:"累计 Token"}),value:(o==null?void 0:o.totalTokens)||0,prefix:e.jsx(l.RocketOutlined,{style:{color:"#667eea"}}),formatter:c=>c==null?void 0:c.toLocaleString(),valueStyle:{color:"#333",fontSize:22,fontWeight:700}})})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Statistic,{title:e.jsx("span",{style:{color:"#666",fontSize:13},children:"累计费用"}),value:(o==null?void 0:o.totalCost)||0,prefix:e.jsx(l.DollarOutlined,{style:{color:"#faad14"}}),valueStyle:{color:"#333",fontSize:22,fontWeight:700}})})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Statistic,{title:e.jsx("span",{style:{color:"#666",fontSize:13},children:"今日 Token"}),value:(o==null?void 0:o.todayTokens)||0,prefix:e.jsx(l.BarChartOutlined,{style:{color:"#52c41a"}}),formatter:c=>c==null?void 0:c.toLocaleString(),valueStyle:{color:"#333",fontSize:22,fontWeight:700}})})}),e.jsx(t.Col,{span:6,children:e.jsx(t.Card,{size:"small",style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Statistic,{title:e.jsx("span",{style:{color:"#666",fontSize:13},children:"今日费用"}),value:(o==null?void 0:o.todayCost)||0,prefix:e.jsx(l.DollarOutlined,{style:{color:"#faad14"}}),precision:4,suffix:"元",valueStyle:{color:"#333",fontSize:22,fontWeight:700}})})})]}),e.jsxs(t.Tabs,{defaultActiveKey:"trend",children:[e.jsx(Qe,{tab:"用量趋势",children:e.jsx(t.Card,{style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(Pt,{option:y,style:{height:300}})})},"trend"),e.jsx(Qe,{tab:"按应用统计",children:e.jsx(t.Card,{style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Table,{columns:M,dataSource:a,rowKey:"appCode",pagination:!1,locale:{emptyText:"暂无数据"}})})},"byApp"),e.jsx(Qe,{tab:"按用户统计",children:e.jsx(t.Card,{style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Table,{columns:E,dataSource:T,rowKey:"userId",pagination:!1,locale:{emptyText:"暂无数据"}})})},"byUser"),e.jsx(Qe,{tab:"调用明细",children:e.jsx(t.Card,{style:{borderRadius:10,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:e.jsx(t.Table,{columns:Q,dataSource:j,loading:h,rowKey:"id",pagination:{pageSize:20,showSizeChanger:!1},locale:{emptyText:"暂无数据"}})})},"records")]})]})};Z.AgentAppEditor=Mt,Z.AgentAppList=_t,Z.AgentAppPage=_t,Z.AgentSharePage=Ns,Z.AkManage=Gs,Z.AkUsageDrawer=Vt,Z.ApiBridgeEditor=Zt,Z.BucketList=Js,Z.CurlImportModal=Yt,Z.FieldMappingEditor=xt,Z.LlmModel=Vs,Z.LlmProvider=Us,Z.McpPage=Hs,Z.ModelManage=Ms,Z.ObjectBrowser=Qs,Z.OpenApiImportModal=Qt,Z.ProductExecute=fl,Z.ProductList=ul,Z.ProductScene=jl,Z.ScriptCenterPage=il,Z.SkillMarket=pl,Z.UsageDashboard=vl,Z.WorkflowEditor=Nt,Z.agentApi=ae,Z.authRequest=qe,Z.ctcRequest=$e,Z.flowApi=De,Z.llmApi=Ae,Z.mcpApi=Ie,Z.ossApi=me,Z.productApi=Se,Z.request=te,Z.sceneApi=ue,Z.scriptApi=be,Z.skillApi=ge,Object.defineProperty(Z,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuku123/z-agent-frontend-component",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "description": "z-agent 共享前端组件 - Agent 应用 / 编辑器 / 工作流 / LLM / AK / MCP / OSS / Skill / Script / Product / Usage 等页面",
6
6
  "keywords": [
@@ -74,4 +74,4 @@
74
74
  "vite": "^6.2.0"
75
75
  },
76
76
  "style": "./dist/z-agent-frontend-component.css"
77
- }
77
+ }
@@ -29,7 +29,6 @@ import {
29
29
  EditOutlined,
30
30
  EyeOutlined,
31
31
  NodeIndexOutlined,
32
- NodeOutlined,
33
32
  PlayCircleOutlined,
34
33
  PlusOutlined,
35
34
  SettingOutlined,
@@ -235,7 +234,7 @@ const SceneTablePage = () => {
235
234
  width: 100,
236
235
  render: (val) => {
237
236
  const map = {CONVERSATION: '对话', TASK: '任务', WORKFLOW: '工作流'}
238
- return <Tag icon={<NodeOutlined/>}>{map[val] || val}</Tag>
237
+ return <Tag icon={<NodeIndexOutlined/>}>{map[val] || val}</Tag>
239
238
  }
240
239
  },
241
240
  {