5 lines
7.5 KiB
JavaScript
5 lines
7.5 KiB
JavaScript
|
|
/*!
|
||
|
|
Build based on gin-vue-admin
|
||
|
|
Time : 1776662816000 */
|
||
|
|
import{a as e,r as a,q as l,g as t,c as r,o,f as s,w as n,b as u,t as i,x as c,bt as p,F as d,J as m,i as y,d as v,b1 as b,h as f,E as g}from"./087AC4D233B64EB0index.D-00lXMX.js";import{i as h,j as x}from"./087AC4D233B64EB0autoCode.D4TxIFGD.js";const w={class:"p-2"},k={class:"flex justify-between items-center font-bold"},S={class:"font-mono whitespace-pre-wrap break-words bg-gray-100 p-2.5 rounded text-gray-700"},V={class:"flex justify-between items-center font-bold"},_={class:"text-sm mb-1"},j={key:0,class:"mt-1 text-xs overflow-y-auto max-h-[100px] p-2 border-t border-gray-200 bg-gray-50 rounded-b"},O={class:"font-semibold mb-1 text-gray-700 flex items-center"},C={class:"text-xs text-gray-500"},U={class:"space-y-2"},J={class:"flex items-center justify-between"},N={class:"flex items-center"},q={class:"font-medium text-gray-800"},E={key:0,class:"ml-1 text-red-500 text-xs"},P={class:"text-xs px-1.5 py-0.5 bg-blue-100 text-blue-700 rounded"},A=["title"],B={key:1,class:"mt-1 text-xs p-2 border-t border-gray-200 bg-gray-50 rounded-b flex items-center justify-center"},T={key:1,class:"mt-5 p-[15px] border border-gray-200 rounded bg-gray-50"},F={key:0},I={class:"bg-gray-100 p-2.5 rounded whitespace-pre-wrap break-words overflow-y-auto"},M={key:1},R={key:2},D={class:"bg-gray-100 p-2.5 rounded whitespace-pre-wrap break-words overflow-y-auto"},z={key:3},G={class:"bg-gray-100 p-2.5 rounded whitespace-pre-wrap break-words overflow-y-auto"},H={class:"dialog-footer"},K=Object.assign({name:"MCPTest"},{__name:"mcpTest",setup(K){const L=e([]),Q=e(!1),W=e(null),X=a({}),Y=e(null),Z=e(null),$=e(JSON.stringify({mcpServers:{gva:{url:"https://127.0.0.1/sse"}}},null,2));l(()=>{(async()=>{const e=await h();0===e.code&&e.data&&e.data.list.tools?(L.value=e.data.list.tools,$.value=JSON.stringify(e.data.mcpServerConfig,null,2)):g.error(e.msg||"获取工具列表失败或数据格式不正确")})()});const ee=async()=>{try{await navigator.clipboard.writeText($.value),g.success("配置已复制到剪贴板")}catch(e){g.error("复制失败: "+e)}},ae=e=>{Z.value=null,e()},le=async()=>{W.value?Y.value&&Y.value.validate(async e=>{if(e){const e=W.value.name,a={...X};W.value.inputSchema&&W.value.inputSchema.properties&&Object.keys(W.value.inputSchema.properties).forEach(e=>{const l=W.value.inputSchema.properties[e];if(("object"===l.type||"array"===l.type)&&a[e]&&"string"==typeof a[e])try{a[e]=JSON.parse(a[e])}catch(t){throw g.error("参数 ".concat(e," 的JSON格式无效: ").concat(t.message)),new Error("参数 ".concat(e," JSON无效"))}});const l=await x({name:e,arguments:a});Z.value=l.data,0===l.code&&g.success("API调用成功")}}):g.warning("没有选中的测试工具")};return(e,a)=>{const l=t("el-button"),g=t("el-tooltip"),h=t("el-card"),x=t("el-col"),K=t("el-row"),te=t("el-input"),re=t("el-option"),oe=t("el-select"),se=t("el-form-item"),ne=t("el-form"),ue=t("el-image"),ie=t("el-dialog");return o(),r("div",w,[s(h,{class:"mb-2"},{header:n(()=>[u("div",k,[a[2]||(a[2]=u("span",null,"MCP 服务器配置示例",-1)),s(g,{content:"复制配置",placement:"top"},{default:n(()=>[s(l,{icon:c(p),circle:"",onClick:ee},null,8,["icon"])]),_:1})])]),default:n(()=>[u("pre",S,i($.value),1)]),_:1}),s(K,{gutter:8},{default:n(()=>[(o(!0),r(d,null,m(L.value,e=>(o(),y(x,{key:e.name,xs:24,sm:12,md:12,lg:8},{default:n(()=>[s(h,{class:"mb-5 min-h-[150px] flex flex-col overflow-hidden"},{header:n(()=>[u("div",V,[u("span",null,i(e.name),1),s(g,{content:"测试工具",placement:"top"},{default:n(()=>[s(l,{icon:c(b),circle:"",onClick:a=>(e=>{W.value=e,Z.value=null;for(const a in X)delete X[a];e.inputSchema&&e.inputSchema.properties&&Object.keys(e.inputSchema.properties).forEach(a=>{const l=e.inputSchema.properties[a];void 0!==l.default?X[a]=l.default:"boolean"===l.type?X[a]=!1:"number"===l.type?X[a]=null:("object"===l.type||l.type,X[a]="")}),Q.value=!0,Y.value&&Y.value.clearValidate()})(e)},null,8,["icon","onClick"])]),_:2},1024)])]),default:n(()=>[u("div",_,i(e.description),1),e.inputSchema&&e.inputSchema.properties&&Object.keys(e.inputSchema.properties).length>0?(o(),r("d
|