flex-mcp 1.0.3 → 1.0.4

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.
Files changed (34) hide show
  1. package/dist/api/configs.d.ts.map +1 -1
  2. package/dist/api/configs.js +26 -199
  3. package/dist/api/configs.js.map +1 -1
  4. package/dist/api/prompts.d.ts.map +1 -1
  5. package/dist/api/prompts.js +1 -58
  6. package/dist/api/prompts.js.map +1 -1
  7. package/dist/mcp/aggregator.d.ts +5 -1
  8. package/dist/mcp/aggregator.d.ts.map +1 -1
  9. package/dist/mcp/aggregator.js +33 -37
  10. package/dist/mcp/aggregator.js.map +1 -1
  11. package/dist/script/context.d.ts +1 -1
  12. package/dist/script/context.d.ts.map +1 -1
  13. package/dist/script/context.js +5 -1
  14. package/dist/script/context.js.map +1 -1
  15. package/dist/script/executor.d.ts +9 -0
  16. package/dist/script/executor.d.ts.map +1 -1
  17. package/dist/script/executor.js +19 -1
  18. package/dist/script/executor.js.map +1 -1
  19. package/dist/web/assets/{Blank-s8a1VcBP.js → Blank-BerVeAls.js} +1 -1
  20. package/dist/web/assets/Configs-BZ4p1nld.js +1 -0
  21. package/dist/web/assets/Dashboard-DVSQDspm.js +27 -0
  22. package/dist/web/assets/{InitScriptEditor-CyQQvKeL.js → InitScriptEditor-DlF0Jn7f.js} +16 -12
  23. package/dist/web/assets/{Layout-C1hga5lx.js → Layout-Br6VMRob.js} +1 -1
  24. package/dist/web/assets/{Layout-BkmH4NiL.js → Layout-SLPXm-dk.js} +1 -1
  25. package/dist/web/assets/{Login-Dbjg2uN-.js → Login-Cm10QZJ1.js} +1 -1
  26. package/dist/web/assets/{Login-DflsSakB.js → Login-Cn9EfrvS.js} +1 -1
  27. package/dist/web/assets/Users-Dj8FIlX1.js +1 -0
  28. package/dist/web/assets/{index-Coivokd4.js → index-Dy8wTpRZ.js} +3 -3
  29. package/dist/web/assets/{style-DkqnAI3H.css → style-0VyF1s_q.css} +1 -1
  30. package/dist/web/index.html +2 -2
  31. package/package.json +1 -1
  32. package/dist/web/assets/Configs-Du0LnEIl.js +0 -1
  33. package/dist/web/assets/Dashboard-DBtv2jAX.js +0 -27
  34. package/dist/web/assets/Users-DKoYWDA0.js +0 -1
@@ -0,0 +1,27 @@
1
+ import{d as Ce,u as $e,r as m,p as se,A as Se,c as y,b as a,f as o,w as n,g as l,B as S,k as F,C as je,D as de,o as h,h as b,N as xe,j as W,E as _e,n as N,G as ke,H as Be,I as ze,J as X,K as Ae,L as Me,m as ee,F as pe,s as fe,t as K,M as Re,O as Te,x as Ue,y as ye,P as He,Q as Ne,R as Oe,S as Ve,U as Le,V as me,W as Pe,X as Je,Y as qe,Z as Ie,_ as Fe,v as We,a as Ke,q as Ye,z as Ge,i as Qe}from"./index-Dy8wTpRZ.js";import{g as Xe,p as Ze,_ as et,u as Ee,I as tt,C as at,M as st}from"./InitScriptEditor-DlF0Jn7f.js";import{_ as De}from"./_plugin-vue_export-helper-DlAUqK2U.js";const lt={class:"variables-manager"},nt={class:"variables-toolbar"},ot={class:"variables-table-container"},rt={class:"modal-form-wrapper"},it=Ce({__name:"VariablesManager",props:{config:{}},emits:["update"],setup(le,{emit:D}){const f=le,p=D,B=$e(),v=m(!1),E=m(!1),M=m(null),L=m(),H=m(""),z={pageSize:10,showSizePicker:!0,pageSizes:[10,20,50]},G=$=>({style:"cursor: pointer; transition: all 0.2s ease;",onMouseenter:u=>{u.currentTarget.style.backgroundColor="rgba(99, 102, 241, 0.04)"},onMouseleave:u=>{u.currentTarget.style.backgroundColor=""}}),O=[{title:"变量名",key:"name",width:100,render($){return N("strong",$.name)}},{title:"值",key:"value",width:500,render($){if($.isSecret)return N(ke,{type:"info",depth:3,italic:!0},{default:()=>"****** (敏感信息)"});const u=String($.value).split(`
2
+ `).map((k,Q,ne)=>{const te=[N("span",{class:"value-line"},k)];return Q<ne.length-1&&te.push(N("br")),te}).flat();return N("div",{class:"variable-value-cell"},u)}},{title:"描述",key:"description",width:300,render($){return N(ke,{depth:3},{default:()=>$.description||"-"})}},{title:"操作",key:"actions",width:150,render($){return N(Be,{size:"small"},{default:()=>[N(S,{size:"small",onClick:()=>A($)},{default:()=>"编辑"}),N(S,{size:"small",type:"error",onClick:()=>J($.id)},{default:()=>"删除"})]})}}],j=se(()=>{if(!H.value)return f.config.variables;const $=H.value.toLowerCase();return f.config.variables.filter(u=>{var k;return u.name.toLowerCase().includes($)||((k=u.description)==null?void 0:k.toLowerCase().includes($))})}),x=m({name:"",value:"",description:"",isSecret:!1}),P={name:{required:!0,message:"请输入变量名",trigger:"blur"},value:{required:!0,message:"请输入变量值",trigger:"blur"}};function A($){M.value=$,x.value={name:$.name,value:$.value,description:$.description||"",isSecret:$.isSecret||!1},v.value=!0}function J($){const u=f.config.variables.filter(k=>k.id!==$);p("update",{variables:u})}async function ve(){var $,u;try{await(($=L.value)==null?void 0:$.validate()),E.value=!0;const k={id:((u=M.value)==null?void 0:u.id)||Xe(),name:x.value.name,value:x.value.value,description:x.value.description||void 0,isSecret:x.value.isSecret},Q=[...f.config.variables],ne=Q.findIndex(te=>te.id===k.id);ne!==-1?Q[ne]=k:Q.push(k),p("update",{variables:Q}),v.value=!1,q()}catch(k){B.error(k.message)}finally{E.value=!1}}function q(){M.value=null,x.value={name:"",value:"",description:"",isSecret:!1}}return Se(()=>v.value,$=>{$||q()}),($,u)=>(h(),y("div",lt,[a("div",nt,[o(l(S),{type:"primary",size:"large",class:"add-variable-btn",onClick:u[0]||(u[0]=k=>v.value=!0)},{icon:n(()=>[...u[8]||(u[8]=[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:n(()=>[u[9]||(u[9]=b(" 添加变量 ",-1))]),_:1}),o(l(F),{value:H.value,"onUpdate:value":u[1]||(u[1]=k=>H.value=k),placeholder:"搜索变量名或描述...",size:"large",clearable:"",class:"search-input"},{prefix:n(()=>[...u[10]||(u[10]=[a("svg",{class:"search-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("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"])]),a("div",ot,[o(l(je),{columns:O,data:j.value,pagination:z,"row-props":G,class:"modern-table"},null,8,["data"])]),o(l(de),{show:v.value,"onUpdate:show":u[7]||(u[7]=k=>v.value=k),preset:"dialog",title:M.value?"编辑变量":"添加变量",class:"variable-edit-modal",style:{maxHeight:"90vh"}},{action:n(()=>[o(l(S),{onClick:u[6]||(u[6]=k=>v.value=!1)},{default:n(()=>[...u[12]||(u[12]=[b("取消",-1)])]),_:1}),o(l(S),{type:"primary",loading:E.value,onClick:ve},{default:n(()=>[...u[13]||(u[13]=[b("保存",-1)])]),_:1},8,["loading"])]),default:n(()=>[a("div",rt,[o(l(xe),{ref_key:"formRef",ref:L,model:x.value,rules:P},{default:n(()=>[o(l(W),{path:"name",label:"变量名"},{default:n(()=>[o(l(F),{value:x.value.name,"onUpdate:value":u[2]||(u[2]=k=>x.value.name=k),placeholder:"例如: API_KEY"},null,8,["value"])]),_:1}),o(l(W),{path:"value",label:"值"},{default:n(()=>[o(l(F),{value:x.value.value,"onUpdate:value":u[3]||(u[3]=k=>x.value.value=k),type:x.value.isSecret?"password":"textarea",rows:x.value.isSecret?void 0:3,placeholder:"变量值"},null,8,["value","type","rows"])]),_:1}),o(l(W),{path:"description",label:"描述"},{default:n(()=>[o(l(F),{value:x.value.description,"onUpdate:value":u[4]||(u[4]=k=>x.value.description=k),type:"textarea",rows:2,placeholder:"可选"},null,8,["value"])]),_:1}),o(l(W),{path:"isSecret",label:"敏感信息"},{default:n(()=>[o(l(_e),{checked:x.value.isSecret,"onUpdate:checked":u[5]||(u[5]=k=>x.value.isSecret=k)},{default:n(()=>[...u[11]||(u[11]=[b("标记为敏感信息(导出时使用占位符)",-1)])]),_:1},8,["checked"])]),_:1})]),_:1},8,["model"])])]),_:1},8,["show","title"])]))}}),ut=De(it,[["__scopeId","data-v-f50b6ccd"]]),dt={class:"prompts-manager"},vt={class:"prompts-toolbar"},ct={class:"prompts-table-container"},pt={class:"modal-header"},ft={class:"modal-title"},mt={class:"modal-subtitle"},gt={class:"modal-content-wrapper"},wt={class:"tab-pane-content"},ht={class:"form-section"},bt={class:"form-grid-2"},kt={class:"form-section"},yt={class:"section-header"},xt={class:"parameters-list"},Ct={class:"parameter-header"},$t={class:"parameter-index"},St={class:"parameter-fields"},Dt={key:0,class:"empty-parameters"},Mt={class:"tab-pane-content"},_t={style:{display:"flex","align-items":"center",gap:"8px"}},zt={viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{width:"18px",height:"18px"}},Tt={class:"messages-section"},Ut={class:"message-header"},Nt={class:"save-status-indicator"},jt=["title"],It={key:0,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Bt={key:1,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},At={key:0,class:"monaco-wrapper"},Vt={key:0,class:"empty-messages"},Et={class:"modal-footer"},Rt={class:"test-content"},Ht={class:"test-messages"},Ot={class:"test-message-header"},Lt={class:"test-message-content"},Pt={key:0,class:"test-message-empty"},Jt=Ce({__name:"PromptsManager",setup(le){const D=$e(),f=m(!1),p=m(!1),B=m(!1),v=m(!1),E=m(!1),M=m(null),L=m(),H=m(""),z=m([]),G=m("content"),O=m(!1),j=m(-1),x=m(new Map),P=m(!1),A=[{label:"用户",value:"user"},{label:"助手",value:"assistant"}],J={pageSize:10,showSizePicker:!0,pageSizes:[10,20,50]},ve=d=>({style:"cursor: pointer; transition: all 0.2s ease;",onMouseenter:t=>{t.currentTarget.style.backgroundColor="rgba(99, 102, 241, 0.04)"},onMouseleave:t=>{t.currentTarget.style.backgroundColor=""}}),q=[{title:"名称",key:"name",width:200,render(d){return N("strong",d.name)}},{title:"描述",key:"description",render(d){return N(ke,{depth:3},{default:()=>d.description||"-"})}},{title:"参数数量",key:"arguments",width:120,render(d){return N(ke,{depth:3},{default:()=>{var t;return`${((t=d.arguments)==null?void 0:t.length)||0} 个`}})}},{title:"消息数量",key:"messages",width:120,render(d){return N(ke,{depth:3},{default:()=>{var t;return`${((t=d.messages)==null?void 0:t.length)||0} 条`}})}},{title:"操作",key:"actions",width:200,render(d){return N(Be,{size:"small"},{default:()=>[N(S,{size:"small",onClick:()=>ie(d)},{default:()=>"编辑"}),N(S,{size:"small",type:"info",onClick:()=>r(d)},{default:()=>"测试"}),N(S,{size:"small",type:"error",onClick:()=>ge(d.id)},{default:()=>"删除"})]})}}],$=se(()=>{if(!H.value)return z.value;const d=H.value.toLowerCase();return z.value.filter(t=>{var e;return t.name.toLowerCase().includes(d)||((e=t.description)==null?void 0:e.toLowerCase().includes(d))})}),u=m({name:"",description:"",arguments:[],messages:[]}),k=m({arguments:{}}),Q=se(()=>!p.value||!u.value.messages||u.value.messages.length===0?[]:u.value.messages.filter(t=>t.content.text).map(t=>({...t,content:{...t.content,text:Ze(t.content.text,k.value.arguments)}}))),ne={name:{required:!0,message:"请输入提示词名称",trigger:"blur"},messages:{required:!0,validator:(d,t)=>!t||t.length===0?new Error("至少需要一条消息"):!0,trigger:"blur"}};function te(d){return x.value.get(d)||!1}function ae(d){x.value.set(d,!0)}function re(d){O.value&&j.value===d?(O.value=!1,j.value=-1):(O.value=!0,j.value=d)}async function Z(){var d,t;try{E.value=!0;const e=await X.get("/prompts");e.data.success&&(z.value=e.data.data)}catch(e){D.error(((t=(d=e.response)==null?void 0:d.data)==null?void 0:t.error)||"加载提示词失败")}finally{E.value=!1}}function ce(){M.value=null,_(),f.value=!0,G.value="content"}function ie(d){M.value=d,u.value={name:d.name,description:d.description||"",arguments:d.arguments?[...d.arguments]:[],messages:d.messages&&d.messages.length>0?[...d.messages]:[{role:"user",content:{type:"text",text:""}}]},x.value.clear(),f.value=!0,G.value="content"}async function ge(d){var t,e;try{await X.delete(`/prompts/${d}`),D.success("删除成功"),await Z()}catch(s){D.error(((e=(t=s.response)==null?void 0:t.data)==null?void 0:e.error)||"删除失败")}}function we(){u.value.arguments.push({name:"",description:"",required:!1})}function oe(d){u.value.arguments.splice(d,1)}function he(){u.value.messages.push({role:"user",content:{type:"text",text:""}}),ae(u.value.messages.length-1)}function ue(d){u.value.messages.splice(d,1),x.value.delete(d),j.value===d?(O.value=!1,j.value=-1):j.value>d&&j.value--}async function be(){var d,t,e;try{await((d=L.value)==null?void 0:d.validate()),B.value=!0;const s={name:u.value.name,description:u.value.description||void 0,arguments:u.value.arguments.filter(i=>i.name),messages:u.value.messages.filter(i=>i.content.text)};M.value?(await X.put(`/prompts/${M.value.id}`,s),D.success("更新成功")):(await X.post("/prompts",s),D.success("创建成功")),x.value.clear(),f.value=!1,await Z(),_()}catch(s){D.error(((e=(t=s.response)==null?void 0:t.data)==null?void 0:e.error)||"保存失败")}finally{B.value=!1}}async function g(){var d,t,e;try{await((d=L.value)==null?void 0:d.validate()),v.value=!0;const s=u.value.arguments.filter(i=>i.name);k.value.arguments=s.reduce((i,U)=>(i[U.name]=k.value.arguments[U.name]||"",i),{}),p.value=!0}catch(s){D.error(((e=(t=s.response)==null?void 0:t.data)==null?void 0:e.error)||"测试失败")}finally{v.value=!1}}async function r(d){M.value=d,u.value={name:d.name,description:d.description||"",arguments:d.arguments?[...d.arguments]:[],messages:d.messages?[...d.messages]:[]};const t=u.value.arguments.filter(e=>e.name);k.value.arguments=t.reduce((e,s)=>(e[s.name]="",e),{}),await g()}function _(){M.value=null,u.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}}`}}]},k.value.arguments={},x.value.clear(),O.value=!1,j.value=-1,P.value=!1}return Se(()=>f.value,async d=>{d?(await Oe(),await new Promise(t=>setTimeout(t,150)),P.value=!0):(_(),P.value=!1)}),ze(()=>{Z()}),(d,t)=>(h(),y("div",dt,[a("div",vt,[o(l(S),{type:"primary",size:"large",class:"add-prompt-btn",onClick:ce},{icon:n(()=>[...t[8]||(t[8]=[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:n(()=>[t[9]||(t[9]=b(" 添加提示词 ",-1))]),_:1}),o(l(F),{value:H.value,"onUpdate:value":t[0]||(t[0]=e=>H.value=e),placeholder:"搜索提示词名称或描述...",size:"large",clearable:"",class:"search-input"},{prefix:n(()=>[...t[10]||(t[10]=[a("svg",{class:"search-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("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"])]),a("div",ct,[o(l(je),{columns:q,data:$.value,pagination:J,"row-props":ve,loading:E.value,class:"modern-table"},null,8,["data","loading"])]),o(l(de),{show:f.value,"onUpdate:show":t[5]||(t[5]=e=>f.value=e),preset:"card",bordered:!1,class:"prompt-edit-modal",style:{width:"90vw",maxWidth:"1400px",height:"90vh",maxHeight:"90vh"}},{header:n(()=>[a("div",pt,[t[11]||(t[11]=a("div",{class:"modal-icon"},[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("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"}),a("path",{d:"M14 2v6h6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),a("path",{d:"M16 13H8",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"}),a("path",{d:"M16 17H8",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"}),a("path",{d:"M10 9H8",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})])],-1)),a("div",null,[a("h3",ft,K(M.value?"编辑提示词":"创建提示词"),1),a("p",mt,K(M.value?"修改提示词的内容和参数":"定义提示词模板和参数"),1)])])]),footer:n(()=>[a("div",Et,[o(l(S),{size:"large",onClick:t[4]||(t[4]=e=>f.value=!1)},{default:n(()=>[...t[30]||(t[30]=[b("取消",-1)])]),_:1}),o(l(S),{type:"info",size:"large",onClick:g,loading:v.value},{default:n(()=>[...t[31]||(t[31]=[b("测试",-1)])]),_:1},8,["loading"]),o(l(S),{type:"primary",size:"large",loading:B.value,onClick:be},{default:n(()=>[b(K(M.value?"保存修改":"创建提示词"),1)]),_:1},8,["loading"])])]),default:n(()=>[a("div",gt,[o(l(xe),{ref_key:"formRef",ref:L,model:u.value,rules:ne,class:"prompt-form"},{default:n(()=>[o(l(Ae),{value:G.value,"onUpdate:value":t[3]||(t[3]=e=>G.value=e),type:"line",animated:"",size:"large",class:"prompt-config-tabs"},{default:n(()=>[o(l(Me),{name:"config",tab:"参数和描述"},{default:n(()=>[a("div",wt,[a("div",ht,[t[14]||(t[14]=a("h4",{class:"section-title"},"基础信息",-1)),a("div",bt,[o(l(W),{path:"name"},{label:n(()=>[...t[12]||(t[12]=[a("div",{class:"form-label"},[a("svg",{class:"label-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("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"})]),a("span",null,"提示词名称")],-1)])]),default:n(()=>[o(l(F),{value:u.value.name,"onUpdate:value":t[1]||(t[1]=e=>u.value.name=e),placeholder:"例如: code-review",size:"large"},null,8,["value"])]),_:1}),o(l(W),{path:"description"},{label:n(()=>[...t[13]||(t[13]=[a("div",{class:"form-label"},[a("svg",{class:"label-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("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"})]),a("span",null,"描述")],-1)])]),default:n(()=>[o(l(F),{value:u.value.description,"onUpdate:value":t[2]||(t[2]=e=>u.value.description=e),placeholder:"提示词的描述信息(可选)",size:"large"},null,8,["value"])]),_:1})])]),a("div",kt,[a("div",yt,[t[17]||(t[17]=a("h4",{class:"section-title"},"参数定义",-1)),o(l(S),{dashed:"",onClick:we,size:"medium"},{icon:n(()=>[...t[15]||(t[15]=[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:n(()=>[t[16]||(t[16]=b(" 添加参数 ",-1))]),_:1})]),a("div",xt,[(h(!0),y(pe,null,fe(u.value.arguments,(e,s)=>(h(),y("div",{key:s,class:"parameter-card"},[a("div",Ct,[a("span",$t,"#"+K(s+1),1),o(l(S),{type:"error",text:"",size:"small",onClick:i=>oe(s)},{icon:n(()=>[...t[18]||(t[18]=[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("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:n(()=>[t[19]||(t[19]=b(" 删除 ",-1))]),_:1},8,["onClick"])]),a("div",St,[o(l(W),{label:"必填",class:"required-field"},{default:n(()=>[o(l(_e),{checked:e.required,"onUpdate:checked":i=>e.required=i},null,8,["checked","onUpdate:checked"])]),_:2},1024),o(l(W),{label:"参数名",path:`arguments[${s}].name`,rule:{required:!0,message:"必填",trigger:"blur"}},{default:n(()=>[o(l(F),{value:e.name,"onUpdate:value":i=>e.name=i,placeholder:"参数名"},null,8,["value","onUpdate:value"])]),_:2},1032,["path"]),o(l(W),{label:"描述"},{default:n(()=>[o(l(F),{value:e.description,"onUpdate:value":i=>e.description=i,placeholder:"参数描述(可选)"},null,8,["value","onUpdate:value"])]),_:2},1024)])]))),128)),u.value.arguments.length===0?(h(),y("div",Dt,[...t[20]||(t[20]=[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"2"}),a("path",{d:"M12 16v-4m0-4h.01",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})],-1),a("p",null,"暂无参数,点击上方按钮添加参数",-1)])])):ee("",!0)])])])]),_:1}),o(l(Me),{name:"content",tab:"提示词内容"},{default:n(()=>[a("div",Mt,[o(l(Re),{type:"info",bordered:!1,class:"template-help-alert"},{header:n(()=>[a("div",_t,[(h(),y("svg",zt,[...t[21]||(t[21]=[a("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),a("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)])])),t[22]||(t[22]=a("span",{style:{"font-weight":"600"}},"模板语法说明",-1))])]),default:n(()=>[t[23]||(t[23]=a("div",{class:"template-help-content"},[a("p",null,[a("strong",null,"变量替换:"),b("使用 "),a("code",null,"{{变量名}}"),b(" 来替换变量值")]),a("p",null,[a("strong",null,"条件逻辑:")]),a("ul",null,[a("li",null,[a("code",null,"{{#if 变量名}}...{{/if}}"),b(" - 当变量为真值时显示内容")]),a("li",null,[a("code",null,"{{#ifnot 变量名}}...{{/ifnot}}"),b(" - 当变量为假值时显示内容")]),a("li",null,[a("code",null,"{{#if 变量名}}...{{else}}...{{/if}}"),b(" - 支持 else 分支")])]),a("p",null,[a("strong",null,"真值判断:"),b("非空字符串、非零数字、true、非空数组/对象都被视为真值")])],-1))]),_:1}),a("div",Tt,[(h(!0),y(pe,null,fe(u.value.messages,(e,s)=>(h(),y("div",{key:s,class:"message-editor-wrapper"},[a("div",Ut,[o(l(Te),{value:e.role,"onUpdate:value":i=>e.role=i,options:A,size:"small",class:"role-selector"},null,8,["value","onUpdate:value"]),o(l(S),{text:"",type:"error",size:"small",onClick:i=>ue(s),class:"remove-message-btn"},{icon:n(()=>[...t[24]||(t[24]=[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("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"])]),a("div",{class:Ue(["editor-container",{fullscreen:O.value&&j.value===s}])},[a("div",Nt,[a("div",{class:Ue(["status-dot",{unsaved:te(s),saved:!te(s)}]),title:te(s)?"未保存":"已保存"},null,10,jt)]),o(l(S),{type:"default",size:"small",class:"fullscreen-btn",onClick:i=>re(s)},{icon:n(()=>[!O.value||j.value!==s?(h(),y("svg",It,[...t[25]||(t[25]=[a("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)])])):(h(),y("svg",Bt,[...t[26]||(t[26]=[a("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:n(()=>[b(" "+K(O.value&&j.value===s?"退出全屏":"全屏"),1)]),_:2},1032,["onClick"]),f.value&&P.value?(h(),y("div",At,[o(et,{modelValue:e.content.text,"onUpdate:modelValue":i=>e.content.text=i,language:"markdown",theme:"vs",options:{minimap:{enabled:!1},fontSize:14,lineHeight:22,padding:{top:16,bottom:16},scrollBeyondLastLine:!1,automaticLayout:!0,wordWrap:"on"},onChange:()=>ae(s)},null,8,["modelValue","onUpdate:modelValue","onChange"])])):ee("",!0)],2)]))),128)),o(l(S),{dashed:"",onClick:he,class:"add-message-btn",size:"small"},{icon:n(()=>[...t[27]||(t[27]=[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:n(()=>[t[28]||(t[28]=b(" 添加消息模板 ",-1))]),_:1}),u.value.messages.length===0?(h(),y("div",Vt,[...t[29]||(t[29]=[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("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),a("p",null,"暂无消息,点击下方按钮添加消息模板",-1)])])):ee("",!0)])])]),_:1})]),_:1},8,["value"])]),_:1},8,["model"])])]),_:1},8,["show"]),o(l(de),{show:p.value,"onUpdate:show":t[7]||(t[7]=e=>p.value=e),preset:"card",title:"测试提示词",style:{width:"90vw",maxWidth:"800px"}},{action:n(()=>[o(l(S),{onClick:t[6]||(t[6]=e=>p.value=!1)},{default:n(()=>[...t[34]||(t[34]=[b("关闭",-1)])]),_:1})]),default:n(()=>[a("div",Rt,[o(l(xe),{model:k.value},{default:n(()=>[(h(!0),y(pe,null,fe(u.value.arguments,e=>(h(),ye(l(W),{key:e.name,label:e.name,required:e.required},{default:n(()=>[o(l(F),{value:k.value.arguments[e.name],"onUpdate:value":s=>k.value.arguments[e.name]=s,placeholder:e.description||`输入 ${e.name}`,clearable:""},null,8,["value","onUpdate:value","placeholder"])]),_:2},1032,["label","required"]))),128))]),_:1},8,["model"]),o(l(He),null,{default:n(()=>[...t[32]||(t[32]=[b("生成的消息(实时预览)",-1)])]),_:1}),a("div",Ht,[(h(!0),y(pe,null,fe(Q.value,(e,s)=>(h(),y("div",{key:s,class:"test-message"},[a("div",Ot,[o(l(Ne),{type:e.role==="user"?"info":"success"},{default:n(()=>[b(K(e.role==="user"?"用户":"助手"),1)]),_:2},1032,["type"])]),a("pre",Lt,K(e.content.text),1)]))),128)),Q.value.length===0?(h(),y("div",Pt,[...t[33]||(t[33]=[a("p",null,"暂无消息内容",-1)])])):ee("",!0)])])]),_:1},8,["show"])]))}}),qt=De(Jt,[["__scopeId","data-v-7fa89c44"]]),Ft={class:"table-editor"},Wt={class:"editor-toolbar"},Kt={class:"toolbar-left"},Yt={key:0,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Gt={key:1,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Qt={class:"toolbar-right"},Xt={class:"save-indicator-wrapper"},Zt={key:0,class:"table-container"},ea={class:"table-wrapper",ref:"tableWrapperRef"},ta={key:1,class:"no-table-message"},aa={class:"import-content"},sa={class:"json-editor-wrapper"},la={class:"json-editor-actions"},na={class:"batch-loading-content"},oa={class:"loading-text"},ra=Ce({__name:"TableEditor",props:{tableDefinition:{},tableId:{}},emits:["saved"],setup(le,{emit:D}){const f=$e(),p=le,B=D,v=m([]),E=m([]),M=m(!1),L=m(!1),H=m(!1),z=m(!0),G=m(50),O=m(1),j=m(""),x=m(!1),P=m("正在处理..."),A=se(()=>({page:O.value,pageSize:G.value,showSizePicker:!0,pageSizes:[20,50,100,200],showQuickJumper:!0,onUpdatePage:t=>{O.value=t},onUpdatePageSize:t=>{G.value=t,O.value=1}})),J=se(()=>p.tableDefinition?[{type:"selection",width:50,fixed:"left"},...p.tableDefinition.columns.map(e=>({title:()=>{const s=N("span",{class:"column-name",title:e.description||void 0},e.name);return N("div",{class:"column-header-cell"},[e.description?N(Ve,{trigger:"hover",placement:"top"},{default:()=>e.description,trigger:()=>s}):s,N(Ne,{size:"tiny",type:be(e.type),style:"margin-left: 6px"},{default:()=>e.type}),e.nullable?null:N("span",{class:"required-mark"},"*")])},key:e.name,minWidth:120,resizable:!0,render(s){return N("div",{class:"cell-wrapper excel-cell"},[e.type==="string"?N(F,{value:s.rowData[e.name],placeholder:"",size:"tiny",class:"excel-input",disabled:z.value,onUpdateValue:i=>{z.value||(s.rowData[e.name]=i,re(s))},onBlur:()=>Z(s,e)}):e.type==="number"?N("input",{type:"number",value:s.rowData[e.name]??"",placeholder:"",class:"excel-input-native",disabled:z.value,onInput:i=>{if(z.value)return;const c=i.target.value,w=Number(c);(!isNaN(w)||c==="")&&(s.rowData[e.name]=c===""?null:w,re(s))},onBlur:()=>Z(s,e)}):e.type==="boolean"?N(_e,{checked:s.rowData[e.name],disabled:z.value,onUpdateChecked:i=>{z.value||(s.rowData[e.name]=i,re(s))}}):e.type==="date"?N("input",{type:"datetime-local",value:ce(s.rowData[e.name]),class:"excel-input-native",disabled:z.value,onInput:i=>{if(z.value)return;const c=i.target.value;if(c){const w=new Date(c);s.rowData[e.name]=w.toISOString()}else s.rowData[e.name]=null;re(s)},onBlur:()=>Z(s,e)}):e.type==="json"?N(F,{type:"textarea",value:typeof s.rowData[e.name]=="string"?s.rowData[e.name]:JSON.stringify(s.rowData[e.name]||{},null,2),placeholder:"",rows:2,size:"tiny",class:"excel-textarea",disabled:z.value,onUpdateValue:i=>{z.value||(s.rowData[e.name]=i)},onBlur:()=>{Z(s,e)}}):null])}}))]:[]),ve=se(()=>{if(p.tableDefinition)return 50+p.tableDefinition.columns.length*120});function q(t){const e=t.id||`new-${v.value.indexOf(t)}`;return{class:E.value.includes(e)?"row-selected":"",style:"cursor: pointer;"}}Se(()=>p.tableId,async t=>{t&&p.tableDefinition?await k():(v.value=[],E.value=[])},{immediate:!0});let $=null;ze(()=>{$=()=>{ge()},window.addEventListener("beforeunload",$)});const u=m(!0);Le(()=>{u.value=!1,$&&(window.removeEventListener("beforeunload",$),$=null),ae.forEach(t=>{clearTimeout(t)}),ae.clear()});async function k(){var t,e;if(p.tableId)try{const s=await X.get(`/tables/data/${p.tableId}`);s.data.success&&(v.value=s.data.data)}catch(s){f.error("加载数据失败: "+(((e=(t=s.response)==null?void 0:t.data)==null?void 0:e.error)||s.message))}}async function Q(){if(!p.tableDefinition)return;const t={tableId:p.tableId||"",rowData:{}};p.tableDefinition.columns.forEach(e=>{if(e.defaultValue!==void 0)t.rowData[e.name]=e.defaultValue;else if(e.nullable)t.rowData[e.name]=null;else switch(e.type){case"string":t.rowData[e.name]="";break;case"number":t.rowData[e.name]=0;break;case"boolean":t.rowData[e.name]=!1;break;case"date":t.rowData[e.name]=new Date().toISOString();break;case"json":t.rowData[e.name]={};break}}),v.value.push(t),await oe(t)}async function ne(){const t=[...E.value],e=v.value.filter(s=>{const i=s.id||`new-${v.value.indexOf(s)}`;return t.includes(i)});if(e.length!==0){x.value=!0,P.value=`正在删除 ${e.length} 条数据...`;try{let s=0,i=0;for(const U of e)if(U.id&&p.tableId)try{await X.delete(`/tables/data/${p.tableId}/${U.id}`),s++}catch(c){console.error("Delete row failed:",c),i++}v.value=v.value.filter(U=>{const c=U.id||`new-${v.value.indexOf(U)}`;return!t.includes(c)}),E.value=[],B("saved"),i>0?f.warning(`成功删除 ${s} 条,失败 ${i} 条`):f.success(`成功删除 ${s} 条数据`)}finally{x.value=!1}}}function te(t){E.value=t}const ae=new Map;async function re(t,e){await we(t)}async function Z(t,e){const s=t.rowData[e.name];if((s==null||s==="")&&!e.nullable&&e.defaultValue===void 0){f.warning(`列 ${e.name} 不能为空`),await oe(t);return}try{switch(e.type){case"number":if(typeof s!="number"&&s!==""&&s!==null){const i=Number(s);isNaN(i)?(f.error(`列 ${e.name} 必须是数字`),t.rowData[e.name]=e.defaultValue??0):t.rowData[e.name]=i}break;case"boolean":typeof s!="boolean"&&s!==null&&s!==void 0&&(t.rowData[e.name]=!!s);break;case"date":if(typeof s=="string"&&s){const i=new Date(s);isNaN(i.getTime())?(f.error(`列 ${e.name} 必须是有效的日期`),t.rowData[e.name]=e.defaultValue??new Date().toISOString()):t.rowData[e.name]=i.toISOString()}break;case"json":if(typeof s=="string"&&s)try{t.rowData[e.name]=JSON.parse(s)}catch{f.error(`列 ${e.name} 必须是有效的 JSON`);return}break}await oe(t)}catch(i){console.error(`列 ${e.name} 数据格式错误:`,i),await oe(t)}}function ce(t){if(!t)return"";const e=new Date(t);if(isNaN(e.getTime()))return"";const s=e.getFullYear(),i=String(e.getMonth()+1).padStart(2,"0"),U=String(e.getDate()).padStart(2,"0"),c=String(e.getHours()).padStart(2,"0"),w=String(e.getMinutes()).padStart(2,"0");return`${s}-${i}-${U}T${c}:${w}`}let ie=!1;async function ge(){ie||!p.tableId||!p.tableDefinition||v.value.length===0||await he()}async function we(t){if(!p.tableId||!p.tableDefinition)return;const e=ae.get(t);e&&clearTimeout(e);const s=setTimeout(async()=>{await oe(t),ae.delete(t)},300);ae.set(t,s)}async function oe(t){var i,U;if(!p.tableId||!p.tableDefinition||!u.value)return;const e=ae.get(t);e&&(clearTimeout(e),ae.delete(t));const s={};p.tableDefinition.columns.forEach(c=>{const w=t.rowData[c.name];if(w===void 0)if(c.defaultValue!==void 0)s[c.name]=c.defaultValue;else if(c.nullable)s[c.name]=null;else switch(c.type){case"string":s[c.name]="";break;case"number":s[c.name]=0;break;case"boolean":s[c.name]=!1;break;case"date":s[c.name]=new Date().toISOString();break;case"json":s[c.name]={};break}else s[c.name]=w});try{if(t.id){const c=await X.put(`/tables/data/${p.tableId}/${t.id}`,{rowData:s});if(!u.value)return;if(c.data.success){const w=c.data.data;t.createdAt=w.createdAt,t.updatedAt=w.updatedAt,ue(),B("saved")}else console.error("Save row failed:",c.data.error),u.value&&f.error("保存失败: "+(c.data.error||"未知错误"))}else{const c=await X.post(`/tables/data/${p.tableId}`,{rowData:s});if(!u.value)return;if(c.data.success){const w=c.data.data;t.id=w.id,t.createdAt=w.createdAt,t.updatedAt=w.updatedAt,ue(),B("saved")}else console.error("Create row failed:",c.data.error),u.value&&f.error("保存失败: "+(c.data.error||"未知错误"))}}catch(c){if(console.error("Save single row failed:",c),u.value){const w=((U=(i=c.response)==null?void 0:i.data)==null?void 0:U.error)||c.message||"保存失败";if(w.includes("Row not found")&&!u.value)return;f.error("保存失败: "+w)}}}async function he(){var t,e,s,i,U;if(!ie&&u.value){if(!p.tableId){console.warn("performSave: tableId is missing");return}if(!p.tableDefinition){console.warn("performSave: tableDefinition is missing");return}if(v.value.length!==0){ie=!0,M.value=!0;try{const c=v.value.map(R=>{const T={};return p.tableDefinition.columns.forEach(C=>{const I=R.rowData[C.name];if(I===void 0)if(C.defaultValue!==void 0)T[C.name]=C.defaultValue;else if(C.nullable)T[C.name]=null;else switch(C.type){case"string":T[C.name]="";break;case"number":T[C.name]=0;break;case"boolean":T[C.name]=!1;break;case"date":T[C.name]=new Date().toISOString();break;case"json":T[C.name]={};break}else T[C.name]=I}),{id:R.id,rowData:T}}),w=await X.put(`/tables/data/${p.tableId}/batch`,{rows:c});if(w.data.success){const R=w.data.data||[];if(R.length>0){const T=new Map;R.forEach(I=>{I.id&&T.set(I.id,I)});const C=new Set;v.value.forEach(I=>{if(I.id&&T.has(I.id)){const V=T.get(I.id);I.createdAt=V.createdAt,I.updatedAt=V.updatedAt,C.add(I.id)}}),v.value.forEach(I=>{if(!I.id){const V=R.find(Y=>Y.id&&!C.has(Y.id));V&&V.id&&(I.id=V.id,I.createdAt=V.createdAt,I.updatedAt=V.updatedAt,C.add(V.id))}})}u.value&&(ue(),B("saved"))}else if(console.error("Save failed:",w.data),u.value){const R=((t=w.data)==null?void 0:t.error)||"未知错误";f.error("保存失败: "+R)}}catch(c){if(console.error("Auto save failed:",c),u.value){const w=((s=(e=c.response)==null?void 0:e.data)==null?void 0:s.error)||c.message||"保存失败";if(w.includes("Row not found")){console.warn("Save failed after component unmount, ignoring error");return}console.error("Error details:",{message:c.message,response:(i=c.response)==null?void 0:i.data,status:(U=c.response)==null?void 0:U.status}),f.error("保存失败: "+w)}}finally{ie=!1,M.value=!1}}}}function ue(){L.value=!0,setTimeout(()=>{L.value=!1},1500)}function be(t){switch(t){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 g(){if(!p.tableId||!p.tableDefinition){f.error("请先选择要导出的表");return}if(v.value.length===0){f.warning("当前表没有数据可导出");return}try{const t=v.value.map(c=>c.rowData),e=JSON.stringify(t,null,2),s=new Blob([e],{type:"application/json"}),i=URL.createObjectURL(s),U=document.createElement("a");U.href=i,U.download=`${p.tableDefinition.name}_data.json`,document.body.appendChild(U),U.click(),document.body.removeChild(U),URL.revokeObjectURL(i),f.success(`成功导出 ${v.value.length} 条数据`)}catch(t){f.error("导出失败: "+(t.message||"未知错误"))}}async function r(t){var e,s;if(!p.tableId||!p.tableDefinition){f.error("请先选择要导入数据的表");return}try{let i;try{const w=JSON.parse(t);if(Array.isArray(w))i=w;else if(w.data&&Array.isArray(w.data))i=w.data,f.warning("检测到旧格式,将只导入数据部分");else{f.error("JSON 格式错误:需要数据数组格式");return}}catch{f.error("JSON 解析失败:文件格式不正确");return}if(i.length===0){f.warning("导入的数据为空"),H.value=!1;return}const U=p.tableDefinition.columns.map(w=>w.name),c=[];if(i.forEach((w,R)=>{if(!w||typeof w!="object"||Array.isArray(w)){c.push(`第 ${R+1} 行:数据必须是对象格式`);return}p.tableDefinition.columns.forEach(T=>{const C=w[T.name];if(!T.nullable&&T.defaultValue===void 0&&(C==null||C==="")&&c.push(`第 ${R+1} 行,列 "${T.name}":必填字段不能为空`),C!=null&&C!=="")switch(T.type){case"number":typeof C!="number"&&!(typeof C=="string"&&!isNaN(Number(C)))&&c.push(`第 ${R+1} 行,列 "${T.name}":必须是数字类型`);break;case"boolean":typeof C!="boolean"&&c.push(`第 ${R+1} 行,列 "${T.name}":必须是布尔类型`);break;case"date":(typeof C!="string"||isNaN(new Date(C).getTime()))&&c.push(`第 ${R+1} 行,列 "${T.name}":必须是有效的日期格式`);break;case"json":if(C!==null&&typeof C!="object"&&typeof C!="string"&&c.push(`第 ${R+1} 行,列 "${T.name}":必须是对象、数组或 JSON 字符串`),typeof C=="string")try{JSON.parse(C)}catch{c.push(`第 ${R+1} 行,列 "${T.name}":JSON 字符串格式无效`)}break;case"string":break}}),Object.keys(w).forEach(T=>{U.includes(T)||c.push(`第 ${R+1} 行:包含未知列 "${T}",将被忽略`)})}),c.length>0){const w=c.slice(0,10).join(`
25
+ `),R=c.length>10?`
26
+ ... 还有 ${c.length-10} 个错误`:"";f.error(`数据校验失败:
27
+ ${w}${R}`);return}M.value=!0,x.value=!0,P.value=`正在导入 ${i.length} 条数据...`;try{const w=i.map(T=>{const C={};return p.tableDefinition.columns.forEach(I=>{const V=T[I.name];let Y=V;if(V!=null&&V!=="")switch(I.type){case"number":Y=typeof V=="string"?Number(V):V;break;case"boolean":Y=typeof V=="boolean"?V:!!V;break;case"date":typeof V=="string"&&(Y=new Date(V).toISOString());break;case"json":if(typeof V=="string")try{Y=JSON.parse(V)}catch{Y=V}break}else if(I.defaultValue!==void 0)Y=I.defaultValue;else if(I.nullable)Y=null;else switch(I.type){case"string":Y="";break;case"number":Y=0;break;case"boolean":Y=!1;break;case"date":Y=new Date().toISOString();break;case"json":Y={};break}C[I.name]=Y}),{rowData:C}}),R=await X.put(`/tables/data/${p.tableId}/batch`,{rows:w});R.data.success?(ue(),await k(),B("saved"),H.value=!1,f.success(`成功导入 ${i.length} 条数据`)):f.error("导入失败:"+(R.data.error||"未知错误"))}catch(w){f.error("导入失败: "+(((s=(e=w.response)==null?void 0:e.data)==null?void 0:s.error)||w.message))}finally{M.value=!1,x.value=!1}}catch(i){f.error("文件读取失败: "+(i.message||"未知错误"))}}async function _(t){var s;const e=(s=t.fileList[0])==null?void 0:s.file;if(e)try{const i=await e.text();await r(i)}catch(i){f.error("文件读取失败: "+(i.message||"未知错误"))}}async function d(){if(!j.value.trim()){f.warning("请输入 JSON 数据");return}await r(j.value.trim()),j.value=""}return(t,e)=>(h(),y("div",Ft,[a("div",Wt,[a("div",Kt,[o(l(S),{size:"large",onClick:e[0]||(e[0]=s=>z.value=!z.value),type:z.value?"warning":"success",ghost:""},{icon:n(()=>[z.value?(h(),y("svg",Yt,[...e[6]||(e[6]=[a("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)])])):(h(),y("svg",Gt,[...e[7]||(e[7]=[a("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),a("path",{d:"M12 15v2M9 17h6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])]))]),default:n(()=>[b(" "+K(z.value?"解锁编辑":"锁定编辑"),1)]),_:1},8,["type"]),o(l(S),{type:"primary",size:"large",onClick:Q,disabled:!le.tableDefinition||z.value},{icon:n(()=>[...e[8]||(e[8]=[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:n(()=>[e[9]||(e[9]=b(" 添加行 ",-1))]),_:1},8,["disabled"]),o(l(S),{size:"large",onClick:ne,disabled:E.value.length===0||z.value,type:"error",ghost:""},{icon:n(()=>[...e[10]||(e[10]=[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("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:n(()=>[b(" 删除选中 ("+K(E.value.length)+") ",1)]),_:1},8,["disabled"]),o(l(S),{size:"large",onClick:g,disabled:!le.tableDefinition||v.value.length===0},{icon:n(()=>[...e[11]||(e[11]=[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("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:n(()=>[e[12]||(e[12]=b(" 导出 JSON ",-1))]),_:1},8,["disabled"]),o(l(S),{size:"large",onClick:e[1]||(e[1]=s=>H.value=!0),disabled:!le.tableDefinition},{icon:n(()=>[...e[13]||(e[13]=[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("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:n(()=>[e[14]||(e[14]=b(" 导入 JSON ",-1))]),_:1},8,["disabled"])]),a("div",Qt,[a("div",Xt,[L.value?(h(),y("div",{key:0,class:Ue(["save-success-indicator",{flash:L.value}])},null,2)):ee("",!0)]),o(l(Ne),{type:"info",size:"large"},{default:n(()=>[b(" 共 "+K(v.value.length)+" 行(编辑即保存) ",1)]),_:1})])]),le.tableDefinition?(h(),y("div",Zt,[a("div",ea,[o(l(je),{columns:J.value,data:v.value,pagination:A.value,"row-key":s=>s.id||`new-${v.value.indexOf(s)}`,"row-props":q,"max-height":600,"scroll-x":ve.value,bordered:!0,"single-line":!1,"onUpdate:checkedRowKeys":te,class:"editable-data-table excel-table"},null,8,["columns","data","pagination","row-key","scroll-x"])],512)])):(h(),y("div",ta,[o(l(me),{description:"请先创建或选择表定义"})])),o(l(de),{show:H.value,"onUpdate:show":e[4]||(e[4]=s=>H.value=s),preset:"card",bordered:!1,class:"import-modal",style:{width:"90vw",maxWidth:"600px"}},{header:n(()=>[...e[15]||(e[15]=[a("div",{class:"modal-header"},[a("div",{class:"modal-icon"},[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("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"})])]),a("div",null,[a("h3",{class:"modal-title"},"导入表数据"),a("p",{class:"modal-subtitle"},"从 JSON 文件导入表数据")])],-1)])]),default:n(()=>[a("div",aa,[o(l(Ae),{"default-value":"file",type:"line"},{default:n(()=>[o(l(Me),{name:"file",tab:"文件上传"},{default:n(()=>[o(l(Pe),{"file-list":[],accept:".json",max:1,onChange:_},{default:n(()=>[o(l(Je),null,{default:n(()=>[...e[16]||(e[16]=[a("div",{class:"upload-area"},[a("svg",{class:"upload-icon",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("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"})]),a("p",{class:"upload-text"},"点击或拖拽 JSON 文件到此处"),a("p",{class:"upload-hint"},"支持导入表数据")],-1)])]),_:1})]),_:1})]),_:1}),o(l(Me),{name:"text",tab:"直接编辑/粘贴"},{default:n(()=>[a("div",sa,[o(l(F),{value:j.value,"onUpdate:value":e[2]||(e[2]=s=>j.value=s),type:"textarea",placeholder:"请粘贴或输入 JSON 数据(数组格式)...",rows:15,class:"json-textarea"},null,8,["value"]),a("div",la,[o(l(S),{onClick:d,type:"primary",disabled:!j.value.trim()},{default:n(()=>[...e[17]||(e[17]=[b(" 导入 ",-1)])]),_:1},8,["disabled"]),o(l(S),{onClick:e[3]||(e[3]=s=>j.value="")},{default:n(()=>[...e[18]||(e[18]=[b(" 清空 ",-1)])]),_:1})])])]),_:1})]),_:1})])]),_:1},8,["show"]),o(l(de),{show:x.value,"onUpdate:show":e[5]||(e[5]=s=>x.value=s),"mask-closable":!1,"close-on-esc":!1,"auto-focus":!1,preset:"dialog",closable:!1,"show-icon":!1,style:{width:"400px"}},{default:n(()=>[a("div",na,[o(l(qe),{size:"large"},{description:n(()=>[a("div",oa,K(P.value),1)]),_:1})])]),_:1},8,["show"])]))}}),ia=De(ra,[["__scopeId","data-v-7b10a9ad"]]),ua={class:"tables-page"},da={class:"tables-toolbar"},va={class:"toolbar-left"},ca={class:"table-select-with-icon"},pa={class:"toolbar-right"},fa={class:"toolbar-switch"},ma={class:"explore-config-panel"},ga={class:"explore-config-list"},wa={key:0,class:"empty-tables-hint"},ha={class:"explore-config-item-info"},ba={class:"table-name"},ka={key:0,class:"table-description"},ya={key:0,class:"tables-table-container"},xa={key:1,class:"no-table-selected"},Ca={class:"columns-section"},$a={class:"columns-header"},Sa={class:"columns-list"},Da={class:"column-index"},Ma={key:0,class:"empty-columns"},_a={class:"form-actions"},za={class:"modal-header"},Ta={class:"modal-subtitle"},Ua={class:"column-descriptions-section"},Na={class:"column-description-label"},ja={class:"column-name-label"},Ia={key:0,class:"empty-columns-hint"},Ba={class:"form-actions"},Aa=Ce({__name:"Tables",setup(le){const D=$e(),f=Ee(),p=m([]),B=m(null),v=m(null),E=m(!1),M=m(!1),L=m(!1),H=m(!1),z=m(!1),G=m(!1),O=m(!1),j=m(null),x=m(""),P=m({}),A=m(!0),J=m({}),ve=[{label:"字符串",value:"string"},{label:"数字",value:"number"},{label:"布尔值",value:"boolean"},{label:"日期",value:"date"},{label:"JSON",value:"json"}],q=m({name:"",description:"",columns:[]}),$={name:{required:!0,message:"表名不能为空",trigger:"blur"}},u=se(()=>p.value.map(g=>({label:g.name,value:g.id,description:g.description})));function k(g){if(g){const r=p.value.find(_=>_.id===g);r&&ce(r)}else B.value=null,v.value=null}const Q=se({get:()=>E.value,set:g=>{E.value=g}});ze(async()=>{await Z(),await ne()});async function ne(){try{if(await f.fetchConfig(),f.currentConfig){const g=f.currentConfig;A.value=g.enableExploreTable!==!1}}catch(g){console.error("加载配置失败:",g)}}async function te(g){O.value=!0;try{await f.updateConfig({enableExploreTable:g}),D.success(g?"已允许 AI 探索数据表":"已禁止 AI 探索数据表")}catch(r){D.error("更新配置失败: "+(r.message||"未知错误")),A.value=!g}finally{O.value=!1}}function ae(g){return g.allowExplore!==!1}async function re(g,r){var _,d;J.value[g]=!0;try{const t=p.value.find(s=>s.id===g);if(!t){D.error("表不存在");return}(await X.put(`/tables/definitions/${g}`,{allowExplore:r})).data.success&&(t.allowExplore=r,D.success(r?`已允许 AI 探索表「${t.name}」`:`已禁止 AI 探索表「${t.name}」`),v.value&&v.value.id===g&&(v.value.allowExplore=r))}catch(t){D.error("更新失败: "+(((d=(_=t.response)==null?void 0:_.data)==null?void 0:d.error)||t.message))}finally{J.value[g]=!1}}async function Z(){var g,r;try{const _=await X.get("/tables/definitions");_.data.success&&(p.value=_.data.data,p.value.length>0&&!B.value&&ce(p.value[0]))}catch(_){D.error("加载表列表失败: "+(((r=(g=_.response)==null?void 0:g.data)==null?void 0:r.error)||_.message))}}function ce(g){B.value=g.id,v.value=g}function ie(){q.value.columns.push({name:"",type:"string",nullable:!0,description:""})}function ge(g){q.value.columns.splice(g,1)}async function we(){j.value&&await j.value.validate(async g=>{var r,_;if(!g){if(q.value.columns.length===0){D.warning("至少需要定义一个列");return}z.value=!0;try{const d=await X.post("/tables/definitions",q.value);d.data.success&&(D.success("表创建成功"),E.value=!1,q.value={name:"",description:"",columns:[]},await Z(),ce(d.data.data))}catch(d){D.error("保存失败: "+(((_=(r=d.response)==null?void 0:r.data)==null?void 0:_.error)||d.message))}finally{z.value=!1}}})}async function oe(){var g,r;if(v.value){H.value=!0;try{(await X.delete(`/tables/definitions/${v.value.id}`)).data.success&&(D.success("表删除成功"),B.value=null,v.value=null,L.value=!1,await Z())}catch(_){D.error("删除失败: "+(((r=(g=_.response)==null?void 0:g.data)==null?void 0:r.error)||_.message))}finally{H.value=!1}}}function he(){}Se(M,g=>{g&&v.value&&(x.value=v.value.description||"",P.value={},v.value.columns&&v.value.columns.forEach(r=>{P.value[r.name]=r.description||""}))});function ue(g){switch(g){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 be(){var g,r;if(!v.value||!B.value){D.error("请先选择一个表");return}G.value=!0;try{const _=v.value.columns.map(t=>({...t,description:P.value[t.name]||void 0})),d=await X.put(`/tables/definitions/${B.value}`,{description:x.value||null,columns:_});d.data.success&&(D.success("表声明和字段声明更新成功"),M.value=!1,v.value&&(v.value.description=d.data.data.description,v.value.columns=d.data.data.columns),await Z())}catch(_){D.error("更新失败: "+(((r=(g=_.response)==null?void 0:g.data)==null?void 0:r.error)||_.message))}finally{G.value=!1}}return(g,r)=>{var d,t;const _=We("n-tag");return h(),y("div",ua,[a("div",da,[a("div",va,[a("div",ca,[o(l(Te),{value:B.value,"onUpdate:value":[r[0]||(r[0]=e=>B.value=e),k],options:u.value,placeholder:"选择表...",size:"large",clearable:"",filterable:"",class:"table-select"},{empty:n(()=>[o(l(me),{description:"暂无表",size:"small"})]),_:1},8,["value","options"]),(d=v.value)!=null&&d.description?(h(),ye(l(Ve),{key:0,trigger:"hover",placement:"top"},{trigger:n(()=>[...r[14]||(r[14]=[a("div",{class:"table-info-icon"},[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("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:n(()=>[b(" "+K(v.value.description),1)]),_:1})):ee("",!0)])]),a("div",pa,[a("div",fa,[o(l(Ie),{value:A.value,"onUpdate:value":[r[1]||(r[1]=e=>A.value=e),te],size:"medium",loading:O.value},{checked:n(()=>[...r[15]||(r[15]=[b("允许 AI 探索数据表",-1)])]),unchecked:n(()=>[...r[16]||(r[16]=[b("禁止 AI 探索数据表",-1)])]),_:1},8,["value","loading"]),o(l(Fe),{trigger:"hover",placement:"bottom-end",style:{width:"400px",maxHeight:"500px"}},{trigger:n(()=>[...r[17]||(r[17]=[a("div",{class:"explore-config-icon",title:"配置表探索权限"},[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("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:n(()=>[a("div",ma,[r[18]||(r[18]=a("div",{class:"explore-config-header"},[a("h4",null,"配置表探索权限"),a("p",{class:"explore-config-hint"},"控制哪些表允许被 AI 探索(默认为允许)")],-1)),a("div",ga,[p.value.length===0?(h(),y("div",wa,[o(l(me),{description:"暂无表",size:"small"})])):ee("",!0),(h(!0),y(pe,null,fe(p.value,e=>(h(),y("div",{key:e.id,class:"explore-config-item"},[a("div",ha,[a("span",ba,K(e.name),1),e.description?(h(),y("span",ka,K(e.description),1)):ee("",!0)]),o(l(Ie),{value:ae(e),"onUpdate:value":s=>re(e.id,s),size:"small",loading:J.value[e.id]},null,8,["value","onUpdate:value","loading"])]))),128))])])]),_:1})]),v.value?(h(),ye(l(S),{key:0,size:"large",ghost:"",onClick:r[2]||(r[2]=e=>M.value=!0),class:"edit-table-btn"},{icon:n(()=>[...r[19]||(r[19]=[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("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"}),a("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:n(()=>[r[20]||(r[20]=b(" 编辑表声明 ",-1))]),_:1})):ee("",!0),v.value?(h(),ye(l(S),{key:1,type:"error",size:"large",ghost:"",onClick:r[3]||(r[3]=e=>L.value=!0),class:"delete-table-btn"},{icon:n(()=>[...r[21]||(r[21]=[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("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:n(()=>[r[22]||(r[22]=b(" 删除表 ",-1))]),_:1})):ee("",!0),o(l(S),{type:"primary",size:"large",onClick:r[4]||(r[4]=e=>E.value=!0),class:"create-table-btn"},{icon:n(()=>[...r[23]||(r[23]=[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:n(()=>[r[24]||(r[24]=b(" 创建新表 ",-1))]),_:1})])]),v.value?(h(),y("div",ya,[o(ia,{"table-definition":v.value,"table-id":B.value,onSaved:he},null,8,["table-definition","table-id"])])):(h(),y("div",xa,[o(l(me),{description:"请选择一个表进行编辑"})])),o(l(de),{show:L.value,"onUpdate:show":r[5]||(r[5]=e=>L.value=e),preset:"dialog",type:"warning",title:"确认删除",content:`确定要删除表「${(t=v.value)==null?void 0:t.name}」吗?此操作将同时删除表中的所有数据,且不可恢复。`,"positive-text":"确认删除","negative-text":"取消","positive-button-props":{type:"error"},loading:H.value,onPositiveClick:oe,onNegativeClick:r[6]||(r[6]=e=>L.value=!1)},null,8,["show","content","loading"]),o(l(de),{show:Q.value,"onUpdate:show":r[10]||(r[10]=e=>Q.value=e),preset:"card",bordered:!1,class:"table-definition-modal",style:{width:"90vw",maxWidth:"800px"}},{header:n(()=>[...r[25]||(r[25]=[a("div",{class:"modal-header"},[a("div",{class:"modal-icon"},[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("path",{d:"M3 3h18v18H3V3zm2 2v14h14V5H5zm2 2h10v2H7V7zm0 4h10v2H7v-2zm0 4h7v2H7v-2z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})])]),a("div",null,[a("h3",{class:"modal-title"}," 创建新表 "),a("p",{class:"modal-subtitle"}," 定义表的结构和列类型(创建后不可修改) ")])],-1)])]),default:n(()=>[o(l(xe),{ref_key:"tableFormRef",ref:j,model:q.value,rules:$,class:"table-form"},{default:n(()=>[o(l(W),{path:"name",label:"表名"},{default:n(()=>[o(l(F),{value:q.value.name,"onUpdate:value":r[7]||(r[7]=e=>q.value.name=e),placeholder:"例如: users, products",size:"large"},null,8,["value"])]),_:1}),o(l(W),{path:"description",label:"描述"},{default:n(()=>[o(l(F),{value:q.value.description,"onUpdate:value":r[8]||(r[8]=e=>q.value.description=e),placeholder:"表的用途说明",size:"large",type:"textarea",rows:2},null,8,["value"])]),_:1}),o(l(W),{label:"列定义"},{default:n(()=>[a("div",Ca,[a("div",$a,[r[28]||(r[28]=a("span",null,null,-1)),o(l(S),{dashed:"",onClick:ie,size:"medium"},{icon:n(()=>[...r[26]||(r[26]=[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("path",{d:"M12 4v16m8-8H4",stroke:"currentColor","stroke-width":"2.5","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:n(()=>[r[27]||(r[27]=b(" 添加列 ",-1))]),_:1})]),a("div",Sa,[(h(!0),y(pe,null,fe(q.value.columns,(e,s)=>(h(),y("div",{key:s,class:"column-row"},[a("span",Da,"#"+K(s+1),1),o(l(W),{path:`columns[${s}].name`,"show-label":!1,rule:{required:!0,message:"必填",trigger:"blur"},class:"column-field-name"},{default:n(()=>[o(l(F),{value:e.name,"onUpdate:value":i=>e.name=i,placeholder:"列名"},null,8,["value","onUpdate:value"])]),_:2},1032,["path"]),o(l(W),{path:`columns[${s}].type`,"show-label":!1,rule:{required:!0,message:"必填",trigger:"change"},class:"column-field-type"},{default:n(()=>[o(l(Te),{value:e.type,"onUpdate:value":i=>e.type=i,options:ve},null,8,["value","onUpdate:value"])]),_:2},1032,["path"]),o(l(_e),{checked:!e.nullable,"onUpdate:checked":i=>e.nullable=!i,class:"column-field-nullable"},{default:n(()=>[...r[29]||(r[29]=[b("必要",-1)])]),_:1},8,["checked","onUpdate:checked"]),o(l(W),{path:`columns[${s}].description`,"show-label":!1,class:"column-field-description"},{default:n(()=>[o(l(F),{value:e.description,"onUpdate:value":i=>e.description=i,placeholder:"列说明(可选)"},null,8,["value","onUpdate:value"])]),_:2},1032,["path"]),o(l(S),{type:"error",text:"",size:"small",onClick:i=>ge(s),class:"column-delete-btn"},{default:n(()=>[...r[30]||(r[30]=[b(" 删除 ",-1)])]),_:1},8,["onClick"])]))),128)),q.value.columns.length===0?(h(),y("div",Ma,[o(l(me),{description:"暂无列,点击上方添加列按钮添加",size:"small"})])):ee("",!0)])])]),_:1}),a("div",_a,[o(l(S),{size:"large",onClick:r[9]||(r[9]=e=>Q.value=!1)},{default:n(()=>[...r[31]||(r[31]=[b(" 取消 ",-1)])]),_:1}),o(l(S),{type:"primary",size:"large",loading:z.value,onClick:we},{default:n(()=>[...r[32]||(r[32]=[b(" 保存 ",-1)])]),_:1},8,["loading"])])]),_:1},8,["model"])]),_:1},8,["show"]),o(l(de),{show:M.value,"onUpdate:show":r[13]||(r[13]=e=>M.value=e),preset:"card",bordered:!1,class:"edit-table-description-modal",style:{width:"90vw",maxWidth:"600px"}},{header:n(()=>{var e;return[a("div",za,[r[34]||(r[34]=a("div",{class:"modal-icon"},[a("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[a("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"}),a("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)),a("div",null,[r[33]||(r[33]=a("h3",{class:"modal-title"}," 编辑表声明 ",-1)),a("p",Ta," 编辑表「"+K((e=v.value)==null?void 0:e.name)+"」的描述信息 ",1)])])]}),default:n(()=>[o(l(xe),{ref:"editTableFormRef",class:"edit-table-form"},{default:n(()=>[o(l(W),{label:"表声明"},{default:n(()=>[o(l(F),{value:x.value,"onUpdate:value":r[11]||(r[11]=e=>x.value=e),placeholder:"表的用途说明",size:"large",type:"textarea",rows:4},null,8,["value"])]),_:1}),o(l(W),{label:"字段声明"},{default:n(()=>{var e,s;return[a("div",Ua,[(h(!0),y(pe,null,fe(((e=v.value)==null?void 0:e.columns)||[],i=>(h(),y("div",{key:i.name,class:"column-description-row"},[a("div",Na,[a("span",ja,K(i.name),1),o(_,{size:"tiny",type:ue(i.type),style:{"margin-left":"8px"}},{default:n(()=>[b(K(i.type),1)]),_:2},1032,["type"])]),o(l(F),{value:P.value[i.name],"onUpdate:value":U=>P.value[i.name]=U,placeholder:`${i.name} 字段的说明(可选)`,size:"medium",clearable:""},null,8,["value","onUpdate:value","placeholder"])]))),128)),!((s=v.value)!=null&&s.columns)||v.value.columns.length===0?(h(),y("div",Ia,[o(l(me),{description:"当前表没有字段",size:"small"})])):ee("",!0)])]}),_:1}),a("div",Ba,[o(l(S),{size:"large",onClick:r[12]||(r[12]=e=>M.value=!1)},{default:n(()=>[...r[35]||(r[35]=[b(" 取消 ",-1)])]),_:1}),o(l(S),{type:"primary",size:"large",loading:G.value,onClick:be},{default:n(()=>[...r[36]||(r[36]=[b(" 保存 ",-1)])]),_:1},8,["loading"])])]),_:1},512)]),_:1},8,["show"])])}}}),Va=De(Aa,[["__scopeId","data-v-bf1554c4"]]),Ea={class:"dashboard-container"},Ra={style:{position:"absolute",width:"0",height:"0"}},Ha={key:0,class:"loading-state"},Oa={key:1,class:"dashboard-content"},La=Ce({__name:"Dashboard",setup(le){const D=$e(),f=Ee(),p=Ke(),B=Ye(),v=Qe(),E=m(B.query.section||"components"),M=se(()=>f.currentConfig),L=se(()=>f.loading),H=se(()=>{var A;return((A=p.user)==null?void 0:A.role)==="admin"}),z=["variables","tables"],G={components:st,tools:at,variables:ut,init:tt,tables:Va,prompts:qt},O=se(()=>G[E.value]);async function j(){try{await f.fetchConfig()}catch(A){D.error(A.message)}}async function x(A){if(M.value)try{await f.updateConfig(A),D.success("更新成功")}catch(J){D.error(J.message)}}function P(A){return H.value&&z.includes(A)?(D.warning("超级管理员不允许访问此功能"),v.replace({name:"UserDashboard",query:{section:"components"}}),E.value="components",!0):!1}return Se(()=>B.query.section,A=>{if(!A)return;const J=A;P(J)||(E.value=J)},{immediate:!0}),ze(()=>{const A=B.query.section;P(A),j()}),(A,J)=>(h(),y("div",Ea,[(h(),y("svg",Ra,[...J[0]||(J[0]=[a("defs",null,[a("linearGradient",{id:"loading-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%"},[a("stop",{offset:"0%","stop-color":"#6366f1"}),a("stop",{offset:"50%","stop-color":"#8b5cf6"}),a("stop",{offset:"100%","stop-color":"#ec4899"})])],-1)])])),L.value&&!M.value?(h(),y("div",Ha,[...J[1]||(J[1]=[a("div",{class:"loading-spinner"},[a("svg",{class:"spinner",viewBox:"0 0 50 50"},[a("circle",{class:"path",cx:"25",cy:"25",r:"20",fill:"none","stroke-width":"4"})])],-1),a("p",{class:"loading-text"},"加载配置中...",-1)])])):M.value?(h(),y("div",Oa,[(h(),ye(Ge(O.value),{config:M.value,onUpdate:x},null,40,["config"]))])):ee("",!0)]))}}),Fa=De(La,[["__scopeId","data-v-5f9aa991"]]);export{Fa as default};