UnisKB/static/admin/assets/ToolResourceIndex-C6P-jNJd.js

2 lines
14 KiB
JavaScript
Raw Normal View History

import{ay as Le,aA as Oe,aB as c,aC as r,aU as ze,aO as Fe,aP as We,aV as je,b6 as Je,aL as He,aD as s,aE as n,aW as k,aH as l,aG as a,aK as b,aJ as m,b2 as V,aI as p,aF as i,aX as Z,aY as q,b1 as _,bX as Xe,aS as v,bZ as ne,bW as Ze,b_ as qe,cm as y,c1 as Ge,c0 as se,b3 as ie,aZ as Ke}from"./admin-DgPvPHD7.js";import{_ as Ye,a as Qe,b as et,c as tt,M as ot}from"./McpToolConfigDialog-CQWDgL8h.js";import{l as lt}from"./permission-api-KeGpSf5X.js";import"./FieldFormDialog.vue_vue_type_script_setup_true_lang-D7Bq1Igx.js";import"./workspace-D2rVZOhW.js";var ce=(U=>(U.CUSTOM="common.custom",U.INTERNAL="views.tool.toolStore.internal",U))(ce||{});const at={class:"resource-manage_tool p-16-24"},nt={class:"ml-4 color-text-primary"},st={class:"flex-between mb-16"},it={class:"complex-search"},ct={class:"table-name flex align-center"},rt=["src"],ut={key:0},pt={key:1},mt={key:2},dt={key:0,class:"flex align-center"},_t={class:"color-text-primary"},ft={key:1,class:"flex align-center"},vt={class:"color-text-primary"},yt={class:"filter"},ht={class:"form-item mb-16 ml-4"},bt={class:"text-right"},gt={class:"mr-8"},kt={class:"mr-8"},Ct={class:"mr-8"},Tt={class:"mr-8"},St=Le({__name:"ToolResourceIndex",setup(U){const{user:G}=Oe(),C=c("name"),g=c({name:"",create_user:"",tool_type:""}),K=c([]),re=c([{label:"MCP",value:"MCP"},{label:r("views.tool.toolStore.title"),value:"TOOL_STORE"},{label:r("views.tool.toolStore.internal"),value:"INTERNAL"},{label:r("common.custom"),value:"CUSTOM"}]),T=c(!1),N=c(!1),Y=c([]),D=ze({current_page:1,page_size:20,total:0}),x=c([]),E=c(!1),R=c([]),d=Fe(()=>We.tool.systemManage),ue=e=>{var o;return d.value.export()||d.value.delete()||d.value.auth()||((o=e.init_field_list)==null?void 0:o.length)>0&&d.value.edit()},Q=c();function pe(e){Q.value.open(e.id)}function me(e){y.exportTool(e.id,e.name,T).catch(o=>{o.response.status!==403&&o.response.data.text().then(u=>{Ge(`${r("views.application.tip.ExportError")}:${JSON.parse(u).message}`)})})}const ee=c();function de(e){y.getToolById(e==null?void 0:e.id,T).then(o=>{ee.value.open(o.data)})}function _e(e){se(`${r("views.tool.delete.confirmTitle")}${e.name} ?`,r("views.tool.delete.confirmMessage"),{confirmButtonText:r("common.confirm"),cancelButtonText:r("common.cancel"),confirmButtonClass:"danger"}).then(()=>{y.delTool(e.id,T).then(()=>{f(),ie(r("common.deleteSuccess"))})}).catch(()=>{})}function fe(e){y.getToolById(e==null?void 0:e.id,N).then(o=>{J.value.open(o.data)})}async function ve(e){j.value=r("views.tool.copyTool");const o=await y.getToolById(e.id,N),u=Ke.cloneDeep(o.data);delete u.id,u.name=u.name+` ${r("common.copyTitle")}`,L.value.open(u)}const L=c(),W=c(),j=c(""),te=c("");function ye(e){e!=null&&e.template_id||(j.value=r("views.tool.editTool"),e?y.getToolById(e==null?void 0:e.id,T).then(o=>{L.value.open(o.data)}):L.value.open(e))}function he(e){e!=null&&e.template_id||(te.value=e?r("views.tool.editMcpTool"):r("views.tool.createMcpTool"),e?y.getToolById(e==null?void 0:e.id,T).then(o=>{W.value.open(o.data)}):W.value.open(e))}const oe=c();function be(e,o){var u;(u=oe.value)==null||u.open(e,o)}function ge(e,o){o&&y.putTool(e==null?void 0:e.id,{name:e.name},T).then(u=>{ie(r("common.saveSuccess")),A()})}const J=c();async function ke(e){if(e.is_active)se(`${r("views.tool.disabled.confirmTitle")}${e.name} ?`,r("views.tool.disabled.confirmMessage"),{confirmButtonText:r("common.status.disable"),confirmButtonClass:"danger"}).then(()=>{const o={is_active:!e.is_active};y.putTool(e.id,o,N).then(()=>(f(),!0)).catch(()=>!1)});else{const o=await y.getToolById(e.id,N);if((!o.data.init_params||Object.keys(o.data.init_params).length===0)&&o.data.init_field_list&&o.data.init_field_list.length>0&&o.data.init_field_list.filter(S=>S.default_value&&S.show_default_value).length!==o.data.init_field_list.length)return J.value.open(o.data,!e.is_active),!1;const u={is_active:!e.is_active};y.putTool(e.id,u,N).then(()=>(f(),!0)).catch(()=>!1)}}const I=c(""),O=c([]);je([()=>x.value,()=>I.value],()=>{I.value.length||(O.value=x.value),O.value=x.value.filter(e=>e.label.toLowerCase().includes(I.