Files
qhmes/deploy-qhmes/frontend/js/PluginToolEditModal-Cu9MDhoq.js

2 lines
11 KiB
Java
Raw Normal View History

2026-05-15 11:34:12 +08:00
var ie=Object.defineProperty,ue=Object.defineProperties;var re=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var G=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var Z=(m,f,p)=>f in m?ie(m,f,{enumerable:!0,configurable:!0,writable:!0,value:p}):m[f]=p,O=(m,f)=>{for(var p in f||(f={}))G.call(f,p)&&Z(m,p,f[p]);if(N)for(var p of N(f))F.call(f,p)&&Z(m,p,f[p]);return m},R=(m,f)=>ue(m,re(f));var V=(m,f)=>{var p={};for(var d in m)G.call(m,d)&&f.indexOf(d)<0&&(p[d]=m[d]);if(m!=null&&N)for(var d of N(m))f.indexOf(d)<0&&F.call(m,d)&&(p[d]=m[d]);return p};var D=(m,f,p)=>new Promise((d,P)=>{var I=n=>{try{_(p.next(n))}catch(c){P(c)}},B=n=>{try{_(p.throw(n))}catch(c){P(c)}},_=n=>n.done?d(n.value):Promise.resolve(n.value).then(I,B);_((p=p.apply(m,f)).next())});import{d as de,ah as k,aC as y,as as g,aF as t,au as C,k as l,r as pe,G as s,ag as H,f as S,u as me}from"./vue-vendor-C7Zq48Yl.js";import"./index-Du0A3ksf.js";import{M as ve}from"./BasicModal-0sAdFEk_.js";import{ak as fe,u as ye,d as ge}from"./index-BI6CMai0.js";import{queryById as J,saveTools as ke}from"./AiragMcp.api-CieQuCEg.js";import"./ModalHeader-keHdAHWH.js";import"./antd-vue-vendor-BPnV8VqP.js";import"./useTimeout-DDl4l82I.js";import"./vxe-table-vendor-B88kchpX.js";import"./index-DeEq83Ov.js";import"./useWindowSizeFn-PRZSD86C.js";import"./index-pxs5MULf.js";import"./index-BgYCgfME.js";import"./index-f8O7TghW.js";import"./useIntersectionObserver-BMxdTqP3.js";const _e={class:"modal"},ce={class:"tool-edit-content"},we={class:"section"},Ce={class:"section"},be={class:"section-header"},Ie={class:"section"},Ue={class:"section-header"},he=de({__name:"PluginToolEditModal",emits:["success","register"],setup(m,{emit:f}){const p=f,{createMessage:d}=ye(),P=S(!1),I=S(void 0),B=S(!1),_=S(-1),n=pe({name:"",description:"",path:"",method:"GET"}),c=S([]),q=S([]),L=[{title:"参数名称",key:"name",width:150},{title:"参数描述",key:"description",width:200},{title:"参数类型",key:"type",width:120},{title:"传入方式",key:"location",width:150},{title:"是否必须",key:"required",width:100},{title:"默认值",key:"defaultValue",width:150},{title:"操作",key:"action",width:100}],K=[{title:"参数名称",key:"name",width:200},{title:"参数描述",key:"description",width:200},{title:"参数类型",key:"type",width:150},{title:"操作",key:"action",width:100}];let z=0;const[Q,{closeModal:M}]=fe(a=>D(null,null,function*(){if(I.value=a==null?void 0:a.pluginId,B.value=!!(a!=null&&a.tool),n.name="",n.description="",n.path="",n.method="GET",c.value=[],q.value=[],_.value=-1,a!=null&&a.tool&&(n.name=a.tool.name||"",n.description=a.tool.description||"",n.path=a.tool.path||"",n.method=a.tool.method||"GET",c.value=(a.tool.parameters||[]).map(e=>R(O({},e),{tempId:`req_${z++}`,required:e.required!==void 0?e.required:!1})),q.value=(a.tool.responses||[]).map(e=>R(O({},e),{tempId:`resp_${z++}`})),I.value)){const e=yield J(I.value),o=e.result||e;if(o.tools)try{const b=typeof o.tools=="string"?JSON.parse(o.tools):o.tools;_.value=b.findIndex(U=>U.name===a.tool.name)}catch(b){_.value=-1}}}));function W(a){a.name&&!/^[a-zA-Z0-9_]+$/.test(a.name)&&(d.warning("参数名称只能包含字母数字和下划线"),a.name=a.name.replace(/[^a-zA-Z0-9_]/g,""))}function X(a){if(!a.name)return;const e=a.type,o=a.name;e==="Object"||e==="Array"?/^[a-zA-Z0-9_.\[\]]+$/.test(o)||(d.warning("参数名称只能包含字母数字下划线点和中括号"),a.name=o.replace(/[^a-zA-Z0-9_.\[\]]/g,"")):/^[a-zA-Z0-9_]+$/.test(o)||(d.warning("非Object/Array类型参数名称只能包含字母数字和下划线"),a.name=o.replace(/[^a-zA-Z0-9_]/g,""))}function Y(a){a.type!=="Object"&&a.type!=="Array"&&a.name&&/[.\[\]]/.test(a.name)&&(d.warning("非Object/Array类型不支持使用点号和中括号"),a.name=a.name.replace(/[.\[\]]/g,""))}function Ae(a){}function ee(){c.value.push({tempId:`req_${z++}`,name:"",description:"",type:"String",location:"Body",required:!1,defaultValue:""})}function te(a){c.value.splice(a,1)}function ae(){q.value.push({tempId:`resp_${z++}`,name: