flex-mcp 1.1.19 → 1.1.21
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.
- package/dist/api/backup.d.ts +6 -0
- package/dist/api/backup.d.ts.map +1 -0
- package/dist/api/backup.js +212 -0
- package/dist/api/backup.js.map +1 -0
- package/dist/api/configs.js +3 -6
- package/dist/api/configs.js.map +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +3 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/prompts.js +37 -7
- package/dist/api/prompts.js.map +1 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +12 -0
- package/dist/config.js.map +1 -1
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +61 -0
- package/dist/db/index.js.map +1 -1
- package/dist/db/schema.d.ts +24 -0
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +2 -0
- package/dist/db/schema.js.map +1 -1
- package/dist/mcp/aggregator.d.ts.map +1 -1
- package/dist/mcp/aggregator.js +128 -74
- package/dist/mcp/aggregator.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/web/assets/Backup-BnJJcJ1y.js +1 -0
- package/dist/web/assets/{Blank-BHJQs5sx.js → Blank-DYHf__-I.js} +1 -1
- package/dist/web/assets/{Configs-BsYYESfj.js → Configs-BhOuA1TR.js} +1 -1
- package/dist/web/assets/Dashboard-XGeMGzfq.js +83 -0
- package/dist/web/assets/InitScriptEditor-tSkIU_zo.js +588 -0
- package/dist/web/assets/Layout-CtytdFcc.js +1 -0
- package/dist/web/assets/{Layout-BmR6ReTO.js → Layout-DoiZawSk.js} +1 -1
- package/dist/web/assets/{Login-CwxdtbCd.js → Login-Cr1ve1cB.js} +1 -1
- package/dist/web/assets/{Login-B12ArZ__.js → Login-DVWgtC9D.js} +1 -1
- package/dist/web/assets/{Users-CyJLDYCZ.js → Users-C4kFgZqa.js} +1 -1
- package/dist/web/assets/index-BBxZKz3O.js +2 -0
- package/dist/web/assets/{monaco-editor-BXWd1EVR.js → monaco-editor-D-KqHnQ9.js} +1 -1
- package/dist/web/assets/{naive-ui-UIL-VU-f.js → naive-ui-C5lXjE56.js} +2 -2
- package/dist/web/assets/style-DyYDoNC5.css +1 -0
- package/dist/web/assets/vendor-D1MaVSrs.js +63 -0
- package/dist/web/index.html +5 -5
- package/package.json +1 -1
- package/dist/web/assets/Dashboard-sRUOp0M_.js +0 -83
- package/dist/web/assets/InitScriptEditor-iTJN-PPD.js +0 -588
- package/dist/web/assets/Layout-DM8EAalA.js +0 -1
- package/dist/web/assets/index-DAevE53R.js +0 -2
- package/dist/web/assets/style-CIoc_HY4.css +0 -1
- package/dist/web/assets/vendor-DpXl860f.js +0 -58
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,CAAC;AAExC,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAGD,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,YAAY,EAAE,CAAC;IAC3B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,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AO,CAAC,eAAe,CAAC,CAAC;QAC3D;;;;WAIG;QACH,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;QAC5D;;;;;WAKG;QACH,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;KAC/G,CAAC;IAGF,GAAG,EAAE;QACH;;;;;;WAMG;QACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;KACpC,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as g}from"./index-BBxZKz3O.js";import{u as q,A as E,B as k,y as $,v as P,L as U,M as V,O as D}from"./naive-ui-C5lXjE56.js";import{q as F,r as y,o as R,c0 as p,c1 as e,c2 as T,bW as c,bV as r,bs as l,bS as A,F as O,bN as H,bU as u,l as d,c7 as m,c5 as C}from"./vendor-D1MaVSrs.js";import{_ as I}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./monaco-editor-D-KqHnQ9.js";const G={class:"backup-page"},K={style:{position:"absolute",width:"0",height:"0"}},Q={class:"backup-container"},W={class:"backup-content"},J={class:"backup-actions"},X={key:0,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Y={class:"backup-list-section"},Z={class:"section-header"},ee={key:0,class:"loading-backups"},te={key:1,class:"backup-list"},ae={class:"backup-info"},se={class:"backup-name"},oe={class:"backup-meta"},ne={key:0,class:"backup-version"},re={class:"backup-size"},ie={class:"backup-time"},le={class:"backup-actions-item"},de=F({__name:"Backup",setup(ce){const i=q(),B=E(),v=y(!1),w=y(!1),b=y([]),_=y(null);async function M(){var t,a;if(v.value)return;v.value=!0;const o=i.loading("正在创建备份,请稍候...",{duration:0});try{const n=(await g.post("/backup")).data;if(n.success)o.destroy(),i.success("备份创建成功!",{duration:3e3}),await h();else throw new Error(n.error||"备份失败")}catch(s){o.destroy();const n=((a=(t=s.response)==null?void 0:t.data)==null?void 0:a.error)||s.message||"备份失败";i.error(n,{duration:5e3})}finally{v.value=!1}}async function h(){var o,t;w.value=!0;try{const a=await g.get("/backup");if(a.data.success)b.value=a.data.data;else throw new Error(a.data.error||"加载失败")}catch(a){const s=((t=(o=a.response)==null?void 0:o.data)==null?void 0:t.error)||a.message||"加载备份列表失败";i.error(s,{duration:5e3})}finally{w.value=!1}}async function N(o){var t,a;try{const s=await g.get(`/backup/download/${o}`,{responseType:"blob"}),n=new Blob([s.data],{type:"application/x-sqlite3"}),x=window.URL.createObjectURL(n),f=document.createElement("a");f.href=x,f.download=o,document.body.appendChild(f),f.click(),document.body.removeChild(f),window.URL.revokeObjectURL(x),i.success("下载成功",{duration:2e3})}catch(s){const n=((a=(t=s.response)==null?void 0:t.data)==null?void 0:a.error)||s.message||"下载失败";i.error(n,{duration:5e3})}}async function j(o){B.warning({title:"确认还原",content:`确定要还原备份 "${o}" 吗?还原操作需要重启服务才能生效。`,positiveText:"确认还原",negativeText:"取消",onPositiveClick:async()=>{var t,a;_.value=o;try{const s=await g.post(`/backup/restore/${o}`);if(s.data.success)i.success("还原已安排,请重启服务以应用更改",{duration:5e3});else throw new Error(s.data.error||"还原失败")}catch(s){const n=((a=(t=s.response)==null?void 0:t.data)==null?void 0:a.error)||s.message||"还原失败";i.error(n,{duration:5e3})}finally{_.value=null}}})}async function z(o){var t,a;try{const s=await g.delete(`/backup/${o}`);if(s.data.success)i.success("删除成功",{duration:2e3}),await h();else throw new Error(s.data.error||"删除失败")}catch(s){const n=((a=(t=s.response)==null?void 0:t.data)==null?void 0:a.error)||s.message||"删除失败";i.error(n,{duration:5e3})}}function L(o){return o<1024?o+" B":o<1024*1024?(o/1024).toFixed(2)+" KB":(o/(1024*1024)).toFixed(2)+" MB"}function S(o){return new Date(o).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})}return R(()=>{h()}),(o,t)=>(u(),p("div",G,[(u(),p("svg",K,[...t[0]||(t[0]=[e("defs",null,[e("linearGradient",{id:"backup-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%"},[e("stop",{offset:"0%","stop-color":"#dc2626"}),e("stop",{offset:"50%","stop-color":"#ea580c"}),e("stop",{offset:"100%","stop-color":"#f59e0b"})])],-1)])])),t[13]||(t[13]=e("div",{class:"page-header"},[e("div",null,[e("h1",{class:"page-title"},"数据备份"),e("p",{class:"page-description"},"一键备份服务数据(不包括文件系统)")])],-1)),e("div",Q,[e("main",W,[t[12]||(t[12]=T('<div class="info-card" data-v-a819af8e><div class="info-icon" data-v-a819af8e><svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-a819af8e><path d="M13 16h-1v-4h1m0-4h-1m2 0h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-v-a819af8e></path></svg></div><div class="info-content" data-v-a819af8e><h3 class="info-title" data-v-a819af8e>备份说明</h3><ul class="info-list" data-v-a819af8e><li data-v-a819af8e><strong data-v-a819af8e>备份内容:</strong>包含所有数据库表的数据</li><li data-v-a819af8e><strong data-v-a819af8e>包含的表:</strong><ul style="margin-top:8px;padding-left:20px;" data-v-a819af8e><li data-v-a819af8e>users(用户信息)</li><li data-v-a819af8e>mcp_configs(MCP 配置)</li><li data-v-a819af8e>table_definitions(表定义)</li><li data-v-a819af8e>table_data(表数据)</li><li data-v-a819af8e>prompts(提示词)</li><li data-v-a819af8e>mcp_component_tools(MCP 组件工具)</li><li data-v-a819af8e>pages(页面)</li><li data-v-a819af8e>functions(函数)</li></ul></li><li data-v-a819af8e><strong data-v-a819af8e>不包括:</strong>文件系统数据(.data/fileSystem/ 目录)</li><li data-v-a819af8e><strong data-v-a819af8e>文件格式:</strong>SQLite 数据库文件(.sqlite)</li><li data-v-a819af8e><strong data-v-a819af8e>还原方法:</strong>点击备份列表中的"还原"按钮,然后重启服务</li></ul></div></div>',1)),e("div",J,[c(l(k),{type:"primary",size:"large",loading:v.value,disabled:v.value,class:"backup-btn",onClick:M},{icon:r(()=>[v.value?C("",!0):(u(),p("svg",X,[...t[1]||(t[1]=[e("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),e("polyline",{points:"17 8 12 3 7 8",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),e("line",{x1:"12",y1:"3",x2:"12",y2:"15",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])]))]),default:r(()=>[d(" "+m(v.value?"正在备份...":"创建备份"),1)]),_:1},8,["loading","disabled"])]),e("div",Y,[e("div",Z,[t[4]||(t[4]=e("h3",{class:"section-title"},"备份列表",-1)),c(l(k),{quaternary:"",size:"small",loading:w.value,onClick:h},{icon:r(()=>[...t[2]||(t[2]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M1 4v6h6M23 20v-6h-6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),e("path",{d:"M20.49 9A9 9 0 005.64 5.64L1 10m22 4l-4.64 4.36A9 9 0 003.51 15",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:r(()=>[t[3]||(t[3]=d(" 刷新 ",-1))]),_:1},8,["loading"])]),w.value?(u(),p("div",ee,[c(l($),{size:"small"}),t[5]||(t[5]=e("span",null,"加载备份列表中...",-1))])):b.value.length>0?(u(),p("div",te,[(u(!0),p(O,null,H(b.value,a=>(u(),p("div",{key:a.filename,class:"backup-item"},[e("div",ae,[e("div",se,m(a.filename),1),e("div",oe,[a.version?(u(),p("span",ne,"v"+m(a.version),1)):C("",!0),e("span",re,m(L(a.size)),1),e("span",ie,m(S(a.createdAt)),1)])]),e("div",le,[c(l(k),{size:"small",onClick:s=>N(a.filename)},{default:r(()=>[...t[6]||(t[6]=[d(" 下载 ",-1)])]),_:1},8,["onClick"]),c(l(k),{type:"warning",size:"small",loading:_.value===a.filename,onClick:s=>j(a.filename)},{default:r(()=>[...t[7]||(t[7]=[d(" 还原 ",-1)])]),_:1},8,["loading","onClick"]),c(l(V),{"show-icon":!1,"positive-text":"删除","negative-text":"取消",onPositiveClick:s=>z(a.filename)},{trigger:r(()=>[c(l(k),{size:"small",type:"error",quaternary:""},{default:r(()=>[...t[8]||(t[8]=[d(" 删除 ",-1)])]),_:1})]),default:r(()=>[t[9]||(t[9]=d(" 确定要删除此备份吗? ",-1))]),_:1},8,["onPositiveClick"])])]))),128))])):(u(),A(l(P),{key:2,description:"暂无备份文件",class:"empty-backups"},{icon:r(()=>[...t[10]||(t[10]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),e("polyline",{points:"17 8 12 3 7 8",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),e("line",{x1:"12",y1:"3",x2:"12",y2:"15",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),_:1}))]),c(l(U),{class:"restore-guide"},{default:r(()=>[c(l(D),{title:"如何还原备份?",name:"restore"},{default:r(()=>[...t[11]||(t[11]=[e("div",{class:"restore-content"},[e("h4",{class:"restore-title"},"还原步骤:"),e("ol",{class:"restore-steps"},[e("li",null,[e("strong",null,"选择备份"),d(":在备份列表中找到要还原的备份")]),e("li",null,[e("strong",null,"点击还原"),d(':点击备份项右侧的"还原"按钮')]),e("li",null,[e("strong",null,"确认操作"),d(":系统会自动备份当前数据库,然后安排还原")]),e("li",null,[e("strong",null,"重启服务"),d(":重启服务后,备份将自动还原")])]),e("div",{class:"restore-warning"},[e("strong",null,"⚠️ 注意事项:"),e("ul",null,[e("li",null,"还原操作会覆盖当前所有数据,请谨慎操作"),e("li",null,"建议在还原前先备份当前数据库"),e("li",null,"还原后需要重新登录(如果用户数据有变化)"),e("li",null,"文件系统数据(.data/fileSystem/)不会被还原,需要单独备份")])])],-1)])]),_:1})]),_:1})])])]))}}),ke=I(de,[["__scopeId","data-v-a819af8e"]]);export{ke as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{q as e,c0 as a,bU as o}from"./vendor-
|
|
1
|
+
import{q as e,c0 as a,bU as o}from"./vendor-D1MaVSrs.js";import{_ as t}from"./_plugin-vue_export-helper-DlAUqK2U.js";const s={class:"blank-view"},n=e({__name:"Blank",setup(_){return(c,r)=>(o(),a("div",s))}}),m=t(n,[["__scopeId","data-v-1be224a2"]]);export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as N}from"./index-
|
|
1
|
+
import{a as N}from"./index-BBxZKz3O.js";import{u as S,M as j,C as H,I as P}from"./InitScriptEditor-tSkIU_zo.js";import{u as T,B as V,p as E,q as I,v as h,h as q,l as D,m as k}from"./naive-ui-C5lXjE56.js";import{q as L,r as d,s as W,o as G,c0 as v,c1 as e,bW as s,bS as x,c5 as b,bV as o,bs as a,c2 as O,c7 as _,bU as r,l as A}from"./vendor-D1MaVSrs.js";import{_ as F}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./monaco-editor-D-KqHnQ9.js";const J={class:"configs-page"},K={style:{position:"absolute",width:"0",height:"0"}},Q={class:"configs-container"},R={class:"config-content"},X={class:"user-selector-section"},Y={class:"selector-header"},Z={key:0,class:"loading-state"},$={key:1,class:"config-stats"},ee={class:"stat-card"},te={class:"stat-content"},se={class:"stat-value"},oe={class:"stat-card"},ae={class:"stat-content"},ne={class:"stat-value"},le={key:0,class:"modal-content"},ie={class:"tab-content"},re={class:"tab-content"},de={class:"tab-content"},ce=L({__name:"Configs",setup(ve){const u=T(),p=S(),i=d(null),f=d(!1),y=d([]),g=d(!1),m=d("components"),l=W(()=>p.currentConfig),C=d([]);async function M(){try{const n=await N.get("/users");y.value=n.data.data.filter(t=>t.role!=="admin"),C.value=y.value.map(t=>({label:t.email,value:t.id}))}catch{u.error("加载用户列表失败")}}async function B(){if(i.value){f.value=!0;try{await p.fetchUserConfig(i.value)}catch(n){u.error(n.message)}finally{f.value=!1}}}function U(){l.value&&(m.value="components",g.value=!0)}async function w(n){if(i.value)try{await p.updateUserConfig(i.value,n),u.success("更新成功")}catch(t){u.error(t.message)}}function z(n){i.value=n,n&&B()}return G(()=>{M()}),(n,t)=>(r(),v("div",J,[(r(),v("svg",K,[...t[3]||(t[3]=[e("defs",null,[e("linearGradient",{id:"loading-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%"},[e("stop",{offset:"0%","stop-color":"#dc2626"}),e("stop",{offset:"50%","stop-color":"#ea580c"}),e("stop",{offset:"100%","stop-color":"#f59e0b"})])],-1)])])),t[15]||(t[15]=e("div",{class:"page-header"},[e("div",null,[e("h1",{class:"page-title"},"配置管理"),e("p",{class:"page-description"},"查看和编辑用户的 MCP 配置")])],-1)),e("div",Q,[e("main",R,[e("div",X,[e("div",Y,[t[6]||(t[6]=e("div",{class:"selector-label"},[e("svg",{class:"label-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]),e("span",null,"选择用户")],-1)),l.value?(r(),x(a(V),{key:0,type:"primary",size:"large",class:"edit-btn",onClick:U},{icon:o(()=>[...t[4]||(t[4]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:o(()=>[t[5]||(t[5]=A(" 编辑配置 ",-1))]),_:1})):b("",!0)]),s(a(E),{value:i.value,"onUpdate:value":[t[0]||(t[0]=c=>i.value=c),z],options:C.value,placeholder:"请选择要配置的用户",size:"large",filterable:"",clearable:"",class:"user-select"},{empty:o(()=>[s(a(h),{description:"暂无用户"})]),_:1},8,["value","options"])]),s(a(I),{class:"content-divider"}),f.value?(r(),v("div",Z,[...t[7]||(t[7]=[e("div",{class:"loading-spinner"},[e("svg",{class:"spinner",viewBox:"0 0 50 50"},[e("circle",{class:"path",cx:"25",cy:"25",r:"20",fill:"none","stroke-width":"4"})])],-1),e("p",{class:"loading-text"},"加载配置中...",-1)])])):l.value?(r(),v("div",$,[e("div",ee,[t[9]||(t[9]=O('<div class="stat-icon stat-icon--primary" data-v-e297e9f7><svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-e297e9f7><rect x="3" y="3" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" data-v-e297e9f7></rect><rect x="14" y="3" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" data-v-e297e9f7></rect><rect x="3" y="14" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" data-v-e297e9f7></rect><rect x="14" y="14" width="7" height="7" rx="1" stroke="currentColor" stroke-width="2" data-v-e297e9f7></rect></svg></div>',1)),e("div",te,[e("div",se,_(l.value.components.length),1),t[8]||(t[8]=e("div",{class:"stat-label"},"MCP 组件",-1))])]),e("div",oe,[t[11]||(t[11]=e("div",{class:"stat-icon stat-icon--success"},[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})])],-1)),e("div",ae,[e("div",ne,_(l.value.customTools.length),1),t[10]||(t[10]=e("div",{class:"stat-label"},"自定义工具",-1))])])])):i.value?(r(),x(a(h),{key:3,description:"该用户暂无配置或加载失败",class:"empty-placeholder"},{icon:o(()=>[...t[13]||(t[13]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),_:1})):(r(),x(a(h),{key:2,description:"请选择一个用户查看配置",class:"empty-placeholder"},{icon:o(()=>[...t[12]||(t[12]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),_:1}))])]),s(a(q),{show:g.value,"onUpdate:show":t[2]||(t[2]=c=>g.value=c),preset:"card",bordered:!1,class:"config-edit-modal",style:{width:"90vw",maxWidth:"1400px",height:"90vh"}},{header:o(()=>[...t[14]||(t[14]=[e("div",{class:"modal-header"},[e("div",{class:"modal-icon"},[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})])]),e("div",null,[e("h3",{class:"modal-title"},"编辑用户配置"),e("p",{class:"modal-subtitle"},"管理 MCP 组件、工具和脚本")])],-1)])]),default:o(()=>[l.value?(r(),v("div",le,[s(a(D),{value:m.value,"onUpdate:value":t[1]||(t[1]=c=>m.value=c),type:"line",animated:"",size:"large",class:"config-tabs"},{default:o(()=>[s(a(k),{name:"components",tab:"MCP 组件"},{default:o(()=>[e("div",ie,[s(j,{config:l.value,onUpdate:w},null,8,["config"])])]),_:1}),s(a(k),{name:"tools",tab:"自定义工具"},{default:o(()=>[e("div",re,[s(H,{config:l.value,onUpdate:w},null,8,["config"])])]),_:1}),s(a(k),{name:"init",tab:"初始化脚本"},{default:o(()=>[e("div",de,[s(P,{config:l.value,onUpdate:w},null,8,["config"])])]),_:1})]),_:1},8,["value"])])):b("",!0)]),_:1},8,["show"])]))}}),he=F(ce,[["__scopeId","data-v-e297e9f7"]]);export{he as default};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import{q as De,r as w,s as te,w as $e,c0 as T,c1 as e,bW as l,bV as o,bs as s,bU as S,l as x,G as I,o as Ie,ah as qe,bm as Ae,Z as Oe,c9 as Qe,c5 as ie,F as he,bN as be,c7 as Q,bS as ze,bT as Xe,aI as et,c6 as tt,c8 as at,c3 as nt}from"./vendor-D1MaVSrs.js";import{g as st,p as lt,_ as Je,u as He,a as ot,I as rt,C as it,M as ut}from"./InitScriptEditor-tSkIU_zo.js";import{u as We,a as E,p as dt}from"./index-BBxZKz3O.js";import{u as _e,B as U,e as H,g as je,h as ge,c as Se,d as K,i as Ne,j as Ue,k as Ke,l as Be,m as we,o as Pe,p as Ve,q as ct,r as Re,s as Ee,t as Ze,v as Me,w as vt,x as pt,y as ft,z as mt,A as gt,C as Le}from"./naive-ui-C5lXjE56.js";import{_ as Te}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./monaco-editor-D-KqHnQ9.js";const wt={class:"variables-manager"},ht={class:"variables-toolbar"},bt={class:"variables-table-container"},yt={class:"modal-form-wrapper"},kt=De({__name:"VariablesManager",props:{config:{}},emits:["update"],setup(ve,{emit:$}){const z=ve,y=$,O=_e(),h=w(!1),L=w(!1),B=w(null),V=w(),F=w(""),N={pageSize:10,showSizePicker:!0,pageSizes:[10,20,50]},G=k=>({style:"cursor: pointer; transition: all 0.2s ease;",onMouseenter:g=>{g.currentTarget.style.backgroundColor="rgba(99, 102, 241, 0.04)"},onMouseleave:g=>{g.currentTarget.style.backgroundColor=""}}),X=[{title:"变量名",key:"name",width:100,render(k){return I("strong",k.name)}},{title:"值",key:"value",width:500,render(k){if(k.isSecret)return I(Ue,{type:"info",depth:3,italic:!0},{default:()=>"****** (敏感信息)"});const g=String(k.value).split(`
|
|
2
|
+
`).map((f,J,ue)=>{const ae=[I("span",{class:"value-line"},f)];return J<ue.length-1&&ae.push(I("br")),ae}).flat();return I("div",{class:"variable-value-cell"},g)}},{title:"描述",key:"description",width:300,render(k){return I(Ue,{depth:3},{default:()=>k.description||"-"})}},{title:"操作",key:"actions",width:150,render(k){return I(Ke,{size:"small"},{default:()=>[I(U,{size:"small",onClick:()=>Z(k)},{default:()=>"编辑"}),I(U,{size:"small",type:"error",onClick:()=>ee(k.id)},{default:()=>"删除"})]})}}],A=te(()=>{if(!F.value)return z.config.variables;const k=F.value.toLowerCase();return z.config.variables.filter(g=>{var f;return g.name.toLowerCase().includes(k)||((f=g.description)==null?void 0:f.toLowerCase().includes(k))})}),j=w({name:"",value:"",description:"",isSecret:!1}),R={name:{required:!0,message:"请输入变量名",trigger:"blur"},value:{required:!0,message:"请输入变量值",trigger:"blur"}};function Z(k){B.value=k,j.value={name:k.name,value:k.value,description:k.description||"",isSecret:k.isSecret||!1},h.value=!0}function ee(k){const g=z.config.variables.filter(f=>f.id!==k);y("update",{variables:g})}async function se(){var k,g;try{await((k=V.value)==null?void 0:k.validate()),L.value=!0;const f={id:((g=B.value)==null?void 0:g.id)||st(),name:j.value.name,value:j.value.value,description:j.value.description||void 0,isSecret:j.value.isSecret},J=[...z.config.variables],ue=J.findIndex(ae=>ae.id===f.id);ue!==-1?J[ue]=f:J.push(f),y("update",{variables:J}),h.value=!1,q()}catch(f){O.error(f.message)}finally{L.value=!1}}function q(){B.value=null,j.value={name:"",value:"",description:"",isSecret:!1}}return $e(()=>h.value,k=>{k||q()}),(k,g)=>(S(),T("div",wt,[e("div",ht,[l(s(U),{type:"primary",size:"large",class:"add-variable-btn",onClick:g[0]||(g[0]=f=>h.value=!0)},{icon:o(()=>[...g[8]||(g[8]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:o(()=>[g[9]||(g[9]=x(" 添加变量 ",-1))]),_:1}),l(s(H),{value:F.value,"onUpdate:value":g[1]||(g[1]=f=>F.value=f),placeholder:"搜索变量名或描述...",size:"large",clearable:"",class:"search-input"},{prefix:o(()=>[...g[10]||(g[10]=[e("svg",{class:"search-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),_:1},8,["value"])]),e("div",bt,[l(s(je),{columns:X,data:A.value,pagination:N,"row-props":G,class:"modern-table"},null,8,["data"])]),l(s(ge),{show:h.value,"onUpdate:show":g[7]||(g[7]=f=>h.value=f),preset:"dialog",title:B.value?"编辑变量":"添加变量",class:"variable-edit-modal",style:{maxHeight:"90vh"}},{action:o(()=>[l(s(U),{onClick:g[6]||(g[6]=f=>h.value=!1)},{default:o(()=>[...g[12]||(g[12]=[x("取消",-1)])]),_:1}),l(s(U),{type:"primary",loading:L.value,onClick:se},{default:o(()=>[...g[13]||(g[13]=[x("保存",-1)])]),_:1},8,["loading"])]),default:o(()=>[e("div",yt,[l(s(Se),{ref_key:"formRef",ref:V,model:j.value,rules:R},{default:o(()=>[l(s(K),{path:"name",label:"变量名"},{default:o(()=>[l(s(H),{value:j.value.name,"onUpdate:value":g[2]||(g[2]=f=>j.value.name=f),placeholder:"例如: API_KEY"},null,8,["value"])]),_:1}),l(s(K),{path:"value",label:"值"},{default:o(()=>[l(s(H),{value:j.value.value,"onUpdate:value":g[3]||(g[3]=f=>j.value.value=f),type:j.value.isSecret?"password":"textarea",rows:j.value.isSecret?void 0:3,placeholder:"变量值"},null,8,["value","type","rows"])]),_:1}),l(s(K),{path:"description",label:"描述"},{default:o(()=>[l(s(H),{value:j.value.description,"onUpdate:value":g[4]||(g[4]=f=>j.value.description=f),type:"textarea",rows:2,placeholder:"可选"},null,8,["value"])]),_:1}),l(s(K),{path:"isSecret",label:"敏感信息"},{default:o(()=>[l(s(Ne),{checked:j.value.isSecret,"onUpdate:checked":g[5]||(g[5]=f=>j.value.isSecret=f)},{default:o(()=>[...g[11]||(g[11]=[x("标记为敏感信息(导出时使用占位符)",-1)])]),_:1},8,["checked"])]),_:1})]),_:1},8,["model"])])]),_:1},8,["show","title"])]))}}),xt=Te(kt,[["__scopeId","data-v-f50b6ccd"]]),Ct={class:"prompts-manager"},$t={class:"prompts-toolbar"},St={class:"prompts-table-container"},Mt={class:"modal-header"},zt={class:"modal-title"},Dt={class:"modal-subtitle"},_t={class:"modal-content-wrapper"},Tt={class:"tab-pane-content"},Ut={class:"form-section"},jt={class:"form-grid-2"},It={class:"form-section"},Nt={class:"section-header"},At={class:"parameters-list"},Bt={class:"parameter-header"},Vt={class:"parameter-index"},Ot={class:"parameter-fields"},Pt={key:0,class:"empty-parameters"},Rt={class:"tab-pane-content"},Et={style:{display:"flex","align-items":"center",gap:"8px"}},Ht={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"18px",height:"18px"}},Lt={class:"messages-section"},Ft={class:"message-header"},qt={class:"save-status-indicator"},Jt=["title"],Wt={key:0,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Kt={key:1,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Zt={key:0,class:"monaco-wrapper"},Gt={key:0,class:"empty-messages"},Yt={class:"modal-footer"},Qt={class:"test-content"},Xt={class:"test-messages"},ea={class:"test-message-header"},ta={class:"test-message-content"},aa={key:0,class:"test-message-empty"},na=De({__name:"PromptsManager",setup(ve){const $=_e(),z=We(),y=w(!1),O=w(!1),h=w(!1),L=w(!1),B=w(!1),V=w(null),F=w(),N=w(""),G=w([]),X=w("content"),A=w(!1),j=w(-1),R=w(new Map),Z=w(!1),ee=[{label:"用户",value:"user"},{label:"助手",value:"assistant"}],se={pageSize:10,showSizePicker:!0,pageSizes:[10,20,50]},q=i=>({style:"cursor: pointer; transition: all 0.2s ease;",onMouseenter:r=>{r.currentTarget.style.backgroundColor="rgba(99, 102, 241, 0.04)"},onMouseleave:r=>{r.currentTarget.style.backgroundColor=""}}),k=[{title:"",key:"drag",width:50,fixed:"left",render(){return I("div",{class:"drag-handle",style:"cursor: move; display: flex; align-items: center; justify-content: center; color: #94a3b8; padding: 8px;"},[I("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:"width: 18px; height: 18px;"},[I("path",{d:"M9 5h6M9 12h6M9 19h6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})])])}},{title:"启用",key:"enabled",width:80,fixed:"left",render(i){return I(Ee,{value:i.enabled!==!1,size:"medium",onUpdateValue:r=>pe(i.id,r)})}},{title:"名称",key:"name",width:200,render(i){return I("strong",i.name)}},{title:"描述",key:"description",render(i){return I(Ue,{depth:3},{default:()=>i.description||"-"})}},{title:"参数数量",key:"arguments",width:120,render(i){return I(Ue,{depth:3},{default:()=>{var r;return`${((r=i.arguments)==null?void 0:r.length)||0} 个`}})}},{title:"消息数量",key:"messages",width:120,render(i){return I(Ue,{depth:3},{default:()=>{var r;return`${((r=i.messages)==null?void 0:r.length)||0} 条`}})}},{title:"操作",key:"actions",width:200,render(i){return I(Ke,{size:"small"},{default:()=>[I(U,{size:"small",onClick:()=>ye(i)},{default:()=>"编辑"}),I(U,{size:"small",type:"info",onClick:()=>t(i)},{default:()=>"测试"}),I(U,{size:"small",type:"error",onClick:()=>ke(i.id)},{default:()=>"删除"})]})}}],g=te(()=>{let i=[...G.value].sort((a,m)=>{const b=a.order??999999,_=m.order??999999;return b-_});if(!N.value)return i;const r=N.value.toLowerCase();return i.filter(a=>{var m;return a.name.toLowerCase().includes(r)||((m=a.description)==null?void 0:m.toLowerCase().includes(r))})}),f=w({name:"",description:"",arguments:[],messages:[]}),J=w({arguments:{}}),ue=te(()=>{if(!O.value||!f.value.messages||f.value.messages.length===0)return[];const i=f.value.messages.filter(D=>D.content.text),r=new Date,a=z.user,m=a!=null&&a.id?`.data/fileSystem/${a.id}`:"<not found>",_={...{context:{user:{id:(a==null?void 0:a.id)||"",email:(a==null?void 0:a.email)||"",role:(a==null?void 0:a.role)||"user",createdAt:a!=null&&a.createdAt?new Date(a.createdAt).toISOString():r.toISOString(),updatedAt:a!=null&&a.updatedAt?new Date(a.updatedAt).toISOString():r.toISOString(),root_dir:m},timestamp:r.toISOString(),now:r.toLocaleString("zh-CN",{timeZone:"Asia/Shanghai"})}},...J.value.arguments};return i.map(D=>({...D,content:{...D.content,text:lt(D.content.text,_)}}))}),ae={name:{required:!0,message:"请输入提示词名称",trigger:"blur"},messages:{required:!0,validator:(i,r)=>!r||r.length===0?new Error("至少需要一条消息"):!0,trigger:"blur"}};function ne(i){return R.value.get(i)||!1}function oe(i){R.value.set(i,!0)}function de(i){A.value&&j.value===i?(A.value=!1,j.value=-1):(A.value=!0,j.value=i)}async function ce(){var i,r;try{B.value=!0;const a=await E.get("/prompts");a.data.success&&(G.value=a.data.data)}catch(a){$.error(((r=(i=a.response)==null?void 0:i.data)==null?void 0:r.error)||"加载提示词失败")}finally{B.value=!1}}function me(){V.value=null,u(),y.value=!0,X.value="content"}function ye(i){V.value=i,f.value={name:i.name,description:i.description||"",arguments:i.arguments?[...i.arguments]:[],messages:i.messages&&i.messages.length>0?[...i.messages]:[{role:"user",content:{type:"text",text:""}}]},R.value.clear(),y.value=!0,X.value="content"}async function ke(i){var r,a;try{await E.delete(`/prompts/${i}`),$.success("删除成功"),await ce()}catch(m){$.error(((a=(r=m.response)==null?void 0:r.data)==null?void 0:a.error)||"删除失败")}}function pe(i,r){const a=G.value.find(m=>m.id===i);a&&E.put(`/prompts/${i}`,{enabled:r}).then(()=>{a.enabled=r,$.success(r?"已启用":"已禁用")}).catch(m=>{var b,_;$.error(((_=(b=m.response)==null?void 0:b.data)==null?void 0:_.error)||"更新失败")})}let re=null;function fe(){Oe(()=>{const i=document.querySelector(".modern-table .n-data-table-tbody");!i||re||(re=Qe.create(i,{handle:".drag-handle",animation:150,ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",onEnd:r=>{const{oldIndex:a,newIndex:m}=r;if(a===void 0||m===void 0||a===m)return;const b=[...G.value].sort((C,d)=>{const n=C.order??999999,v=d.order??999999;return n-v}),[_]=b.splice(a,1);b.splice(m,0,_);const D=b.map((C,d)=>({id:C.id,order:d}));Promise.all(D.map(C=>E.put(`/prompts/${C.id}`,{order:C.order}))).then(()=>{D.forEach(C=>{const d=G.value.find(n=>n.id===C.id);d&&(d.order=C.order)}),$.success("排序已更新")}).catch(C=>{var d,n;$.error(((n=(d=C.response)==null?void 0:d.data)==null?void 0:n.error)||"更新排序失败"),ce()})}}))})}function xe(){f.value.arguments.push({name:"",description:"",required:!1})}function M(i){f.value.arguments.splice(i,1)}function c(){f.value.messages.push({role:"user",content:{type:"text",text:""}}),oe(f.value.messages.length-1)}function P(i){f.value.messages.splice(i,1),R.value.delete(i),j.value===i?(A.value=!1,j.value=-1):j.value>i&&j.value--}async function Y(){var i,r,a,m,b;try{await((i=F.value)==null?void 0:i.validate()),h.value=!0;const _={name:f.value.name,description:f.value.description||void 0,arguments:f.value.arguments.filter(D=>D.name),messages:f.value.messages.filter(D=>D.content.text),enabled:((r=V.value)==null?void 0:r.enabled)!==void 0?V.value.enabled:!0,order:((a=V.value)==null?void 0:a.order)!==void 0?V.value.order:G.value.reduce((C,d)=>{const n=d.order??0;return Math.max(C,n)},-1)+1};V.value?(await E.put(`/prompts/${V.value.id}`,_),$.success("更新成功")):(await E.post("/prompts",_),$.success("创建成功")),R.value.clear(),y.value=!1,await ce(),u()}catch(_){$.error(((b=(m=_.response)==null?void 0:m.data)==null?void 0:b.error)||"保存失败")}finally{h.value=!1}}async function p(){var i,r,a;try{await((i=F.value)==null?void 0:i.validate()),L.value=!0;const m=f.value.arguments.filter(b=>b.name);J.value.arguments=m.reduce((b,_)=>(b[_.name]=J.value.arguments[_.name]||"",b),{}),O.value=!0}catch(m){$.error(((a=(r=m.response)==null?void 0:r.data)==null?void 0:a.error)||"测试失败")}finally{L.value=!1}}async function t(i){V.value=i,f.value={name:i.name,description:i.description||"",arguments:i.arguments?[...i.arguments]:[],messages:i.messages?[...i.messages]:[]};const r=f.value.arguments.filter(a=>a.name);J.value.arguments=r.reduce((a,m)=>(a[m.name]="",a),{}),await p()}function u(){V.value=null,f.value={name:"",description:"",arguments:[],messages:[{role:"user",content:{type:"text",text:`# 提示词模板
|
|
3
|
+
|
|
4
|
+
## 变量替换
|
|
5
|
+
用户名:{{username}}
|
|
6
|
+
任务类型:{{taskType}}
|
|
7
|
+
|
|
8
|
+
## 条件逻辑
|
|
9
|
+
|
|
10
|
+
{{#if includeDetails}}
|
|
11
|
+
详细信息:{{projectName}} - {{deadline}}
|
|
12
|
+
{{/if}}
|
|
13
|
+
|
|
14
|
+
{{#if urgent}}
|
|
15
|
+
⚠️ 紧急任务
|
|
16
|
+
{{else}}
|
|
17
|
+
普通任务
|
|
18
|
+
{{/if}}
|
|
19
|
+
|
|
20
|
+
{{#ifnot completed}}
|
|
21
|
+
进行中
|
|
22
|
+
{{else}}
|
|
23
|
+
已完成
|
|
24
|
+
{{/ifnot}}`}}]},J.value.arguments={},R.value.clear(),A.value=!1,j.value=-1,Z.value=!1}return $e(()=>y.value,async i=>{i?(await Oe(),await new Promise(r=>setTimeout(r,150)),Z.value=!0):(u(),Z.value=!1)}),$e(()=>g.value,()=>{re&&(re.destroy(),re=null),setTimeout(()=>{fe()},100)},{flush:"post"}),Ie(()=>{ce(),setTimeout(()=>{fe()},300)}),qe(()=>{re&&(re.destroy(),re=null)}),(i,r)=>(S(),T("div",Ct,[e("div",$t,[l(s(U),{type:"primary",size:"large",class:"add-prompt-btn",onClick:me},{icon:o(()=>[...r[8]||(r[8]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:o(()=>[r[9]||(r[9]=x(" 添加提示词 ",-1))]),_:1}),l(s(H),{value:N.value,"onUpdate:value":r[0]||(r[0]=a=>N.value=a),placeholder:"搜索提示词名称或描述...",size:"large",clearable:"",class:"search-input"},{prefix:o(()=>[...r[10]||(r[10]=[e("svg",{class:"search-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),_:1},8,["value"])]),e("div",St,[l(s(je),{columns:k,data:g.value,pagination:se,"row-props":q,loading:B.value,"row-key":a=>a.id,class:Ae(["modern-table",{"draggable-table":!0}])},null,8,["data","loading","row-key"])]),l(s(ge),{show:y.value,"onUpdate:show":r[5]||(r[5]=a=>y.value=a),preset:"card",bordered:!1,class:"prompt-edit-modal",style:{width:"90vw",maxWidth:"1400px",height:"90vh",maxHeight:"90vh"}},{header:o(()=>[e("div",Mt,[r[11]||(r[11]=e("div",{class:"modal-icon"},[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8l-6-6z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),e("path",{d:"M14 2v6h6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),e("path",{d:"M16 13H8",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"}),e("path",{d:"M16 17H8",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"}),e("path",{d:"M10 9H8",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})])],-1)),e("div",null,[e("h3",zt,Q(V.value?"编辑提示词":"创建提示词"),1),e("p",Dt,Q(V.value?"修改提示词的内容和参数":"定义提示词模板和参数"),1)])])]),footer:o(()=>[e("div",Yt,[l(s(U),{size:"large",onClick:r[4]||(r[4]=a=>y.value=!1)},{default:o(()=>[...r[30]||(r[30]=[x("取消",-1)])]),_:1}),l(s(U),{type:"info",size:"large",onClick:p,loading:L.value},{default:o(()=>[...r[31]||(r[31]=[x("测试",-1)])]),_:1},8,["loading"]),l(s(U),{type:"primary",size:"large",loading:h.value,onClick:Y},{default:o(()=>[x(Q(V.value?"保存修改":"创建提示词"),1)]),_:1},8,["loading"])])]),default:o(()=>[e("div",_t,[l(s(Se),{ref_key:"formRef",ref:F,model:f.value,rules:ae,class:"prompt-form"},{default:o(()=>[l(s(Be),{value:X.value,"onUpdate:value":r[3]||(r[3]=a=>X.value=a),type:"line",animated:"",size:"large",class:"prompt-config-tabs"},{default:o(()=>[l(s(we),{name:"config",tab:"参数和描述"},{default:o(()=>[e("div",Tt,[e("div",Ut,[r[14]||(r[14]=e("h4",{class:"section-title"},"基础信息",-1)),e("div",jt,[l(s(K),{path:"name"},{label:o(()=>[...r[12]||(r[12]=[e("div",{class:"form-label"},[e("svg",{class:"label-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]),e("span",null,"提示词名称")],-1)])]),default:o(()=>[l(s(H),{value:f.value.name,"onUpdate:value":r[1]||(r[1]=a=>f.value.name=a),placeholder:"例如: code-review",size:"large"},null,8,["value"])]),_:1}),l(s(K),{path:"description"},{label:o(()=>[...r[13]||(r[13]=[e("div",{class:"form-label"},[e("svg",{class:"label-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]),e("span",null,"描述")],-1)])]),default:o(()=>[l(s(H),{value:f.value.description,"onUpdate:value":r[2]||(r[2]=a=>f.value.description=a),placeholder:"提示词的描述信息(可选)",size:"large"},null,8,["value"])]),_:1})])]),e("div",It,[e("div",Nt,[r[17]||(r[17]=e("h4",{class:"section-title"},"参数定义",-1)),l(s(U),{dashed:"",onClick:xe,size:"medium"},{icon:o(()=>[...r[15]||(r[15]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:o(()=>[r[16]||(r[16]=x(" 添加参数 ",-1))]),_:1})]),e("div",At,[(S(!0),T(he,null,be(f.value.arguments,(a,m)=>(S(),T("div",{key:m,class:"parameter-card"},[e("div",Bt,[e("span",Vt,"#"+Q(m+1),1),l(s(U),{type:"error",text:"",size:"small",onClick:b=>M(m)},{icon:o(()=>[...r[18]||(r[18]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:o(()=>[r[19]||(r[19]=x(" 删除 ",-1))]),_:1},8,["onClick"])]),e("div",Ot,[l(s(K),{label:"必填",class:"required-field"},{default:o(()=>[l(s(Ne),{checked:a.required,"onUpdate:checked":b=>a.required=b},null,8,["checked","onUpdate:checked"])]),_:2},1024),l(s(K),{label:"参数名",path:`arguments[${m}].name`,rule:{required:!0,message:"必填",trigger:"blur"}},{default:o(()=>[l(s(H),{value:a.name,"onUpdate:value":b=>a.name=b,placeholder:"参数名"},null,8,["value","onUpdate:value"])]),_:2},1032,["path"]),l(s(K),{label:"描述"},{default:o(()=>[l(s(H),{value:a.description,"onUpdate:value":b=>a.description=b,placeholder:"参数描述(可选)"},null,8,["value","onUpdate:value"])]),_:2},1024)])]))),128)),f.value.arguments.length===0?(S(),T("div",Pt,[...r[20]||(r[20]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"2"}),e("path",{d:"M12 16v-4m0-4h.01",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})],-1),e("p",null,"暂无参数,点击上方按钮添加参数",-1)])])):ie("",!0)])])])]),_:1}),l(s(we),{name:"content",tab:"提示词内容"},{default:o(()=>[e("div",Rt,[l(s(Pe),{type:"info",bordered:!1,class:"template-help-alert"},{header:o(()=>[e("div",Et,[(S(),T("svg",Ht,[...r[21]||(r[21]=[e("path",{d:"M12 22c5.421 0 10-4.579 10-10h-2a8 8 0 11-8-8v2c0 5.421-4.579 10-10 10z",fill:"currentColor",opacity:"0.1"},null,-1),e("path",{d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])),r[22]||(r[22]=e("span",{style:{"font-weight":"600"}},"模板语法说明",-1))])]),default:o(()=>[r[23]||(r[23]=e("div",{class:"template-help-content"},[e("p",null,[e("strong",null,"变量替换:"),x("使用 "),e("code",null,"{{变量名}}"),x(" 来替换变量值")]),e("p",null,[e("strong",null,"嵌套属性:"),x("支持访问嵌套属性,如 "),e("code",null,"{{context.user.email}}")]),e("p",null,[e("strong",null,"内置 Context 变量:")]),e("ul",null,[e("li",null,[e("code",null,"{{context.user.email}}"),x(" - 当前用户邮箱")]),e("li",null,[e("code",null,"{{context.user.id}}"),x(" - 当前用户ID")]),e("li",null,[e("code",null,"{{context.user.role}}"),x(" - 当前用户角色")]),e("li",null,[e("code",null,"{{context.user.root_dir}}"),x(" - 用户文件路径根目录(实际路径)")]),e("li",null,[e("code",null,"{{context.now}}"),x(" - 当前时间")]),e("li",null,[e("code",null,"{{context.timestamp}}"),x(" - 时间戳")])]),e("p",null,[e("strong",null,"条件逻辑:")]),e("ul",null,[e("li",null,[e("code",null,"{{#if 变量名}}...{{/if}}"),x(" - 当变量为真值时显示内容")]),e("li",null,[e("code",null,"{{#ifnot 变量名}}...{{/ifnot}}"),x(" - 当变量为假值时显示内容")]),e("li",null,[e("code",null,"{{#if 变量名}}...{{else}}...{{/if}}"),x(" - 支持 else 分支")]),e("li",null,[x("条件逻辑也支持嵌套属性,如 "),e("code",null,"{{#if context.user.email}}...{{/if}}")])]),e("p",null,[e("strong",null,"真值判断:"),x("非空字符串、非零数字、true、非空数组/对象都被视为真值")])],-1))]),_:1}),e("div",Lt,[(S(!0),T(he,null,be(f.value.messages,(a,m)=>(S(),T("div",{key:m,class:"message-editor-wrapper"},[e("div",Ft,[l(s(Ve),{value:a.role,"onUpdate:value":b=>a.role=b,options:ee,size:"small",class:"role-selector"},null,8,["value","onUpdate:value"]),l(s(U),{text:"",type:"error",size:"small",onClick:b=>P(m),class:"remove-message-btn"},{icon:o(()=>[...r[24]||(r[24]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),_:1},8,["onClick"])]),e("div",{class:Ae(["editor-container",{fullscreen:A.value&&j.value===m}])},[e("div",qt,[e("div",{class:Ae(["status-dot",{unsaved:ne(m),saved:!ne(m)}]),title:ne(m)?"未保存":"已保存"},null,10,Jt)]),l(s(U),{type:"default",size:"small",class:"fullscreen-btn",onClick:b=>de(m)},{icon:o(()=>[!A.value||j.value!==m?(S(),T("svg",Wt,[...r[25]||(r[25]=[e("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])):(S(),T("svg",Kt,[...r[26]||(r[26]=[e("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])]))]),default:o(()=>[x(" "+Q(A.value&&j.value===m?"退出全屏":"全屏"),1)]),_:2},1032,["onClick"]),y.value&&Z.value?(S(),T("div",Zt,[l(Je,{modelValue:a.content.text,"onUpdate:modelValue":b=>a.content.text=b,language:"markdown",theme:"vs",options:{minimap:{enabled:!1},fontSize:14,lineHeight:22,padding:{top:16,bottom:16},scrollBeyondLastLine:!1,automaticLayout:!0,wordWrap:"on"},onChange:()=>oe(m)},null,8,["modelValue","onUpdate:modelValue","onChange"])])):ie("",!0)],2)]))),128)),l(s(U),{dashed:"",onClick:c,class:"add-message-btn",size:"small"},{icon:o(()=>[...r[27]||(r[27]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:o(()=>[r[28]||(r[28]=x(" 添加消息模板 ",-1))]),_:1}),f.value.messages.length===0?(S(),T("div",Gt,[...r[29]||(r[29]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1),e("p",null,"暂无消息,点击下方按钮添加消息模板",-1)])])):ie("",!0)])])]),_:1})]),_:1},8,["value"])]),_:1},8,["model"])])]),_:1},8,["show"]),l(s(ge),{show:O.value,"onUpdate:show":r[7]||(r[7]=a=>O.value=a),preset:"card",title:"测试提示词",style:{width:"90vw",maxWidth:"800px"}},{action:o(()=>[l(s(U),{onClick:r[6]||(r[6]=a=>O.value=!1)},{default:o(()=>[...r[34]||(r[34]=[x("关闭",-1)])]),_:1})]),default:o(()=>[e("div",Qt,[l(s(Se),{model:J.value},{default:o(()=>[(S(!0),T(he,null,be(f.value.arguments,a=>(S(),ze(s(K),{key:a.name,label:a.name,required:a.required},{default:o(()=>[l(s(H),{value:J.value.arguments[a.name],"onUpdate:value":m=>J.value.arguments[a.name]=m,placeholder:a.description||`输入 ${a.name}`,clearable:""},null,8,["value","onUpdate:value","placeholder"])]),_:2},1032,["label","required"]))),128))]),_:1},8,["model"]),l(s(ct),null,{default:o(()=>[...r[32]||(r[32]=[x("生成的消息(实时预览)",-1)])]),_:1}),e("div",Xt,[(S(!0),T(he,null,be(ue.value,(a,m)=>(S(),T("div",{key:m,class:"test-message"},[e("div",ea,[l(s(Re),{type:a.role==="user"?"info":"success"},{default:o(()=>[x(Q(a.role==="user"?"用户":"助手"),1)]),_:2},1032,["type"])]),e("pre",ta,Q(a.content.text),1)]))),128)),ue.value.length===0?(S(),T("div",aa,[...r[33]||(r[33]=[e("p",null,"暂无消息内容",-1)])])):ie("",!0)])])]),_:1},8,["show"])]))}}),sa=Te(na,[["__scopeId","data-v-b1842237"]]),la={class:"table-editor"},oa={class:"editor-toolbar"},ra={class:"toolbar-left"},ia={key:0,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},ua={key:1,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},da={class:"toolbar-right"},ca={class:"save-indicator-wrapper"},va={key:0,class:"table-container"},pa={class:"table-wrapper",ref:"tableWrapperRef"},fa={key:1,class:"no-table-message"},ma={class:"import-content"},ga={class:"json-editor-wrapper"},wa={class:"json-editor-actions"},ha={class:"batch-loading-content"},ba={class:"loading-text"},ya=De({__name:"TableEditor",props:{tableDefinition:{},tableId:{}},emits:["saved"],setup(ve,{emit:$}){const z=_e(),y=ve,O=$,h=w([]),L=w([]),B=w(!1),V=w(!1),F=w(!1),N=w(!0),G=w(50),X=w(1),A=w(""),j=w(!1),R=w("正在处理..."),Z=te(()=>({page:X.value,pageSize:G.value,showSizePicker:!0,pageSizes:[20,50,100,200],showQuickJumper:!0,onUpdatePage:p=>{X.value=p},onUpdatePageSize:p=>{G.value=p,X.value=1}})),ee=te(()=>y.tableDefinition?[{type:"selection",width:50,fixed:"left"},...y.tableDefinition.columns.map(t=>({title:()=>{const u=I("span",{class:"column-name",title:t.description||void 0},t.name);return I("div",{class:"column-header-cell"},[t.description?I(Ze,{trigger:"hover",placement:"top"},{default:()=>t.description,trigger:()=>u}):u,I(Re,{size:"tiny",type:xe(t.type),style:"margin-left: 6px"},{default:()=>t.type}),t.nullable?null:I("span",{class:"required-mark"},"*")])},key:t.name,minWidth:120,resizable:!0,render(u){return I("div",{class:"cell-wrapper excel-cell"},[t.type==="string"?I(H,{value:u.rowData[t.name],placeholder:"",size:"tiny",class:"excel-input",disabled:N.value,onUpdateValue:i=>{N.value||(u.rowData[t.name]=i,oe(u))},onBlur:()=>de(u,t)}):t.type==="number"?I("input",{type:"number",value:u.rowData[t.name]??"",placeholder:"",class:"excel-input-native",disabled:N.value,onInput:i=>{if(N.value)return;const a=i.target.value,m=Number(a);(!isNaN(m)||a==="")&&(u.rowData[t.name]=a===""?null:m,oe(u))},onBlur:()=>de(u,t)}):t.type==="boolean"?I(Ne,{checked:u.rowData[t.name],disabled:N.value,onUpdateChecked:i=>{N.value||(u.rowData[t.name]=i,oe(u))}}):t.type==="date"?I("input",{type:"datetime-local",value:ce(u.rowData[t.name]),class:"excel-input-native",disabled:N.value,onInput:i=>{if(N.value)return;const a=i.target.value;if(a){const m=new Date(a);u.rowData[t.name]=m.toISOString()}else u.rowData[t.name]=null;oe(u)},onBlur:()=>de(u,t)}):t.type==="json"?I(H,{type:"textarea",value:typeof u.rowData[t.name]=="string"?u.rowData[t.name]:JSON.stringify(u.rowData[t.name]||{},null,2),placeholder:"",rows:2,size:"tiny",class:"excel-textarea",disabled:N.value,onUpdateValue:i=>{N.value||(u.rowData[t.name]=i)},onBlur:()=>{de(u,t)}}):null])}}))]:[]),se=te(()=>{if(y.tableDefinition)return 50+y.tableDefinition.columns.length*120});function q(p){const t=p.id||`new-${h.value.indexOf(p)}`;return{class:L.value.includes(t)?"row-selected":"",style:"cursor: pointer;"}}$e(()=>y.tableId,async p=>{p&&y.tableDefinition?await f():(h.value=[],L.value=[])},{immediate:!0});let k=null;Ie(()=>{k=()=>{ye()},window.addEventListener("beforeunload",k)});const g=w(!0);qe(()=>{g.value=!1,k&&(window.removeEventListener("beforeunload",k),k=null),ne.forEach(p=>{clearTimeout(p)}),ne.clear()});async function f(){var p,t;if(y.tableId)try{const u=await E.get(`/tables/data/${y.tableId}`);u.data.success&&(h.value=u.data.data)}catch(u){z.error("加载数据失败: "+(((t=(p=u.response)==null?void 0:p.data)==null?void 0:t.error)||u.message))}}async function J(){if(!y.tableDefinition)return;const p={tableId:y.tableId||"",rowData:{}};y.tableDefinition.columns.forEach(t=>{if(t.defaultValue!==void 0)p.rowData[t.name]=t.defaultValue;else if(t.nullable)p.rowData[t.name]=null;else switch(t.type){case"string":p.rowData[t.name]="";break;case"number":p.rowData[t.name]=0;break;case"boolean":p.rowData[t.name]=!1;break;case"date":p.rowData[t.name]=new Date().toISOString();break;case"json":p.rowData[t.name]={};break}}),h.value.push(p),await pe(p)}async function ue(){const p=[...L.value],t=h.value.filter(u=>{const i=u.id||`new-${h.value.indexOf(u)}`;return p.includes(i)});if(t.length!==0){j.value=!0,R.value=`正在删除 ${t.length} 条数据...`;try{let u=0,i=0;for(const r of t)if(r.id&&y.tableId)try{await E.delete(`/tables/data/${y.tableId}/${r.id}`),u++}catch(a){console.error("Delete row failed:",a),i++}h.value=h.value.filter(r=>{const a=r.id||`new-${h.value.indexOf(r)}`;return!p.includes(a)}),L.value=[],O("saved"),i>0?z.warning(`成功删除 ${u} 条,失败 ${i} 条`):z.success(`成功删除 ${u} 条数据`)}finally{j.value=!1}}}function ae(p){L.value=p}const ne=new Map;async function oe(p,t){await ke(p)}async function de(p,t){const u=p.rowData[t.name];if((u==null||u==="")&&!t.nullable&&t.defaultValue===void 0){z.warning(`列 ${t.name} 不能为空`),await pe(p);return}try{switch(t.type){case"number":if(typeof u!="number"&&u!==""&&u!==null){const i=Number(u);isNaN(i)?(z.error(`列 ${t.name} 必须是数字`),p.rowData[t.name]=t.defaultValue??0):p.rowData[t.name]=i}break;case"boolean":typeof u!="boolean"&&u!==null&&u!==void 0&&(p.rowData[t.name]=!!u);break;case"date":if(typeof u=="string"&&u){const i=new Date(u);isNaN(i.getTime())?(z.error(`列 ${t.name} 必须是有效的日期`),p.rowData[t.name]=t.defaultValue??new Date().toISOString()):p.rowData[t.name]=i.toISOString()}break;case"json":if(typeof u=="string"&&u)try{p.rowData[t.name]=JSON.parse(u)}catch{z.error(`列 ${t.name} 必须是有效的 JSON`);return}break}await pe(p)}catch(i){console.error(`列 ${t.name} 数据格式错误:`,i),await pe(p)}}function ce(p){if(!p)return"";const t=new Date(p);if(isNaN(t.getTime()))return"";const u=t.getFullYear(),i=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),a=String(t.getHours()).padStart(2,"0"),m=String(t.getMinutes()).padStart(2,"0");return`${u}-${i}-${r}T${a}:${m}`}let me=!1;async function ye(){me||!y.tableId||!y.tableDefinition||h.value.length===0||await re()}async function ke(p){if(!y.tableId||!y.tableDefinition)return;const t=ne.get(p);t&&clearTimeout(t);const u=setTimeout(async()=>{await pe(p),ne.delete(p)},300);ne.set(p,u)}async function pe(p){var i,r;if(!y.tableId||!y.tableDefinition||!g.value)return;const t=ne.get(p);t&&(clearTimeout(t),ne.delete(p));const u={};y.tableDefinition.columns.forEach(a=>{const m=p.rowData[a.name];if(m===void 0)if(a.defaultValue!==void 0)u[a.name]=a.defaultValue;else if(a.nullable)u[a.name]=null;else switch(a.type){case"string":u[a.name]="";break;case"number":u[a.name]=0;break;case"boolean":u[a.name]=!1;break;case"date":u[a.name]=new Date().toISOString();break;case"json":u[a.name]={};break}else u[a.name]=m});try{if(p.id){const a=await E.put(`/tables/data/${y.tableId}/${p.id}`,{rowData:u});if(!g.value)return;if(a.data.success){const m=a.data.data;p.createdAt=m.createdAt,p.updatedAt=m.updatedAt,fe(),O("saved")}else console.error("Save row failed:",a.data.error),g.value&&z.error("保存失败: "+(a.data.error||"未知错误"))}else{const a=await E.post(`/tables/data/${y.tableId}`,{rowData:u});if(!g.value)return;if(a.data.success){const m=a.data.data;p.id=m.id,p.createdAt=m.createdAt,p.updatedAt=m.updatedAt,fe(),O("saved")}else console.error("Create row failed:",a.data.error),g.value&&z.error("保存失败: "+(a.data.error||"未知错误"))}}catch(a){if(console.error("Save single row failed:",a),g.value){const m=((r=(i=a.response)==null?void 0:i.data)==null?void 0:r.error)||a.message||"保存失败";if(m.includes("Row not found")&&!g.value)return;z.error("保存失败: "+m)}}}async function re(){var p,t,u,i,r;if(!me&&g.value){if(!y.tableId){console.warn("performSave: tableId is missing");return}if(!y.tableDefinition){console.warn("performSave: tableDefinition is missing");return}if(h.value.length!==0){me=!0,B.value=!0;try{const a=h.value.map(b=>{const _={};return y.tableDefinition.columns.forEach(D=>{const C=b.rowData[D.name];if(C===void 0)if(D.defaultValue!==void 0)_[D.name]=D.defaultValue;else if(D.nullable)_[D.name]=null;else switch(D.type){case"string":_[D.name]="";break;case"number":_[D.name]=0;break;case"boolean":_[D.name]=!1;break;case"date":_[D.name]=new Date().toISOString();break;case"json":_[D.name]={};break}else _[D.name]=C}),{id:b.id,rowData:_}}),m=await E.put(`/tables/data/${y.tableId}/batch`,{rows:a});if(m.data.success){const b=m.data.data||[];if(b.length>0){const _=new Map;b.forEach(C=>{C.id&&_.set(C.id,C)});const D=new Set;h.value.forEach(C=>{if(C.id&&_.has(C.id)){const d=_.get(C.id);C.createdAt=d.createdAt,C.updatedAt=d.updatedAt,D.add(C.id)}}),h.value.forEach(C=>{if(!C.id){const d=b.find(n=>n.id&&!D.has(n.id));d&&d.id&&(C.id=d.id,C.createdAt=d.createdAt,C.updatedAt=d.updatedAt,D.add(d.id))}})}g.value&&(fe(),O("saved"))}else if(console.error("Save failed:",m.data),g.value){const b=((p=m.data)==null?void 0:p.error)||"未知错误";z.error("保存失败: "+b)}}catch(a){if(console.error("Auto save failed:",a),g.value){const m=((u=(t=a.response)==null?void 0:t.data)==null?void 0:u.error)||a.message||"保存失败";if(m.includes("Row not found")){console.warn("Save failed after component unmount, ignoring error");return}console.error("Error details:",{message:a.message,response:(i=a.response)==null?void 0:i.data,status:(r=a.response)==null?void 0:r.status}),z.error("保存失败: "+m)}}finally{me=!1,B.value=!1}}}}function fe(){V.value=!0,setTimeout(()=>{V.value=!1},1500)}function xe(p){switch(p){case"string":return"info";case"number":return"success";case"boolean":return"warning";case"date":return"default";case"json":return"error";default:return"default"}}async function M(){if(!y.tableId||!y.tableDefinition){z.error("请先选择要导出的表");return}if(h.value.length===0){z.warning("当前表没有数据可导出");return}try{const p=h.value.map(a=>a.rowData),t=JSON.stringify(p,null,2),u=new Blob([t],{type:"application/json"}),i=URL.createObjectURL(u),r=document.createElement("a");r.href=i,r.download=`${y.tableDefinition.name}_data.json`,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(i),z.success(`成功导出 ${h.value.length} 条数据`)}catch(p){z.error("导出失败: "+(p.message||"未知错误"))}}async function c(p){var t,u;if(!y.tableId||!y.tableDefinition){z.error("请先选择要导入数据的表");return}try{let i;try{const b=JSON.parse(p);if(Array.isArray(b))i=b;else if(b.data&&Array.isArray(b.data))i=b.data,z.warning("检测到旧格式,将只导入数据部分");else{z.error("JSON 格式错误:需要数据数组格式");return}}catch{z.error("JSON 解析失败:文件格式不正确");return}if(i.length===0){z.warning("导入的数据为空"),F.value=!1;return}const r=y.tableDefinition.columns.map(b=>b.name),a=[],m=[];if(i.forEach((b,_)=>{if(!b||typeof b!="object"||Array.isArray(b)){a.push(`第 ${_+1} 行:数据必须是对象格式`);return}y.tableDefinition.columns.forEach(D=>{const C=b[D.name];if(!D.nullable&&D.defaultValue===void 0&&(C==null||C==="")&&a.push(`第 ${_+1} 行,列 "${D.name}":必填字段不能为空`),C!=null&&C!=="")switch(D.type){case"number":typeof C!="number"&&!(typeof C=="string"&&!isNaN(Number(C)))&&a.push(`第 ${_+1} 行,列 "${D.name}":必须是数字类型`);break;case"boolean":typeof C!="boolean"&&a.push(`第 ${_+1} 行,列 "${D.name}":必须是布尔类型`);break;case"date":(typeof C!="string"||isNaN(new Date(C).getTime()))&&a.push(`第 ${_+1} 行,列 "${D.name}":必须是有效的日期格式`);break;case"json":if(C!==null&&typeof C!="object"&&typeof C!="string"&&a.push(`第 ${_+1} 行,列 "${D.name}":必须是对象、数组或 JSON 字符串`),typeof C=="string")try{JSON.parse(C)}catch{a.push(`第 ${_+1} 行,列 "${D.name}":JSON 字符串格式无效`)}break;case"string":break}}),Object.keys(b).forEach(D=>{r.includes(D)||m.push(`第 ${_+1} 行:包含未知列 "${D}",将被忽略`)})}),m.length>0){const b=m.slice(0,10).join(`
|
|
25
|
+
`),_=m.length>10?`
|
|
26
|
+
... 还有 ${m.length-10} 个警告`:"";z.warning(`导入时将忽略以下额外字段:
|
|
27
|
+
${b}${_}`)}if(a.length>0){const b=a.slice(0,10).join(`
|
|
28
|
+
`),_=a.length>10?`
|
|
29
|
+
... 还有 ${a.length-10} 个错误`:"";z.error(`数据校验失败:
|
|
30
|
+
${b}${_}`);return}B.value=!0,j.value=!0,R.value=`正在导入 ${i.length} 条数据...`;try{const b=i.map(D=>{const C={};return y.tableDefinition.columns.forEach(d=>{const n=D[d.name];let v=n;if(n!=null&&n!=="")switch(d.type){case"number":v=typeof n=="string"?Number(n):n;break;case"boolean":v=typeof n=="boolean"?n:!!n;break;case"date":typeof n=="string"&&(v=new Date(n).toISOString());break;case"json":if(typeof n=="string")try{v=JSON.parse(n)}catch{v=n}break}else if(d.defaultValue!==void 0)v=d.defaultValue;else if(d.nullable)v=null;else switch(d.type){case"string":v="";break;case"number":v=0;break;case"boolean":v=!1;break;case"date":v=new Date().toISOString();break;case"json":v={};break}C[d.name]=v}),{rowData:C}}),_=await E.put(`/tables/data/${y.tableId}/batch`,{rows:b});_.data.success?(fe(),await f(),O("saved"),F.value=!1,z.success(`成功导入 ${i.length} 条数据`)):z.error("导入失败:"+(_.data.error||"未知错误"))}catch(b){z.error("导入失败: "+(((u=(t=b.response)==null?void 0:t.data)==null?void 0:u.error)||b.message))}finally{B.value=!1,j.value=!1}}catch(i){z.error("文件读取失败: "+(i.message||"未知错误"))}}async function P(p){var u;const t=(u=p.fileList[0])==null?void 0:u.file;if(t)try{const i=await t.text();await c(i)}catch(i){z.error("文件读取失败: "+(i.message||"未知错误"))}}async function Y(){if(!A.value.trim()){z.warning("请输入 JSON 数据");return}await c(A.value.trim()),A.value=""}return(p,t)=>(S(),T("div",la,[e("div",oa,[e("div",ra,[l(s(U),{size:"large",onClick:t[0]||(t[0]=u=>N.value=!N.value),type:N.value?"warning":"success",ghost:""},{icon:o(()=>[N.value?(S(),T("svg",ia,[...t[6]||(t[6]=[e("path",{d:"M19 11H5a2 2 0 00-2 2v7a2 2 0 002 2h14a2 2 0 002-2v-7a2 2 0 00-2-2zM7 11V7a5 5 0 0110 0v4",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])):(S(),T("svg",ua,[...t[7]||(t[7]=[e("path",{d:"M19 11H5a2 2 0 00-2 2v7a2 2 0 002 2h14a2 2 0 002-2v-7a2 2 0 00-2-2zM7 11V7a5 5 0 0110 0v4",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1),e("path",{d:"M12 15v2M9 17h6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])]))]),default:o(()=>[x(" "+Q(N.value?"解锁编辑":"锁定编辑"),1)]),_:1},8,["type"]),l(s(U),{type:"primary",size:"large",onClick:J,disabled:!ve.tableDefinition||N.value},{icon:o(()=>[...t[8]||(t[8]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:o(()=>[t[9]||(t[9]=x(" 添加行 ",-1))]),_:1},8,["disabled"]),l(s(U),{size:"large",onClick:ue,disabled:L.value.length===0||N.value,type:"error",ghost:""},{icon:o(()=>[...t[10]||(t[10]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:o(()=>[x(" 删除选中 ("+Q(L.value.length)+") ",1)]),_:1},8,["disabled"]),l(s(U),{size:"large",onClick:M,disabled:!ve.tableDefinition||h.value.length===0},{icon:o(()=>[...t[11]||(t[11]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:o(()=>[t[12]||(t[12]=x(" 导出 JSON ",-1))]),_:1},8,["disabled"]),l(s(U),{size:"large",onClick:t[1]||(t[1]=u=>F.value=!0),disabled:!ve.tableDefinition},{icon:o(()=>[...t[13]||(t[13]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:o(()=>[t[14]||(t[14]=x(" 导入 JSON ",-1))]),_:1},8,["disabled"])]),e("div",da,[e("div",ca,[V.value?(S(),T("div",{key:0,class:Ae(["save-success-indicator",{flash:V.value}])},null,2)):ie("",!0)]),l(s(Re),{type:"info",size:"large"},{default:o(()=>[x(" 共 "+Q(h.value.length)+" 行(编辑即保存) ",1)]),_:1})])]),ve.tableDefinition?(S(),T("div",va,[e("div",pa,[l(s(je),{columns:ee.value,data:h.value,pagination:Z.value,"row-key":u=>u.id||`new-${h.value.indexOf(u)}`,"row-props":q,"max-height":600,"scroll-x":se.value,bordered:!0,"single-line":!1,"onUpdate:checkedRowKeys":ae,class:"editable-data-table excel-table"},null,8,["columns","data","pagination","row-key","scroll-x"])],512)])):(S(),T("div",fa,[l(s(Me),{description:"请先创建或选择表定义"})])),l(s(ge),{show:F.value,"onUpdate:show":t[4]||(t[4]=u=>F.value=u),preset:"card",bordered:!1,class:"import-modal",style:{width:"90vw",maxWidth:"600px"}},{header:o(()=>[...t[15]||(t[15]=[e("div",{class:"modal-header"},[e("div",{class:"modal-icon"},[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})])]),e("div",null,[e("h3",{class:"modal-title"},"导入表数据"),e("p",{class:"modal-subtitle"},"从 JSON 文件导入表数据")])],-1)])]),default:o(()=>[e("div",ma,[l(s(Be),{"default-value":"file",type:"line"},{default:o(()=>[l(s(we),{name:"file",tab:"文件上传"},{default:o(()=>[l(s(vt),{"file-list":[],accept:".json",max:1,onChange:P},{default:o(()=>[l(s(pt),null,{default:o(()=>[...t[16]||(t[16]=[e("div",{class:"upload-area"},[e("svg",{class:"upload-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4m17-7l-5-5m0 0L7 8m9-5v12",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})]),e("p",{class:"upload-text"},"点击或拖拽 JSON 文件到此处"),e("p",{class:"upload-hint"},"支持导入表数据")],-1)])]),_:1})]),_:1})]),_:1}),l(s(we),{name:"text",tab:"直接编辑/粘贴"},{default:o(()=>[e("div",ga,[l(s(H),{value:A.value,"onUpdate:value":t[2]||(t[2]=u=>A.value=u),type:"textarea",placeholder:"请粘贴或输入 JSON 数据(数组格式)...",rows:15,class:"json-textarea"},null,8,["value"]),e("div",wa,[l(s(U),{onClick:Y,type:"primary",disabled:!A.value.trim()},{default:o(()=>[...t[17]||(t[17]=[x(" 导入 ",-1)])]),_:1},8,["disabled"]),l(s(U),{onClick:t[3]||(t[3]=u=>A.value="")},{default:o(()=>[...t[18]||(t[18]=[x(" 清空 ",-1)])]),_:1})])])]),_:1})]),_:1})])]),_:1},8,["show"]),l(s(ge),{show:j.value,"onUpdate:show":t[5]||(t[5]=u=>j.value=u),"mask-closable":!1,"close-on-esc":!1,"auto-focus":!1,preset:"dialog",closable:!1,"show-icon":!1,style:{width:"400px"}},{default:o(()=>[e("div",ha,[l(s(ft),{size:"large"},{description:o(()=>[e("div",ba,Q(R.value),1)]),_:1})])]),_:1},8,["show"])]))}}),ka=Te(ya,[["__scopeId","data-v-da42254c"]]),xa={class:"tables-page"},Ca={class:"tables-toolbar"},$a={class:"toolbar-left"},Sa={class:"table-select-with-icon"},Ma={class:"toolbar-right"},za={class:"toolbar-switch"},Da={class:"explore-config-panel"},_a={class:"explore-config-list"},Ta={key:0,class:"empty-tables-hint"},Ua={class:"explore-config-item-info"},ja={class:"table-name"},Ia={key:0,class:"table-description"},Na={key:0,class:"tables-table-container"},Aa={key:1,class:"no-table-selected"},Ba={class:"columns-section"},Va={class:"columns-header"},Oa={class:"columns-list"},Pa={class:"column-index"},Ra={key:0,class:"empty-columns"},Ea={class:"form-actions"},Ha={class:"modal-header"},La={class:"modal-subtitle"},Fa={class:"column-descriptions-section"},qa={class:"column-description-label"},Ja={class:"column-name-label"},Wa={key:0,class:"empty-columns-hint"},Ka={class:"form-actions"},Za=De({__name:"Tables",setup(ve){const $=_e(),z=He(),y=w([]),O=w(null),h=w(null),L=w(!1),B=w(!1),V=w(!1),F=w(!1),N=w(!1),G=w(!1),X=w(!1),A=w(null),j=w(""),R=w({}),Z=w(!0),ee=w({}),se=[{label:"字符串",value:"string"},{label:"数字",value:"number"},{label:"布尔值",value:"boolean"},{label:"日期",value:"date"},{label:"JSON",value:"json"}],q=w({name:"",description:"",columns:[]}),k={name:{required:!0,message:"表名不能为空",trigger:"blur"}},g=te(()=>y.value.map(M=>({label:M.name,value:M.id,description:M.description})));function f(M){if(M){const c=y.value.find(P=>P.id===M);c&&ce(c)}else O.value=null,h.value=null}const J=te({get:()=>L.value,set:M=>{L.value=M}});Ie(async()=>{await de(),await ue()});async function ue(){try{if(await z.fetchConfig(),z.currentConfig){const M=z.currentConfig;Z.value=M.enableExploreTable!==!1}}catch(M){console.error("加载配置失败:",M)}}async function ae(M){X.value=!0;try{await z.updateConfig({enableExploreTable:M}),$.success(M?"已允许 AI 探索数据表":"已禁止 AI 探索数据表")}catch(c){$.error("更新配置失败: "+(c.message||"未知错误")),Z.value=!M}finally{X.value=!1}}function ne(M){return M.allowExplore!==!1}async function oe(M,c){var P,Y;ee.value[M]=!0;try{const p=y.value.find(u=>u.id===M);if(!p){$.error("表不存在");return}(await E.put(`/tables/definitions/${M}`,{allowExplore:c})).data.success&&(p.allowExplore=c,$.success(c?`已允许 AI 探索表「${p.name}」`:`已禁止 AI 探索表「${p.name}」`),h.value&&h.value.id===M&&(h.value.allowExplore=c))}catch(p){$.error("更新失败: "+(((Y=(P=p.response)==null?void 0:P.data)==null?void 0:Y.error)||p.message))}finally{ee.value[M]=!1}}async function de(){var M,c;try{const P=await E.get("/tables/definitions");P.data.success&&(y.value=P.data.data,y.value.length>0&&!O.value&&ce(y.value[0]))}catch(P){$.error("加载表列表失败: "+(((c=(M=P.response)==null?void 0:M.data)==null?void 0:c.error)||P.message))}}function ce(M){O.value=M.id,h.value=M}function me(){q.value.columns.push({name:"",type:"string",nullable:!0,description:""})}function ye(M){q.value.columns.splice(M,1)}async function ke(){A.value&&await A.value.validate(async M=>{var c,P;if(!M){if(q.value.columns.length===0){$.warning("至少需要定义一个列");return}N.value=!0;try{const Y=await E.post("/tables/definitions",q.value);Y.data.success&&($.success("表创建成功"),L.value=!1,q.value={name:"",description:"",columns:[]},await de(),ce(Y.data.data))}catch(Y){$.error("保存失败: "+(((P=(c=Y.response)==null?void 0:c.data)==null?void 0:P.error)||Y.message))}finally{N.value=!1}}})}async function pe(){var M,c;if(h.value){F.value=!0;try{(await E.delete(`/tables/definitions/${h.value.id}`)).data.success&&($.success("表删除成功"),O.value=null,h.value=null,V.value=!1,await de())}catch(P){$.error("删除失败: "+(((c=(M=P.response)==null?void 0:M.data)==null?void 0:c.error)||P.message))}finally{F.value=!1}}}function re(){}$e(B,M=>{M&&h.value&&(j.value=h.value.description||"",R.value={},h.value.columns&&h.value.columns.forEach(c=>{R.value[c.name]=c.description||""}))});function fe(M){switch(M){case"string":return"info";case"number":return"success";case"boolean":return"warning";case"date":return"default";case"json":return"error";default:return"default"}}async function xe(){var M,c;if(!h.value||!O.value){$.error("请先选择一个表");return}G.value=!0;try{const P=h.value.columns.map(p=>({...p,description:R.value[p.name]||void 0})),Y=await E.put(`/tables/definitions/${O.value}`,{description:j.value||null,columns:P});Y.data.success&&($.success("表声明和字段声明更新成功"),B.value=!1,h.value&&(h.value.description=Y.data.data.description,h.value.columns=Y.data.data.columns),await de())}catch(P){$.error("更新失败: "+(((c=(M=P.response)==null?void 0:M.data)==null?void 0:c.error)||P.message))}finally{G.value=!1}}return(M,c)=>{var Y,p;const P=Xe("n-tag");return S(),T("div",xa,[e("div",Ca,[e("div",$a,[e("div",Sa,[l(s(Ve),{value:O.value,"onUpdate:value":[c[0]||(c[0]=t=>O.value=t),f],options:g.value,placeholder:"选择表...",size:"large",clearable:"",filterable:"",class:"table-select"},{empty:o(()=>[l(s(Me),{description:"暂无表",size:"small"})]),_:1},8,["value","options"]),(Y=h.value)!=null&&Y.description?(S(),ze(s(Ze),{key:0,trigger:"hover",placement:"top"},{trigger:o(()=>[...c[14]||(c[14]=[e("div",{class:"table-info-icon"},[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})])],-1)])]),default:o(()=>[x(" "+Q(h.value.description),1)]),_:1})):ie("",!0)])]),e("div",Ma,[e("div",za,[l(s(Ee),{value:Z.value,"onUpdate:value":[c[1]||(c[1]=t=>Z.value=t),ae],size:"medium",loading:X.value},{checked:o(()=>[...c[15]||(c[15]=[x("允许 AI 探索数据表",-1)])]),unchecked:o(()=>[...c[16]||(c[16]=[x("禁止 AI 探索数据表",-1)])]),_:1},8,["value","loading"]),l(s(mt),{trigger:"hover",placement:"bottom-end",style:{width:"400px",maxHeight:"500px"}},{trigger:o(()=>[...c[17]||(c[17]=[e("div",{class:"explore-config-icon",title:"配置表探索权限"},[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94L14.4 2.81c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z",fill:"currentColor"})])],-1)])]),default:o(()=>[e("div",Da,[c[18]||(c[18]=e("div",{class:"explore-config-header"},[e("h4",null,"配置表探索权限"),e("p",{class:"explore-config-hint"},"控制哪些表允许被 AI 探索(默认为允许)")],-1)),e("div",_a,[y.value.length===0?(S(),T("div",Ta,[l(s(Me),{description:"暂无表",size:"small"})])):ie("",!0),(S(!0),T(he,null,be(y.value,t=>(S(),T("div",{key:t.id,class:"explore-config-item"},[e("div",Ua,[e("span",ja,Q(t.name),1),t.description?(S(),T("span",Ia,Q(t.description),1)):ie("",!0)]),l(s(Ee),{value:ne(t),"onUpdate:value":u=>oe(t.id,u),size:"small",loading:ee.value[t.id]},null,8,["value","onUpdate:value","loading"])]))),128))])])]),_:1})]),h.value?(S(),ze(s(U),{key:0,size:"large",ghost:"",onClick:c[2]||(c[2]=t=>B.value=!0),class:"edit-table-btn"},{icon:o(()=>[...c[19]||(c[19]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),e("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:o(()=>[c[20]||(c[20]=x(" 编辑表声明 ",-1))]),_:1})):ie("",!0),h.value?(S(),ze(s(U),{key:1,type:"error",size:"large",ghost:"",onClick:c[3]||(c[3]=t=>V.value=!0),class:"delete-table-btn"},{icon:o(()=>[...c[21]||(c[21]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:o(()=>[c[22]||(c[22]=x(" 删除表 ",-1))]),_:1})):ie("",!0),l(s(U),{type:"primary",size:"large",onClick:c[4]||(c[4]=t=>L.value=!0),class:"create-table-btn"},{icon:o(()=>[...c[23]||(c[23]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:o(()=>[c[24]||(c[24]=x(" 创建新表 ",-1))]),_:1})])]),h.value?(S(),T("div",Na,[l(ka,{"table-definition":h.value,"table-id":O.value,onSaved:re},null,8,["table-definition","table-id"])])):(S(),T("div",Aa,[l(s(Me),{description:"请选择一个表进行编辑"})])),l(s(ge),{show:V.value,"onUpdate:show":c[5]||(c[5]=t=>V.value=t),preset:"dialog",type:"warning",title:"确认删除",content:`确定要删除表「${(p=h.value)==null?void 0:p.name}」吗?此操作将同时删除表中的所有数据,且不可恢复。`,"positive-text":"确认删除","negative-text":"取消","positive-button-props":{type:"error"},loading:F.value,onPositiveClick:pe,onNegativeClick:c[6]||(c[6]=t=>V.value=!1)},null,8,["show","content","loading"]),l(s(ge),{show:J.value,"onUpdate:show":c[10]||(c[10]=t=>J.value=t),preset:"card",bordered:!1,class:"table-definition-modal",style:{width:"90vw",maxWidth:"800px"}},{header:o(()=>[...c[25]||(c[25]=[e("div",{class:"modal-header"},[e("div",{class:"modal-icon"},[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M3 3h18v18H3V3zm2 2v14h14V5H5zm2 2h10v2H7V7zm0 4h10v2H7v-2zm0 4h7v2H7v-2z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})])]),e("div",null,[e("h3",{class:"modal-title"}," 创建新表 "),e("p",{class:"modal-subtitle"}," 定义表的结构和列类型(创建后不可修改) ")])],-1)])]),default:o(()=>[l(s(Se),{ref_key:"tableFormRef",ref:A,model:q.value,rules:k,class:"table-form"},{default:o(()=>[l(s(K),{path:"name",label:"表名"},{default:o(()=>[l(s(H),{value:q.value.name,"onUpdate:value":c[7]||(c[7]=t=>q.value.name=t),placeholder:"例如: users, products",size:"large"},null,8,["value"])]),_:1}),l(s(K),{path:"description",label:"描述"},{default:o(()=>[l(s(H),{value:q.value.description,"onUpdate:value":c[8]||(c[8]=t=>q.value.description=t),placeholder:"表的用途说明",size:"large",type:"textarea",rows:2},null,8,["value"])]),_:1}),l(s(K),{label:"列定义"},{default:o(()=>[e("div",Ba,[e("div",Va,[c[28]||(c[28]=e("span",null,null,-1)),l(s(U),{dashed:"",onClick:me,size:"medium"},{icon:o(()=>[...c[26]||(c[26]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:o(()=>[c[27]||(c[27]=x(" 添加列 ",-1))]),_:1})]),e("div",Oa,[(S(!0),T(he,null,be(q.value.columns,(t,u)=>(S(),T("div",{key:u,class:"column-row"},[e("span",Pa,"#"+Q(u+1),1),l(s(K),{path:`columns[${u}].name`,"show-label":!1,rule:{required:!0,message:"必填",trigger:"blur"},class:"column-field-name"},{default:o(()=>[l(s(H),{value:t.name,"onUpdate:value":i=>t.name=i,placeholder:"列名"},null,8,["value","onUpdate:value"])]),_:2},1032,["path"]),l(s(K),{path:`columns[${u}].type`,"show-label":!1,rule:{required:!0,message:"必填",trigger:"change"},class:"column-field-type"},{default:o(()=>[l(s(Ve),{value:t.type,"onUpdate:value":i=>t.type=i,options:se},null,8,["value","onUpdate:value"])]),_:2},1032,["path"]),l(s(Ne),{checked:!t.nullable,"onUpdate:checked":i=>t.nullable=!i,class:"column-field-nullable"},{default:o(()=>[...c[29]||(c[29]=[x("必要",-1)])]),_:1},8,["checked","onUpdate:checked"]),l(s(K),{path:`columns[${u}].description`,"show-label":!1,class:"column-field-description"},{default:o(()=>[l(s(H),{value:t.description,"onUpdate:value":i=>t.description=i,placeholder:"列说明(可选)"},null,8,["value","onUpdate:value"])]),_:2},1032,["path"]),l(s(U),{type:"error",text:"",size:"small",onClick:i=>ye(u),class:"column-delete-btn"},{default:o(()=>[...c[30]||(c[30]=[x(" 删除 ",-1)])]),_:1},8,["onClick"])]))),128)),q.value.columns.length===0?(S(),T("div",Ra,[l(s(Me),{description:"暂无列,点击上方添加列按钮添加",size:"small"})])):ie("",!0)])])]),_:1}),e("div",Ea,[l(s(U),{size:"large",onClick:c[9]||(c[9]=t=>J.value=!1)},{default:o(()=>[...c[31]||(c[31]=[x(" 取消 ",-1)])]),_:1}),l(s(U),{type:"primary",size:"large",loading:N.value,onClick:ke},{default:o(()=>[...c[32]||(c[32]=[x(" 保存 ",-1)])]),_:1},8,["loading"])])]),_:1},8,["model"])]),_:1},8,["show"]),l(s(ge),{show:B.value,"onUpdate:show":c[13]||(c[13]=t=>B.value=t),preset:"card",bordered:!1,class:"edit-table-description-modal",style:{width:"90vw",maxWidth:"600px"}},{header:o(()=>{var t;return[e("div",Ha,[c[34]||(c[34]=e("div",{class:"modal-icon"},[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),e("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})])],-1)),e("div",null,[c[33]||(c[33]=e("h3",{class:"modal-title"}," 编辑表声明 ",-1)),e("p",La," 编辑表「"+Q((t=h.value)==null?void 0:t.name)+"」的描述信息 ",1)])])]}),default:o(()=>[l(s(Se),{ref:"editTableFormRef",class:"edit-table-form"},{default:o(()=>[l(s(K),{label:"表声明"},{default:o(()=>[l(s(H),{value:j.value,"onUpdate:value":c[11]||(c[11]=t=>j.value=t),placeholder:"表的用途说明",size:"large",type:"textarea",rows:4},null,8,["value"])]),_:1}),l(s(K),{label:"字段声明"},{default:o(()=>{var t,u;return[e("div",Fa,[(S(!0),T(he,null,be(((t=h.value)==null?void 0:t.columns)||[],i=>(S(),T("div",{key:i.name,class:"column-description-row"},[e("div",qa,[e("span",Ja,Q(i.name),1),l(P,{size:"tiny",type:fe(i.type),style:{"margin-left":"8px"}},{default:o(()=>[x(Q(i.type),1)]),_:2},1032,["type"])]),l(s(H),{value:R.value[i.name],"onUpdate:value":r=>R.value[i.name]=r,placeholder:`${i.name} 字段的说明(可选)`,size:"medium",clearable:""},null,8,["value","onUpdate:value","placeholder"])]))),128)),!((u=h.value)!=null&&u.columns)||h.value.columns.length===0?(S(),T("div",Wa,[l(s(Me),{description:"当前表没有字段",size:"small"})])):ie("",!0)])]}),_:1}),e("div",Ka,[l(s(U),{size:"large",onClick:c[12]||(c[12]=t=>B.value=!1)},{default:o(()=>[...c[35]||(c[35]=[x(" 取消 ",-1)])]),_:1}),l(s(U),{type:"primary",size:"large",loading:G.value,onClick:xe},{default:o(()=>[...c[36]||(c[36]=[x(" 保存 ",-1)])]),_:1},8,["loading"])])]),_:1},512)]),_:1},8,["show"])])}}}),Ga=Te(Za,[["__scopeId","data-v-c01436bb"]]),Ya={class:"interfaces-manager"},Qa={class:"pages-section"},Xa={class:"section-toolbar"},en={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"16px",height:"16px"}},tn={class:"functions-section"},an={class:"section-toolbar"},nn={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"16px",height:"16px"}},sn={class:"sdk-section"},ln={style:{"margin-top":"12px"}},on={style:{display:"flex","align-items":"center",gap:"12px"}},rn={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"24px",height:"24px"}},un={style:{display:"flex","justify-content":"flex-end",gap:"12px"}},dn={style:{display:"flex","align-items":"center",gap:"12px"}},cn={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"24px",height:"24px"}},vn={style:{"margin-top":"24px"}},pn={style:{display:"flex","justify-content":"space-between","align-items":"center","margin-bottom":"12px"}},fn={style:{display:"flex","justify-content":"space-between","margin-bottom":"8px"}},mn={style:{display:"grid","grid-template-columns":"repeat(4, 1fr)",gap:"12px"}},gn={class:"script-editor-section"},wn={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"16px",height:"16px"}},hn={key:0,class:"monaco-wrapper"},bn={style:{display:"flex","justify-content":"flex-end",gap:"12px"}},Fe=`/**
|
|
31
|
+
* 函数脚本
|
|
32
|
+
* @param args 函数参数对象 (类型根据 Schema 声明自动生成)
|
|
33
|
+
* @param context 上下文对象 (提供常用工具方法等)
|
|
34
|
+
*/
|
|
35
|
+
export default async function (args: ToolArgs, context: Context) {
|
|
36
|
+
const { log } = context;
|
|
37
|
+
|
|
38
|
+
log.info('函数执行中');
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
// 返回结果
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
`,yn=De({__name:"InterfacesManager",setup(ve){const $=_e(),z=gt(),y=He(),O=w([]),h=w([]),L=w("pages"),B=w([]),V=w(""),F=w(!1),N=w(null),G=w(!1),X=w(),A=w({name:"",description:"",content:""}),j={name:{required:!0,message:"请输入页面名称",trigger:"blur"},content:{required:!0,message:"请输入页面内容",trigger:"blur"}},R=w([]),Z=w(""),ee=w(!1),se=w(null),q=w(!1),k=w(),g=w("basic"),f=w({name:"",description:"",serverScript:Fe,parameters:[]}),J={name:{required:!0,message:"请输入函数名称",trigger:"blur"},description:{required:!0,message:"请输入函数描述",trigger:"blur"},serverScript:{required:!0,message:"请输入函数脚本",trigger:"blur"}},ue=[{label:"string",value:"string"},{label:"number",value:"number"},{label:"boolean",value:"boolean"},{label:"object",value:"object"},{label:"array",value:"array"}],ae=w("");async function ne(){try{const d=await E.get("/configs/all-tools");d.data.success&&d.data.data.tools?O.value=d.data.data.tools:O.value=[]}catch(d){console.error("Failed to load MCP tools:",d),O.value=[]}}async function oe(){try{const d=await E.get("/tables/definitions");d.data.success&&(h.value=d.data.data||[])}catch(d){console.error("Failed to load tables:",d),h.value=[]}}const de=te(()=>{const d=y.currentConfig;return d?ot({config:d,mcpTools:O.value,tables:h.value}):"declare interface Context {}"}),ce=te(()=>!f.value.parameters||f.value.parameters.length===0?`
|
|
45
|
+
/**
|
|
46
|
+
* 函数参数类型
|
|
47
|
+
*/
|
|
48
|
+
declare interface ToolArgs {
|
|
49
|
+
[key: string]: any;
|
|
50
|
+
}
|
|
51
|
+
`:`
|
|
52
|
+
/**
|
|
53
|
+
* 函数参数类型
|
|
54
|
+
* 根据 Schema 声明自动生成
|
|
55
|
+
*/
|
|
56
|
+
declare interface ToolArgs {
|
|
57
|
+
${f.value.parameters.filter(n=>n.name&&n.name.trim()).map(n=>{const v=n.name.trim(),le=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(v)?v:`"${v.replace(/"/g,'\\"')}"`,Ge=n.required?"":"?",Ye=n.description?`/** ${n.description.replace(/\*\//g,"* /")} */
|
|
58
|
+
`:"";let Ce="any";switch(n.type){case"string":Ce="string";break;case"number":Ce="number";break;case"boolean":Ce="boolean";break;case"object":Ce="Record<string, any>";break;case"array":Ce="any[]";break;default:Ce="any"}return`${Ye}${le}${Ge}: ${Ce};`}).join(`
|
|
59
|
+
`)}
|
|
60
|
+
}
|
|
61
|
+
`),me=te(()=>[{content:de.value,filePath:"file:///context.d.ts"},{content:ce.value,filePath:"file:///tool-args.d.ts"}]),ye=te(()=>"height: 500px; width: 100%; border-radius: 4px; overflow: hidden;");function ke(d){f.value.serverScript=d}const pe=te(()=>{const d=window.location.origin;return"<script"+' src="'+d+"/api/interfaces/sdk/"+ae.value+'">'+"<\/script>"}),re=te(()=>{const d="<script",n="<\/script>";if(R.value.length===0)return`<!-- 示例:调用函数 -->
|
|
62
|
+
<button onclick="callFunction()">调用函数</button>
|
|
63
|
+
`+d+`>
|
|
64
|
+
async function callFunction() {
|
|
65
|
+
try {
|
|
66
|
+
const result = await MCPSDK.myFunction('参数1', 123);
|
|
67
|
+
console.log('结果:', result);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.error('调用失败:', error);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
`+n;const v=R.value[0],W=v.parameters.map(le=>le.name).join(", ");return"<!-- 示例:调用函数 "+v.name+` -->
|
|
73
|
+
<button onclick="callFunction()">调用函数</button>
|
|
74
|
+
`+d+`>
|
|
75
|
+
async function callFunction() {
|
|
76
|
+
try {
|
|
77
|
+
const result = await MCPSDK.`+v.name+"("+W+`);
|
|
78
|
+
console.log('结果:', result);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error('调用失败:', error);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
`+n}),fe=te(()=>{if(!V.value)return B.value;const d=V.value.toLowerCase();return B.value.filter(n=>n.name.toLowerCase().includes(d)||n.description&&n.description.toLowerCase().includes(d))}),xe=[{title:"页面名称",key:"name",width:200},{title:"描述",key:"description",width:300},{title:"操作",key:"actions",width:250,render:d=>I("div",{style:"display: flex; gap: 8px;"},[I(U,{size:"small",type:"primary",onClick:n=>{n.stopPropagation(),u(d)}},{default:()=>"打开"}),I(U,{size:"small",onClick:n=>{n.stopPropagation(),i(d)}},{default:()=>"编辑"}),I(U,{size:"small",type:"error",onClick:n=>{n.stopPropagation(),a(d)}},{default:()=>"删除"})])}],M=d=>({style:{cursor:"pointer"},onClick:()=>u(d)}),c=te(()=>{if(!Z.value)return R.value;const d=Z.value.toLowerCase();return R.value.filter(n=>n.name.toLowerCase().includes(d)||n.description.toLowerCase().includes(d))}),P=[{title:"函数名称",key:"name",width:200},{title:"描述",key:"description",width:300},{title:"参数",key:"parameters",render:d=>d.parameters.map(n=>`${n.name}: ${n.type}`).join(", ")||"无"},{title:"操作",key:"actions",width:200,render:d=>I("div",{style:"display: flex; gap: 8px;"},[I(U,{size:"small",onClick:()=>b(d)},{default:()=>"编辑"}),I(U,{size:"small",type:"error",onClick:()=>D(d)},{default:()=>"删除"})])}],Y=d=>({style:{cursor:"pointer"},onClick:()=>b(d)});async function p(){var d,n;try{const v=await E.get("/interfaces/pages");v.data.success&&(B.value=v.data.data)}catch(v){$.error("加载页面列表失败: "+(((n=(d=v.response)==null?void 0:d.data)==null?void 0:n.error)||v.message))}}function t(){return{name:"",type:"string",description:"",required:!1}}function u(d){if(!ae.value){$.warning("用户信息未加载,请稍后再试"),C().then(()=>{if(ae.value){const le=`${window.location.origin}/api/interfaces/page/${ae.value}/${d.id}`;window.open(le,"_blank")}else $.error("无法获取用户信息")});return}if(!d||!d.id){$.error("页面信息不完整");return}const v=`${window.location.origin}/api/interfaces/page/${ae.value}/${d.id}`;console.log("打开页面:",v),window.open(v,"_blank")}function i(d){N.value=d,A.value={name:d.name,description:d.description||"",content:d.content},F.value=!0}async function r(){X.value&&await X.value.validate(async d=>{var n,v;if(!d){G.value=!0;try{N.value?(await E.put(`/interfaces/pages/${N.value.id}`,A.value),$.success("更新成功")):(await E.post("/interfaces/pages",A.value),$.success("创建成功")),F.value=!1,N.value=null,A.value={name:"",description:"",content:""},await p()}catch(W){$.error("保存失败: "+(((v=(n=W.response)==null?void 0:n.data)==null?void 0:v.error)||W.message))}finally{G.value=!1}}})}function a(d){z.warning({title:"确认删除",content:`确定要删除页面 "${d.name}" 吗?`,positiveText:"删除",negativeText:"取消",onPositiveClick:async()=>{var n,v;try{await E.delete(`/interfaces/pages/${d.id}`),$.success("删除成功"),await p()}catch(W){$.error("删除失败: "+(((v=(n=W.response)==null?void 0:n.data)==null?void 0:v.error)||W.message))}}})}async function m(){var d,n;try{const v=await E.get("/interfaces/functions");v.data.success&&(R.value=v.data.data)}catch(v){$.error("加载函数列表失败: "+(((n=(d=v.response)==null?void 0:d.data)==null?void 0:n.error)||v.message))}}function b(d){se.value=d,f.value={name:d.name,description:d.description,serverScript:d.serverScript||Fe,parameters:JSON.parse(JSON.stringify(d.parameters))},g.value="basic",ee.value=!0}async function _(){k.value&&await k.value.validate(async d=>{var n,v;if(!d){if(!f.value.serverScript){$.error("请输入函数脚本");return}q.value=!0;try{const W={name:f.value.name,description:f.value.description,serverScript:f.value.serverScript,parameters:f.value.parameters.filter(le=>le.name)};se.value?(await E.put(`/interfaces/functions/${se.value.id}`,W),$.success("更新成功")):(await E.post("/interfaces/functions",W),$.success("创建成功")),ee.value=!1,se.value=null,f.value={name:"",description:"",serverScript:"",parameters:[]},await m()}catch(W){$.error("保存失败: "+(((v=(n=W.response)==null?void 0:n.data)==null?void 0:v.error)||W.message))}finally{q.value=!1}}})}function D(d){z.warning({title:"确认删除",content:`确定要删除函数 "${d.name}" 吗?`,positiveText:"删除",negativeText:"取消",onPositiveClick:async()=>{var n,v;try{await E.delete(`/interfaces/functions/${d.id}`),$.success("删除成功"),await m()}catch(W){$.error("删除失败: "+(((v=(n=W.response)==null?void 0:n.data)==null?void 0:v.error)||W.message))}}})}async function C(){var d,n;try{const v=await E.get("/interfaces/user-hash");v.data.success?(ae.value=v.data.data.userHash,console.log("用户hash加载成功:",ae.value)):(console.error("获取用户hash失败:",v.data.error),$.error("获取用户信息失败: "+(v.data.error||"未知错误")))}catch(v){console.error("获取用户hash失败:",v),$.error("获取用户信息失败: "+(((n=(d=v.response)==null?void 0:d.data)==null?void 0:n.error)||v.message))}}return $e(()=>ee.value,async d=>{d&&(await Oe(),await ne(),await oe(),y.currentConfig||(await y.fetchConfig(),await ne(),await oe()))}),Ie(()=>{p(),m(),C(),y.currentConfig?(ne(),oe()):y.fetchConfig().then(()=>{ne(),oe()})}),(d,n)=>(S(),T("div",Ya,[l(s(Be),{value:L.value,"onUpdate:value":n[4]||(n[4]=v=>L.value=v),type:"line",animated:"",size:"large"},{default:o(()=>[l(s(we),{name:"pages",tab:"页面管理"},{default:o(()=>[e("div",Qa,[e("div",Xa,[l(s(U),{type:"primary",size:"large",onClick:n[0]||(n[0]=v=>F.value=!0)},{icon:o(()=>[...n[17]||(n[17]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:o(()=>[n[18]||(n[18]=x(" 创建页面 ",-1))]),_:1}),l(s(H),{value:V.value,"onUpdate:value":n[1]||(n[1]=v=>V.value=v),placeholder:"搜索页面...",size:"large",clearable:"",style:{"max-width":"300px"}},{prefix:o(()=>[(S(),T("svg",en,[...n[19]||(n[19]=[e("path",{d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])]))]),_:1},8,["value"])]),l(s(je),{columns:xe,data:fe.value,pagination:!1,"row-props":M,class:"modern-table"},null,8,["data"])])]),_:1}),l(s(we),{name:"functions",tab:"函数管理"},{default:o(()=>[e("div",tn,[e("div",an,[l(s(U),{type:"primary",size:"large",onClick:n[2]||(n[2]=v=>ee.value=!0)},{icon:o(()=>[...n[20]||(n[20]=[e("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[e("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:o(()=>[n[21]||(n[21]=x(" 创建函数 ",-1))]),_:1}),l(s(H),{value:Z.value,"onUpdate:value":n[3]||(n[3]=v=>Z.value=v),placeholder:"搜索函数...",size:"large",clearable:"",style:{"max-width":"300px"}},{prefix:o(()=>[(S(),T("svg",nn,[...n[22]||(n[22]=[e("path",{d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])]))]),_:1},8,["value"])]),l(s(je),{columns:P,data:c.value,pagination:!1,"row-props":Y,class:"modern-table"},null,8,["data"])])]),_:1}),l(s(we),{name:"sdk",tab:"SDK信息"},{default:o(()=>[e("div",sn,[l(s(Pe),{type:"info",bordered:!1,style:{"margin-bottom":"24px"}},{header:o(()=>[...n[23]||(n[23]=[e("strong",null,"SDK使用说明",-1)])]),default:o(()=>[e("div",ln,[n[24]||(n[24]=e("p",null,"在页面中引入以下脚本即可使用SDK调用您创建的函数:",-1)),l(s(Le),{code:pe.value,language:"html",style:{margin:"12px 0"}},null,8,["code"]),n[25]||(n[25]=e("p",{style:{"margin-top":"12px"}},"使用示例:",-1)),l(s(Le),{code:re.value,language:"html",style:{margin:"12px 0"}},null,8,["code"])])]),_:1})])]),_:1})]),_:1},8,["value"]),l(s(ge),{show:F.value,"onUpdate:show":n[9]||(n[9]=v=>F.value=v),preset:"card",bordered:!1,style:{width:"90vw","max-width":"1200px","max-height":"90vh"}},{header:o(()=>[e("div",on,[(S(),T("svg",rn,[...n[26]||(n[26]=[e("path",{d:"M8 9l3 3-3 3m5 0h3M5 20h14a1 1 0 001-1V5a1 1 0 00-1-1H5a1 1 0 00-1 1v14a1 1 0 001 1z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])),e("span",null,Q(N.value?"编辑页面":"创建页面"),1)])]),footer:o(()=>[e("div",un,[l(s(U),{onClick:n[8]||(n[8]=v=>F.value=!1)},{default:o(()=>[...n[27]||(n[27]=[x("取消",-1)])]),_:1}),l(s(U),{type:"primary",onClick:r,loading:G.value},{default:o(()=>[...n[28]||(n[28]=[x("保存",-1)])]),_:1},8,["loading"])])]),default:o(()=>[l(s(Se),{ref_key:"pageFormRef",ref:X,model:A.value,rules:j},{default:o(()=>[l(s(K),{label:"页面名称",path:"name"},{default:o(()=>[l(s(H),{value:A.value.name,"onUpdate:value":n[5]||(n[5]=v=>A.value.name=v),placeholder:"例如: my-page",size:"large"},null,8,["value"])]),_:1}),l(s(K),{label:"页面描述",path:"description"},{default:o(()=>[l(s(H),{value:A.value.description,"onUpdate:value":n[6]||(n[6]=v=>A.value.description=v),placeholder:"页面描述",size:"large"},null,8,["value"])]),_:1}),l(s(K),{label:"页面内容",path:"content"},{default:o(()=>[l(s(H),{value:A.value.content,"onUpdate:value":n[7]||(n[7]=v=>A.value.content=v),type:"textarea",placeholder:'HTML内容,记得引入SDK脚本:<script src="SDK_URL"><\/script>',rows:15,size:"large"},null,8,["value"])]),_:1})]),_:1},8,["model"])]),_:1},8,["show"]),l(s(ge),{show:ee.value,"onUpdate:show":n[16]||(n[16]=v=>ee.value=v),preset:"card",bordered:!1,style:{width:"90vw","max-width":"1400px","max-height":"90vh"}},{header:o(()=>[e("div",dn,[(S(),T("svg",cn,[...n[29]||(n[29]=[e("path",{d:"M14.7 6.3a1 1 0 000 1.4l1.6 1.6a1 1 0 001.4 0l3.77-3.77a6 6 0 01-7.94 7.94l-6.91 6.91a2.12 2.12 0 01-3-3l6.91-6.91a6 6 0 017.94-7.94l-3.76 3.76z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])),e("span",null,Q(se.value?"编辑函数":"创建函数"),1)])]),footer:o(()=>[e("div",bn,[l(s(U),{onClick:n[15]||(n[15]=v=>ee.value=!1)},{default:o(()=>[...n[36]||(n[36]=[x("取消",-1)])]),_:1}),l(s(U),{type:"primary",onClick:_,loading:q.value},{default:o(()=>[...n[37]||(n[37]=[x("保存",-1)])]),_:1},8,["loading"])])]),default:o(()=>[l(s(Be),{value:g.value,"onUpdate:value":n[14]||(n[14]=v=>g.value=v),type:"line",animated:""},{default:o(()=>[l(s(we),{name:"basic",tab:"基础信息"},{default:o(()=>[l(s(Se),{ref_key:"functionFormRef",ref:k,model:f.value,rules:J},{default:o(()=>[l(s(K),{label:"函数名称",path:"name"},{default:o(()=>[l(s(H),{value:f.value.name,"onUpdate:value":n[10]||(n[10]=v=>f.value.name=v),placeholder:"例如: myFunction",size:"large"},null,8,["value"])]),_:1}),l(s(K),{label:"函数描述",path:"description"},{default:o(()=>[l(s(H),{value:f.value.description,"onUpdate:value":n[11]||(n[11]=v=>f.value.description=v),placeholder:"函数描述",size:"large"},null,8,["value"])]),_:1})]),_:1},8,["model"]),e("div",vn,[e("div",pn,[n[31]||(n[31]=e("h4",null,"参数定义",-1)),l(s(U),{dashed:"",onClick:n[12]||(n[12]=v=>f.value.parameters.push(t())),size:"medium"},{default:o(()=>[...n[30]||(n[30]=[x("添加参数",-1)])]),_:1})]),(S(!0),T(he,null,be(f.value.parameters,(v,W)=>(S(),T("div",{key:W,style:{"margin-bottom":"12px",padding:"12px",border:"1px solid #e0e0e0","border-radius":"4px"}},[e("div",fn,[e("span",null,"参数 #"+Q(W+1),1),l(s(U),{type:"error",text:"",size:"small",onClick:le=>f.value.parameters.splice(W,1)},{default:o(()=>[...n[32]||(n[32]=[x("删除",-1)])]),_:1},8,["onClick"])]),e("div",mn,[l(s(Ne),{checked:v.required,"onUpdate:checked":le=>v.required=le},{default:o(()=>[...n[33]||(n[33]=[x("必填",-1)])]),_:1},8,["checked","onUpdate:checked"]),l(s(H),{value:v.name,"onUpdate:value":le=>v.name=le,placeholder:"参数名"},null,8,["value","onUpdate:value"]),l(s(Ve),{value:v.type,"onUpdate:value":le=>v.type=le,options:ue,placeholder:"类型"},null,8,["value","onUpdate:value"]),l(s(H),{value:v.description,"onUpdate:value":le=>v.description=le,placeholder:"描述"},null,8,["value","onUpdate:value"])])]))),128))])]),_:1}),l(s(we),{name:"script",tab:"函数实现"},{default:o(()=>[e("div",gn,[l(s(Pe),{type:"info",bordered:!1,style:{"margin-bottom":"16px"}},{icon:o(()=>[(S(),T("svg",wn,[...n[34]||(n[34]=[e("path",{d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])]))]),default:o(()=>[n[35]||(n[35]=x(" 在函数实现中可以使用 args 和 context 参数,类型定义已自动生成 ",-1))]),_:1}),l(s(K),{label:"函数脚本"},{default:o(()=>{var v;return[ee.value&&g.value==="script"?(S(),T("div",hn,[(S(),ze(Je,{key:`function-editor-${((v=se.value)==null?void 0:v.id)||"new"}-${g.value}`,modelValue:f.value.serverScript,"onUpdate:modelValue":n[13]||(n[13]=W=>f.value.serverScript=W),language:"typescript",options:{minimap:{enabled:!0},fontSize:14,lineHeight:22,padding:{top:16,bottom:16},scrollBeyondLastLine:!1,automaticLayout:!0},"extra-libs":me.value,style:et(ye.value),onChange:ke},null,8,["modelValue","extra-libs","style"]))])):ie("",!0)]}),_:1})])]),_:1})]),_:1},8,["value"])]),_:1},8,["show"])]))}}),kn=Te(yn,[["__scopeId","data-v-162a021f"]]),xn={class:"dashboard-container"},Cn={style:{position:"absolute",width:"0",height:"0"}},$n={key:0,class:"loading-state"},Sn={key:1,class:"dashboard-content"},Mn=De({__name:"Dashboard",setup(ve){const $=_e(),z=He(),y=We(),O=tt(),h=nt(),L=w(O.query.section||"components"),B=te(()=>z.currentConfig),V=te(()=>z.loading),F=te(()=>{var k;return((k=y.user)==null?void 0:k.role)==="admin"}),N=["variables","tables"],G={components:ut,tools:it,variables:xt,init:rt,tables:Ga,prompts:sa,interfaces:kn},X=te(()=>G[L.value]);async function A(){try{await z.fetchConfig(),dt().catch(k=>{console.warn("Monaco Editor 预加载失败:",k)})}catch(k){$.error(k.message)}}function j(k,g){let f=null;return(...J)=>{f&&clearTimeout(f),f=setTimeout(()=>{k(...J)},g)}}const R=w(!1);let Z=null;const ee=j(async k=>{if(!(!B.value||R.value)){Z=JSON.parse(JSON.stringify(B.value));try{R.value=!0,B.value&&Object.assign(B.value,k),await z.updateConfig(k),$.success("更新成功")}catch(g){Z&&B.value&&Object.assign(B.value,Z),$.error(g.message)}finally{R.value=!1}}},500);async function se(k){B.value&&ee(k)}function q(k){return F.value&&N.includes(k)?($.warning("超级管理员不允许访问此功能"),h.replace({name:"UserDashboard",query:{section:"components"}}),L.value="components",!0):!1}return $e(()=>O.query.section,k=>{if(!k)return;const g=k;q(g)||(L.value=g)},{immediate:!0}),Ie(()=>{const k=O.query.section;q(k),A()}),(k,g)=>(S(),T("div",xn,[(S(),T("svg",Cn,[...g[0]||(g[0]=[e("defs",null,[e("linearGradient",{id:"loading-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%"},[e("stop",{offset:"0%","stop-color":"#6366f1"}),e("stop",{offset:"50%","stop-color":"#8b5cf6"}),e("stop",{offset:"100%","stop-color":"#ec4899"})])],-1)])])),V.value&&!B.value?(S(),T("div",$n,[...g[1]||(g[1]=[e("div",{class:"loading-spinner"},[e("svg",{class:"spinner",viewBox:"0 0 50 50"},[e("circle",{class:"path",cx:"25",cy:"25",r:"20",fill:"none","stroke-width":"4"})])],-1),e("p",{class:"loading-text"},"加载配置中...",-1)])])):B.value?(S(),T("div",Sn,[(S(),ze(at(X.value),{config:B.value,onUpdate:se},null,40,["config"]))])):ie("",!0)]))}}),In=Te(Mn,[["__scopeId","data-v-2a3a6272"]]);export{In as default};
|