@gientech/modual 2.1.34 → 2.1.36

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/database.js CHANGED
@@ -1,4 +1,4 @@
1
- import{jsxs as L,jsx as n,Fragment as De}from"react/jsx-runtime";import{useState as F,useMemo as W,useRef as $,useEffect as me}from"react";import{J,s as be,N as ye}from"./assets/index-DD8xyayB.js";import{a as Fe,T as Ie,d as ge,F as O}from"./assets/index-8h59dJlj.js";import{O as K}from"./assets/index-BqE1gm_T.js";/* empty css */import{M as ee,s as R}from"./assets/index-DoUk2Ei_.js";/* empty css */import"react-dom";const Ee=({url:m,token:v,role:B,eventsEmit:g})=>{const c=Fe.create({baseURL:m,timeout:1e6});return c.interceptors.request.use(e=>{let t=v;return!t&&!["user/login","user/kaptcha","user/regist"].some(u=>e.url.includes(u))?(g&&g("request:error_auth",{errorMsg:"\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F",redirect:"/login"}),Promise.reject(new Error("\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F"))):(e.headers.Authorization=t||"",e.headers.userName=B==="\u672A\u767B\u5F55\u7528\u6237"?"":B,e)}),c.interceptors.response.use(e=>{const t=["user/kaptcha"],r=e.data;if(t.some(E=>e.config.url&&e.config.url.includes(E))||r.size&&r.type)return r;const{success:u,errorMsg:b,errorCode:D}=r;return u?r:(g&&g("request:error_business",{errorCode:D,errorMsg:b||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",response:r}),!1)},async e=>{var t,r,u,b,D,E,C,h,w;if(e.message==="canceled")return Promise.reject(e);if(g){let d="request:error_network",j={errorMsg:"\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25",error:e};((t=e==null?void 0:e.response)==null?void 0:t.status)===401?(d="request:error_auth",j={errorMsg:"\u6CA1\u6709\u8DB3\u591F\u6743\u9650",error:e,redirect:"/login"}):(((u=(r=e==null?void 0:e.response)==null?void 0:r.data)==null?void 0:u.errorCode)==="30013"||((D=(b=e==null?void 0:e.response)==null?void 0:b.data)==null?void 0:D.errorCode)==="30023")&&(d="request:error_business",j={errorCode:(C=(E=e==null?void 0:e.response)==null?void 0:E.data)==null?void 0:C.errorCode,errorMsg:((w=(h=e==null?void 0:e.response)==null?void 0:h.data)==null?void 0:w.errorMsg)||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",error:e}),g(d,j)}return console.log("Error occurs",e),Promise.reject(e)}),{getDatabaseList:async e=>{try{const t=await c.get(`/queryPageDBList?${new URLSearchParams(e).toString()}`),{success:r,data:u}=t;if(r)return u}catch(t){console.log("getDatabaseList error:",t)}},getShareDatabaseList:async e=>{try{const t=await c.get(`/queryShareDBList?${new URLSearchParams(e).toString()}`),{success:r,data:u}=t;if(r)return u}catch(t){console.log("getShareDatabaseList error:",t)}},delDatabaseById:async(e,t)=>{const r=q(t);try{const u=await c.delete(`/${r}/deleteDB/${e}`),{success:b,data:D}=u;if(b)return D}catch(u){console.log("delDatabaseById error:",u)}},saveDatabase:async(e,t)=>{const r=q(t);try{const u=await c.post(`/${r}/saveDBInfo`,e),{success:b,data:D}=u;if(b)return D}catch(u){console.log("saveDatabase error:",u)}},testConnection:async e=>{try{const t=await c.post("/directDB/testConnect",e),{success:r,data:u}=t;if(r)return u}catch(t){console.log("testConnection error:",t)}},syncSchema:async e=>{try{const t=await c.get(`/directDB/syncSchema/${e}`),{success:r,data:u}=t;if(r)return u}catch(t){console.log("syncSchema error:",t)}}}},q=m=>m=="DataTable"?"dataTable":"directDB",Me="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzYiIGhlaWdodD0iMzYiIHZpZXdCb3g9IjAgMCAzNiAzNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGQ9Ik0xNCAxMkMxNCAxMC44OTU0IDE0Ljg5NTQgMTAgMTYgMTBIMjlDMzEuMjA5MSAxMCAzMyAxMS43OTA5IDMzIDE0VjI2QzMzIDMwLjQxODMgMjkuNDE4MyAzNCAyNSAzNEgxNkMxNC44OTU0IDM0IDE0IDMzLjEwNDYgMTQgMzJWMTJaIiBmaWxsPSJ1cmwoI3BhaW50MF9saW5lYXJfNDQ3Ml8xODA1MikiLz4NCjxmb3JlaWduT2JqZWN0IHg9Ii0xIiB5PSItMSIgd2lkdGg9IjMyIiBoZWlnaHQ9IjM2Ij48ZGl2IHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hodG1sIiBzdHlsZT0iYmFja2Ryb3AtZmlsdGVyOmJsdXIoMnB4KTtjbGlwLXBhdGg6dXJsKCNiZ2JsdXJfMF80NDcyXzE4MDUyX2NsaXBfcGF0aCk7aGVpZ2h0OjEwMCU7d2lkdGg6MTAwJSI+PC9kaXY+PC9mb3JlaWduT2JqZWN0PjxnIGRhdGEtZmlnbWEtYmctYmx1ci1yYWRpdXM9IjQiPg0KPHBhdGggZD0iTTMgN0MzIDQuNzkwODYgNC43OTA4NiAzIDcgM0gyM0MyNS4yMDkxIDMgMjcgNC43OTA4NiAyNyA3VjE5QzI3IDI1LjYyNzQgMjEuNjI3NCAzMSAxNSAzMUg3QzQuNzkwODYgMzEgMyAyOS4yMDkxIDMgMjdWN1oiIGZpbGw9IndoaXRlIiBmaWxsLW9wYWNpdHk9IjAuNDYiLz4NCjxwYXRoIGQ9Ik03IDMuMjVIMjNDMjUuMDcxMSAzLjI1IDI2Ljc1IDQuOTI4OTMgMjYuNzUgN1YxOUMyNi43NSAyNS40ODkzIDIxLjQ4OTMgMzAuNzUgMTUgMzAuNzVIN0M0LjkyODkzIDMwLjc1IDMuMjUgMjkuMDcxMSAzLjI1IDI3VjdDMy4yNSA0LjkyODkzIDQuOTI4OTMgMy4yNSA3IDMuMjVaIiBzdHJva2U9IndoaXRlIiBzdHJva2Utb3BhY2l0eT0iMC4zNCIgc3Ryb2tlLXdpZHRoPSIwLjUiLz4NCjwvZz4NCjxnIGZpbHRlcj0idXJsKCNmaWx0ZXIxX2RfNDQ3Ml8xODA1MikiPg0KPHBhdGggZD0iTTE0IDE5VjExLjY2NjciIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iMS44Mzk3MiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+DQo8cGF0aCBkPSJNMTEgMTRMMTIgMTNMMTQgMTFMMTYgMTNMMTcgMTQiIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+DQo8cGF0aCBkPSJNMTAgMjJIMTgiIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+DQo8L2c+DQo8ZGVmcz4NCjxjbGlwUGF0aCBpZD0iYmdibHVyXzBfNDQ3Ml8xODA1Ml9jbGlwX3BhdGgiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEgMSkiPjxwYXRoIGQ9Ik0zIDdDMyA0Ljc5MDg2IDQuNzkwODYgMyA3IDNIMjNDMjUuMjA5MSAzIDI3IDQuNzkwODYgMjcgN1YxOUMyNyAyNS42Mjc0IDIxLjYyNzQgMzEgMTUgMzFIN0M0Ljc5MDg2IDMxIDMgMjkuMjA5MSAzIDI3VjdaIi8+DQo8L2NsaXBQYXRoPjxmaWx0ZXIgaWQ9ImZpbHRlcjFfZF80NDcyXzE4MDUyIiB4PSI1IiB5PSI2IiB3aWR0aD0iMTgiIGhlaWdodD0iMjEiIGZpbHRlclVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzPSJzUkdCIj4NCjxmZUZsb29kIGZsb29kLW9wYWNpdHk9IjAiIHJlc3VsdD0iQmFja2dyb3VuZEltYWdlRml4Ii8+DQo8ZmVDb2xvck1hdHJpeCBpbj0iU291cmNlQWxwaGEiIHR5cGU9Im1hdHJpeCIgdmFsdWVzPSIwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAxMjcgMCIgcmVzdWx0PSJoYXJkQWxwaGEiLz4NCjxmZU9mZnNldC8+DQo8ZmVHYXVzc2lhbkJsdXIgc3RkRGV2aWF0aW9uPSIyIi8+DQo8ZmVDb21wb3NpdGUgaW4yPSJoYXJkQWxwaGEiIG9wZXJhdG9yPSJvdXQiLz4NCjxmZUNvbG9yTWF0cml4IHR5cGU9Im1hdHJpeCIgdmFsdWVzPSIwIDAgMCAwIDAgMCAwIDAgMCAwLjM5NjA3OCAwIDAgMCAwIDAuOTg0MzE0IDAgMCAwIDAuNCAwIi8+DQo8ZmVCbGVuZCBtb2RlPSJub3JtYWwiIGluMj0iQmFja2dyb3VuZEltYWdlRml4IiByZXN1bHQ9ImVmZmVjdDFfZHJvcFNoYWRvd180NDcyXzE4MDUyIi8+DQo8ZmVCbGVuZCBtb2RlPSJub3JtYWwiIGluPSJTb3VyY2VHcmFwaGljIiBpbjI9ImVmZmVjdDFfZHJvcFNoYWRvd180NDcyXzE4MDUyIiByZXN1bHQ9InNoYXBlIi8+DQo8L2ZpbHRlcj4NCjxsaW5lYXJHcmFkaWVudCBpZD0icGFpbnQwX2xpbmVhcl80NDcyXzE4MDUyIiB4MT0iMjMuNSIgeTE9IjEwIiB4Mj0iMjMuNSIgeTI9IjM0IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+DQo8c3RvcCBzdG9wLWNvbG9yPSIjNjRBMEZEIi8+DQo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiMwMTVBRkYiLz4NCjwvbGluZWFyR3JhZGllbnQ+DQo8L2RlZnM+DQo8L3N2Zz4NCg==",pe=""+new URL("assets/database_connect.svg",import.meta.url).href,fe=""+new URL("assets/mysql.svg",import.meta.url).href,Ae=""+new URL("assets/SQLServer.png",import.meta.url).href,Ce=""+new URL("assets/PostgreSQL.png",import.meta.url).href,he=""+new URL("assets/Doris.png",import.meta.url).href,Be=[{label:"MySQL",value:"MySQL",icon:fe},{label:"PostgreSQL",value:"PostgreSQL",icon:Ce},{label:"SQLServer",value:"SQLServer",icon:Ae},{label:"Doris",value:"Doris",icon:he}],Ne=({drawerTitle:m,drawerVisible:v,isConnectSuccess:B,handleDrawerClose:g,dbInfo:c,dbType:l,eventsEmit:p})=>{const[Q,V]=F(!1),[G,N]=F(!1),[e,t]=F({}),[r,u]=F(!1),b=W(()=>({id:l,layout:"vertical",formWidth:"500px",fields:[{id:"name",name:"name",label:"\u6570\u636E\u5E93\u540D\u79F0",type:"input",required:!0,placeholder:"\u4EC5\u652F\u6301\u6C49\u5B57\u3001\u6570\u5B57\u3001\u82F1\u6587\u3001\u7B26\u53F7",validate:a=>{if(!a)return"\u6570\u636E\u5E93\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A";if(!/[\u4E00-\u9FA5A-Za-z0-9\W]/.test(a))return"\u4EC5\u652F\u6301\u6C49\u5B57\u3001\u6570\u5B57\u3001\u82F1\u6587\u3001\u7B26\u53F7"},counter:100},{id:"description",name:"description",label:"\u6570\u636E\u5E93\u63CF\u8FF0",type:"textarea",counter:150,required:!1,placeholder:"\u8BF7\u8F93\u5165\u6570\u636E\u5E93\u63CF\u8FF0,\u6B64\u63CF\u8FF0\u4EC5\u7528\u4E8E\u533A\u5206\u4E0D\u540C\u6570\u636E\u5E93,\u4E0D\u4F1A\u5F71\u54CD\u6570\u636E\u5E93\u8C03\u7528",defaultValue:""}]}),[l,c]),D=W(()=>({id:l,layout:"vertical",formWidth:"470px",fields:[{id:"name",name:"name",label:"\u6570\u636E\u5E93\u540D\u79F0",type:"input",required:!0,placeholder:"\u4EC5\u652F\u6301\u6C49\u5B57\u3001\u6570\u5B57\u3001\u82F1\u6587\u3001\u7B26\u53F7",validate:a=>{if(!a)return"\u6570\u636E\u5E93\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A";if(!/[\u4E00-\u9FA5A-Za-z0-9\W]/.test(a))return"\u4EC5\u652F\u6301\u6C49\u5B57\u3001\u6570\u5B57\u3001\u82F1\u6587\u3001\u7B26\u53F7"},counter:100},{id:"description",name:"description",label:"\u6570\u636E\u5E93\u63CF\u8FF0",type:"textarea",required:!1,counter:150,placeholder:"\u8BF7\u8F93\u5165\u6570\u636E\u5E93\u63CF\u8FF0,\u6B64\u63CF\u8FF0\u4EC5\u7528\u4E8E\u533A\u5206\u4E0D\u540C\u6570\u636E\u5E93,\u4E0D\u4F1A\u5F71\u54CD\u6570\u636E\u5E93\u8C03\u7528",defaultValue:""},{id:"db-info",label:"\u76F4\u8FDE\u6570\u636E\u6E90\u4FE1\u606F",type:"title",level:2},{id:"dbType",name:"dbType",label:"\u6570\u636E\u6E90\u7C7B\u578B",type:"select",disabled:!!c,required:!0,options:Be.map(a=>{const{label:i,value:M,icon:k}=a;return{label:i,value:M,render:()=>L("div",{className:"flex items-center gap-2",children:[n("img",{src:k,width:24}),n("span",{children:i})]})}})},{id:"dbHost",name:"dbHost",label:"\u4E3B\u673A\u5730\u5740",type:"input",required:!0,disabled:!!c,placeholder:"\u8BF7\u8F93\u5165IP\u5730\u5740\u6216\u8005\u57DF\u540D"},{id:"dbPort",name:"dbPort",label:"\u7AEF\u53E3\u53F7",type:"number",required:!0,disabled:!!c,placeholder:"\u8BF7\u8F93\u5165\u7AEF\u53E3\u540D\u79F0"},{id:"dbDatabase",name:"dbDatabase",label:"\u8FDE\u63A5\u6570\u636E\u5E93\u540D",disabled:!!c,placeholder:"\u8BF7\u8F93\u5165\u8FDE\u63A5\u6570\u636E\u5E93\u540D",required:!0,type:"input"},{type:"col",children:[{id:"dbUser",type:"input",name:"dbUser",label:"\u7528\u6237\u540D",disabled:!!c,placeholder:"\u8BF7\u8F93\u5165\u7528\u6237\u540D",required:!0},{id:"dbPassword",type:"password",name:"dbPassword",label:"\u5BC6\u7801",placeholder:"\u8BF7\u8F93\u5165\u5BC6\u7801",required:!0,disabled:r?!1:!!c}]}]}),[l,c,r]),E=$(null),C=(a,i,M)=>{switch(console.log("[Form] eventsEmit:",a,i,M),a){case"form:ready":i.formRef&&(E.current=i.formRef);break;case"form_field_change":console.log("\u5B57\u6BB5\u503C\u53D8\u5316:",i),t(k=>({...k,[i.fieldId]:i.value}));break;case"form_validation_error":console.log("\u8868\u5355\u9A8C\u8BC1\u9519\u8BEF:",i);break;default:console.log("\u672A\u5904\u7406\u7684\u4E8B\u4EF6:",a,i)}p==null||p(a,i,M)},h=async()=>{try{V(!0);const a=await E.current.getAllData();a.isValid&&(console.log(a,"==="),l=="DirectDB"&&m=="\u7F16\u8F91\u6570\u636E\u5E93"&&!r&&(a.fields=a.fields.filter(i=>i.name=="name"||i.name=="description")),await p("form_submitted",a,void 0),u(!1))}catch(a){console.error("\u274C \u63D0\u4EA4\u8868\u5355\u6570\u636E\u5931\u8D25:",a)}finally{V(!1)}},w=async()=>{try{N(!0);const a=await E.current.getAllData();if(a.isValid){const i=a.fields.reduce((M,k)=>(M[k.name]=k.value,M),{});await p("form:connect_test",i,void 0)}}catch{N(!1)}finally{N(!1)}},d=W(()=>{const a=l=="DataTable"?b:D;return{label:"\u52A8\u6001\u8868\u5355\u793A\u4F8B",defaultActiveId:a.id,model:null,views:[{label:"\u7528\u6237\u6CE8\u518C\u8868\u5355",id:a.id,type:"form",size:"md",formWidth:a.formWidth,formConfig:{layout:a.layout,showReset:!1,showSubmit:!1,formWidth:a.formWidth,getFormData:()=>({...e,timestamp:new Date().toISOString(),formId:a.id}),onFieldChange:(i,M)=>{C("form_field_change",{fieldId:i,value:M},void 0)},onValidationError:i=>{C("form_validation_error",i,void 0)}}}],dataSource:[{id:a.id,fields:a.fields,defaultValues:{...c}}],eventsEmit:C}},[l,b,D,v,c]),j=W(()=>l=="DirectDB"?c?r&&!B:!B:!1,[l,B,r,v]);return L(ee,{title:m,width:620,onCancel:()=>{g(),u(!1)},open:v,destroyOnHidden:!0,footer:L("div",{className:"flex justify-end gap-3",style:{justifyContent:"end"},children:[n(J,{mode:"default",label:"\u53D6\u6D88",onClick:()=>{g(),u(!1)}}),n(J,{mode:"primary",label:"\u786E\u8BA4",loading:Q,disabled:j,onClick:h})]}),children:[n(K,{...d},"example-form"),l==="DirectDB"&&n(De,{children:m=="\u7F16\u8F91\u6570\u636E\u5E93"&&!r?n(J,{mode:"primary",className:"mt-[10px]",label:"\u4FEE\u6539\u5BC6\u7801",onClick:()=>{u(!0),E.current.setValues({dbPassword:void 0})}}):n(Ie,{title:"\u9700\u901A\u8FC7\u6D4B\u8BD5\u624D\u53EF\u521B\u5EFA\u6210\u529F",children:n(J,{mode:"primary",className:"mt-[10px]",label:"\u8FDE\u63A5\u6D4B\u8BD5",loading:G,onClick:w})})})]})},we=""+new URL("assets/empty.png",import.meta.url).href,{confirm:je}=ee,ke=ge.div`
1
+ import{jsxs as Z,jsx as c,Fragment as De}from"react/jsx-runtime";import{useState as y,useMemo as T,useRef as K,useEffect as me}from"react";import{J as Q,s as ge,N as be}from"./assets/index-CtPe9ln8.js";import{a as ye,T as Ee,d as Fe,F as O}from"./assets/index-8h59dJlj.js";import{O as $}from"./assets/index-w1SriKuR.js";/* empty css */import{M as ee,s as H}from"./assets/index-DoUk2Ei_.js";/* empty css */import"react-dom";const pe=({url:m,token:z,role:B,eventsEmit:F})=>{const l=ye.create({baseURL:m,timeout:1e6});return l.interceptors.request.use(e=>{let t=z;return!t&&!["user/login","user/kaptcha","user/regist"].some(u=>e.url.includes(u))?(F&&F("request:error_auth",{errorMsg:"\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F",redirect:"/login"}),Promise.reject(new Error("\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F"))):(e.headers.Authorization=t||"",e.headers.userName=B==="\u672A\u767B\u5F55\u7528\u6237"?"":B,e)}),l.interceptors.response.use(e=>{const t=["user/kaptcha"],r=e.data;if(t.some(p=>e.config.url&&e.config.url.includes(p))||r.size&&r.type)return r;const{success:u,errorMsg:g,errorCode:D}=r;return u?r:(F&&F("request:error_business",{errorCode:D,errorMsg:g||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",response:r}),!1)},async e=>{var t,r,u,g,D,p,A,h,N;if(e.message==="canceled")return Promise.reject(e);if(F){let d="request:error_network",v={errorMsg:"\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25",error:e};((t=e==null?void 0:e.response)==null?void 0:t.status)===401?(d="request:error_auth",v={errorMsg:"\u6CA1\u6709\u8DB3\u591F\u6743\u9650",error:e,redirect:"/login"}):(((u=(r=e==null?void 0:e.response)==null?void 0:r.data)==null?void 0:u.errorCode)==="30013"||((D=(g=e==null?void 0:e.response)==null?void 0:g.data)==null?void 0:D.errorCode)==="30023")&&(d="request:error_business",v={errorCode:(A=(p=e==null?void 0:e.response)==null?void 0:p.data)==null?void 0:A.errorCode,errorMsg:((N=(h=e==null?void 0:e.response)==null?void 0:h.data)==null?void 0:N.errorMsg)||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",error:e}),F(d,v)}return console.log("Error occurs",e),Promise.reject(e)}),{getDatabaseList:async e=>{try{const t=await l.get(`/queryPageDBList?${new URLSearchParams(e).toString()}`),{success:r,data:u}=t;if(r)return u}catch(t){console.log("getDatabaseList error:",t)}},getShareDatabaseList:async e=>{try{const t=await l.get(`/queryShareDBList?${new URLSearchParams(e).toString()}`),{success:r,data:u}=t;if(r)return u}catch(t){console.log("getShareDatabaseList error:",t)}},delDatabaseById:async(e,t)=>{const r=q(t);try{const u=await l.delete(`/${r}/deleteDB/${e}`),{success:g,data:D}=u;if(g)return D}catch(u){console.log("delDatabaseById error:",u)}},saveDatabase:async(e,t)=>{const r=q(t);try{const u=await l.post(`/${r}/saveDBInfo`,e),{success:g,data:D}=u;if(g)return D}catch(u){console.log("saveDatabase error:",u)}},testConnection:async e=>{try{const t=await l.post("/directDB/testConnect",e),{success:r,data:u}=t;if(r)return u}catch(t){console.log("testConnection error:",t)}},syncSchema:async e=>{try{const t=await l.get(`/directDB/syncSchema/${e}`),{success:r,data:u}=t;if(r)return u}catch(t){console.log("syncSchema error:",t)}}}},q=m=>m=="DataTable"?"dataTable":"directDB",Ie="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzYiIGhlaWdodD0iMzYiIHZpZXdCb3g9IjAgMCAzNiAzNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE0IDEyQzE0IDEwLjg5NTQgMTQuODk1NCAxMCAxNiAxMEgyOUMzMS4yMDkxIDEwIDMzIDExLjc5MDkgMzMgMTRWMjZDMzMgMzAuNDE4MyAyOS40MTgzIDM0IDI1IDM0SDE2QzE0Ljg5NTQgMzQgMTQgMzMuMTA0NiAxNCAzMlYxMloiIGZpbGw9InVybCgjcGFpbnQwX2xpbmVhcl80NDcyXzE4MDUyKSIvPgo8Zm9yZWlnbk9iamVjdCB4PSItMSIgeT0iLTEiIHdpZHRoPSIzMiIgaGVpZ2h0PSIzNiI+PGRpdiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94aHRtbCIgc3R5bGU9ImJhY2tkcm9wLWZpbHRlcjpibHVyKDJweCk7Y2xpcC1wYXRoOnVybCgjYmdibHVyXzBfNDQ3Ml8xODA1Ml9jbGlwX3BhdGgpO2hlaWdodDoxMDAlO3dpZHRoOjEwMCUiPjwvZGl2PjwvZm9yZWlnbk9iamVjdD48ZyBkYXRhLWZpZ21hLWJnLWJsdXItcmFkaXVzPSI0Ij4KPHBhdGggZD0iTTMgN0MzIDQuNzkwODYgNC43OTA4NiAzIDcgM0gyM0MyNS4yMDkxIDMgMjcgNC43OTA4NiAyNyA3VjE5QzI3IDI1LjYyNzQgMjEuNjI3NCAzMSAxNSAzMUg3QzQuNzkwODYgMzEgMyAyOS4yMDkxIDMgMjdWN1oiIGZpbGw9IndoaXRlIiBmaWxsLW9wYWNpdHk9IjAuNDYiLz4KPHBhdGggZD0iTTcgMy4yNUgyM0MyNS4wNzExIDMuMjUgMjYuNzUgNC45Mjg5MyAyNi43NSA3VjE5QzI2Ljc1IDI1LjQ4OTMgMjEuNDg5MyAzMC43NSAxNSAzMC43NUg3QzQuOTI4OTMgMzAuNzUgMy4yNSAyOS4wNzExIDMuMjUgMjdWN0MzLjI1IDQuOTI4OTMgNC45Mjg5MyAzLjI1IDcgMy4yNVoiIHN0cm9rZT0id2hpdGUiIHN0cm9rZS1vcGFjaXR5PSIwLjM0IiBzdHJva2Utd2lkdGg9IjAuNSIvPgo8L2c+CjxnIGZpbHRlcj0idXJsKCNmaWx0ZXIxX2RfNDQ3Ml8xODA1MikiPgo8cGF0aCBkPSJNMTQgMTlWMTEuNjY2NyIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIxLjgzOTcyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPHBhdGggZD0iTTExIDE0TDEyIDEzTDE0IDExTDE2IDEzTDE3IDE0IiBzdHJva2U9IndoaXRlIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPgo8cGF0aCBkPSJNMTAgMjJIMTgiIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+CjwvZz4KPGRlZnM+CjxjbGlwUGF0aCBpZD0iYmdibHVyXzBfNDQ3Ml8xODA1Ml9jbGlwX3BhdGgiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEgMSkiPjxwYXRoIGQ9Ik0zIDdDMyA0Ljc5MDg2IDQuNzkwODYgMyA3IDNIMjNDMjUuMjA5MSAzIDI3IDQuNzkwODYgMjcgN1YxOUMyNyAyNS42Mjc0IDIxLjYyNzQgMzEgMTUgMzFIN0M0Ljc5MDg2IDMxIDMgMjkuMjA5MSAzIDI3VjdaIi8+CjwvY2xpcFBhdGg+PGZpbHRlciBpZD0iZmlsdGVyMV9kXzQ0NzJfMTgwNTIiIHg9IjUiIHk9IjYiIHdpZHRoPSIxOCIgaGVpZ2h0PSIyMSIgZmlsdGVyVW5pdHM9InVzZXJTcGFjZU9uVXNlIiBjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM9InNSR0IiPgo8ZmVGbG9vZCBmbG9vZC1vcGFjaXR5PSIwIiByZXN1bHQ9IkJhY2tncm91bmRJbWFnZUZpeCIvPgo8ZmVDb2xvck1hdHJpeCBpbj0iU291cmNlQWxwaGEiIHR5cGU9Im1hdHJpeCIgdmFsdWVzPSIwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAxMjcgMCIgcmVzdWx0PSJoYXJkQWxwaGEiLz4KPGZlT2Zmc2V0Lz4KPGZlR2F1c3NpYW5CbHVyIHN0ZERldmlhdGlvbj0iMiIvPgo8ZmVDb21wb3NpdGUgaW4yPSJoYXJkQWxwaGEiIG9wZXJhdG9yPSJvdXQiLz4KPGZlQ29sb3JNYXRyaXggdHlwZT0ibWF0cml4IiB2YWx1ZXM9IjAgMCAwIDAgMCAwIDAgMCAwIDAuMzk2MDc4IDAgMCAwIDAgMC45ODQzMTQgMCAwIDAgMC40IDAiLz4KPGZlQmxlbmQgbW9kZT0ibm9ybWFsIiBpbjI9IkJhY2tncm91bmRJbWFnZUZpeCIgcmVzdWx0PSJlZmZlY3QxX2Ryb3BTaGFkb3dfNDQ3Ml8xODA1MiIvPgo8ZmVCbGVuZCBtb2RlPSJub3JtYWwiIGluPSJTb3VyY2VHcmFwaGljIiBpbjI9ImVmZmVjdDFfZHJvcFNoYWRvd180NDcyXzE4MDUyIiByZXN1bHQ9InNoYXBlIi8+CjwvZmlsdGVyPgo8bGluZWFyR3JhZGllbnQgaWQ9InBhaW50MF9saW5lYXJfNDQ3Ml8xODA1MiIgeDE9IjIzLjUiIHkxPSIxMCIgeDI9IjIzLjUiIHkyPSIzNCIgZ3JhZGllbnRVbml0cz0idXNlclNwYWNlT25Vc2UiPgo8c3RvcCBzdG9wLWNvbG9yPSIjNjRBMEZEIi8+CjxzdG9wIG9mZnNldD0iMSIgc3RvcC1jb2xvcj0iIzAxNUFGRiIvPgo8L2xpbmVhckdyYWRpZW50Pgo8L2RlZnM+Cjwvc3ZnPgo=",fe=""+new URL("assets/database_connect.svg",import.meta.url).href,Me=""+new URL("assets/mysql.svg",import.meta.url).href,Ce=""+new URL("assets/SQLServer.png",import.meta.url).href,Ae=""+new URL("assets/PostgreSQL.png",import.meta.url).href,he=""+new URL("assets/Doris.png",import.meta.url).href,Be=[{label:"MySQL",value:"MySQL",icon:Me},{label:"PostgreSQL",value:"PostgreSQL",icon:Ae},{label:"SQLServer",value:"SQLServer",icon:Ce},{label:"Doris",value:"Doris",icon:he}],we=({drawerTitle:m,drawerVisible:z,isConnectSuccess:B,handleDrawerClose:F,dbInfo:l,dbType:n,eventsEmit:f})=>{const[G,W]=y(!1),[R,w]=y(!1),[e,t]=y({}),[r,u]=y(!1),g=T(()=>({id:n,layout:"vertical",formWidth:"500px",fields:[{id:"name",name:"name",label:"\u6570\u636E\u5E93\u540D\u79F0",type:"input",required:!0,placeholder:"\u4EC5\u652F\u6301\u6C49\u5B57\u3001\u6570\u5B57\u3001\u82F1\u6587\u3001\u7B26\u53F7",validate:a=>{if(!a)return"\u6570\u636E\u5E93\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A";if(!/[\u4E00-\u9FA5A-Za-z0-9\W]/.test(a))return"\u4EC5\u652F\u6301\u6C49\u5B57\u3001\u6570\u5B57\u3001\u82F1\u6587\u3001\u7B26\u53F7"},counter:100},{id:"description",name:"description",label:"\u6570\u636E\u5E93\u63CF\u8FF0",type:"textarea",counter:150,required:!1,placeholder:"\u8BF7\u8F93\u5165\u6570\u636E\u5E93\u63CF\u8FF0,\u6B64\u63CF\u8FF0\u4EC5\u7528\u4E8E\u533A\u5206\u4E0D\u540C\u6570\u636E\u5E93,\u4E0D\u4F1A\u5F71\u54CD\u6570\u636E\u5E93\u8C03\u7528",defaultValue:""}]}),[n,l]),D=T(()=>({id:n,layout:"vertical",formWidth:"470px",fields:[{id:"name",name:"name",label:"\u6570\u636E\u5E93\u540D\u79F0",type:"input",required:!0,placeholder:"\u4EC5\u652F\u6301\u6C49\u5B57\u3001\u6570\u5B57\u3001\u82F1\u6587\u3001\u7B26\u53F7",validate:a=>{if(!a)return"\u6570\u636E\u5E93\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A";if(!/[\u4E00-\u9FA5A-Za-z0-9\W]/.test(a))return"\u4EC5\u652F\u6301\u6C49\u5B57\u3001\u6570\u5B57\u3001\u82F1\u6587\u3001\u7B26\u53F7"},counter:100},{id:"description",name:"description",label:"\u6570\u636E\u5E93\u63CF\u8FF0",type:"textarea",required:!1,counter:150,placeholder:"\u8BF7\u8F93\u5165\u6570\u636E\u5E93\u63CF\u8FF0,\u6B64\u63CF\u8FF0\u4EC5\u7528\u4E8E\u533A\u5206\u4E0D\u540C\u6570\u636E\u5E93,\u4E0D\u4F1A\u5F71\u54CD\u6570\u636E\u5E93\u8C03\u7528",defaultValue:""},{id:"db-info",label:"\u76F4\u8FDE\u6570\u636E\u6E90\u4FE1\u606F",type:"title",level:2},{id:"dbType",name:"dbType",label:"\u6570\u636E\u6E90\u7C7B\u578B",type:"select",disabled:!!l,required:!0,options:Be.map(a=>{const{label:i,value:I,icon:x}=a;return{label:i,value:I,render:()=>Z("div",{className:"flex items-center gap-2",children:[c("img",{src:x,width:24}),c("span",{children:i})]})}})},{id:"dbHost",name:"dbHost",label:"\u4E3B\u673A\u5730\u5740",type:"input",required:!0,disabled:!!l,placeholder:"\u8BF7\u8F93\u5165IP\u5730\u5740\u6216\u8005\u57DF\u540D"},{id:"dbPort",name:"dbPort",label:"\u7AEF\u53E3\u53F7",type:"number",required:!0,disabled:!!l,placeholder:"\u8BF7\u8F93\u5165\u7AEF\u53E3\u540D\u79F0"},{id:"dbDatabase",name:"dbDatabase",label:"\u8FDE\u63A5\u6570\u636E\u5E93\u540D",disabled:!!l,placeholder:"\u8BF7\u8F93\u5165\u8FDE\u63A5\u6570\u636E\u5E93\u540D",required:!0,type:"input"},{type:"col",children:[{id:"dbUser",type:"input",name:"dbUser",label:"\u7528\u6237\u540D",disabled:!!l,placeholder:"\u8BF7\u8F93\u5165\u7528\u6237\u540D",required:!0},{id:"dbPassword",type:"password",name:"dbPassword",label:"\u5BC6\u7801",placeholder:"\u8BF7\u8F93\u5165\u5BC6\u7801",required:!0,disabled:r?!1:!!l}]}]}),[n,l,r]),p=K(null),A=(a,i,I)=>{switch(console.log("[Form] eventsEmit:",a,i,I),a){case"form:ready":i.formRef&&(p.current=i.formRef);break;case"form_field_change":console.log("\u5B57\u6BB5\u503C\u53D8\u5316:",i),t(x=>({...x,[i.fieldId]:i.value}));break;case"form_validation_error":console.log("\u8868\u5355\u9A8C\u8BC1\u9519\u8BEF:",i);break;default:console.log("\u672A\u5904\u7406\u7684\u4E8B\u4EF6:",a,i)}f==null||f(a,i,I)},h=async()=>{try{W(!0);const a=await p.current.getAllData();a.isValid&&(console.log(a,"==="),n=="DirectDB"&&m=="\u7F16\u8F91\u6570\u636E\u5E93"&&!r&&(a.fields=a.fields.filter(i=>i.name=="name"||i.name=="description")),await f("form_submitted",a,void 0),u(!1))}catch(a){console.error("\u274C \u63D0\u4EA4\u8868\u5355\u6570\u636E\u5931\u8D25:",a)}finally{W(!1)}},N=async()=>{try{w(!0);const a=await p.current.getAllData();if(a.isValid){const i=a.fields.reduce((I,x)=>(I[x.name]=x.value,I),{});await f("form:connect_test",i,void 0)}}catch{w(!1)}finally{w(!1)}},d=T(()=>{const a=n=="DataTable"?g:D;return{label:"\u52A8\u6001\u8868\u5355\u793A\u4F8B",defaultActiveId:a.id,model:null,views:[{label:"\u7528\u6237\u6CE8\u518C\u8868\u5355",id:a.id,type:"form",size:"md",formWidth:a.formWidth,formConfig:{layout:a.layout,showReset:!1,showSubmit:!1,formWidth:a.formWidth,getFormData:()=>({...e,timestamp:new Date().toISOString(),formId:a.id}),onFieldChange:(i,I)=>{A("form_field_change",{fieldId:i,value:I},void 0)},onValidationError:i=>{A("form_validation_error",i,void 0)}}}],dataSource:[{id:a.id,fields:a.fields,defaultValues:{...l}}],eventsEmit:A}},[n,g,D,z,l]),v=T(()=>n=="DirectDB"?l?r&&!B:!B:!1,[n,B,r,z]);return Z(ee,{title:m,width:620,onCancel:()=>{F(),u(!1)},open:z,destroyOnHidden:!0,footer:Z("div",{className:"flex justify-end gap-3",style:{justifyContent:"end"},children:[c(Q,{mode:"default",label:"\u53D6\u6D88",onClick:()=>{F(),u(!1)}}),c(Q,{mode:"primary",label:"\u786E\u8BA4",loading:G,disabled:v,onClick:h})]}),children:[c($,{...d},"example-form"),n==="DirectDB"&&c(De,{children:m=="\u7F16\u8F91\u6570\u636E\u5E93"&&!r?c(Q,{mode:"primary",className:"mt-[10px]",label:"\u4FEE\u6539\u5BC6\u7801",onClick:()=>{u(!0),p.current.setValues({dbPassword:void 0})}}):c(Ee,{title:"\u9700\u901A\u8FC7\u6D4B\u8BD5\u624D\u53EF\u521B\u5EFA\u6210\u529F",children:c(Q,{mode:"primary",className:"mt-[10px]",label:"\u8FDE\u63A5\u6D4B\u8BD5",loading:R,onClick:N})})})]})},Ne=""+new URL("assets/empty.png",import.meta.url).href,{confirm:ve}=ee,xe=Fe.div`
2
2
  width: 282px;
3
3
  height: 81px;
4
4
  display: flex;
@@ -17,4 +17,4 @@ import{jsxs as L,jsx as n,Fragment as De}from"react/jsx-runtime";import{useState
17
17
  background-color: #F1F5FF;
18
18
  };
19
19
  border: 1px solid #EBEBEB
20
- `,xe=[{key:"add_file_db",label:"\u4E0A\u4F20\u6570\u636E\u5E93",dsc:"\u901A\u8FC7\u4E0A\u4F20Excel\u3001csv\u7B49\u683C\u5F0F\u6570\u636E\u8868\u521B\u5EFA\u6570\u636E\u5E93\u3002",icon:Me},{key:"add_direct_db",label:"\u76F4\u8FDE\u6570\u636E\u5E93",dsc:"\u901A\u8FC7\u4E0E\u5DF2\u6709\u4E1A\u52A1\u5EFA\u7ACB\u8FDE\u63A5\u521B\u5EFA\u6570\u636E\u5E93\u3002",icon:pe}],Pe=m=>{const{url:v,token:B,role:g,CustomComponents:c,getBtnDisabled:l}=m,[p,Q]=F("my-db"),[V,G]=F({app:"ready",container:"ready",content:"ready"}),[N,e]=F(!1),[t,r]=F([{id:"my-db",data:[]},{id:"shared-db",data:[]}]),u=$(null),[b,D]=F(!1),[E,C]=F(""),[h,w]=F("DataTable"),[d,j]=F(),[a,i]=F(!1),{getDatabaseList:M,delDatabaseById:k,saveDatabase:ue,testConnection:te,getShareDatabaseList:ae,syncSchema:se}=Ee({url:v,token:B,role:g,eventsEmit:m.eventsEmit}),H=W(()=>[{label:"\u6211\u7684\u6570\u636E\u5E93",id:"my-db",type:"card",cardType:"database",rowHeight:220,viewPageSize:12,viewBehavior:"pagination",actions:[{label:"\u7F16\u8F91",key:"edit"},{label:"\u5220\u9664",key:"delete"}],toolbar:[{type:"customized",key:"add",render:()=>n(be,{mode:"primary",label:"\u521B\u5EFA\u6570\u636E\u5E93",actions:xe.map(o=>({key:o.key,component:n(ke,{children:L("div",{className:"flex flex-grow",children:[n("div",{className:"mr-[6px]",children:n("img",{src:o.icon})}),L("div",{children:[n("div",{className:"text-base font-bold mb-1 text-[14px]",children:o.label}),n("div",{className:"text-[#888] text-[10px]",children:o.dsc})]})]})},o.key)})),eventEmit:Y})},{type:"fuzzy_search",key:"search",label:"\u8F93\u5165\u540D\u79F0\u641C\u7D22",searchKeys:["name","description"],position:"right"}]},{label:"\u5171\u4EAB\u6570\u636E\u5E93",id:"shared-db",type:"card",cardType:"database",rowHeight:240,toolbar:[{type:"fuzzy_search",key:"search",label:"\u641C\u7D22",position:"right"}],actions:[{label:"\u7F16\u8F91",key:"edit"},{label:"\u5220\u9664",key:"delete"}]}],[t]);me(()=>{G(o=>({...o,content:"loading"})),re()},[]);const re=async()=>{var o,s,f,y;try{const[A,z]=await Promise.allSettled([M({pageNo:1,pageSize:999}),ae({pageNo:1,pageSize:999})]);let T=[];if(A.status==="fulfilled"&&A.value&&(o=A.value)!=null&&o.records){const x=X((s=A.value)==null?void 0:s.records);T.push({id:"my-db",data:x||[]})}if(z.status==="fulfilled"&&z.value&&(f=z.value)!=null&&f.records){const x=X((y=z.value)==null?void 0:y.records);T.push({id:"shared-db",data:x||[]})}r(T),G(x=>({...x,content:"ready"}))}catch(A){console.log("[DatabaseApiError] getDatabaseList:",A)}},X=o=>(o||[]).map(s=>{const f=U("shared-db").map((y,A)=>({...y,key:y.type==="divider"?`${y.key}_${s.id}`:y.key,disabled:l&&l(y.key=="edit"?7:4,s.permission)}));return s.datasourceType=="DirectDB"&&f.push({label:"\u540C\u6B65\u8868\u7ED3\u6784",key:"sync_schema",disabled:l&&l(7,s.permission)}),console.log("[DatabaseViewAdopter] actions:",f),{...s,actions:f||[]}}),ie="admin",oe=()=>L("div",{className:"flex flex-col items-center justify-center h-full",children:[n("div",{className:"text-xl font-semibold mb-3",style:{color:"#374151"},children:n("img",{src:we,width:120})}),n("div",{className:"text-base mb-6",style:{color:"#6b7280"},children:"\u6682\u65E0\u6570\u636E\uFF0C\u8BF7\u5148\u6DFB\u52A0\u6570\u636E\u5E93"})]}),U=o=>{const s=H.find(y=>y.id===o);return(s==null?void 0:s.actions)||[]},ce=W(()=>{var s;const o=((s=t==null?void 0:t.find(f=>f.id===p))==null?void 0:s.data)||[];return N?[]:o},[p,t,N]),_=()=>{D(!1),i(!1),j(void 0)},ne=async o=>{console.log("[DatabaseViewAdopter] \u6D4B\u8BD5\u8FDE\u63A5:",o);const s=await te(o);return s&&(i(!0),R.success("\u8FDE\u63A5\u6D4B\u8BD5\u6210\u529F\uFF01")),s};async function Y(o,s,f){var y,A,z,T,x;switch(console.log("[DatabaseViewAdopter] mergedEventsEmit",o,s),o){case"card_delete":je({title:"\u786E\u8BA4\u5220\u9664\u6570\u636E\u5E93\uFF1F",content:"\u5220\u9664\u540E\uFF0C\u8BE5\u6570\u636E\u5E93\u5C06\u65E0\u6CD5\u6062\u590D",okText:"\u5220\u9664",cancelText:"\u53D6\u6D88",async onOk(){await k(s.id,s.datasourceType)&&(u!=null&&u.current)&&(u==null||u.current.appFn.removeItem(s.id))},onCancel(){console.log("Cancel")}});break;case"card_edit":C("\u7F16\u8F91\u6570\u636E\u5E93"),D(!0),w(s.datasourceType),delete s.render,j(s);break;case"select":Q(s.id);break;case"filesDir_clicked":Q(s.id);break;case"dropdown_action":C("\u521B\u5EFA\u6570\u636E\u5E93"),D(!0),s.key=="add_file_db"?w("DataTable"):w("DirectDB");break;case"form_submitted":try{const S=s.fields.reduce((Z,I)=>(Z[I.name]=I.value,Z),{}),le=d?{id:d==null?void 0:d.id,...S}:S,P=await ue(le,h);if(P){if(d){const Z={...d,...S,datasourceType:h,actions:U("my-db").map((I,de)=>({...I,key:I.type==="divider"?`${I.key}_${P}`:I.key,allow:!0}))};(A=(y=u==null?void 0:u.current)==null?void 0:y.appFn)==null||A.updateItem(Z,d==null?void 0:d.id),R.success("\u6570\u636E\u5E93\u7F16\u8F91\u6210\u529F\uFF01")}else{const Z={...S,...P,createBy:ie,datasourceType:h,actions:U("my-db").map((I,de)=>({...I,key:I.type==="divider"?`${I.key}_${P}`:I.key,allow:!0}))};(T=(z=u==null?void 0:u.current)==null?void 0:z.appFn)==null||T.addItem(Z,{animate:!0,position:"start"}),R.success("\u6570\u636E\u5E93\u521B\u5EFA\u6210\u529F\uFF01")}return P}}catch(S){console.error("\u4FDD\u5B58\u5931\u8D25\uFF01",S)}finally{_()}break;case"form:connect_test":return await ne(s);case"toolbar_test_empty":console.log("[DatabaseViewAdopter] toolbar_test_empty \u4E8B\u4EF6\u89E6\u53D1"),e(!N);break;case"card_sync_schema":await se(s.id)&&(i(!0),R.success("\u540C\u6B65\u8868\u7ED3\u6784\u6210\u529F\uFF01"));break;default:(x=m.eventsEmit)==null||x.call(m,o,s);break}}return L(ye,{title:"\u6570\u636E\u5E93\u7BA1\u7406",children:[n(K,{ref:u,label:"",model:"tabs",defaultActiveId:p,views:H,dataSource:ce,eventsEmit:Y,status:V,CustomComponents:{EmptyData:oe,...c},styles:{theme:{...O,colors:{...O.colors,listBackground:"#ffffff"}},mode:"light"}},"db"),n(Ne,{drawerTitle:E,drawerVisible:b,isConnectSuccess:a,dbType:h,dbInfo:d,handleDrawerClose:_,eventsEmit:Y})]})};export{Pe as default};
20
+ `,Se=[{key:"add_file_db",label:"\u4E0A\u4F20\u6570\u636E\u5E93",dsc:"\u901A\u8FC7\u4E0A\u4F20Excel\u3001csv\u7B49\u683C\u5F0F\u6570\u636E\u8868\u521B\u5EFA\u6570\u636E\u5E93\u3002",icon:Ie},{key:"add_direct_db",label:"\u76F4\u8FDE\u6570\u636E\u5E93",dsc:"\u901A\u8FC7\u4E0E\u5DF2\u6709\u4E1A\u52A1\u5EFA\u7ACB\u8FDE\u63A5\u521B\u5EFA\u6570\u636E\u5E93\u3002",icon:fe}],Ve=m=>{const{url:z,token:B,role:F,CustomComponents:l,getBtnDisabled:n}=m,[f,G]=y("my-db"),[W,R]=y({app:"ready",container:"ready",content:"ready"}),[w,e]=y(!1),[t,r]=y([{id:"my-db",data:[]},{id:"shared-db",data:[]}]),u=K(null),[g,D]=y(!1),[p,A]=y(""),[h,N]=y("DataTable"),[d,v]=y(),[a,i]=y(!1),{getDatabaseList:I,delDatabaseById:x,saveDatabase:ue,testConnection:te,getShareDatabaseList:ae,syncSchema:se}=pe({url:z,token:B,role:F,eventsEmit:m.eventsEmit}),J=T(()=>[{label:"\u6211\u7684\u6570\u636E\u5E93",id:"my-db",type:"card",cardType:"database",rowHeight:220,viewPageSize:12,viewBehavior:"pagination",actions:[{label:"\u7F16\u8F91",key:"edit"},{label:"\u5220\u9664",key:"delete"}],toolbar:[{type:"customized",key:"add",render:()=>c(ge,{mode:"primary",label:"\u521B\u5EFA\u6570\u636E\u5E93",actions:Se.map(o=>({key:o.key,component:c(xe,{children:Z("div",{className:"flex flex-grow",children:[c("div",{className:"mr-[6px]",children:c("img",{src:o.icon})}),Z("div",{children:[c("div",{className:"text-base font-bold mb-1 text-[14px]",children:o.label}),c("div",{className:"text-[#888] text-[10px]",children:o.dsc})]})]})},o.key)})),eventEmit:_})},{type:"fuzzy_search",key:"search",label:"\u8F93\u5165\u540D\u79F0\u641C\u7D22",searchKeys:["name","description"],position:"right"}]},{label:"\u5171\u4EAB\u6570\u636E\u5E93",id:"shared-db",type:"card",cardType:"database",rowHeight:240,toolbar:[{type:"fuzzy_search",key:"search",label:"\u641C\u7D22",position:"right"}],actions:[{label:"\u7F16\u8F91",key:"edit"},{label:"\u5220\u9664",key:"delete"}]}],[t]);me(()=>{R(o=>({...o,content:"loading"})),re()},[]);const re=async()=>{var o,s,M,b;try{const[C,j]=await Promise.allSettled([I({pageNo:1,pageSize:999}),ae({pageNo:1,pageSize:999})]);let P=[];if(C.status==="fulfilled"&&C.value&&(o=C.value)!=null&&o.records){const S=Y((s=C.value)==null?void 0:s.records);P.push({id:"my-db",data:S||[]})}if(j.status==="fulfilled"&&j.value&&(M=j.value)!=null&&M.records){const S=Y((b=j.value)==null?void 0:b.records);P.push({id:"shared-db",data:S||[]})}r(P),R(S=>({...S,content:"ready"}))}catch(C){console.log("[DatabaseApiError] getDatabaseList:",C)}},Y=o=>(o||[]).map(s=>{const M=U("shared-db").map((b,C)=>({...b,key:b.type==="divider"?`${b.key}_${s.id}`:b.key,disabled:n&&n(b.key=="edit"?7:4,s.permission)}));return s.datasourceType=="DirectDB"&&M.push({label:"\u540C\u6B65\u8868\u7ED3\u6784",key:"sync_schema",disabled:n&&n(7,s.permission)}),console.log("[DatabaseViewAdopter] actions:",M),{...s,actions:M||[]}}),ie="admin",oe=()=>Z("div",{className:"flex flex-col items-center justify-center h-full",children:[c("div",{className:"text-xl font-semibold mb-3",style:{color:"#374151"},children:c("img",{src:Ne,width:120})}),c("div",{className:"text-base mb-6",style:{color:"#6b7280"},children:"\u6682\u65E0\u6570\u636E\uFF0C\u8BF7\u5148\u6DFB\u52A0\u6570\u636E\u5E93"})]}),U=o=>{const s=J.find(b=>b.id===o);return(s==null?void 0:s.actions)||[]},le=T(()=>{var s;const o=((s=t==null?void 0:t.find(M=>M.id===f))==null?void 0:s.data)||[];return w?[]:o},[f,t,w]),X=()=>{D(!1),i(!1),v(void 0)},ce=async o=>{console.log("[DatabaseViewAdopter] \u6D4B\u8BD5\u8FDE\u63A5:",o);const s=await te(o);return s&&(i(!0),H.success("\u8FDE\u63A5\u6D4B\u8BD5\u6210\u529F\uFF01")),s};async function _(o,s,M){var b,C,j,P,S;switch(console.log("[DatabaseViewAdopter] mergedEventsEmit",o,s),o){case"card_delete":ve({title:"\u786E\u8BA4\u5220\u9664\u6570\u636E\u5E93\uFF1F",content:"\u5220\u9664\u540E\uFF0C\u8BE5\u6570\u636E\u5E93\u5C06\u65E0\u6CD5\u6062\u590D",okText:"\u5220\u9664",cancelText:"\u53D6\u6D88",async onOk(){await x(s.id,s.datasourceType)&&(u!=null&&u.current)&&(u==null||u.current.appFn.removeItem(s.id))},onCancel(){console.log("Cancel")}});break;case"card_edit":A("\u7F16\u8F91\u6570\u636E\u5E93"),D(!0),N(s.datasourceType),delete s.render,v(s);break;case"select":G(s.id);break;case"filesDir_clicked":G(s.id);break;case"dropdown_action":A("\u521B\u5EFA\u6570\u636E\u5E93"),D(!0),s.key=="add_file_db"?N("DataTable"):N("DirectDB");break;case"form_submitted":try{const k=s.fields.reduce((L,E)=>(L[E.name]=E.value,L),{}),ne=d?{id:d==null?void 0:d.id,...k}:k,V=await ue(ne,h);if(V){if(d){const L={...d,...k,datasourceType:h,actions:U("my-db").map((E,de)=>({...E,key:E.type==="divider"?`${E.key}_${V}`:E.key,allow:!0}))};(C=(b=u==null?void 0:u.current)==null?void 0:b.appFn)==null||C.updateItem(L,d==null?void 0:d.id),H.success("\u6570\u636E\u5E93\u7F16\u8F91\u6210\u529F\uFF01")}else{const L={...k,...V,createBy:ie,datasourceType:h,actions:U("my-db").map((E,de)=>({...E,key:E.type==="divider"?`${E.key}_${V}`:E.key,allow:!0}))};(P=(j=u==null?void 0:u.current)==null?void 0:j.appFn)==null||P.addItem(L,{animate:!0,position:"start"}),H.success("\u6570\u636E\u5E93\u521B\u5EFA\u6210\u529F\uFF01")}return V}}catch(k){console.error("\u4FDD\u5B58\u5931\u8D25\uFF01",k)}finally{X()}break;case"form:connect_test":return await ce(s);case"toolbar_test_empty":console.log("[DatabaseViewAdopter] toolbar_test_empty \u4E8B\u4EF6\u89E6\u53D1"),e(!w);break;case"card_sync_schema":await se(s.id)&&(i(!0),H.success("\u540C\u6B65\u8868\u7ED3\u6784\u6210\u529F\uFF01"));break;default:(S=m.eventsEmit)==null||S.call(m,o,s);break}}return Z(be,{title:"\u6570\u636E\u5E93\u7BA1\u7406",children:[c($,{ref:u,label:"",model:"tabs",defaultActiveId:f,views:J,dataSource:le,eventsEmit:_,status:W,CustomComponents:{EmptyData:oe,...l},styles:{theme:{...O,colors:{...O.colors,listBackground:"#ffffff"}},mode:"light"}},"db"),c(we,{drawerTitle:p,drawerVisible:g,isConnectSuccess:a,dbType:h,dbInfo:d,handleDrawerClose:X,eventsEmit:_})]})};export{Ve as default};
package/databaseId.js CHANGED
@@ -1 +1 @@
1
- import{jsx as t,jsxs as T,Fragment as Ee}from"react/jsx-runtime";import{useMemo as J,useState as C,useRef as Fe,useCallback as Y,useEffect as Be}from"react";import{u as Me}from"./assets/index-CpW6Dhpp.js";import{F as ze,J as H,C as Le,T as _e,U as Ve,N as Ne}from"./assets/index-DD8xyayB.js";import{a as Re,T as pe,a6 as Ue,F as ge}from"./assets/index-8h59dJlj.js";import{O as Ae}from"./assets/index-BqE1gm_T.js";/* empty css *//* empty css */import{N as xe}from"./assets/index-WQa7_NYu.js";import{s as G,M as Ce}from"./assets/index-DoUk2Ei_.js";import{D as we}from"./assets/index-BN3yu4iN.js";import{X as me}from"./assets/x-CmbLQ9dc.js";import{P as Ge,L as He}from"./assets/index-B-AFa3n1.js";import{B as he}from"./assets/index-BdNcL3V6.js";import{T as ve}from"./assets/triangle-alert-BycMPaz2.js";import"react-dom";import"./assets/index-C6WKbL3A.js";import"./assets/index-CVis9Agw.js";const We="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M14%201C13.4997%201.50025%2013.25%201.99975%2013.25%202.5C13.25%203.00025%2013.4997%203.49975%2014%204C13.4997%203.49975%2013.0003%203.25%2012.5%203.25C11.9997%203.25%2011.5003%203.49975%2011%204C11.5003%203.49975%2011.75%203.00025%2011.75%202.5C11.75%201.99975%2011.5003%201.50025%2011%201C11.5003%201.50025%2011.9997%201.75%2012.5%201.75C13.0003%201.75%2013.4997%201.50025%2014%201Z'%20fill='%23055AFF'/%3e%3cpath%20d='M13%206.28571V13C13%2013.5523%2012.5523%2014%2012%2014H4C3.44772%2014%203%2013.5523%203%2013V3C3%202.44772%203.44772%202%204%202H9.25'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3cline%20x1='5.65'%20y1='6.35'%20x2='10.35'%20y2='6.35'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3cline%20x1='5.65'%20y1='9.35'%20x2='8.35'%20y2='9.35'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3c/svg%3e",$e="data:image/svg+xml,%3csvg%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M42%2022C43.1046%2022%2044%2022.8954%2044%2024V42C44%2043.1046%2043.1046%2044%2042%2044H6C4.89543%2044%204%2043.1046%204%2042V24.0088C4%2022.9042%204.89543%2022.0078%206%2022.0078C7.10457%2022.0078%208%2022.9042%208%2024.0088V40H40V24C40%2022.8954%2040.8954%2022%2042%2022ZM24.0293%204.00195C24.0808%204.00272%2024.1322%204.00504%2024.1836%204.00977C24.1904%204.01042%2024.1973%204.011%2024.2041%204.01172C24.2673%204.01819%2024.3301%204.02757%2024.3926%204.04004C24.3939%204.04031%2024.3952%204.04075%2024.3965%204.04102C24.7693%204.11623%2025.125%204.29691%2025.4141%204.58594L34.4141%2013.5859C35.1951%2014.367%2035.1951%2015.633%2034.4141%2016.4141C33.633%2017.1951%2032.367%2017.1951%2031.5859%2016.4141L25.9922%2010.8203V32C25.9922%2033.1046%2025.0968%2034%2023.9922%2034C22.8876%2034%2021.9922%2033.1046%2021.9922%2032V10.8359L16.4141%2016.4141C15.633%2017.1951%2014.367%2017.1951%2013.5859%2016.4141C12.8049%2015.633%2012.8049%2014.367%2013.5859%2013.5859L22.498%204.67285C22.8016%204.33138%2023.2194%204.09559%2023.6924%204.02441C23.7122%204.02135%2023.732%204.01809%2023.752%204.01562C23.7862%204.01152%2023.8207%204.00919%2023.8555%204.00684C23.8887%204.00446%2023.9218%204.00268%2023.9551%204.00195C23.9674%204.00173%2023.9798%204%2023.9922%204C24.0046%204%2024.0169%204.00173%2024.0293%204.00195Z'%20fill='url(%23paint0_linear_4072_34663)'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_4072_34663'%20x1='4'%20y1='-7.25'%20x2='54.4707'%20y2='1.556'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%232B69FF'/%3e%3cstop%20offset='1'%20stop-color='%238F91FF'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",ke=({url:a,token:w,role:F,eventsEmit:p})=>{const d=Re.create({baseURL:a,timeout:1e6});return d.interceptors.request.use(u=>{let s=w;return!s&&!["user/login","user/kaptcha","user/regist"].some(i=>u.url.includes(i))?(p&&p("request:error_auth",{errorMsg:"\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F",redirect:"/login"}),Promise.reject(new Error("\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F"))):(u.headers.Authorization=s||"",u.headers.userName=F==="\u672A\u767B\u5F55\u7528\u6237"?"":F,u)}),d.interceptors.response.use(u=>{const s=["user/kaptcha"],o=u.data;if(s.some(g=>u.config.url&&u.config.url.includes(g))||o.size&&o.type)return o;const{success:i,errorMsg:b,errorCode:D}=o;if(i)return o;p&&p("request:error_business",{errorCode:D,errorMsg:b||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",response:o})},u=>{var s,o,i,b,D,g,c,R,q;if(u.message==="canceled")return Promise.reject(u);if(p){let j="request:error_network",O={errorMsg:"\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25",error:u};((s=u==null?void 0:u.response)==null?void 0:s.status)===401?(j="request:error_auth",O={errorMsg:"\u6CA1\u6709\u8DB3\u591F\u6743\u9650",error:u,redirect:"/login"}):(((i=(o=u==null?void 0:u.response)==null?void 0:o.data)==null?void 0:i.errorCode)==="30013"||((D=(b=u==null?void 0:u.response)==null?void 0:b.data)==null?void 0:D.errorCode)==="30023")&&(j="request:error_business",O={errorCode:(c=(g=u==null?void 0:u.response)==null?void 0:g.data)==null?void 0:c.errorCode,errorMsg:((q=(R=u==null?void 0:u.response)==null?void 0:R.data)==null?void 0:q.errorMsg)||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",error:u}),p(j,O)}return Promise.reject(u)}),{getTableList:async u=>{try{const s=await d.get(`/directDB/queryTableList/${u}`),{success:o,data:i}=s;if(o)return i}catch(s){console.log("getTableList error:",s)}},getTableTreeList:async u=>{try{const s=await d.get(`/dataTable/queryTableFileTreeList/${u}`),{success:o,data:i}=s;if(o)return i}catch(s){console.log("getTableTreeList error:",s)}},getDBDetailById:async(u,s)=>{const o=ye(s);try{const i=await d.get(`/${o}/queryDBInfo/${u}`),{success:b,data:D}=i;if(b)return D}catch(i){console.log("getDBDetailById error:",i)}},delTableById:async(u,s)=>{const o=ye(s);try{const i=await d.delete(`/${o}/deleteTable/${u}`),{success:b,data:D}=i;if(b)return D}catch(i){console.log("delTableById error:",i)}},delFileById:async u=>{try{const s=await d.delete(`/dataTable/deleteTableFileData/${u}`),{success:o,data:i}=s;if(o)return i}catch(s){console.log("delFileById",s)}},parseFiles:async({fileIds:u,isGenDescription:s,tableDescriptionMap:o})=>{try{const i=await d.post("/dataTable/parseFiles",{fileIds:u,isGenDescription:s,tableDescriptionMap:o}),{success:b,data:D}=i;if(b)return D}catch(i){console.log("parseFiles error:",i)}},reParseFile:async u=>{try{const s=await d.post(`/dataTable/reParseFile/${u}`),{success:o,data:i}=s;if(o)return i}catch(s){console.log("reParseFile error:",s)}},parseAppendFile:async({fileIds:u,tableId:s})=>{try{const o=await d.post("/dataTable/parseAppendFiles",{fileIds:u,tableId:s}),{success:i,data:b}=o;if(i)return b}catch(o){console.log("parseAppendFile error:",o)}},deleteUploadedFiles:async u=>{try{const s=await d.post("/dataTable/cancelUploadFile",{fileIds:u}),{success:o,data:i}=s;if(o)return i}catch(s){console.log("deleteUploadedFiles error:",s)}},getTableInfoById:async u=>{try{const s=await d.get(`/dataTable/queryTableMeta/${u}`),{success:o,data:i}=s;if(o)return i}catch(s){console.log("getTableInfoById error:",s)}},updateTableInfo:async({tableId:u,description:s,businessName:o})=>{try{const i=await d.post("/dataTable/updateTableInfo",{tableId:u,businessName:o,description:s}),{success:b,data:D}=i;if(b)return D}catch(i){console.log("updateTableInfo error:",i)}},optimizeDesc:async u=>{try{const s=await d.get(`/genTableDescription/${u}`),{success:o,data:i}=s;if(o)return i}catch(s){console.log("optimizeDesc error:",s)}}}},ye=a=>a=="DataTable"?"dataTable":"directDB",ne='<template key="type" placeholder="\u8F93\u5165\u8868\u683C\u7C7B\u578B"></template>\u8868\u683C\u4E3B\u8981\u5C55\u793A\u4E86<template key="scene" placeholder="\u8F93\u5165\u573A\u666F\u540D\u79F0"></template>\u573A\u666F\u7684\u6570\u636E,\u5305\u542B<template key="primary_key" placeholder="\u4E3B\u8981\u5B57\u6BB5(\u53EF\u5199\u591A\u4E2A,\u7528\u987F\u53F7\u5206\u9694)"></template>\u7B49\u4E3B\u8981\u5B57\u6BB5,\u652F\u6301\u7528\u6237\u67E5\u8BE2<template key="search_direction" placeholder="\u5927\u6982\u4ECB\u7ECD\u9700\u8981\u67E5\u8BE2\u7684\u65B9\u5411"></template>\u95EE\u9898,\u5982\u679C\u8BBE\u8BA1\u591A\u8868\u5173\u8054\u67E5\u8BE2,\u6700\u597D\u8BF4\u660E\u6B64\u8868\u683C\u901A\u8FC7<template key="key_name" placeholder="\u5B57\u6BB5\u540D\u79F0"></template>\u5B57\u6BB5\u53EF\u4EE5\u5173\u8054\u53E6\u4E00\u4E2A<template key="table_name" placeholder="\u8868\u683C\u540D\u79F0"></template>\u8868\u683C\u3002',Ze={colors:{background:"#ffffff",border:"#e5e7eb",appBackground:"#ffffff",listBackground:"#ffffff",dashboardBackground:"#ffffff"},space:{padding:"0",margin:"md",shadow:"none"}},qe=({drawerTitle:a,drawerVisible:w,uploadUrl:F,handleDrawerClose:p,dbId:d,tableInfo:m,token:Z,url:E,role:X})=>{const M=J(()=>({id:"upload",layout:"vertical",formWidth:"670px",fields:[{id:"fileIds",name:"fileIds",type:"uploader",required:!1,defaultValue:"",uploaderConfig:{multiple:!m,accept:".csv,.xlsx,.xls",maxFiles:m?1:20,url:F,autoUpload:!0,headers:{Authorization:Z},queryParams:{databaseId:d,...m&&{tableId:m.tableId}},placeholder:T("div",{children:[t("div",{className:"text-lg font-bold",children:"\u70B9\u51FB\u6216\u5C06\u6587\u4EF6\u62D6\u62FD\u5230\u6B64\u5904\u4E0A\u4F20"}),T("div",{className:"flex flex-col gap-1.8 mt-[12px]",children:[t("div",{className:"text-[#888888] font-[12px]",children:"\u6570\u91CF\uFF1A\u226420 \u6587\u4EF6\uFF08\u5F53\u524D 0/20\uFF09"}),t("div",{className:"text-[#888888] font-[12px]",style:{width:"580px"},children:"\u683C\u5F0F\uFF1A.xlsx / .xls / .csv /\uFF08\u7B2C\u4E00\u884C\u662F\u8868\u5934\uFF0C\u5176\u4ED6\u884C\u662F\u6570\u636E\uFF1BCSV \u652F\u6301 UTF-8/GBK/GB2312\u2026\uFF09"}),t("div",{className:"text-[#888888] font-[12px]",children:"\u5355\u6587\u4EF6\u9650\u5236\uFF1A \u226410\u4E07\u884C\uFF0C\u226460\u5217\uFF08\u8D85\u51FA\u81EA\u52A8\u5FFD\u7565\uFF09\uFF1B \u6BCF\u6587\u4EF6 \u22641\u4E2ASheet"}),t("div",{className:"text-[#888888] font-[12px]",children:"\u4E0A\u4F20\u7684\u6587\u4EF6\uFF0C\u5982\u679C\u6709\u4E0D\u7B26\u5408\u6587\u672C\u683C\u5F0F\u7684\u6570\u636E\u7CFB\u7EDF\u81EA\u52A8\u5FFD\u7565"})]})]}),listName:m?"\u8FFD\u52A0\u6587\u4EF6":"\u4E0A\u4F20\u6587\u4EF6\u5217\u8868",icons:{dragUpload:t("img",{src:$e,width:40}),itemStatus:{pending:t("span",{style:{fontSize:"12px",color:"#6b7280"}}),uploading:t("span",{style:{fontSize:"12px",color:"#007bff"}}),success:t("span",{style:{fontSize:"12px",color:"#10b981"}}),error:t("span",{style:{fontSize:"12px",color:"#ef4444"},children:"\u5931\u8D25"})},fileType:{default:t(ze,{size:20,style:{color:"#6b7280"}})}},...!m&&{buttons:[{label:"\u4F7F\u7528\u6A21\u7248",icon:t("img",{src:We}),mode:"text",onClick:()=>{i(!0)}}]},...!m&&{itemForm:[{type:"textarea",name:"description",counter:150,placeholder:"\u4E3A\u4E86\u63D0\u9AD8\u95EE\u7B54\u51C6\u786E\u7387\uFF0C\u8BF7\u8F93\u5165\u63CF\u8FF0"}]}}}]}),[m]),[L,h]=C(!1),[f,W]=C({}),V=Fe(null),[$,N]=C(!1),[u,s]=C([]),[o,i]=C(!1),[b,D]=C(ne),[g,c]=C(null),[R,q]=C(ne),[j,O]=C(0),{parseFiles:ue,parseAppendFile:te,deleteUploadedFiles:ae}=ke({url:E,token:Z,role:X}),K=Y(async(n,l,S)=>{var B;switch(console.log("[DynamicFormAdopter] \u4E8B\u4EF6:",n,l),n){case"form:ready":l.formRef?V.current=l.formRef:console.log("\u274C data.formRef \u4E3A\u7A7A\uFF0C\u65E0\u6CD5\u4FDD\u5B58\u8868\u5355\u5F15\u7528");break;case"form:submit":P();break;case"form_field_change":W(A=>({...A,[l.fieldId]:l.value}));break;case"uploader:error":(B=l.item)!=null&&B.id?s(A=>[{id:l.item.id,status:l.item.status},...A]):G.error(l==null?void 0:l.message);break;case"uploader:success":s(A=>[{id:l.item.id,status:l.item.status},...A]);break;case"uploader:remove":const _=l.item.status;s(A=>A.filter(r=>r.id!==l.item.id)),_=="success"&&await ee([l.item.uploadApiRes]);break;default:console.log("\u672A\u5904\u7406\u7684\u4E8B\u4EF6:",n)}},[]),se=J(()=>({label:"\u52A8\u6001\u8868\u5355\u793A\u4F8B",defaultActiveId:"form-view",model:null,views:[{label:"\u7528\u6237\u6CE8\u518C\u8868\u5355",id:"form-view",type:"form",size:"md",formWidth:M.formWidth,formConfig:{layout:M.layout,showReset:!1,showSubmit:!1,formWidth:M.formWidth,getFormData:()=>({...f,timestamp:new Date().toISOString(),formId:M.id}),onFieldChange:(n,l)=>{K("form_field_change",{fieldId:n,value:l},void 0)},onValidationError:n=>{K("form_validation_error",n,void 0)}}}],dataSource:[{id:M.id,fields:M.fields,defaultValues:{}}],eventsEmit:K,styles:{theme:Ze}}),[m,M]),P=async()=>{var n;try{h(!0);const l=await V.current.getAllData();if(l.isValid){const S=(n=l.fields.find(B=>B.name=="fileIds"))==null?void 0:n.value;if(Array.isArray(S)&&(S==null?void 0:S.length)>0){let B;if(m)B=await te({fileIds:S.map(_=>_.uploadApiRes),tableId:m.id});else{const _={fileIds:S.map(A=>A.uploadApiRes),tableDescriptionMap:S.reduce((A,r)=>(A[r.uploadApiRes]=r.formData.description,A),{}),isGenDescription:$};B=await ue(_)}B&&p("refresh")}}}catch(l){console.error("\u8868\u5355\u6570\u636E\u5931\u8D25:",l)}finally{p(),h(!1),N(!1)}},Q=async n=>{var l;try{const S=await V.current.getAllData();if(S.isValid){const B=(l=S.fields.find(_=>_.name=="fileIds"))==null?void 0:l.value;if(B&&Array.isArray(B)&&(B==null?void 0:B.length)>0){const _=B.map(r=>r.uploadApiRes),A=await ee(_)}}}catch(S){console.error("\u8868\u5355\u6570\u636E\u5931\u8D25:",S)}finally{p(),N(!1)}},ee=async n=>{try{const l=await ae(n);if(l)return l}catch(l){console.error("\u5220\u9664\u6587\u4EF6\u6570\u636E\u5931\u8D25:",l)}},ie=n=>{N(n)},oe=Y(n=>{D(n),console.log("\u6A21\u7248\u5185\u5BB9\u53D8\u5316:",n)},[]),re=Y(n=>{c(()=>n),console.log("getData\u51FD\u6570\u5DF2\u8BBE\u7F6E")},[]),le=Y(async()=>{try{if(!g){console.error("getData\u51FD\u6570\u5C1A\u672A\u51C6\u5907\u597D\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");return}const n=g("pure_string");await navigator.clipboard.writeText(n),G.success("\u5DF2\u590D\u5236",1)}catch(n){console.error("\u590D\u5236\u5931\u8D25:",n)}finally{i(!1)}},[g]);return T(we,{title:a,className:"database-upload-drawer",placement:"right",width:720,closeIcon:!1,extra:t(me,{size:20,color:"#888888",onClick:()=>Q(),className:"cursor-pointer"}),open:w,destroyOnHidden:!0,footer:T("div",{className:"flex items-center",style:{justifyContent:m?"end":"space-between"},children:[!m&&T("div",{className:"flex gap-2 items-center",children:[t("span",{children:"\u81EA\u52A8\u751F\u6210\u6570\u636E\u8868\u63CF\u8FF0"})," ",t(pe,{title:"\u81EA\u52A8\u751F\u6210\u5F00\u542F\u65F6\u5C06\u57FA\u4E8E\u6570\u636E\u667A\u80FD\u751F\u6210\u63CF\u8FF0\uFF1B\u82E5\u5F00\u542F\u6B64\u529F\u80FD\u5E76\u624B\u52A8\u586B\u5199\u63CF\u8FF0\uFF0C\u5C06\u4F18\u5148\u91C7\u7528\u7528\u6237\u586B\u5199\u7684\u5185\u5BB9\u3002",children:t(Le,{size:14})}),t(Ue,{onChange:ie})]}),T("div",{className:"flex self-end gap-3",children:[t(H,{mode:"default",style:{marginRight:10},label:"\u53D6\u6D88",onClick:Q}),t(H,{mode:"primary",label:"\u786E\u8BA4\u5BFC\u5165",loading:L,disabled:u.some(n=>n.status=="error"),onClick:async()=>{await P()}})]})]}),children:[t(Ae,{...se},"upload-file"),t(Ce,{title:T("div",{children:["\u6A21\u7248",t("span",{className:"text-[12px] text-[#888888] ml-[8px]",children:"\u5B8C\u6210\u7F16\u8F91\u540E\uFF0C\u53EF\u5C06\u6587\u672C\u590D\u5236\u7C98\u8D34\u5230\u76F8\u5E94\u63CF\u8FF0\u6846\u4E2D\u3002"})]}),width:672,destroyOnHidden:!0,open:o,onCancel:()=>i(!1),footer:T("div",{className:"flex justify-end items-center gap-3",children:[t(H,{mode:"default",label:"\u91CD\u7F6E",onClick:()=>{q(ne),O(n=>n+1)}}),t(H,{mode:"primary",label:"\u590D\u5236",onClick:le})]}),children:t(xe,{data:R,onChange:oe,onGetData:re,styles:{theme:{colors:{primary:"#0969da",secondary:"#6b7280",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6",background:"#ffffff",text:"#1f2937",border:"#e5e7eb",disabled:"#9ca3af",disabledBackground:"#f3f4f6",disabledText:"#6b7280",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)",appBackground:"transparent",listBackground:"#f9fafb",dashboardBackground:"#ffffff",textSecondary:"#6b7280"},space:{sidebar:"260px",size:"12px",radius:"8px",padding:"1rem",margin:"1rem",shadow:"0 2px 8px rgba(0,0,0,0.1)",lineHeight:"1.8"},icons:{},fonts:{body:{size:"14px",weight:"normal",family:"PingFang SC, Microsoft YaHei, Arial, sans-serif"},heading:{size:"14px",weight:"600",family:"PingFang SC, Microsoft YaHei, Arial, sans-serif"}},others:{baseFontWeight:"normal"}},templateField:{backgroundColor:"#E5EEFF",borderColor:"#84ADFF",borderRadius:"6px",padding:"6px 12px",margin:"2px",fontSize:"14px",fontWeight:"500",minWidth:"80px",textColor:"#84ADFF"}}},j)})]})},je="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M14%201C13.4997%201.50025%2013.25%201.99975%2013.25%202.5C13.25%203.00025%2013.4997%203.49975%2014%204C13.4997%203.49975%2013.0003%203.25%2012.5%203.25C11.9997%203.25%2011.5003%203.49975%2011%204C11.5003%203.49975%2011.75%203.00025%2011.75%202.5C11.75%201.99975%2011.5003%201.50025%2011%201C11.5003%201.50025%2011.9997%201.75%2012.5%201.75C13.0003%201.75%2013.4997%201.50025%2014%201Z'%20fill='%23055AFF'/%3e%3cpath%20d='M13%206.28571V13C13%2013.5523%2012.5523%2014%2012%2014H4C3.44772%2014%203%2013.5523%203%2013V3C3%202.44772%203.44772%202%204%202H9.25'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3cline%20x1='5.65'%20y1='6.35'%20x2='10.35'%20y2='6.35'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3cline%20x1='5.65'%20y1='9.35'%20x2='8.35'%20y2='9.35'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3c/svg%3e",Oe="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_4199_8826)'%3e%3cpath%20d='M15.5554%2012.4444C14.9626%2013.0373%2014.6666%2013.6293%2014.6666%2014.2222C14.6666%2014.8151%2014.9626%2015.4071%2015.5554%2016C14.9626%2015.4071%2014.3706%2015.1111%2013.7777%2015.1111C13.1848%2015.1111%2012.5928%2015.4071%2011.9999%2016C12.5928%2015.4071%2012.8888%2014.8151%2012.8888%2014.2222C12.8888%2013.6293%2012.5928%2013.0373%2011.9999%2012.4444C12.5928%2013.0373%2013.1848%2013.3333%2013.7777%2013.3333C14.3706%2013.3333%2014.9626%2013.0373%2015.5554%2012.4444ZM14.6488%204.01778C15.1905%204.55954%2015.4948%205.29431%2015.4948%206.06044C15.4948%206.82658%2015.1905%207.56135%2014.6488%208.10311L7.735%2015.0169C7.46766%2015.2892%207.14901%2015.5058%206.79746%2015.6543C6.44592%2015.8028%206.06844%2015.8801%205.68684%2015.8819C5.30523%2015.8836%204.92706%2015.8097%204.57417%2015.6645C4.22127%2015.5193%203.90065%2015.3056%203.63081%2015.0357C3.36097%2014.7659%203.14727%2014.4453%203.00205%2014.0924C2.85682%2013.7395%202.78295%2013.3613%202.7847%2012.9797C2.78646%2012.5981%202.8638%2012.2206%203.01226%2011.8691C3.16072%2011.5176%203.37736%2011.1989%203.64967%2010.9316L3.95545%2010.6249L3.85145%2010.5244C3.30922%2010.0267%202.76522%209.77778%202.22211%209.77778C1.62923%209.77778%201.03722%2010.0738%200.444336%2010.6667C1.03722%2010.0738%201.33322%209.48178%201.33322%208.88889C1.33322%208.296%201.03722%207.704%200.444336%207.11111C1.03722%207.704%201.62923%208%202.22211%208C2.815%208%203.407%207.704%203.99989%207.11111C3.407%207.704%203.111%208.296%203.111%208.88889C3.111%209.46667%203.39278%2010.0444%203.95545%2010.6222L10.5634%204.01778C11.1052%203.47606%2011.84%203.17173%2012.6061%203.17173C13.3723%203.17173%2014.107%203.47606%2014.6488%204.01778ZM9.55189%206.91378L4.59189%2011.8738C4.30004%2012.1655%204.13603%2012.5612%204.13594%2012.9739C4.1359%2013.1782%204.17611%2013.3806%204.25426%2013.5694C4.33242%2013.7582%204.44699%2013.9297%204.59145%2014.0742C4.7359%2014.2187%204.9074%2014.3334%205.09617%2014.4116C5.28493%2014.4898%205.48725%2014.5301%205.69158%2014.5302C6.10424%2014.5303%206.50004%2014.3664%206.79189%2014.0747L11.7519%209.11378L9.55189%206.91378ZM11.5066%204.96089L10.495%205.97156L12.695%208.17156L13.7057%207.16C13.9846%206.86582%2014.1377%206.47437%2014.1323%206.069C14.1269%205.66364%2013.9635%205.27639%2013.6768%204.98973C13.3902%204.70306%2013.0029%204.53964%2012.5976%204.53425C12.1922%204.52887%2011.8007%204.68194%2011.5066%204.96089ZM9.59545%200C8.85589%200.740444%208.48434%201.48178%208.48434%202.22222C8.48434%202.96267%208.85589%203.704%209.59545%204.44444C8.85589%203.704%208.11456%203.33333%207.37322%203.33333C6.63367%203.33333%205.89234%203.704%205.151%204.44444C5.89234%203.704%206.26211%202.96267%206.26211%202.22222C6.26211%201.48178%205.89322%200.740444%205.15189%200C5.89322%200.740444%206.63456%201.11111%207.37411%201.11111C8.11545%201.11111%208.85678%200.740444%209.59634%200H9.59545Z'%20fill='%23055AFF'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_4199_8826'%3e%3crect%20width='16'%20height='16'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",{confirm:Ye}=Ce,Xe='<template key="type" placeholder="\u8F93\u5165\u8868\u683C\u7C7B\u578B"></template>\u8868\u683C\u4E3B\u8981\u5C55\u793A\u4E86<template key="scene" placeholder="\u8F93\u5165\u573A\u666F\u540D\u79F0"></template>\u573A\u666F\u7684\u6570\u636E,\u5305\u542B<template key="primary_key" placeholder="\u4E3B\u8981\u5B57\u6BB5(\u53EF\u5199\u591A\u4E2A,\u7528\u987F\u53F7\u5206\u9694)"></template>\u7B49\u4E3B\u8981\u5B57\u6BB5,\u652F\u6301\u7528\u6237\u67E5\u8BE2<template key="search_direction" placeholder="\u5927\u6982\u4ECB\u7ECD\u9700\u8981\u67E5\u8BE2\u7684\u65B9\u5411"></template>\u95EE\u9898,\u5982\u679C\u8BBE\u8BA1\u591A\u8868\u5173\u8054\u67E5\u8BE2,\u6700\u597D\u8BF4\u660E\u6B64\u8868\u683C\u901A\u8FC7<template key="key_name" placeholder="\u5B57\u6BB5\u540D\u79F0"></template>\u5B57\u6BB5\u53EF\u4EE5\u5173\u8054\u53E6\u4E00\u4E2A<template key="table_name" placeholder="\u8868\u683C\u540D\u79F0"></template>\u8868\u683C\u3002',Ke=({drawerTitle:a,drawerVisible:w,tableInfo:F,handleDrawerClose:p,optimizeDesc:d,eventsEmit:m})=>{const Z=J(()=>(F==null?void 0:F.data.find(c=>c.columnId=="name").value)||"-",[F]),[E,X]=C(""),[M,L]=C(null),[h,f]=C(""),[W,V]=C(0),[$,N]=C(!1),[u,s]=C(!1);Be(()=>{const c=(F==null?void 0:F.data.find(R=>R.columnId=="description").value)||"-";f(c)},[F]);const o=()=>{Ye({title:"\u4F60\u786E\u5B9A\u8981\u4F7F\u7528\u6A21\u677F\u5417\uFF1F",content:"\u8FD9\u5C06\u66FF\u6362\u4F60\u5F53\u524D\u5DF2\u586B\u5199\u7684\u5185\u5BB9\uFF0C\u4E14\u65E0\u6CD5\u64A4\u9500\u3002",okText:"\u786E\u8BA4\u66FF\u6362",cancelText:"\u53D6\u6D88",onOk(){f(Xe),V(c=>c+1)},onCancel(){console.log("Cancel")}})},i=Y(c=>{X(c),console.log("\u6A21\u7248\u5185\u5BB9\u53D8\u5316:",c)},[]),b=Y(c=>{L(()=>c),console.log("getData\u51FD\u6570\u5DF2\u8BBE\u7F6E")},[]),D=async()=>{try{N(!0);const c=await d(F.tableId);c&&(f(c),V(R=>R+1),N(!1))}catch{G.error("AI \u4F18\u5316\u5931\u8D25")}},g=Y(()=>{if(!M){console.error("getData\u51FD\u6570\u5C1A\u672A\u51C6\u5907\u597D\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");return}const c=M("pure_string");m("table_info:update",c)},[M,m]);return T(we,{title:a,placement:"right",width:720,onClose:p,closeIcon:!1,extra:t(me,{size:20,color:"#888888",onClick:p,className:"cursor-pointer"}),open:w,destroyOnHidden:!0,footer:t("div",{className:"flex items-center",style:{justifyContent:"end"},children:T("div",{className:"flex self-end gap-3",children:[t(H,{mode:"default",style:{marginRight:10},label:"\u53D6\u6D88",onClick:p}),t(H,{mode:"primary",label:"\u786E\u8BA4",onClick:()=>g(),disabled:$})]})}),children:[t("div",{className:"mb-[10px] font-bold",children:Z}),T("div",{className:"mb-[10px]",children:[t("span",{style:{color:"#FF3B30",marginRight:"4px"},children:"*"}),t("span",{children:"\u6570\u636E\u8868\u63CF\u8FF0"}),t("span",{className:"text-[#888888] ml-[4px]",children:"(\u8BF7\u51C6\u786E\u586B\u5199\u8868\u683C\u7684\u5E94\u7528\u573A\u666F\u63CF\u8FF0\uFF0C\u5927\u6A21\u578B\u5C06\u4F9D\u8D56\u6B64\u4FE1\u606F\u8BC6\u522B\u5E76\u6B63\u786E\u8C03\u7528\u8BE5\u6570\u636E\u8868\u3002)"})]}),t(xe,{data:h,onChange:i,onGetData:b,styles:{theme:{colors:{primary:"#0969da",secondary:"#6b7280",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6",background:"#ffffff",text:"#1f2937",border:"#e5e7eb",disabled:"#9ca3af",disabledBackground:"#f3f4f6",disabledText:"#6b7280",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)",appBackground:"transparent",listBackground:"#f9fafb",dashboardBackground:"#ffffff",textSecondary:"#6b7280"},space:{sidebar:"260px",size:"12px",radius:"8px",padding:"1rem",margin:"1rem",shadow:"0 2px 8px rgba(0,0,0,0.1)",lineHeight:"1.8"},icons:{},fonts:{body:{size:"14px",weight:"normal",family:"PingFang SC, Microsoft YaHei, Arial, sans-serif"},heading:{size:"14px",weight:"600",family:"PingFang SC, Microsoft YaHei, Arial, sans-serif"}},others:{baseFontWeight:"normal"}},templateField:{backgroundColor:"#E5EEFF",borderColor:"#84ADFF",borderRadius:"6px",padding:"6px 12px",margin:"2px",fontSize:"14px",fontWeight:"500",minWidth:"80px",textColor:"#84ADFF"}}},W),T("div",{children:[t(Ge,{open:u,onOpenChange:c=>s(!!c),content:t("div",{style:{width:"600px",margin:"10px",padding:"10px"},onClick:o,className:"hover:bg-gray-100 h-[80px] cursor-pointer rounded",children:"______\u8868\u683C\u4E3B\u8981\u5C55\u793A\u4E86______\u573A\u666F\u7684\u6570\u636E\uFF0C\u5305\u542B______\u3001______\u3001______\u7B49\u4E3B\u8981\u5B57\u6BB5\uFF0C\u652F\u6301\u7528\u6237\u67E5\u8BE2______\u95EE\u9898(\u5927\u6982\u4ECB\u7ECD)\u5982\u679C\u6D89\u53CA\u591A\u8868\u5173\u8054\u67E5\u8BE2\uFF0C\u6700\u597D\u8BF4\u660E\u6B64\u8868\u683C\u901A\u8FC7______\u5B57\u6BB5\u53EF\u4EE5\u5173\u8054\u53E6\u4E00\u4E2A______\u8868\u683C\u3002"}),title:T("div",{className:"flex justify-between items-center",style:{margin:"10px"},children:[t("div",{className:"text-[16px]",children:"\u6A21\u7248"}),t(me,{size:20,color:"#888888",onClick:()=>s(!1),className:"cursor-pointer"})]}),trigger:"click",destroyOnHidden:!0,placement:"bottomRight",getPopupContainer:c=>c,children:t("span",{children:t(H,{mode:"text",icon:t("img",{src:je}),children:"\u4F7F\u7528\u6A21\u7248"})})}),t(H,{onClick:D,mode:"text",icon:t("img",{src:Oe}),loading:$,children:"AI\u4F18\u5316"})]})]})},Je=""+new URL("assets/empty.png",import.meta.url).href;var U=(a=>(a[a.DATE=0]="DATE",a[a.VIEW=1]="VIEW",a[a.ERROR=2]="ERROR",a[a.AUTHORIZE=3]="AUTHORIZE",a[a.DELETE=4]="DELETE",a[a.ANALYSIS_OR_EXTRACT=5]="ANALYSIS_OR_EXTRACT",a[a.DOWNLOAD=6]="DOWNLOAD",a[a.EDIT=7]="EDIT",a[a.ADD=8]="ADD",a[a.ANALYSIS_CONFIG=9]="ANALYSIS_CONFIG",a[a.AUTHORIZE_CONFIG=10]="AUTHORIZE_CONFIG",a))(U||{}),fe=(a=>(a.GENERATING="generating",a.SUCCESS="success",a.FAIL="fail",a))(fe||{});const ce={success:"green",error:"red",warning:"orange",processing:"blue",info:"cyan",default:"default"},Pe=a=>typeof a=="string"&&a in ce?ce[a]:ce.default,de=a=>{const{value:w,cell:F}=a;switch(F.columnId){case"importstatus":return w?t(pe,{title:"\u6709\u8FFD\u52A0\u5931\u8D25\u7684\u6587\u4EF6\uFF0C\u8BF7\u53CA\u65F6\u5904\u7406",children:t(_e,{color:"red",bordered:!1,children:"\u8FFD\u52A0\u5931\u8D25"})}):t(Ee,{});case"status":const p=Pe(a.cell.statusType);return w=="\u5BFC\u5165\u5931\u8D25"?t(pe,{title:F.errorMsg,children:T("div",{className:"flex items-center gap-2",children:[t(he,{color:p,text:w}),t(ve,{size:14,color:"red"})]})}):t(he,{color:p,text:w});default:return t(Ee,{})}},De=[{statusType:"success",value:"\u5BFC\u5165\u6210\u529F",status:"30"},{statusType:"error",value:"\u5BFC\u5165\u5931\u8D25",status:"00"},{statusType:"default",value:"\u5F85\u5BFC\u5165",status:"10"},{statusType:"processing",value:"\u5BFC\u5165\u4E2D",status:"20"},{statusType:"processing",value:"\u5BFC\u5165\u4E2D",status:"11"}],Qe=a=>{var p,d;const{cell:w,value:F}=a;return typeof F=="string"?t("div",{title:F,style:{maxWidth:240,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:F}):(p=w.tableMeta)!=null&&p.isGenDescription&&((d=w.tableMeta)==null?void 0:d.generateDescriptionStatus)=="generating"?T("div",{className:"flex items-center gap-1 text-[#84ADFF]",style:{color:"#84ADFF"},children:[t("span",{children:"\u751F\u6210\u4E2D"}),t(He,{size:14})]}):"-"},eu=({dbInfo:a,setDrawerTitle:w,setDrawerVisible:F,getBtnDisabled:p})=>T("div",{className:"flex flex-col items-center justify-center h-full",children:[t("div",{className:"text-xl font-semibold mb-3",children:t("img",{src:Je,width:120})}),t("div",{className:"text-base mb-2",style:{color:"#888888"},children:"\u6682\u65E0\u6570\u636E\u6587\u4EF6"}),t("div",{className:"flex gap-3",children:t(H,{mode:"primary",label:"\u4E0A\u4F20\u6570\u636E\u6587\u4EF6",disabled:p&&p(8,a==null?void 0:a.permission),onClick:()=>{w("\u4E0A\u4F20\u6570\u636E\u6587\u4EF6"),F(!0)}})})]}),{confirm:be}=Ce,hu=a=>{const{url:w,token:F,role:p,id:d,dbType:m,CustomComponents:Z,getBtnDisabled:E,uploadUrl:X}=a,[M,L]=C({container:"ready",content:"ready"}),h=Fe(null),f=Fe(null),[W,V]=C(),[$,N]=C({}),[u,s]=C(),[o,i]=C(!1),[b,D]=C(""),[g,c]=C(),[R,q]=C(!1),[j,O]=C(""),{getTableList:ue,delTableById:te,delFileById:ae,updateTableInfo:K,optimizeDesc:se,getTableTreeList:P,reParseFile:Q,getDBDetailById:ee}=ke({url:w,token:F,role:p,eventsEmit:a.eventsEmit});Be(()=>(d&&m&&(L(r=>({...r,container:"loading"})),ie()),()=>{f.current&&(clearTimeout(f.current),f.current=null)}),[d,m]);const ie=async()=>{try{const r=await ee(d,m);r&&(s(r),L(e=>({...e,container:"ready",content:"loading"})))}catch(r){console.log("[TableApiError] getDBInfo:",r)}await A()},oe=async()=>{try{if(m=="DirectDB"){const r=await ue(d);if(r){const e=le(r);return V(e||[]),L(z=>({...z,content:"ready"})),e||[]}else L(e=>({...e,content:"error"}))}else{const r=await P(d);if(r){const e=re(r);return V(e||[]),L(z=>({...z,content:"ready"})),e||[]}else L(e=>({...e,content:"error"}))}}catch(r){console.log("[TableApiError] getTableList:",r)}};function re(r){return(r||[]).map((e,z)=>{var x,I;let y=De.find(v=>v.status==e.status);const k=e.children.some(v=>v.status=="00");return{id:e.fileId.toString(),tableId:e.tableId,data:[{columnId:"name",value:(e==null?void 0:e.originalFilename)||"-",type:"label"},{columnId:"description",value:(x=e==null?void 0:e.tableMeta)==null?void 0:x.description,type:"customized",tableMeta:e==null?void 0:e.tableMeta},{columnId:"count",value:`${e.rowCount}\u884C\uFF0C${e.columnCount}\u5217`,type:"text"},{columnId:"status",...y,type:"customized",errorMsg:e.errorMsg},{columnId:"importstatus",value:k,type:"customized"},{columnId:"createdAt",value:e.gmtCreate,type:"date"},{columnId:"updatedAt",value:e.gmtModified,type:"date"},...e.status=="30"?[{columnId:"actions",value:"view",label:"\u67E5\u770B",type:"action",disabled:E&&E(U.VIEW,e.permission)},{columnId:"actions",value:"edit",label:"\u4FEE\u6539\u914D\u7F6E",type:"action",disabled:E&&E(U.EDIT,e.permission)},{columnId:"actions",value:"addData",label:"\u8FFD\u52A0\u6570\u636E",type:"action",disabled:E&&E(U.EDIT,e.permission)}]:[],...e.status=="00"?[{columnId:"actions",value:"reValidate",label:"\u91CD\u65B0\u5BFC\u5165",type:"action"}]:[],{columnId:"actions",value:"delete",label:"\u5220\u9664",type:"action",disabled:E&&E(U.DELETE,e.permission)}],expanded:!1,...e.children&&((I=e.children)==null?void 0:I.length)>0&&{children:[...(e.children||[]).map(v=>{const Ie=De.find(Se=>Se.status==v.status),Te=[{columnId:"name",value:v.originalFilename,type:"text"},{columnId:"count",value:`${v.rowCount}\u884C\uFF0C${v.columnCount}\u5217`,type:"text"},{columnId:"status",...Ie,errorMsg:v.errorMsg,type:"customized"},{columnId:"createdAt",value:v.gmtCreate,type:"date"},{columnId:"updatedAt",value:v.gmtModified,type:"date"},...v.status=="30"?[{columnId:"actions",value:"view",label:"\u67E5\u770B",type:"action",disabled:E&&E(U.VIEW,v.permission)}]:[],...v.status=="00"?[{columnId:"actions",value:"reValidate",label:"\u91CD\u65B0\u5BFC\u5165",type:"action",disabled:E&&E(U.ADD,v.permission)}]:[],{columnId:"actions",value:"delete_sub",label:"\u5220\u9664",type:"action",disabled:E&&E(U.DELETE,v.permission)}];return{id:v.fileId.toString(),tableId:v.tableId,data:Te}})]}}})}function le(r){return(r||[]).map((e,z)=>({id:e.id||Me(8),data:[{columnId:"name",value:e.physicalName},{columnId:"cnname",value:e.businessName},{columnId:"colcount",value:e.columnCount},{columnId:"count",value:`${e.rowCount}\u884C\uFF0C${e.columnCount}\u5217`},{columnId:"actions",value:"view",label:"\u67E5\u770B",disabled:E&&E(U.VIEW,e.permission)}]}))}async function n(r,e,z){switch(console.log("[adopter] mergedEventsEmit",r,e,z),r){case"table_action_delete":{try{if(console.log("[delete] \u5220\u9664\u4E8B\u4EF6\u6570\u636E:",e),!e||!e.tableId&&!e.id){console.error("[delete] \u5220\u9664\u4E8B\u4EF6\u6570\u636E\u4E0D\u5B8C\u6574:",e),G.error("\u5220\u9664\u5931\u8D25\uFF1A\u6570\u636E\u4E0D\u5B8C\u6574");return}const y=e.tableId||e.id,k=e.id;be({title:"\u786E\u8BA4\u5220\u9664\u6570\u636E\u5E93\uFF1F",content:"\u8BE5\u6570\u636E\u8868\u53CA\u5176\u8FFD\u52A0\u6570\u636E\u90FD\u5C06\u88AB\u5220\u9664\u4E14\u65E0\u6CD5\u6062\u590D",icon:t(ve,{color:"#FF4D4F",className:"mr-[8px]"}),okText:"\u5220\u9664",cancelText:"\u53D6\u6D88",async onOk(){await te(y,m)&&(h!=null&&h.current)?(h==null||h.current.appFn.removeItem(k),G.success("\u5220\u9664\u6210\u529F")):G.error("\u5220\u9664\u5931\u8D25")}})}catch(y){console.error("\u5220\u9664\u8868\u6570\u636E\u5931\u8D25:",y),G.error("\u5220\u9664\u5931\u8D25")}break}case"table_action_edit":{O("\u4FEE\u6539\u6570\u636E\u914D\u7F6E"),q(!0),c(e);break}case"toolbar_upload":{D("\u4E0A\u4F20\u6570\u636E\u6587\u4EF6"),i(!0);break}case"table_action_addData":{D("\u8FFD\u52A0\u6570\u636E"),i(!0),c(e);break}case"table_action_reValidate":{await Q(e.id)&&(f.current&&(clearTimeout(f.current),f.current=null),await A());break}case"table_info:update":{try{if(g!=null&&g.id){const y=(g==null?void 0:g.data.find(x=>x.columnId=="name").value)||"-";if(await K({tableId:g.tableId,description:e,businessName:y})&&(h!=null&&h.current)){const x={...g,data:g.data.map(I=>I.columnId=="description"?{...I,value:e}:I)};h==null||h.current.appFn.updateItem(x,g.id),G.success("\u4FEE\u6539\u914D\u7F6E\u6210\u529F")}}}catch(y){console.error("\u4FEE\u6539\u914D\u7F6E\u5931\u8D25",y)}finally{B()}break}case"table_action_delete_sub":{try{be({title:"\u786E\u8BA4\u5220\u9664\u6570\u636E\uFF1F",content:"\u5220\u9664\u540E\uFF0C\u8BE5\u6570\u636E\u5C06\u65E0\u6CD5\u6062\u590D",okText:"\u5220\u9664",cancelText:"\u53D6\u6D88",async onOk(){const{id:y,tableId:k}=e;await ae(e.id)&&(h!=null&&h.current)&&(N(I=>({...I,[k]:[...I[k]||[],y]})),e.data.find(I=>I.status=="00")&&(f.current&&(clearTimeout(f.current),f.current=null),A()),z.removeItem(y,k),G.success("\u8FFD\u52A0\u6587\u4EF6\u6570\u636E\u5220\u9664\u6210\u529F"))}})}catch{console.log("\u5220\u9664\u8868\u6570\u636E\u5931\u8D25")}break}case"toolbar_auth":{typeof a.eventsEmit=="function"&&a.eventsEmit("toolbar_auth",u);break}default:typeof a.eventsEmit=="function"&&a.eventsEmit(r,e);break}}const l=J(()=>({label:"\u6570\u636E\u8868\u7BA1\u7406",model:null,defaultActiveId:"direct-table-view",views:[{label:"\u6211\u7684\u6570\u636E\u5E93",id:"direct-table-view",type:"table",viewBehavior:"pagination",allowMultiSelect:!1,columns:[{id:"name",title:"\u6570\u636E\u8868\u82F1\u6587\u540D\u79F0",type:"label"},{id:"cnname",title:"\u6570\u636E\u8868\u4E2D\u6587\u540D\u79F0",type:"label"},{id:"colcount",title:"\u5B57\u6BB5\u6570",type:"text"},{id:"count",title:"\u6570\u636E\u91CF",type:"text"},{id:"actions",title:"\u64CD\u4F5C",type:"action"}],toolbar:[{type:"fuzzy_search",key:"search",label:"\u641C\u7D22",searchKeys:["name","description"],position:"right"},{type:"button",key:"auth",label:"\u914D\u7F6E",btnType:"default",position:"right"}]}]}),[W,m]),S=J(()=>({label:"\u6570\u636E\u8868\u7BA1\u7406",model:null,defaultActiveId:"data-table-view",views:[{label:"\u4E0A\u4F20\u6570\u636E\u5217\u8868",id:"data-table-view",type:"table",viewBehavior:"pagination",allowMultiSelect:!1,viewPageSize:10,columns:[{id:"name",title:"\u6587\u4EF6\u540D",type:"label",tip:"\u6587\u4EF6\u540D"},{id:"description",title:"\u63CF\u8FF0",type:"customized",component:t(Qe,{}),helpText:"\u6253\u5F00\u81EA\u52A8\u751F\u6210\u63CF\u8FF0\u5F00\u5173\u540E\uFF0C\u82E5\u63CF\u8FF0\u672A\u6B63\u5E38\u751F\u6210\uFF0C\u5219\u63CF\u8FF0\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u5982\u60A8\u4ECD\u7136\u9700\u8981\u63CF\u8FF0\uFF0C\u5219\u9700\u8981\u624B\u52A8\u6DFB\u52A0"},{id:"count",title:"\u6570\u636E\u91CF",type:"text",tip:"\u6570\u636E\u91CF"},{id:"status",title:"\u5BFC\u5165\u72B6\u6001",type:"customized",component:t(de,{})},{id:"importstatus",title:"\u8FFD\u52A0\u63D0\u793A",type:"customized",component:t(de,{})},{id:"createdAt",title:"\u521B\u5EFA\u65F6\u95F4",type:"date",tip:"\u521B\u5EFA\u65F6\u95F4"},{id:"updatedAt",title:"\u66F4\u65B0\u65F6\u95F4",type:"date",tip:"\u66F4\u65B0\u65F6\u95F4"},{id:"actions",title:"\u64CD\u4F5C",type:"action"}],toolbar:[{type:"button",key:"upload",label:"\u4E0A\u4F20\u6570\u636E\u6587\u4EF6",btnType:"primary",disabled:E&&E(U.ADD,u==null?void 0:u.permission),icon:t(Ve,{size:12})},{type:"fuzzy_search",key:"search",label:"\u641C\u7D22",searchKeys:["name","description",["name"]],position:"right"},{type:"button",key:"auth",label:"\u914D\u7F6E",btnType:"default",position:"right"}]}],subTableConfig:{type:"table",allowMultiSelect:!1,viewBehavior:"pagination",viewPageSize:5,columns:[{title:"\u8FFD\u52A0\u6587\u4EF6\u540D",id:"name",type:"text",tip:"\u8FFD\u52A0\u6587\u4EF6\u540D"},{title:"\u6570\u636E\u91CF",id:"count",type:"text",tip:"\u6570\u636E\u91CF"},{id:"status",title:"\u5BFC\u5165\u72B6\u6001",type:"customized",tip:"\u5BFC\u5165\u72B6\u6001",component:t(de,{})},{title:"\u521B\u5EFA\u65F6\u95F4",id:"createdAt",type:"date",tip:"\u521B\u5EFA\u65F6\u95F4"},{title:"\u66F4\u6539\u65F6\u95F4",id:"updatedAt",type:"date",tip:"\u66F4\u6539\u65F6\u95F4"},{title:"\u64CD\u4F5C",id:"actions",type:"action"}]},subTablePendingIds:$,onSubTableRowAnimationComplete:(r,e)=>{N(z=>({...z,[r]:(z[r]||[]).filter(y=>y!==e)}))}}),[$,W,m,u]),B=r=>{i(!1),q(!1),c(void 0),r=="refresh"&&(f.current&&(clearTimeout(f.current),f.current=null),A())};function _(r){var e,z;if(!Array.isArray(r))return!0;for(const y of r){if(y.data){const k=y.data.find(I=>I.columnId==="status"),x=y.data.find(I=>I.columnId==="description");if(console.log("+++++",k.status==="20"||k.status==="11"||((e=x==null?void 0:x.tableMeta)==null?void 0:e.generateDescriptionStatus)==fe.GENERATING),k&&(k.status==="20"||k.status==="11"||((z=x==null?void 0:x.tableMeta)==null?void 0:z.generateDescriptionStatus)==fe.GENERATING))return!1}if(Array.isArray(y.children)){for(const k of y.children)if(k.data){const x=k.data.find(I=>I.columnId==="status");if(x&&(x.status==="20"||x.status==="11"))return!1}}}return!0}const A=async()=>{const r=await oe();_(r||[])?f.current&&(clearTimeout(f.current),f.current=null):(f.current&&(clearTimeout(f.current),f.current=null),f.current=setTimeout(()=>{A()},5e3))};return T(Ne,{title:u==null?void 0:u.name,description:(u==null?void 0:u.description)||"-",goBack:()=>{var r;(r=a.eventsEmit)==null||r.call(a,"goBack",{})},children:[t(Ae,{dataSource:W,ref:h,eventsEmit:n,status:M,styles:{theme:{...ge,colors:{...ge.colors,tableFirstColumnBg:"#ffffff",tableLastColumnBg:"#ffffff",paginationBackground:"#ffffff",subTableBackground:"#F5F5F5",tableHeaderBg:"#F5F5F5"}},mode:"light"},CustomComponents:{EmptyData:()=>t(eu,{dbInfo:u,setDrawerTitle:D,setDrawerVisible:i,getBtnDisabled:E}),...Z},...m=="DataTable"?S:l}),t(qe,{drawerTitle:b,drawerVisible:o,handleDrawerClose:B,dbId:d,token:F,url:w,uploadUrl:X,role:p,tableInfo:g}),t(Ke,{drawerTitle:j,drawerVisible:R,handleDrawerClose:B,tableInfo:g,optimizeDesc:se,eventsEmit:n})]})};export{hu as default};
1
+ import{jsx as t,jsxs as T,Fragment as Ee}from"react/jsx-runtime";import{useMemo as J,useState as C,useRef as Fe,useCallback as Y,useEffect as Be}from"react";import{u as Me}from"./assets/index-CpW6Dhpp.js";import{F as ze,J as H,C as Le,T as _e,U as Ve,N as Ne}from"./assets/index-CtPe9ln8.js";import{a as Re,T as pe,a6 as Ue,F as ge}from"./assets/index-8h59dJlj.js";import{O as Ae}from"./assets/index-w1SriKuR.js";/* empty css *//* empty css */import{N as xe}from"./assets/index-C9ax6WsW.js";import{s as G,M as Ce}from"./assets/index-DoUk2Ei_.js";import{D as we}from"./assets/index-BN3yu4iN.js";import{X as me}from"./assets/x-CmbLQ9dc.js";import{P as Ge,L as He}from"./assets/index-B-AFa3n1.js";import{B as he}from"./assets/index-BdNcL3V6.js";import{T as ve}from"./assets/triangle-alert-BycMPaz2.js";import"react-dom";import"./assets/index-C6WKbL3A.js";import"./assets/index-CVis9Agw.js";const We="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M14%201C13.4997%201.50025%2013.25%201.99975%2013.25%202.5C13.25%203.00025%2013.4997%203.49975%2014%204C13.4997%203.49975%2013.0003%203.25%2012.5%203.25C11.9997%203.25%2011.5003%203.49975%2011%204C11.5003%203.49975%2011.75%203.00025%2011.75%202.5C11.75%201.99975%2011.5003%201.50025%2011%201C11.5003%201.50025%2011.9997%201.75%2012.5%201.75C13.0003%201.75%2013.4997%201.50025%2014%201Z'%20fill='%23055AFF'/%3e%3cpath%20d='M13%206.28571V13C13%2013.5523%2012.5523%2014%2012%2014H4C3.44772%2014%203%2013.5523%203%2013V3C3%202.44772%203.44772%202%204%202H9.25'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3cline%20x1='5.65'%20y1='6.35'%20x2='10.35'%20y2='6.35'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3cline%20x1='5.65'%20y1='9.35'%20x2='8.35'%20y2='9.35'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3c/svg%3e",$e="data:image/svg+xml,%3csvg%20width='48'%20height='48'%20viewBox='0%200%2048%2048'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M42%2022C43.1046%2022%2044%2022.8954%2044%2024V42C44%2043.1046%2043.1046%2044%2042%2044H6C4.89543%2044%204%2043.1046%204%2042V24.0088C4%2022.9042%204.89543%2022.0078%206%2022.0078C7.10457%2022.0078%208%2022.9042%208%2024.0088V40H40V24C40%2022.8954%2040.8954%2022%2042%2022ZM24.0293%204.00195C24.0808%204.00272%2024.1322%204.00504%2024.1836%204.00977C24.1904%204.01042%2024.1973%204.011%2024.2041%204.01172C24.2673%204.01819%2024.3301%204.02757%2024.3926%204.04004C24.3939%204.04031%2024.3952%204.04075%2024.3965%204.04102C24.7693%204.11623%2025.125%204.29691%2025.4141%204.58594L34.4141%2013.5859C35.1951%2014.367%2035.1951%2015.633%2034.4141%2016.4141C33.633%2017.1951%2032.367%2017.1951%2031.5859%2016.4141L25.9922%2010.8203V32C25.9922%2033.1046%2025.0968%2034%2023.9922%2034C22.8876%2034%2021.9922%2033.1046%2021.9922%2032V10.8359L16.4141%2016.4141C15.633%2017.1951%2014.367%2017.1951%2013.5859%2016.4141C12.8049%2015.633%2012.8049%2014.367%2013.5859%2013.5859L22.498%204.67285C22.8016%204.33138%2023.2194%204.09559%2023.6924%204.02441C23.7122%204.02135%2023.732%204.01809%2023.752%204.01562C23.7862%204.01152%2023.8207%204.00919%2023.8555%204.00684C23.8887%204.00446%2023.9218%204.00268%2023.9551%204.00195C23.9674%204.00173%2023.9798%204%2023.9922%204C24.0046%204%2024.0169%204.00173%2024.0293%204.00195Z'%20fill='url(%23paint0_linear_4072_34663)'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_4072_34663'%20x1='4'%20y1='-7.25'%20x2='54.4707'%20y2='1.556'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%232B69FF'/%3e%3cstop%20offset='1'%20stop-color='%238F91FF'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",ke=({url:a,token:w,role:F,eventsEmit:p})=>{const d=Re.create({baseURL:a,timeout:1e6});return d.interceptors.request.use(u=>{let s=w;return!s&&!["user/login","user/kaptcha","user/regist"].some(i=>u.url.includes(i))?(p&&p("request:error_auth",{errorMsg:"\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F",redirect:"/login"}),Promise.reject(new Error("\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F"))):(u.headers.Authorization=s||"",u.headers.userName=F==="\u672A\u767B\u5F55\u7528\u6237"?"":F,u)}),d.interceptors.response.use(u=>{const s=["user/kaptcha"],o=u.data;if(s.some(g=>u.config.url&&u.config.url.includes(g))||o.size&&o.type)return o;const{success:i,errorMsg:b,errorCode:D}=o;if(i)return o;p&&p("request:error_business",{errorCode:D,errorMsg:b||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",response:o})},u=>{var s,o,i,b,D,g,c,R,q;if(u.message==="canceled")return Promise.reject(u);if(p){let j="request:error_network",O={errorMsg:"\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25",error:u};((s=u==null?void 0:u.response)==null?void 0:s.status)===401?(j="request:error_auth",O={errorMsg:"\u6CA1\u6709\u8DB3\u591F\u6743\u9650",error:u,redirect:"/login"}):(((i=(o=u==null?void 0:u.response)==null?void 0:o.data)==null?void 0:i.errorCode)==="30013"||((D=(b=u==null?void 0:u.response)==null?void 0:b.data)==null?void 0:D.errorCode)==="30023")&&(j="request:error_business",O={errorCode:(c=(g=u==null?void 0:u.response)==null?void 0:g.data)==null?void 0:c.errorCode,errorMsg:((q=(R=u==null?void 0:u.response)==null?void 0:R.data)==null?void 0:q.errorMsg)||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",error:u}),p(j,O)}return Promise.reject(u)}),{getTableList:async u=>{try{const s=await d.get(`/directDB/queryTableList/${u}`),{success:o,data:i}=s;if(o)return i}catch(s){console.log("getTableList error:",s)}},getTableTreeList:async u=>{try{const s=await d.get(`/dataTable/queryTableFileTreeList/${u}`),{success:o,data:i}=s;if(o)return i}catch(s){console.log("getTableTreeList error:",s)}},getDBDetailById:async(u,s)=>{const o=ye(s);try{const i=await d.get(`/${o}/queryDBInfo/${u}`),{success:b,data:D}=i;if(b)return D}catch(i){console.log("getDBDetailById error:",i)}},delTableById:async(u,s)=>{const o=ye(s);try{const i=await d.delete(`/${o}/deleteTable/${u}`),{success:b,data:D}=i;if(b)return D}catch(i){console.log("delTableById error:",i)}},delFileById:async u=>{try{const s=await d.delete(`/dataTable/deleteTableFileData/${u}`),{success:o,data:i}=s;if(o)return i}catch(s){console.log("delFileById",s)}},parseFiles:async({fileIds:u,isGenDescription:s,tableDescriptionMap:o})=>{try{const i=await d.post("/dataTable/parseFiles",{fileIds:u,isGenDescription:s,tableDescriptionMap:o}),{success:b,data:D}=i;if(b)return D}catch(i){console.log("parseFiles error:",i)}},reParseFile:async u=>{try{const s=await d.post(`/dataTable/reParseFile/${u}`),{success:o,data:i}=s;if(o)return i}catch(s){console.log("reParseFile error:",s)}},parseAppendFile:async({fileIds:u,tableId:s})=>{try{const o=await d.post("/dataTable/parseAppendFiles",{fileIds:u,tableId:s}),{success:i,data:b}=o;if(i)return b}catch(o){console.log("parseAppendFile error:",o)}},deleteUploadedFiles:async u=>{try{const s=await d.post("/dataTable/cancelUploadFile",{fileIds:u}),{success:o,data:i}=s;if(o)return i}catch(s){console.log("deleteUploadedFiles error:",s)}},getTableInfoById:async u=>{try{const s=await d.get(`/dataTable/queryTableMeta/${u}`),{success:o,data:i}=s;if(o)return i}catch(s){console.log("getTableInfoById error:",s)}},updateTableInfo:async({tableId:u,description:s,businessName:o})=>{try{const i=await d.post("/dataTable/updateTableInfo",{tableId:u,businessName:o,description:s}),{success:b,data:D}=i;if(b)return D}catch(i){console.log("updateTableInfo error:",i)}},optimizeDesc:async u=>{try{const s=await d.get(`/genTableDescription/${u}`),{success:o,data:i}=s;if(o)return i}catch(s){console.log("optimizeDesc error:",s)}}}},ye=a=>a=="DataTable"?"dataTable":"directDB",ne='<template key="type" placeholder="\u8F93\u5165\u8868\u683C\u7C7B\u578B"></template>\u8868\u683C\u4E3B\u8981\u5C55\u793A\u4E86<template key="scene" placeholder="\u8F93\u5165\u573A\u666F\u540D\u79F0"></template>\u573A\u666F\u7684\u6570\u636E,\u5305\u542B<template key="primary_key" placeholder="\u4E3B\u8981\u5B57\u6BB5(\u53EF\u5199\u591A\u4E2A,\u7528\u987F\u53F7\u5206\u9694)"></template>\u7B49\u4E3B\u8981\u5B57\u6BB5,\u652F\u6301\u7528\u6237\u67E5\u8BE2<template key="search_direction" placeholder="\u5927\u6982\u4ECB\u7ECD\u9700\u8981\u67E5\u8BE2\u7684\u65B9\u5411"></template>\u95EE\u9898,\u5982\u679C\u8BBE\u8BA1\u591A\u8868\u5173\u8054\u67E5\u8BE2,\u6700\u597D\u8BF4\u660E\u6B64\u8868\u683C\u901A\u8FC7<template key="key_name" placeholder="\u5B57\u6BB5\u540D\u79F0"></template>\u5B57\u6BB5\u53EF\u4EE5\u5173\u8054\u53E6\u4E00\u4E2A<template key="table_name" placeholder="\u8868\u683C\u540D\u79F0"></template>\u8868\u683C\u3002',Ze={colors:{background:"#ffffff",border:"#e5e7eb",appBackground:"#ffffff",listBackground:"#ffffff",dashboardBackground:"#ffffff"},space:{padding:"0",margin:"md",shadow:"none"}},qe=({drawerTitle:a,drawerVisible:w,uploadUrl:F,handleDrawerClose:p,dbId:d,tableInfo:m,token:Z,url:E,role:X})=>{const M=J(()=>({id:"upload",layout:"vertical",formWidth:"670px",fields:[{id:"fileIds",name:"fileIds",type:"uploader",required:!1,defaultValue:"",uploaderConfig:{multiple:!m,accept:".csv,.xlsx,.xls",maxFiles:m?1:20,url:F,autoUpload:!0,headers:{Authorization:Z},queryParams:{databaseId:d,...m&&{tableId:m.tableId}},placeholder:T("div",{children:[t("div",{className:"text-lg font-bold",children:"\u70B9\u51FB\u6216\u5C06\u6587\u4EF6\u62D6\u62FD\u5230\u6B64\u5904\u4E0A\u4F20"}),T("div",{className:"flex flex-col gap-1.8 mt-[12px]",children:[t("div",{className:"text-[#888888] font-[12px]",children:"\u6570\u91CF\uFF1A\u226420 \u6587\u4EF6\uFF08\u5F53\u524D 0/20\uFF09"}),t("div",{className:"text-[#888888] font-[12px]",style:{width:"580px"},children:"\u683C\u5F0F\uFF1A.xlsx / .xls / .csv /\uFF08\u7B2C\u4E00\u884C\u662F\u8868\u5934\uFF0C\u5176\u4ED6\u884C\u662F\u6570\u636E\uFF1BCSV \u652F\u6301 UTF-8/GBK/GB2312\u2026\uFF09"}),t("div",{className:"text-[#888888] font-[12px]",children:"\u5355\u6587\u4EF6\u9650\u5236\uFF1A \u226410\u4E07\u884C\uFF0C\u226460\u5217\uFF08\u8D85\u51FA\u81EA\u52A8\u5FFD\u7565\uFF09\uFF1B \u6BCF\u6587\u4EF6 \u22641\u4E2ASheet"}),t("div",{className:"text-[#888888] font-[12px]",children:"\u4E0A\u4F20\u7684\u6587\u4EF6\uFF0C\u5982\u679C\u6709\u4E0D\u7B26\u5408\u6587\u672C\u683C\u5F0F\u7684\u6570\u636E\u7CFB\u7EDF\u81EA\u52A8\u5FFD\u7565"})]})]}),listName:m?"\u8FFD\u52A0\u6587\u4EF6":"\u4E0A\u4F20\u6587\u4EF6\u5217\u8868",icons:{dragUpload:t("img",{src:$e,width:40}),itemStatus:{pending:t("span",{style:{fontSize:"12px",color:"#6b7280"}}),uploading:t("span",{style:{fontSize:"12px",color:"#007bff"}}),success:t("span",{style:{fontSize:"12px",color:"#10b981"}}),error:t("span",{style:{fontSize:"12px",color:"#ef4444"},children:"\u5931\u8D25"})},fileType:{default:t(ze,{size:20,style:{color:"#6b7280"}})}},...!m&&{buttons:[{label:"\u4F7F\u7528\u6A21\u7248",icon:t("img",{src:We}),mode:"text",onClick:()=>{i(!0)}}]},...!m&&{itemForm:[{type:"textarea",name:"description",counter:150,placeholder:"\u4E3A\u4E86\u63D0\u9AD8\u95EE\u7B54\u51C6\u786E\u7387\uFF0C\u8BF7\u8F93\u5165\u63CF\u8FF0"}]}}}]}),[m]),[L,h]=C(!1),[f,W]=C({}),V=Fe(null),[$,N]=C(!1),[u,s]=C([]),[o,i]=C(!1),[b,D]=C(ne),[g,c]=C(null),[R,q]=C(ne),[j,O]=C(0),{parseFiles:ue,parseAppendFile:te,deleteUploadedFiles:ae}=ke({url:E,token:Z,role:X}),K=Y(async(n,l,S)=>{var B;switch(console.log("[DynamicFormAdopter] \u4E8B\u4EF6:",n,l),n){case"form:ready":l.formRef?V.current=l.formRef:console.log("\u274C data.formRef \u4E3A\u7A7A\uFF0C\u65E0\u6CD5\u4FDD\u5B58\u8868\u5355\u5F15\u7528");break;case"form:submit":P();break;case"form_field_change":W(A=>({...A,[l.fieldId]:l.value}));break;case"uploader:error":(B=l.item)!=null&&B.id?s(A=>[{id:l.item.id,status:l.item.status},...A]):G.error(l==null?void 0:l.message);break;case"uploader:success":s(A=>[{id:l.item.id,status:l.item.status},...A]);break;case"uploader:remove":const _=l.item.status;s(A=>A.filter(r=>r.id!==l.item.id)),_=="success"&&await ee([l.item.uploadApiRes]);break;default:console.log("\u672A\u5904\u7406\u7684\u4E8B\u4EF6:",n)}},[]),se=J(()=>({label:"\u52A8\u6001\u8868\u5355\u793A\u4F8B",defaultActiveId:"form-view",model:null,views:[{label:"\u7528\u6237\u6CE8\u518C\u8868\u5355",id:"form-view",type:"form",size:"md",formWidth:M.formWidth,formConfig:{layout:M.layout,showReset:!1,showSubmit:!1,formWidth:M.formWidth,getFormData:()=>({...f,timestamp:new Date().toISOString(),formId:M.id}),onFieldChange:(n,l)=>{K("form_field_change",{fieldId:n,value:l},void 0)},onValidationError:n=>{K("form_validation_error",n,void 0)}}}],dataSource:[{id:M.id,fields:M.fields,defaultValues:{}}],eventsEmit:K,styles:{theme:Ze}}),[m,M]),P=async()=>{var n;try{h(!0);const l=await V.current.getAllData();if(l.isValid){const S=(n=l.fields.find(B=>B.name=="fileIds"))==null?void 0:n.value;if(Array.isArray(S)&&(S==null?void 0:S.length)>0){let B;if(m)B=await te({fileIds:S.map(_=>_.uploadApiRes),tableId:m.id});else{const _={fileIds:S.map(A=>A.uploadApiRes),tableDescriptionMap:S.reduce((A,r)=>(A[r.uploadApiRes]=r.formData.description,A),{}),isGenDescription:$};B=await ue(_)}B&&p("refresh")}}}catch(l){console.error("\u8868\u5355\u6570\u636E\u5931\u8D25:",l)}finally{p(),h(!1),N(!1)}},Q=async n=>{var l;try{const S=await V.current.getAllData();if(S.isValid){const B=(l=S.fields.find(_=>_.name=="fileIds"))==null?void 0:l.value;if(B&&Array.isArray(B)&&(B==null?void 0:B.length)>0){const _=B.map(r=>r.uploadApiRes),A=await ee(_)}}}catch(S){console.error("\u8868\u5355\u6570\u636E\u5931\u8D25:",S)}finally{p(),N(!1)}},ee=async n=>{try{const l=await ae(n);if(l)return l}catch(l){console.error("\u5220\u9664\u6587\u4EF6\u6570\u636E\u5931\u8D25:",l)}},ie=n=>{N(n)},oe=Y(n=>{D(n),console.log("\u6A21\u7248\u5185\u5BB9\u53D8\u5316:",n)},[]),re=Y(n=>{c(()=>n),console.log("getData\u51FD\u6570\u5DF2\u8BBE\u7F6E")},[]),le=Y(async()=>{try{if(!g){console.error("getData\u51FD\u6570\u5C1A\u672A\u51C6\u5907\u597D\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");return}const n=g("pure_string");await navigator.clipboard.writeText(n),G.success("\u5DF2\u590D\u5236",1)}catch(n){console.error("\u590D\u5236\u5931\u8D25:",n)}finally{i(!1)}},[g]);return T(we,{title:a,className:"database-upload-drawer",placement:"right",width:720,closeIcon:!1,extra:t(me,{size:20,color:"#888888",onClick:()=>Q(),className:"cursor-pointer"}),open:w,destroyOnHidden:!0,footer:T("div",{className:"flex items-center",style:{justifyContent:m?"end":"space-between"},children:[!m&&T("div",{className:"flex gap-2 items-center",children:[t("span",{children:"\u81EA\u52A8\u751F\u6210\u6570\u636E\u8868\u63CF\u8FF0"})," ",t(pe,{title:"\u81EA\u52A8\u751F\u6210\u5F00\u542F\u65F6\u5C06\u57FA\u4E8E\u6570\u636E\u667A\u80FD\u751F\u6210\u63CF\u8FF0\uFF1B\u82E5\u5F00\u542F\u6B64\u529F\u80FD\u5E76\u624B\u52A8\u586B\u5199\u63CF\u8FF0\uFF0C\u5C06\u4F18\u5148\u91C7\u7528\u7528\u6237\u586B\u5199\u7684\u5185\u5BB9\u3002",children:t(Le,{size:14})}),t(Ue,{onChange:ie})]}),T("div",{className:"flex self-end gap-3",children:[t(H,{mode:"default",style:{marginRight:10},label:"\u53D6\u6D88",onClick:Q}),t(H,{mode:"primary",label:"\u786E\u8BA4\u5BFC\u5165",loading:L,disabled:u.some(n=>n.status=="error"),onClick:async()=>{await P()}})]})]}),children:[t(Ae,{...se},"upload-file"),t(Ce,{title:T("div",{children:["\u6A21\u7248",t("span",{className:"text-[12px] text-[#888888] ml-[8px]",children:"\u5B8C\u6210\u7F16\u8F91\u540E\uFF0C\u53EF\u5C06\u6587\u672C\u590D\u5236\u7C98\u8D34\u5230\u76F8\u5E94\u63CF\u8FF0\u6846\u4E2D\u3002"})]}),width:672,destroyOnHidden:!0,open:o,onCancel:()=>i(!1),footer:T("div",{className:"flex justify-end items-center gap-3",children:[t(H,{mode:"default",label:"\u91CD\u7F6E",onClick:()=>{q(ne),O(n=>n+1)}}),t(H,{mode:"primary",label:"\u590D\u5236",onClick:le})]}),children:t(xe,{data:R,onChange:oe,onGetData:re,styles:{theme:{colors:{primary:"#0969da",secondary:"#6b7280",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6",background:"#ffffff",text:"#1f2937",border:"#e5e7eb",disabled:"#9ca3af",disabledBackground:"#f3f4f6",disabledText:"#6b7280",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)",appBackground:"transparent",listBackground:"#f9fafb",dashboardBackground:"#ffffff",textSecondary:"#6b7280"},space:{sidebar:"260px",size:"12px",radius:"8px",padding:"1rem",margin:"1rem",shadow:"0 2px 8px rgba(0,0,0,0.1)",lineHeight:"1.8"},icons:{},fonts:{body:{size:"14px",weight:"normal",family:"PingFang SC, Microsoft YaHei, Arial, sans-serif"},heading:{size:"14px",weight:"600",family:"PingFang SC, Microsoft YaHei, Arial, sans-serif"}},others:{baseFontWeight:"normal"}},templateField:{backgroundColor:"#E5EEFF",borderColor:"#84ADFF",borderRadius:"6px",padding:"6px 12px",margin:"2px",fontSize:"14px",fontWeight:"500",minWidth:"80px",textColor:"#84ADFF"}}},j)})]})},je="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M14%201C13.4997%201.50025%2013.25%201.99975%2013.25%202.5C13.25%203.00025%2013.4997%203.49975%2014%204C13.4997%203.49975%2013.0003%203.25%2012.5%203.25C11.9997%203.25%2011.5003%203.49975%2011%204C11.5003%203.49975%2011.75%203.00025%2011.75%202.5C11.75%201.99975%2011.5003%201.50025%2011%201C11.5003%201.50025%2011.9997%201.75%2012.5%201.75C13.0003%201.75%2013.4997%201.50025%2014%201Z'%20fill='%23055AFF'/%3e%3cpath%20d='M13%206.28571V13C13%2013.5523%2012.5523%2014%2012%2014H4C3.44772%2014%203%2013.5523%203%2013V3C3%202.44772%203.44772%202%204%202H9.25'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3cline%20x1='5.65'%20y1='6.35'%20x2='10.35'%20y2='6.35'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3cline%20x1='5.65'%20y1='9.35'%20x2='8.35'%20y2='9.35'%20stroke='%23055AFF'%20stroke-width='1.3'%20stroke-linecap='round'/%3e%3c/svg%3e",Oe="data:image/svg+xml,%3csvg%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_4199_8826)'%3e%3cpath%20d='M15.5554%2012.4444C14.9626%2013.0373%2014.6666%2013.6293%2014.6666%2014.2222C14.6666%2014.8151%2014.9626%2015.4071%2015.5554%2016C14.9626%2015.4071%2014.3706%2015.1111%2013.7777%2015.1111C13.1848%2015.1111%2012.5928%2015.4071%2011.9999%2016C12.5928%2015.4071%2012.8888%2014.8151%2012.8888%2014.2222C12.8888%2013.6293%2012.5928%2013.0373%2011.9999%2012.4444C12.5928%2013.0373%2013.1848%2013.3333%2013.7777%2013.3333C14.3706%2013.3333%2014.9626%2013.0373%2015.5554%2012.4444ZM14.6488%204.01778C15.1905%204.55954%2015.4948%205.29431%2015.4948%206.06044C15.4948%206.82658%2015.1905%207.56135%2014.6488%208.10311L7.735%2015.0169C7.46766%2015.2892%207.14901%2015.5058%206.79746%2015.6543C6.44592%2015.8028%206.06844%2015.8801%205.68684%2015.8819C5.30523%2015.8836%204.92706%2015.8097%204.57417%2015.6645C4.22127%2015.5193%203.90065%2015.3056%203.63081%2015.0357C3.36097%2014.7659%203.14727%2014.4453%203.00205%2014.0924C2.85682%2013.7395%202.78295%2013.3613%202.7847%2012.9797C2.78646%2012.5981%202.8638%2012.2206%203.01226%2011.8691C3.16072%2011.5176%203.37736%2011.1989%203.64967%2010.9316L3.95545%2010.6249L3.85145%2010.5244C3.30922%2010.0267%202.76522%209.77778%202.22211%209.77778C1.62923%209.77778%201.03722%2010.0738%200.444336%2010.6667C1.03722%2010.0738%201.33322%209.48178%201.33322%208.88889C1.33322%208.296%201.03722%207.704%200.444336%207.11111C1.03722%207.704%201.62923%208%202.22211%208C2.815%208%203.407%207.704%203.99989%207.11111C3.407%207.704%203.111%208.296%203.111%208.88889C3.111%209.46667%203.39278%2010.0444%203.95545%2010.6222L10.5634%204.01778C11.1052%203.47606%2011.84%203.17173%2012.6061%203.17173C13.3723%203.17173%2014.107%203.47606%2014.6488%204.01778ZM9.55189%206.91378L4.59189%2011.8738C4.30004%2012.1655%204.13603%2012.5612%204.13594%2012.9739C4.1359%2013.1782%204.17611%2013.3806%204.25426%2013.5694C4.33242%2013.7582%204.44699%2013.9297%204.59145%2014.0742C4.7359%2014.2187%204.9074%2014.3334%205.09617%2014.4116C5.28493%2014.4898%205.48725%2014.5301%205.69158%2014.5302C6.10424%2014.5303%206.50004%2014.3664%206.79189%2014.0747L11.7519%209.11378L9.55189%206.91378ZM11.5066%204.96089L10.495%205.97156L12.695%208.17156L13.7057%207.16C13.9846%206.86582%2014.1377%206.47437%2014.1323%206.069C14.1269%205.66364%2013.9635%205.27639%2013.6768%204.98973C13.3902%204.70306%2013.0029%204.53964%2012.5976%204.53425C12.1922%204.52887%2011.8007%204.68194%2011.5066%204.96089ZM9.59545%200C8.85589%200.740444%208.48434%201.48178%208.48434%202.22222C8.48434%202.96267%208.85589%203.704%209.59545%204.44444C8.85589%203.704%208.11456%203.33333%207.37322%203.33333C6.63367%203.33333%205.89234%203.704%205.151%204.44444C5.89234%203.704%206.26211%202.96267%206.26211%202.22222C6.26211%201.48178%205.89322%200.740444%205.15189%200C5.89322%200.740444%206.63456%201.11111%207.37411%201.11111C8.11545%201.11111%208.85678%200.740444%209.59634%200H9.59545Z'%20fill='%23055AFF'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_4199_8826'%3e%3crect%20width='16'%20height='16'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",{confirm:Ye}=Ce,Xe='<template key="type" placeholder="\u8F93\u5165\u8868\u683C\u7C7B\u578B"></template>\u8868\u683C\u4E3B\u8981\u5C55\u793A\u4E86<template key="scene" placeholder="\u8F93\u5165\u573A\u666F\u540D\u79F0"></template>\u573A\u666F\u7684\u6570\u636E,\u5305\u542B<template key="primary_key" placeholder="\u4E3B\u8981\u5B57\u6BB5(\u53EF\u5199\u591A\u4E2A,\u7528\u987F\u53F7\u5206\u9694)"></template>\u7B49\u4E3B\u8981\u5B57\u6BB5,\u652F\u6301\u7528\u6237\u67E5\u8BE2<template key="search_direction" placeholder="\u5927\u6982\u4ECB\u7ECD\u9700\u8981\u67E5\u8BE2\u7684\u65B9\u5411"></template>\u95EE\u9898,\u5982\u679C\u8BBE\u8BA1\u591A\u8868\u5173\u8054\u67E5\u8BE2,\u6700\u597D\u8BF4\u660E\u6B64\u8868\u683C\u901A\u8FC7<template key="key_name" placeholder="\u5B57\u6BB5\u540D\u79F0"></template>\u5B57\u6BB5\u53EF\u4EE5\u5173\u8054\u53E6\u4E00\u4E2A<template key="table_name" placeholder="\u8868\u683C\u540D\u79F0"></template>\u8868\u683C\u3002',Ke=({drawerTitle:a,drawerVisible:w,tableInfo:F,handleDrawerClose:p,optimizeDesc:d,eventsEmit:m})=>{const Z=J(()=>(F==null?void 0:F.data.find(c=>c.columnId=="name").value)||"-",[F]),[E,X]=C(""),[M,L]=C(null),[h,f]=C(""),[W,V]=C(0),[$,N]=C(!1),[u,s]=C(!1);Be(()=>{const c=(F==null?void 0:F.data.find(R=>R.columnId=="description").value)||"-";f(c)},[F]);const o=()=>{Ye({title:"\u4F60\u786E\u5B9A\u8981\u4F7F\u7528\u6A21\u677F\u5417\uFF1F",content:"\u8FD9\u5C06\u66FF\u6362\u4F60\u5F53\u524D\u5DF2\u586B\u5199\u7684\u5185\u5BB9\uFF0C\u4E14\u65E0\u6CD5\u64A4\u9500\u3002",okText:"\u786E\u8BA4\u66FF\u6362",cancelText:"\u53D6\u6D88",onOk(){f(Xe),V(c=>c+1)},onCancel(){console.log("Cancel")}})},i=Y(c=>{X(c),console.log("\u6A21\u7248\u5185\u5BB9\u53D8\u5316:",c)},[]),b=Y(c=>{L(()=>c),console.log("getData\u51FD\u6570\u5DF2\u8BBE\u7F6E")},[]),D=async()=>{try{N(!0);const c=await d(F.tableId);c&&(f(c),V(R=>R+1),N(!1))}catch{G.error("AI \u4F18\u5316\u5931\u8D25")}},g=Y(()=>{if(!M){console.error("getData\u51FD\u6570\u5C1A\u672A\u51C6\u5907\u597D\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");return}const c=M("pure_string");m("table_info:update",c)},[M,m]);return T(we,{title:a,placement:"right",width:720,onClose:p,closeIcon:!1,extra:t(me,{size:20,color:"#888888",onClick:p,className:"cursor-pointer"}),open:w,destroyOnHidden:!0,footer:t("div",{className:"flex items-center",style:{justifyContent:"end"},children:T("div",{className:"flex self-end gap-3",children:[t(H,{mode:"default",style:{marginRight:10},label:"\u53D6\u6D88",onClick:p}),t(H,{mode:"primary",label:"\u786E\u8BA4",onClick:()=>g(),disabled:$})]})}),children:[t("div",{className:"mb-[10px] font-bold",children:Z}),T("div",{className:"mb-[10px]",children:[t("span",{style:{color:"#FF3B30",marginRight:"4px"},children:"*"}),t("span",{children:"\u6570\u636E\u8868\u63CF\u8FF0"}),t("span",{className:"text-[#888888] ml-[4px]",children:"(\u8BF7\u51C6\u786E\u586B\u5199\u8868\u683C\u7684\u5E94\u7528\u573A\u666F\u63CF\u8FF0\uFF0C\u5927\u6A21\u578B\u5C06\u4F9D\u8D56\u6B64\u4FE1\u606F\u8BC6\u522B\u5E76\u6B63\u786E\u8C03\u7528\u8BE5\u6570\u636E\u8868\u3002)"})]}),t(xe,{data:h,onChange:i,onGetData:b,styles:{theme:{colors:{primary:"#0969da",secondary:"#6b7280",success:"#10b981",warning:"#f59e0b",error:"#ef4444",info:"#3b82f6",background:"#ffffff",text:"#1f2937",border:"#e5e7eb",disabled:"#9ca3af",disabledBackground:"#f3f4f6",disabledText:"#6b7280",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)",appBackground:"transparent",listBackground:"#f9fafb",dashboardBackground:"#ffffff",textSecondary:"#6b7280"},space:{sidebar:"260px",size:"12px",radius:"8px",padding:"1rem",margin:"1rem",shadow:"0 2px 8px rgba(0,0,0,0.1)",lineHeight:"1.8"},icons:{},fonts:{body:{size:"14px",weight:"normal",family:"PingFang SC, Microsoft YaHei, Arial, sans-serif"},heading:{size:"14px",weight:"600",family:"PingFang SC, Microsoft YaHei, Arial, sans-serif"}},others:{baseFontWeight:"normal"}},templateField:{backgroundColor:"#E5EEFF",borderColor:"#84ADFF",borderRadius:"6px",padding:"6px 12px",margin:"2px",fontSize:"14px",fontWeight:"500",minWidth:"80px",textColor:"#84ADFF"}}},W),T("div",{children:[t(Ge,{open:u,onOpenChange:c=>s(!!c),content:t("div",{style:{width:"600px",margin:"10px",padding:"10px"},onClick:o,className:"hover:bg-gray-100 h-[80px] cursor-pointer rounded",children:"______\u8868\u683C\u4E3B\u8981\u5C55\u793A\u4E86______\u573A\u666F\u7684\u6570\u636E\uFF0C\u5305\u542B______\u3001______\u3001______\u7B49\u4E3B\u8981\u5B57\u6BB5\uFF0C\u652F\u6301\u7528\u6237\u67E5\u8BE2______\u95EE\u9898(\u5927\u6982\u4ECB\u7ECD)\u5982\u679C\u6D89\u53CA\u591A\u8868\u5173\u8054\u67E5\u8BE2\uFF0C\u6700\u597D\u8BF4\u660E\u6B64\u8868\u683C\u901A\u8FC7______\u5B57\u6BB5\u53EF\u4EE5\u5173\u8054\u53E6\u4E00\u4E2A______\u8868\u683C\u3002"}),title:T("div",{className:"flex justify-between items-center",style:{margin:"10px"},children:[t("div",{className:"text-[16px]",children:"\u6A21\u7248"}),t(me,{size:20,color:"#888888",onClick:()=>s(!1),className:"cursor-pointer"})]}),trigger:"click",destroyOnHidden:!0,placement:"bottomRight",getPopupContainer:c=>c,children:t("span",{children:t(H,{mode:"text",icon:t("img",{src:je}),children:"\u4F7F\u7528\u6A21\u7248"})})}),t(H,{onClick:D,mode:"text",icon:t("img",{src:Oe}),loading:$,children:"AI\u4F18\u5316"})]})]})},Je=""+new URL("assets/empty.png",import.meta.url).href;var U=(a=>(a[a.DATE=0]="DATE",a[a.VIEW=1]="VIEW",a[a.ERROR=2]="ERROR",a[a.AUTHORIZE=3]="AUTHORIZE",a[a.DELETE=4]="DELETE",a[a.ANALYSIS_OR_EXTRACT=5]="ANALYSIS_OR_EXTRACT",a[a.DOWNLOAD=6]="DOWNLOAD",a[a.EDIT=7]="EDIT",a[a.ADD=8]="ADD",a[a.ANALYSIS_CONFIG=9]="ANALYSIS_CONFIG",a[a.AUTHORIZE_CONFIG=10]="AUTHORIZE_CONFIG",a))(U||{}),fe=(a=>(a.GENERATING="generating",a.SUCCESS="success",a.FAIL="fail",a))(fe||{});const ce={success:"green",error:"red",warning:"orange",processing:"blue",info:"cyan",default:"default"},Pe=a=>typeof a=="string"&&a in ce?ce[a]:ce.default,de=a=>{const{value:w,cell:F}=a;switch(F.columnId){case"importstatus":return w?t(pe,{title:"\u6709\u8FFD\u52A0\u5931\u8D25\u7684\u6587\u4EF6\uFF0C\u8BF7\u53CA\u65F6\u5904\u7406",children:t(_e,{color:"red",bordered:!1,children:"\u8FFD\u52A0\u5931\u8D25"})}):t(Ee,{});case"status":const p=Pe(a.cell.statusType);return w=="\u5BFC\u5165\u5931\u8D25"?t(pe,{title:F.errorMsg,children:T("div",{className:"flex items-center gap-2",children:[t(he,{color:p,text:w}),t(ve,{size:14,color:"red"})]})}):t(he,{color:p,text:w});default:return t(Ee,{})}},De=[{statusType:"success",value:"\u5BFC\u5165\u6210\u529F",status:"30"},{statusType:"error",value:"\u5BFC\u5165\u5931\u8D25",status:"00"},{statusType:"default",value:"\u5F85\u5BFC\u5165",status:"10"},{statusType:"processing",value:"\u5BFC\u5165\u4E2D",status:"20"},{statusType:"processing",value:"\u5BFC\u5165\u4E2D",status:"11"}],Qe=a=>{var p,d;const{cell:w,value:F}=a;return typeof F=="string"?t("div",{title:F,style:{maxWidth:240,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:F}):(p=w.tableMeta)!=null&&p.isGenDescription&&((d=w.tableMeta)==null?void 0:d.generateDescriptionStatus)=="generating"?T("div",{className:"flex items-center gap-1 text-[#84ADFF]",style:{color:"#84ADFF"},children:[t("span",{children:"\u751F\u6210\u4E2D"}),t(He,{size:14})]}):"-"},eu=({dbInfo:a,setDrawerTitle:w,setDrawerVisible:F,getBtnDisabled:p})=>T("div",{className:"flex flex-col items-center justify-center h-full",children:[t("div",{className:"text-xl font-semibold mb-3",children:t("img",{src:Je,width:120})}),t("div",{className:"text-base mb-2",style:{color:"#888888"},children:"\u6682\u65E0\u6570\u636E\u6587\u4EF6"}),t("div",{className:"flex gap-3",children:t(H,{mode:"primary",label:"\u4E0A\u4F20\u6570\u636E\u6587\u4EF6",disabled:p&&p(8,a==null?void 0:a.permission),onClick:()=>{w("\u4E0A\u4F20\u6570\u636E\u6587\u4EF6"),F(!0)}})})]}),{confirm:be}=Ce,hu=a=>{const{url:w,token:F,role:p,id:d,dbType:m,CustomComponents:Z,getBtnDisabled:E,uploadUrl:X}=a,[M,L]=C({container:"ready",content:"ready"}),h=Fe(null),f=Fe(null),[W,V]=C(),[$,N]=C({}),[u,s]=C(),[o,i]=C(!1),[b,D]=C(""),[g,c]=C(),[R,q]=C(!1),[j,O]=C(""),{getTableList:ue,delTableById:te,delFileById:ae,updateTableInfo:K,optimizeDesc:se,getTableTreeList:P,reParseFile:Q,getDBDetailById:ee}=ke({url:w,token:F,role:p,eventsEmit:a.eventsEmit});Be(()=>(d&&m&&(L(r=>({...r,container:"loading"})),ie()),()=>{f.current&&(clearTimeout(f.current),f.current=null)}),[d,m]);const ie=async()=>{try{const r=await ee(d,m);r&&(s(r),L(e=>({...e,container:"ready",content:"loading"})))}catch(r){console.log("[TableApiError] getDBInfo:",r)}await A()},oe=async()=>{try{if(m=="DirectDB"){const r=await ue(d);if(r){const e=le(r);return V(e||[]),L(z=>({...z,content:"ready"})),e||[]}else L(e=>({...e,content:"error"}))}else{const r=await P(d);if(r){const e=re(r);return V(e||[]),L(z=>({...z,content:"ready"})),e||[]}else L(e=>({...e,content:"error"}))}}catch(r){console.log("[TableApiError] getTableList:",r)}};function re(r){return(r||[]).map((e,z)=>{var x,I;let y=De.find(v=>v.status==e.status);const k=e.children.some(v=>v.status=="00");return{id:e.fileId.toString(),tableId:e.tableId,data:[{columnId:"name",value:(e==null?void 0:e.originalFilename)||"-",type:"label"},{columnId:"description",value:(x=e==null?void 0:e.tableMeta)==null?void 0:x.description,type:"customized",tableMeta:e==null?void 0:e.tableMeta},{columnId:"count",value:`${e.rowCount}\u884C\uFF0C${e.columnCount}\u5217`,type:"text"},{columnId:"status",...y,type:"customized",errorMsg:e.errorMsg},{columnId:"importstatus",value:k,type:"customized"},{columnId:"createdAt",value:e.gmtCreate,type:"date"},{columnId:"updatedAt",value:e.gmtModified,type:"date"},...e.status=="30"?[{columnId:"actions",value:"view",label:"\u67E5\u770B",type:"action",disabled:E&&E(U.VIEW,e.permission)},{columnId:"actions",value:"edit",label:"\u4FEE\u6539\u914D\u7F6E",type:"action",disabled:E&&E(U.EDIT,e.permission)},{columnId:"actions",value:"addData",label:"\u8FFD\u52A0\u6570\u636E",type:"action",disabled:E&&E(U.EDIT,e.permission)}]:[],...e.status=="00"?[{columnId:"actions",value:"reValidate",label:"\u91CD\u65B0\u5BFC\u5165",type:"action"}]:[],{columnId:"actions",value:"delete",label:"\u5220\u9664",type:"action",disabled:E&&E(U.DELETE,e.permission)}],expanded:!1,...e.children&&((I=e.children)==null?void 0:I.length)>0&&{children:[...(e.children||[]).map(v=>{const Ie=De.find(Se=>Se.status==v.status),Te=[{columnId:"name",value:v.originalFilename,type:"text"},{columnId:"count",value:`${v.rowCount}\u884C\uFF0C${v.columnCount}\u5217`,type:"text"},{columnId:"status",...Ie,errorMsg:v.errorMsg,type:"customized"},{columnId:"createdAt",value:v.gmtCreate,type:"date"},{columnId:"updatedAt",value:v.gmtModified,type:"date"},...v.status=="30"?[{columnId:"actions",value:"view",label:"\u67E5\u770B",type:"action",disabled:E&&E(U.VIEW,v.permission)}]:[],...v.status=="00"?[{columnId:"actions",value:"reValidate",label:"\u91CD\u65B0\u5BFC\u5165",type:"action",disabled:E&&E(U.ADD,v.permission)}]:[],{columnId:"actions",value:"delete_sub",label:"\u5220\u9664",type:"action",disabled:E&&E(U.DELETE,v.permission)}];return{id:v.fileId.toString(),tableId:v.tableId,data:Te}})]}}})}function le(r){return(r||[]).map((e,z)=>({id:e.id||Me(8),data:[{columnId:"name",value:e.physicalName},{columnId:"cnname",value:e.businessName},{columnId:"colcount",value:e.columnCount},{columnId:"count",value:`${e.rowCount}\u884C\uFF0C${e.columnCount}\u5217`},{columnId:"actions",value:"view",label:"\u67E5\u770B",disabled:E&&E(U.VIEW,e.permission)}]}))}async function n(r,e,z){switch(console.log("[adopter] mergedEventsEmit",r,e,z),r){case"table_action_delete":{try{if(console.log("[delete] \u5220\u9664\u4E8B\u4EF6\u6570\u636E:",e),!e||!e.tableId&&!e.id){console.error("[delete] \u5220\u9664\u4E8B\u4EF6\u6570\u636E\u4E0D\u5B8C\u6574:",e),G.error("\u5220\u9664\u5931\u8D25\uFF1A\u6570\u636E\u4E0D\u5B8C\u6574");return}const y=e.tableId||e.id,k=e.id;be({title:"\u786E\u8BA4\u5220\u9664\u6570\u636E\u5E93\uFF1F",content:"\u8BE5\u6570\u636E\u8868\u53CA\u5176\u8FFD\u52A0\u6570\u636E\u90FD\u5C06\u88AB\u5220\u9664\u4E14\u65E0\u6CD5\u6062\u590D",icon:t(ve,{color:"#FF4D4F",className:"mr-[8px]"}),okText:"\u5220\u9664",cancelText:"\u53D6\u6D88",async onOk(){await te(y,m)&&(h!=null&&h.current)?(h==null||h.current.appFn.removeItem(k),G.success("\u5220\u9664\u6210\u529F")):G.error("\u5220\u9664\u5931\u8D25")}})}catch(y){console.error("\u5220\u9664\u8868\u6570\u636E\u5931\u8D25:",y),G.error("\u5220\u9664\u5931\u8D25")}break}case"table_action_edit":{O("\u4FEE\u6539\u6570\u636E\u914D\u7F6E"),q(!0),c(e);break}case"toolbar_upload":{D("\u4E0A\u4F20\u6570\u636E\u6587\u4EF6"),i(!0);break}case"table_action_addData":{D("\u8FFD\u52A0\u6570\u636E"),i(!0),c(e);break}case"table_action_reValidate":{await Q(e.id)&&(f.current&&(clearTimeout(f.current),f.current=null),await A());break}case"table_info:update":{try{if(g!=null&&g.id){const y=(g==null?void 0:g.data.find(x=>x.columnId=="name").value)||"-";if(await K({tableId:g.tableId,description:e,businessName:y})&&(h!=null&&h.current)){const x={...g,data:g.data.map(I=>I.columnId=="description"?{...I,value:e}:I)};h==null||h.current.appFn.updateItem(x,g.id),G.success("\u4FEE\u6539\u914D\u7F6E\u6210\u529F")}}}catch(y){console.error("\u4FEE\u6539\u914D\u7F6E\u5931\u8D25",y)}finally{B()}break}case"table_action_delete_sub":{try{be({title:"\u786E\u8BA4\u5220\u9664\u6570\u636E\uFF1F",content:"\u5220\u9664\u540E\uFF0C\u8BE5\u6570\u636E\u5C06\u65E0\u6CD5\u6062\u590D",okText:"\u5220\u9664",cancelText:"\u53D6\u6D88",async onOk(){const{id:y,tableId:k}=e;await ae(e.id)&&(h!=null&&h.current)&&(N(I=>({...I,[k]:[...I[k]||[],y]})),e.data.find(I=>I.status=="00")&&(f.current&&(clearTimeout(f.current),f.current=null),A()),z.removeItem(y,k),G.success("\u8FFD\u52A0\u6587\u4EF6\u6570\u636E\u5220\u9664\u6210\u529F"))}})}catch{console.log("\u5220\u9664\u8868\u6570\u636E\u5931\u8D25")}break}case"toolbar_auth":{typeof a.eventsEmit=="function"&&a.eventsEmit("toolbar_auth",u);break}default:typeof a.eventsEmit=="function"&&a.eventsEmit(r,e);break}}const l=J(()=>({label:"\u6570\u636E\u8868\u7BA1\u7406",model:null,defaultActiveId:"direct-table-view",views:[{label:"\u6211\u7684\u6570\u636E\u5E93",id:"direct-table-view",type:"table",viewBehavior:"pagination",allowMultiSelect:!1,columns:[{id:"name",title:"\u6570\u636E\u8868\u82F1\u6587\u540D\u79F0",type:"label"},{id:"cnname",title:"\u6570\u636E\u8868\u4E2D\u6587\u540D\u79F0",type:"label"},{id:"colcount",title:"\u5B57\u6BB5\u6570",type:"text"},{id:"count",title:"\u6570\u636E\u91CF",type:"text"},{id:"actions",title:"\u64CD\u4F5C",type:"action"}],toolbar:[{type:"fuzzy_search",key:"search",label:"\u641C\u7D22",searchKeys:["name","description"],position:"right"},{type:"button",key:"auth",label:"\u914D\u7F6E",btnType:"default",position:"right"}]}]}),[W,m]),S=J(()=>({label:"\u6570\u636E\u8868\u7BA1\u7406",model:null,defaultActiveId:"data-table-view",views:[{label:"\u4E0A\u4F20\u6570\u636E\u5217\u8868",id:"data-table-view",type:"table",viewBehavior:"pagination",allowMultiSelect:!1,viewPageSize:10,columns:[{id:"name",title:"\u6587\u4EF6\u540D",type:"label",tip:"\u6587\u4EF6\u540D"},{id:"description",title:"\u63CF\u8FF0",type:"customized",component:t(Qe,{}),helpText:"\u6253\u5F00\u81EA\u52A8\u751F\u6210\u63CF\u8FF0\u5F00\u5173\u540E\uFF0C\u82E5\u63CF\u8FF0\u672A\u6B63\u5E38\u751F\u6210\uFF0C\u5219\u63CF\u8FF0\u5185\u5BB9\u4E3A\u7A7A\uFF0C\u5982\u60A8\u4ECD\u7136\u9700\u8981\u63CF\u8FF0\uFF0C\u5219\u9700\u8981\u624B\u52A8\u6DFB\u52A0"},{id:"count",title:"\u6570\u636E\u91CF",type:"text",tip:"\u6570\u636E\u91CF"},{id:"status",title:"\u5BFC\u5165\u72B6\u6001",type:"customized",component:t(de,{})},{id:"importstatus",title:"\u8FFD\u52A0\u63D0\u793A",type:"customized",component:t(de,{})},{id:"createdAt",title:"\u521B\u5EFA\u65F6\u95F4",type:"date",tip:"\u521B\u5EFA\u65F6\u95F4"},{id:"updatedAt",title:"\u66F4\u65B0\u65F6\u95F4",type:"date",tip:"\u66F4\u65B0\u65F6\u95F4"},{id:"actions",title:"\u64CD\u4F5C",type:"action"}],toolbar:[{type:"button",key:"upload",label:"\u4E0A\u4F20\u6570\u636E\u6587\u4EF6",btnType:"primary",disabled:E&&E(U.ADD,u==null?void 0:u.permission),icon:t(Ve,{size:12})},{type:"fuzzy_search",key:"search",label:"\u641C\u7D22",searchKeys:["name","description",["name"]],position:"right"},{type:"button",key:"auth",label:"\u914D\u7F6E",btnType:"default",position:"right"}]}],subTableConfig:{type:"table",allowMultiSelect:!1,viewBehavior:"pagination",viewPageSize:5,columns:[{title:"\u8FFD\u52A0\u6587\u4EF6\u540D",id:"name",type:"text",tip:"\u8FFD\u52A0\u6587\u4EF6\u540D"},{title:"\u6570\u636E\u91CF",id:"count",type:"text",tip:"\u6570\u636E\u91CF"},{id:"status",title:"\u5BFC\u5165\u72B6\u6001",type:"customized",tip:"\u5BFC\u5165\u72B6\u6001",component:t(de,{})},{title:"\u521B\u5EFA\u65F6\u95F4",id:"createdAt",type:"date",tip:"\u521B\u5EFA\u65F6\u95F4"},{title:"\u66F4\u6539\u65F6\u95F4",id:"updatedAt",type:"date",tip:"\u66F4\u6539\u65F6\u95F4"},{title:"\u64CD\u4F5C",id:"actions",type:"action"}]},subTablePendingIds:$,onSubTableRowAnimationComplete:(r,e)=>{N(z=>({...z,[r]:(z[r]||[]).filter(y=>y!==e)}))}}),[$,W,m,u]),B=r=>{i(!1),q(!1),c(void 0),r=="refresh"&&(f.current&&(clearTimeout(f.current),f.current=null),A())};function _(r){var e,z;if(!Array.isArray(r))return!0;for(const y of r){if(y.data){const k=y.data.find(I=>I.columnId==="status"),x=y.data.find(I=>I.columnId==="description");if(console.log("+++++",k.status==="20"||k.status==="11"||((e=x==null?void 0:x.tableMeta)==null?void 0:e.generateDescriptionStatus)==fe.GENERATING),k&&(k.status==="20"||k.status==="11"||((z=x==null?void 0:x.tableMeta)==null?void 0:z.generateDescriptionStatus)==fe.GENERATING))return!1}if(Array.isArray(y.children)){for(const k of y.children)if(k.data){const x=k.data.find(I=>I.columnId==="status");if(x&&(x.status==="20"||x.status==="11"))return!1}}}return!0}const A=async()=>{const r=await oe();_(r||[])?f.current&&(clearTimeout(f.current),f.current=null):(f.current&&(clearTimeout(f.current),f.current=null),f.current=setTimeout(()=>{A()},5e3))};return T(Ne,{title:u==null?void 0:u.name,description:(u==null?void 0:u.description)||"-",goBack:()=>{var r;(r=a.eventsEmit)==null||r.call(a,"goBack",{})},children:[t(Ae,{dataSource:W,ref:h,eventsEmit:n,status:M,styles:{theme:{...ge,colors:{...ge.colors,tableFirstColumnBg:"#ffffff",tableLastColumnBg:"#ffffff",paginationBackground:"#ffffff",subTableBackground:"#F5F5F5",tableHeaderBg:"#F5F5F5"}},mode:"light"},CustomComponents:{EmptyData:()=>t(eu,{dbInfo:u,setDrawerTitle:D,setDrawerVisible:i,getBtnDisabled:E}),...Z},...m=="DataTable"?S:l}),t(qe,{drawerTitle:b,drawerVisible:o,handleDrawerClose:B,dbId:d,token:F,url:w,uploadUrl:X,role:p,tableInfo:g}),t(Ke,{drawerTitle:j,drawerVisible:R,handleDrawerClose:B,tableInfo:g,optimizeDesc:se,eventsEmit:n})]})};export{hu as default};
package/databaseTable.js CHANGED
@@ -1,4 +1,4 @@
1
- import{jsxs as Y,jsx as N}from"react/jsx-runtime";import*as f from"react";import F,{useContext as de,Children as $e,useState as G,useRef as Le,useEffect as Ne,useMemo as Pe}from"react";import{u as ce}from"./assets/index-CpW6Dhpp.js";import{c as ze,n as ge,f as k,s as Fe,B as ue,h as Me,m as Te,y as E,r as _e,u as Oe,D as Ae,E as je,_ as ye,G as Re,H as be,R as xe,J as He,a as qe,I as We,L as Ge}from"./assets/index-8h59dJlj.js";import{J as Se,N as ke}from"./assets/index-DD8xyayB.js";import{D as Ve}from"./assets/index-BN3yu4iN.js";import{P as Xe,S as Je}from"./assets/index-C6WKbL3A.js";import{X as Ue}from"./assets/x-CmbLQ9dc.js";import{O as Ke}from"./assets/index-BqE1gm_T.js";/* empty css *//* empty css */import{M as Ye,s as Ce}from"./assets/index-DoUk2Ei_.js";import"react-dom";/**
1
+ import{jsxs as Y,jsx as N}from"react/jsx-runtime";import*as f from"react";import F,{useContext as de,Children as $e,useState as G,useRef as Le,useEffect as Ne,useMemo as Pe}from"react";import{u as ce}from"./assets/index-CpW6Dhpp.js";import{c as ze,n as ge,f as k,s as Fe,B as ue,h as Me,m as Te,y as E,r as _e,u as Oe,D as Ae,E as je,_ as ye,G as Re,H as be,R as xe,J as He,a as qe,I as We,L as Ge}from"./assets/index-8h59dJlj.js";import{J as Se,N as ke}from"./assets/index-CtPe9ln8.js";import{D as Ve}from"./assets/index-BN3yu4iN.js";import{P as Xe,S as Je}from"./assets/index-C6WKbL3A.js";import{X as Ue}from"./assets/x-CmbLQ9dc.js";import{O as Ke}from"./assets/index-w1SriKuR.js";/* empty css *//* empty css */import{M as Ye,s as Ce}from"./assets/index-DoUk2Ei_.js";import"react-dom";/**
2
2
  * @license lucide-react v0.456.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
package/index.js CHANGED
@@ -1 +1 @@
1
- import{DrawerType as B}from"./chat.js";import{C as R}from"./assets/index-DTbBckjs.js";import"./database.js";import"./databaseId.js";import"./databaseTable.js";import"react/jsx-runtime";import"react";import"./modelManage.js";import"./sensitive.js";import{G as W,B as b}from"./assets/GientechStreamReader-CwcCZLSJ.js";import"./assets/index-BQF0qnEM.js";import{F as q}from"./assets/index-8h59dJlj.js";import"./assets/index-WQa7_NYu.js";import"react-dom";import"./assets/index-DD8xyayB.js";import"./assets/index-C6WKbL3A.js";import"./assets/index-CVis9Agw.js";import"./assets/index-CpW6Dhpp.js";import"./assets/plus-CnVxGdOo.js";import"./assets/x-CmbLQ9dc.js";import"./assets/index-DoUk2Ei_.js";import"./assets/index-B-AFa3n1.js";/* empty css *//* empty css */import"./assets/index-BN3yu4iN.js";import"./assets/index-BdNcL3V6.js";import"./assets/index-BqE1gm_T.js";import"./assets/triangle-alert-BycMPaz2.js";export{R as ChatCompareComponent,B as DrawerType,W as GientechStreamReader,q as defaultTheme,b as registerPDFWorker};
1
+ import{DrawerType as B}from"./chat.js";import{C as R}from"./assets/index-C_tt8KnS.js";import"./database.js";import"./databaseId.js";import"./databaseTable.js";import"react/jsx-runtime";import"react";import"./modelManage.js";import"./sensitive.js";import{G as W,B as b}from"./assets/GientechStreamReader-C8rYtUxB.js";import"./assets/index-pbEQPM5Z.js";import{F as q}from"./assets/index-8h59dJlj.js";import"./assets/index-C9ax6WsW.js";import"react-dom";import"./assets/index-CtPe9ln8.js";import"./assets/index-C6WKbL3A.js";import"./assets/index-CVis9Agw.js";import"./assets/index-CpW6Dhpp.js";import"./assets/plus-CnVxGdOo.js";import"./assets/x-CmbLQ9dc.js";import"./assets/index-DoUk2Ei_.js";import"./assets/index-B-AFa3n1.js";/* empty css *//* empty css */import"./assets/index-BN3yu4iN.js";import"./assets/index-BdNcL3V6.js";import"./assets/index-w1SriKuR.js";import"./assets/triangle-alert-BycMPaz2.js";export{R as ChatCompareComponent,B as DrawerType,W as GientechStreamReader,q as defaultTheme,b as registerPDFWorker};
package/modelManage.js CHANGED
@@ -1 +1 @@
1
- import{jsx as o,jsxs as V}from"react/jsx-runtime";import{useState as D,useMemo as O,useRef as Q,useEffect as ee}from"react";import{J as L,N as Ie}from"./assets/index-DD8xyayB.js";import{a as ve,b as $,S as se,T as ue,F as ae}from"./assets/index-8h59dJlj.js";import{O as ne}from"./assets/index-BqE1gm_T.js";import{D as we}from"./assets/index-BN3yu4iN.js";import{X as ke}from"./assets/x-CmbLQ9dc.js";import{M as ce,s as j}from"./assets/index-DoUk2Ei_.js";import{T as xe}from"./assets/triangle-alert-BycMPaz2.js";/* empty css *//* empty css */import{P as Le}from"./assets/plus-CnVxGdOo.js";import{B as oe}from"./assets/index-BdNcL3V6.js";import"react-dom";const Se=""+new URL("assets/empty.png",import.meta.url).href,Re=({url:s,token:B,role:c,eventsEmit:p})=>{const F=ve.create({baseURL:s,timeout:1e6});return F.interceptors.request.use(e=>{let a=B;return!a&&!["user/login","user/kaptcha","user/regist"].some(l=>e.url.includes(l))?(p&&p("request:error_auth",{errorMsg:"\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F",redirect:"/login"}),Promise.reject(new Error("\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F"))):(e.headers.Authorization=a||"",e.headers.userName=c==="\u672A\u767B\u5F55\u7528\u6237"?"":c,e)}),F.interceptors.response.use(e=>{const a=["user/kaptcha"],u=e.data;if(a.some(k=>e.config.url&&e.config.url.includes(k))||u.size&&u.type)return u;const{success:l,errorMsg:g,errorCode:x}=u;return l?u:(p&&p("request:error_business",{errorCode:x,errorMsg:g||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",response:u}),!1)},e=>{var a,u,l,g,x,k,z,W,q;if(e.message==="canceled")return Promise.reject(e);if(p){let v="request:error_network",N={errorMsg:"\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25",error:e};((a=e==null?void 0:e.response)==null?void 0:a.status)===401?(v="request:error_auth",N={errorMsg:"\u6CA1\u6709\u8DB3\u591F\u6743\u9650",error:e,redirect:"/login"}):(((l=(u=e==null?void 0:e.response)==null?void 0:u.data)==null?void 0:l.errorCode)==="30013"||((x=(g=e==null?void 0:e.response)==null?void 0:g.data)==null?void 0:x.errorCode)==="30023")&&(v="request:error_business",N={errorCode:(z=(k=e==null?void 0:e.response)==null?void 0:k.data)==null?void 0:z.errorCode,errorMsg:((q=(W=e==null?void 0:e.response)==null?void 0:W.data)==null?void 0:q.message)||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",error:e}),p(v,N)}return Promise.reject(e)}),{getModelList:async e=>{try{const a=await F.get(`/allPage?${new URLSearchParams(e).toString()}`),{success:u,data:l}=a;if(u)return l}catch(a){return console.log("getModelList error:",a),!1}},delModelById:async e=>{try{const a=await F.delete(`/delete?id=${e}`),{success:u,data:l}=a;if(u)return l}catch(a){console.log("delModelById error:",a)}},createModel:async e=>{try{const a=await F.post("/create",e),{success:u,data:l}=a;if(u)return l}catch(a){console.log("createModel error:",a)}},updateModelById:async e=>{try{const a=await F.put("/update",e),{success:u,data:l}=a;if(u)return l}catch(a){console.log("updateModelById error:",a)}},getUseTypeList:async()=>{try{const e=await F.get("/getModelTypes"),{success:a,data:u}=e;if(a)return u}catch(e){return console.log("getUseTypeList error:",e),!1}},getModelProtocolsList:async()=>{try{const e=await F.get("/getModelProtocols"),{success:a,data:u}=e;if(a)return u}catch(e){return console.log("getModelProtocolsList error:",e),!1}},testStatus:async()=>{try{const e=await F.post("/check"),{success:a,data:u}=e;if(a)return u}catch(e){console.log("testStatus error:",e)}},replaceModel:async(e,a)=>{try{const u=await F.get(`/replaceModel?sourceModelId=${e}&targetModelId=${a}`),{success:l,data:g}=u;if(l)return g}catch(u){console.log("replaceModel error:",u)}},checkModel:async e=>{try{const a=await F.get(`/checkModelReference?modelName=${e}`),{success:u,data:l}=a;if(u)return l}catch(a){console.log("checkModelReference error:",a)}}}},ze=({drawerTitle:s,drawerVisible:B,modelInfo:c,handleDrawerClose:p,modelUseTypeOpt:F,modelProtocolsOpt:S,eventsEmit:i})=>{const[M,R]=D(!1),[U,n]=D(!1),f=O(()=>({id:"config-model",layout:"vertical",formWidth:"550px",fields:[{id:"modelName",name:"modelName",label:"\u6A21\u578B\u540D\u79F0",type:"input",required:!0,placeholder:"\u8BF7\u8F93\u5165\u6A21\u578B\u540D\u79F0",counter:30},{id:"modelIde",name:"modelIde",label:"\u6A21\u578BID",type:"input",required:!0,placeholder:"\u8BF7\u8F93\u5165\u6A21\u578BID",defaultValue:""},{id:"apiKey",name:"apiKey",label:"APIKey",type:"input",required:!1,placeholder:"\u8BF7\u8F93\u5165APIKey",defaultValue:""},{id:"url",name:"url",label:"\u8BF7\u6C42URL",type:"input",required:!0,placeholder:"\u8BF7\u8F93\u5165\u8BF7\u6C42URL",defaultValue:""},{id:"modelProtocol",name:"modelProtocol",label:"\u6A21\u578B\u4F20\u8F93\u534F\u8BAE",type:"select",required:!0,options:S},{id:"type",name:"type",label:"\u4F7F\u7528\u7C7B\u578B",type:"select",required:!0,options:F,defaultValue:1},{id:"dec",name:"dec",label:"\u8BF4\u660E",type:"textarea",required:!1}]}),[c,F,S]),A=Q(null),I=async(u,l,g)=>{var x;switch(console.log("[Form] eventsEmit:",u,l,g),u){case"form:ready":l.formRef&&(A.current=l.formRef);break;case"form:change":if(!((x=A.current)!=null&&x.getValue)){console.log("\u8868\u5355\u5F15\u7528\u672A\u5C31\u7EEA\uFF0C\u8DF3\u8FC7 formdata_onchange \u4E8B\u4EF6");return}const k=await A.current.getValue("type");k==2||k==3?n(!0):n(!1);break;default:console.log("\u672A\u5904\u7406\u7684\u4E8B\u4EF6:",u,l)}i==null||i(u,l,g)},e=async()=>{try{R(!0);const u=await A.current.getAllData();u.isValid&&(c!=null&&c.id?await i("form_submitted_edit",u,void 0):await i("form_submitted_add",u,void 0))}catch(u){console.error("\u274C \u63D0\u4EA4\u8868\u5355\u6570\u636E\u5931\u8D25:",u)}finally{R(!1)}},a=O(()=>{const u=c==null?void 0:c.data.reduce((l,g)=>(l[g.columnId]=g.value,l),{});return{label:"\u52A8\u6001\u8868\u5355\u793A\u4F8B",defaultActiveId:f.id,model:null,views:[{label:"\u7528\u6237\u6CE8\u518C\u8868\u5355",id:f.id,type:"form",size:"md",formWidth:f.formWidth,formConfig:{layout:f.layout,showReset:!1,showSubmit:!1,formWidth:f.formWidth}}],dataSource:[{id:f.id,fields:f.fields,defaultValues:u||{}}],eventsEmit:I}},[c,U,f]);return o(we,{title:s,placement:"right",width:560,onClose:p,closeIcon:!1,extra:o(ke,{size:20,color:"#888888",onClick:p,className:"cursor-pointer"}),open:B,destroyOnHidden:!0,footer:V("div",{className:"flex justify-end items-center gap-3",children:[o(L,{mode:"default",label:"\u53D6\u6D88",onClick:p}),o(L,{mode:"primary",label:"\u786E\u8BA4",loading:M,onClick:e})]}),children:o(ne,{...a},"example-form")})},{Item:le}=$,Ve=({modelVisible:s,options:B,eventsEmit:c,replaceModel:p})=>{const[F,S]=D(!1),[i]=$.useForm(),M=$.useWatch("sourceModelId",i),R=O(()=>{const n=B.find(f=>f.value==M);return n?B.filter(A=>A.useType==n.useType&&A.value!==M&&A.status==1):[]},[M]);return ee(()=>{M&&i.setFieldValue("targetModelId",void 0)},[M]),V(ce,{open:s,title:"\u6A21\u578B\u66FF\u6362",width:620,destroyOnHidden:!0,onCancel:()=>{i.resetFields(),c&&c("close_model")},footer:V("div",{className:"flex justify-end gap-3",style:{justifyContent:"end",margin:"20px 4px"},children:[o(L,{mode:"default",label:"\u53D6\u6D88",onClick:()=>{i.resetFields(),c&&c("close_model")}}),o(L,{mode:"primary",label:"\u786E\u8BA4",loading:F,onClick:async()=>{try{S(!0);const n=await i.validateFields(),{sourceModelId:f,targetModelId:A}=n;await p(f,A)&&(j.success("\u6A21\u578B\u66FF\u6362\u6210\u529F"),i.resetFields(),c&&c("replace_model"))}catch(n){console.log("e---->",n)}finally{S(!1)}}})]}),children:[V("div",{className:"flex gap-3",style:{margin:"20px 4px"},children:[o("div",{children:o(xe,{size:22,color:"#f4a02a"})}),o("span",{className:"text-[14px]",children:"\u5982\u9700\u66F4\u6362\u6A21\u578B\uFF0C\u5728\u4E00\u952E\u66FF\u6362\u65F6\uFF0C\u7CFB\u7EDF\u5C06\u81EA\u52A8\u66F4\u65B0\u77E5\u8BC6\u89E3\u6790\u914D\u7F6E\u3001\u68C0\u7D22\u6D4B\u8BD5\u548C\u52A9\u624B\u914D\u7F6E\u4E2D\u7684\u6A21\u578B\u3002\u82E5\u66FF\u6362\u7684\u662F\u6587\u6863\u89E3\u6790\u7528\u7684Embedding\u6A21\u578B\uFF0C\u5219\u4F7F\u7528\u8BE5\u6A21\u578B\u7684\u6587\u6863\u5C06\u5168\u90E8\u91CD\u65B0\u6392\u961F\u89E3\u6790\uFF0C\u72B6\u6001\u53D8\u4E3A\u201C\u89E3\u6790\u4E2D\u201D\uFF0C\u4E14\u672A\u89E3\u6790\u5B8C\u6210\u7684\u6587\u6863\u6682\u4E0D\u53EF\u68C0\u7D22\uFF01"})]}),V($,{form:i,colon:!1,labelCol:{span:5},wrapperCol:{span:18},style:{margin:"40px 60px"},children:[o(le,{label:"\u6A21\u578B\u540D\u79F0",name:"sourceModelId",rules:[{required:!0,message:""}],children:o(se,{placeholder:"\u8BF7\u9009\u62E9",options:B})}),o(le,{label:"\u66FF\u6362\u4E3A",name:"targetModelId",rules:[{required:!0,message:""}],children:o(se,{placeholder:"\u8BF7\u9009\u62E9",options:R})})]})]})},X={success:"green",error:"red",warning:"orange",processing:"blue",info:"cyan",default:"default"},J=[{statusType:"success",value:"\u53EF\u7528",status:1},{statusType:"error",value:"\u4E0D\u53EF\u7528",status:0},{statusType:"warning",value:"\u68C0\u6D4B\u4E2D",status:2}],Ue=s=>typeof s=="string"&&s in X?X[s]:X.default;var K=(s=>(s[s.DATE=0]="DATE",s[s.VIEW=1]="VIEW",s[s.ERROR=2]="ERROR",s[s.AUTHORIZE=3]="AUTHORIZE",s[s.DELETE=4]="DELETE",s[s.ANALYSIS_OR_EXTRACT=5]="ANALYSIS_OR_EXTRACT",s[s.DOWNLOAD=6]="DOWNLOAD",s[s.EDIT=7]="EDIT",s[s.ADD=8]="ADD",s[s.ANALYSIS_CONFIG=9]="ANALYSIS_CONFIG",s[s.AUTHORIZE_CONFIG=10]="AUTHORIZE_CONFIG",s))(K||{});const{confirm:re}=ce,qe={pageNum:1,pageSize:1e3},Ne=s=>{const{value:B,cell:c}=s,p=Ue(s.cell.statusType);return B=="\u4E0D\u53EF\u7528"?o(ue,{title:c.errorMsg,children:o("div",{className:"flex items-center gap-2",children:o(oe,{color:p,text:B})})}):o(oe,{color:p,text:B})};function Qe(s){const{url:B,token:c,role:p,CustomComponents:F,eventsEmit:S,getBtnDisabled:i,showModelReplace:M}=s,[R,U]=D({container:"ready",content:"ready"}),n=Q(null),[f,A]=D(),I=Q(null),[e,a]=D(!1),[u,l]=D(!1),[g,x]=D([]),[k,z]=D(!1),[W,q]=D(""),[v,N]=D(),[Z,ie]=D([]),[P,de]=D([]),{getModelList:me,delModelById:Fe,createModel:pe,updateModelById:fe,getUseTypeList:ye,getModelProtocolsList:ge,testStatus:Be,replaceModel:Ae,checkModel:Ee}=Re({url:B,token:c,role:p,eventsEmit:S});ee(()=>{U(r=>({...r,content:"loading"})),G(),De()},[]),ee(()=>{},[k]);const be=r=>(r||[]).map((t,m)=>{let d=J.find(w=>w.status==t.status);return{id:t.id,data:[{columnId:"modelName",value:t.modelName},{columnId:"modelProtocol",value:t.modelProtocol,type:"customized"},{columnId:"type",value:t.type,type:"customized"},{columnId:"dec",value:t.dec},{columnId:"status",...d,type:"customized",errorMsg:t.errorMsg},{columnId:"actions",value:"edit",label:"\u7F16\u8F91",status:t.status,type:"action",disabled:i&&i(K.EDIT,t.permission)},{columnId:"actions",value:"auth",label:"\u6388\u6743",type:"action",status:t.status,disabled:i&&i(K.AUTHORIZE,t.permission)},{columnId:"actions",value:"delete",label:"\u5220\u9664",type:"action",status:t.status,disabled:i&&i(K.AUTHORIZE,t.permission)},{columnId:"url",value:t.url},{columnId:"apiKey",value:t.apiKey},{columnId:"modelIde",value:t.modelIde},{columnId:"thinking",value:t.thinking}]}}),De=async()=>{try{const[r,t]=await Promise.allSettled([ye(),ge()]);r.status==="fulfilled"&&r.value&&ie((r.value||[]).map(m=>({...m,value:Number(m.value)}))),t.status==="fulfilled"&&t.value&&de((t.value||[]).map(m=>({...m,value:Number(m.value)})))}catch(r){console.error("[TableApiError] getTableList:",r)}},te=async()=>{try{const r=await me(qe);if(r.records){const t=be(r.records),m=(r.records||[]).map(d=>({value:d.id,label:d.modelName,useType:d.type,status:d.status}));return x(m),A(t||[]),U(d=>({...d,content:"ready"})),t||[]}}catch(r){console.error("[TableApiError] getTableList:",r)}},G=async()=>{const r=await te();he(r||[])?I.current&&(clearTimeout(I.current),I.current=null):(I.current&&(clearTimeout(I.current),I.current=null),I.current=setTimeout(()=>{G()},5e3))};function he(r){if(!Array.isArray(r))return!0;for(const t of r)if(t.data){const m=t.data.find(d=>d.columnId==="status");if(m&&m.status===2)return!1}return!0}const Ce=O(()=>({label:"\u6570\u636E\u5E93\u8868\u683C",defaultActiveId:"model-table",model:null,views:[{label:"\u6A21\u578B",id:"model-table",type:"table",viewBehavior:"pagination",allowMultiSelect:!1,viewPageSize:10,columns:[{id:"modelName",title:"\u6A21\u578B\u540D\u79F0",type:"label"},{id:"modelProtocol",title:"\u6A21\u578B\u4F20\u8F93\u534F\u8BAE",type:"customized",component:r=>{var d;const{value:t}=r,m=(d=P.find(w=>w.value==t))==null?void 0:d.label;return o("span",{children:m})}},{id:"type",title:"\u4F7F\u7528\u7C7B\u578B",type:"customized",component:r=>{var d;const{value:t}=r,m=(d=Z.find(w=>w.value==t))==null?void 0:d.label;return o("span",{children:m})}},{id:"dec",title:"\u8BF4\u660E",type:"paragraph"},{id:"status",title:"\u72B6\u6001",type:"customized",component:o(Ne,{}),helpText:"\u5F53\u524D\u6A21\u578B\u72B6\u6001\u4E3A\u521D\u6B21\u65B0\u589E\u6821\u9A8C\u72B6\u6001\uFF0C\u82E5\u6A21\u578B\u4E0B\u7EBF\uFF0C\u6B64\u72B6\u6001\u4E0D\u4F1A\u4E3B\u52A8\u66F4\u65B0\uFF0C\u9700\u624B\u52A8\u6267\u884C\u6A21\u578B\u5220\u9664"},{id:"actions",title:"\u64CD\u4F5C",type:"customized",component:r=>{const{value:t,cell:m,row:d}=r,{disabled:w,label:H,status:_}=m;return _==2?o(ue,{title:"\u68C0\u6D4B\u4E2D\uFF0C\u8BF7\u7A0D\u540E",children:o(L,{mode:"text",label:H,disabled:!0})}):w?o(ue,{title:"\u89D2\u8272\u65E0\u6743\u9650\u64CD\u4F5C",children:o(L,{mode:"text",label:H,disabled:w})}):o(L,{mode:"text",label:H,onClick:()=>T(`table_action_${t}`,d,void 0)})}}],toolbar:[{type:"button",btnType:"primary",key:"add",label:"\u65B0\u5EFA",icon:o(Le,{})},...M?[{type:"customized",key:"test",render:()=>o(L,{loading:e,mode:"primary",label:"\u6A21\u578B\u72B6\u6001\u68C0\u6D4B",onClick:()=>{T("toolbar_test")}})},{type:"button",btnType:"primary",key:"replace",label:"\u6A21\u578B\u66FF\u6362"}]:[]]}]}),[f,Z,P,e,M]),Me=()=>V("div",{className:"flex flex-col items-center justify-center h-full",children:[o("div",{className:"text-xl font-semibold mb-3",style:{color:"#374151"},children:o("img",{src:Se,width:120})}),o("div",{className:"text-base mb-6",style:{color:"#6b7280"},children:"\u6682\u65E0\u6570\u636E\uFF0C\u8BF7\u5148\u65B0\u5EFA\u6A21\u578B"}),o("div",{className:"flex gap-3",children:o(L,{mode:"primary",label:"\u65B0\u5EFA\u6A21\u578B",onClick:()=>{q("\u65B0\u5EFA"),z(!0)}})})]});async function T(r,t,m){var d,w,H,_;switch(console.log("[adopter] mergedEventsEmit",r,t,m),r){case"toolbar_add":{q("\u65B0\u5EFA"),z(!0);break}case"toolbar_test":{a(!0),await Be()&&(a(!1),await G(),j.success("\u6A21\u578B\u68C0\u6D4B\u4E2D\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85\u72B6\u6001\u66F4\u65B0\uFF01"));break}case"toolbar_replace":{l(!0);break}case"table_action_delete":{try{const h=t.data.find(b=>b.columnId=="modelName").value;if(await Ee(h)>0)re({title:"\u5220\u9664\u6A21\u578B",content:o("div",{style:{marginRight:"20px"},children:"\u5F53\u524D\u6A21\u578B\u5728\u7CFB\u7EDF\u5185\u5DF2\u88AB\u914D\u7F6E\u4F7F\u7528\uFF0C\u5220\u9664\u53EF\u80FD\u5F71\u54CD\u6587\u6863\u89E3\u6790\u3001\u95EE\u7B54\u3001\u591A\u6A21\u6001\u80FD\u529B\u4F7F\u7528\u7B49\uFF0C\u8BF7\u60A8\u5148\u4F7F\u7528\u201C\u6A21\u578B\u4E00\u952E\u66FF\u6362\u201D\u80FD\u529B\u5C06\u8BE5\u6A21\u578B\u66FF\u6362\u4E3A\u540C\u7C7B\u578B\u6A21\u578B\uFF0C\u518D\u5220\u9664\u6A21\u578B"}),okText:"\u786E\u8BA4",cancelText:"\u53D6\u6D88"});else{const b=t.data.find(C=>C.columnId=="modelName").value;re({title:"\u786E\u8BA4\u5220\u9664\uFF1F",content:`\u786E\u5B9A\u8981\u5220\u9664\u6A21\u578B \u201C${b}\u201D \u5417\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002`,okText:"\u5220\u9664",cancelText:"\u53D6\u6D88",async onOk(){await Fe(t.id)&&(n!=null&&n.current)&&(n==null||n.current.appFn.removeItem(t.id),j.success("\u5220\u9664\u6210\u529F"))}})}}catch(h){console.error("\u5220\u9664\u8868\u6570\u636E\u5931\u8D25",h)}break}case"table_action_edit":{q("\u7F16\u8F91"),z(!0),N(t);break}case"form_submitted_add":{try{const h=t.fields.reduce((b,C)=>(b[C.name]=C.value,b),{}),E=await pe({...h});if(E){let b=J.find(y=>y.status==E.status);const C={id:E.id,data:[...(Object.keys(E)||[]).map(y=>({columnId:y,value:E[y],...(y=="modelProtocol"||y=="type")&&{type:"customized"},...y=="status"&&{...b,type:"customized",errorMsg:E.errorMsg}})),{columnId:"actions",value:"edit",label:"\u7F16\u8F91",type:"action"},{columnId:"actions",value:"auth",label:"\u6388\u6743",type:"action"},{columnId:"actions",value:"delete",label:"\u5220\u9664",type:"action"}]};(w=(d=n==null?void 0:n.current)==null?void 0:d.appFn)==null||w.addItem(C,{animate:!0,position:"start"}),j.success("\u6A21\u578B\u65B0\u589E\u6210\u529F\uFF01")}}catch(h){console.error("\u4FDD\u5B58\u5931\u8D25\uFF01",h)}finally{Y()}break}case"form_submitted_edit":{try{const h=t.fields.reduce((b,C)=>(b[C.name]=C.value,b),{}),E=await fe({...h,id:v.id});if(E){let b=J.find(y=>y.status==E.status);const C={...v,data:v.data.map(y=>{if(E[y.columnId]!==null&&E[y.columnId]!==void 0){if(y.columnId=="status")return{...y,...b};y.value=E[y.columnId]}return y})};(_=(H=n==null?void 0:n.current)==null?void 0:H.appFn)==null||_.updateItem(C,v==null?void 0:v.id),j.success("\u6A21\u578B\u7F16\u8F91\u6210\u529F\uFF01")}}catch(h){console.error("\u4FDD\u5B58\u5931\u8D25\uFF01",h)}finally{Y()}break}case"replace_model":{await te(),l(!1);break}case"close_model":{l(!1);break}default:typeof s.eventsEmit=="function"&&s.eventsEmit(r,t);break}}const Y=()=>{z(!1),N(void 0)};return V(Ie,{title:"\u6A21\u578B\u7BA1\u7406",children:[o(ne,{dataSource:f,ref:n,eventsEmit:T,status:R,CustomComponents:{EmptyData:Me,...F},styles:{theme:{...ae,colors:{...ae.colors,tableFirstColumnBg:"#ffffff",tableLastColumnBg:"#ffffff",paginationBackground:"#ffffff",subTableBackground:"#F5F5F5",tableHeaderBg:"#F5F5F5"}},mode:"light"},...Ce}),o(ze,{drawerTitle:W,drawerVisible:k,handleDrawerClose:Y,modelInfo:v,modelUseTypeOpt:Z,modelProtocolsOpt:P,eventsEmit:T}),o(Ve,{modelVisible:u,options:g,eventsEmit:T,replaceModel:Ae})]})}export{Qe as default};
1
+ import{jsx as o,jsxs as V}from"react/jsx-runtime";import{useState as h,useMemo as O,useRef as Q,useEffect as re}from"react";import{J as L,N as ve}from"./assets/index-CtPe9ln8.js";import{a as Ie,b as _,S as te,T as ee,F as se}from"./assets/index-8h59dJlj.js";import{O as ne}from"./assets/index-w1SriKuR.js";import{D as we}from"./assets/index-BN3yu4iN.js";import{X as xe}from"./assets/x-CmbLQ9dc.js";import{M as ce,s as j}from"./assets/index-DoUk2Ei_.js";import{T as ke}from"./assets/triangle-alert-BycMPaz2.js";/* empty css *//* empty css */import{P as Le}from"./assets/plus-CnVxGdOo.js";import{B as ae}from"./assets/index-BdNcL3V6.js";import"react-dom";const Se=""+new URL("assets/empty.png",import.meta.url).href,Re=({url:s,token:B,role:n,eventsEmit:p})=>{const m=Ie.create({baseURL:s,timeout:1e6});return m.interceptors.request.use(e=>{let a=B;return!a&&!["user/login","user/kaptcha","user/regist"].some(l=>e.url.includes(l))?(p&&p("request:error_auth",{errorMsg:"\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F",redirect:"/login"}),Promise.reject(new Error("\u672A\u767B\u5F55\u6216token\u5DF2\u8FC7\u671F"))):(e.headers.Authorization=a||"",e.headers.userName=n==="\u672A\u767B\u5F55\u7528\u6237"?"":n,e)}),m.interceptors.response.use(e=>{const a=["user/kaptcha"],u=e.data;if(a.some(x=>e.config.url&&e.config.url.includes(x))||u.size&&u.type)return u;const{success:l,errorMsg:g,errorCode:k}=u;return l?u:(p&&p("request:error_business",{errorCode:k,errorMsg:g||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",response:u}),!1)},e=>{var a,u,l,g,k,x,T,W,q;if(e.message==="canceled")return Promise.reject(e);if(p){let I="request:error_network",U={errorMsg:"\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25",error:e};((a=e==null?void 0:e.response)==null?void 0:a.status)===401?(I="request:error_auth",U={errorMsg:"\u6CA1\u6709\u8DB3\u591F\u6743\u9650",error:e,redirect:"/login"}):(((l=(u=e==null?void 0:e.response)==null?void 0:u.data)==null?void 0:l.errorCode)==="30013"||((k=(g=e==null?void 0:e.response)==null?void 0:g.data)==null?void 0:k.errorCode)==="30023")&&(I="request:error_business",U={errorCode:(T=(x=e==null?void 0:e.response)==null?void 0:x.data)==null?void 0:T.errorCode,errorMsg:((q=(W=e==null?void 0:e.response)==null?void 0:W.data)==null?void 0:q.message)||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",error:e}),p(I,U)}return Promise.reject(e)}),{getModelList:async e=>{try{const a=await m.get(`/allPage?${new URLSearchParams(e).toString()}`),{success:u,data:l}=a;if(u)return l}catch(a){return console.log("getModelList error:",a),!1}},delModelById:async e=>{try{const a=await m.delete(`/delete?id=${e}`),{success:u,data:l}=a;if(u)return l}catch(a){console.log("delModelById error:",a)}},createModel:async e=>{try{const a=await m.post("/create",e),{success:u,data:l}=a;if(u)return l}catch(a){console.log("createModel error:",a)}},updateModelById:async e=>{try{const a=await m.put("/update",e),{success:u,data:l}=a;if(u)return l}catch(a){console.log("updateModelById error:",a)}},getUseTypeList:async()=>{try{const e=await m.get("/getModelTypes"),{success:a,data:u}=e;if(a)return u}catch(e){return console.log("getUseTypeList error:",e),!1}},getModelProtocolsList:async()=>{try{const e=await m.get("/getModelProtocols"),{success:a,data:u}=e;if(a)return u}catch(e){return console.log("getModelProtocolsList error:",e),!1}},testStatus:async()=>{try{const e=await m.post("/check"),{success:a,data:u}=e;if(a)return u}catch(e){console.log("testStatus error:",e)}},replaceModel:async(e,a)=>{try{const u=await m.get(`/replaceModel?sourceModelId=${e}&targetModelId=${a}`),{success:l,data:g}=u;if(l)return g}catch(u){console.log("replaceModel error:",u)}},checkModel:async e=>{try{const a=await m.get(`/checkModelReference?modelName=${e}`),{success:u,data:l}=a;if(u)return l}catch(a){console.log("checkModelReference error:",a)}}}},Te=({drawerTitle:s,drawerVisible:B,modelInfo:n,handleDrawerClose:p,modelUseTypeOpt:m,modelProtocolsOpt:S,eventsEmit:i})=>{const[v,R]=h(!1),[z,c]=h(!1),f=O(()=>({id:"config-model",layout:"vertical",formWidth:"550px",fields:[{id:"modelName",name:"modelName",label:"\u6A21\u578B\u540D\u79F0",type:"input",required:!0,placeholder:"\u8BF7\u8F93\u5165\u6A21\u578B\u540D\u79F0",counter:30},{id:"modelIde",name:"modelIde",label:"\u6A21\u578BID",type:"input",required:!0,placeholder:"\u8BF7\u8F93\u5165\u6A21\u578BID",defaultValue:""},{id:"apiKey",name:"apiKey",label:"APIKey",type:"input",required:!1,placeholder:"\u8BF7\u8F93\u5165APIKey",defaultValue:""},{id:"url",name:"url",label:"\u8BF7\u6C42URL",type:"input",required:!0,placeholder:"\u8BF7\u8F93\u5165\u8BF7\u6C42URL",defaultValue:""},{id:"modelProtocol",name:"modelProtocol",label:"\u6A21\u578B\u4F20\u8F93\u534F\u8BAE",type:"select",required:!0,options:S},{id:"type",name:"type",label:"\u4F7F\u7528\u7C7B\u578B",type:"select",required:!0,options:m,defaultValue:1},{id:"maxTokens",name:"maxTokens",label:"\u4E0A\u4E0B\u6587\u957F\u5EA6",type:"slider",range:{max:1e5,min:200},step:1,sliderInline:!0,required:!0,helpText:"\u8BF7\u5411\u6A21\u578B\u90E8\u7F72\u6216\u8FD0\u7EF4\u4EBA\u5458\u786E\u8BA4\u5F53\u524D\u6A21\u578B\u7684\u6700\u5927\u4E0A\u4E0B\u6587\u957F\u5EA6\uFF08Max Tokens / Context Length\uFF09\uFF0C\u5E76\u786E\u8BA4\u63A8\u7406\u670D\u52A1\uFF08\u5982 vLLM\uFF09\u662F\u5426\u914D\u7F6E\u4E86\u989D\u5916\u7684\u8F93\u5165\u957F\u5EA6\u9650\u5236"},{id:"dec",name:"dec",label:"\u8BF4\u660E",type:"textarea",required:!1}]}),[n,m,S]),A=Q(null),E=async(u,l,g)=>{var k;switch(console.log("[Form] eventsEmit:",u,l,g),u){case"form:ready":l.formRef&&(A.current=l.formRef);break;case"form:change":if(!((k=A.current)!=null&&k.getValue)){console.log("\u8868\u5355\u5F15\u7528\u672A\u5C31\u7EEA\uFF0C\u8DF3\u8FC7 formdata_onchange \u4E8B\u4EF6");return}const x=await A.current.getValue("type");x==2||x==3?c(!0):c(!1),x==2&&A.current.setValues({maxTokens:512});break;default:console.log("\u672A\u5904\u7406\u7684\u4E8B\u4EF6:",u,l)}i==null||i(u,l,g)},e=async()=>{try{R(!0);const u=await A.current.getAllData();u.isValid&&(n!=null&&n.id?await i("form_submitted_edit",u,void 0):await i("form_submitted_add",u,void 0))}catch(u){console.error("\u274C \u63D0\u4EA4\u8868\u5355\u6570\u636E\u5931\u8D25:",u)}finally{R(!1)}},a=O(()=>{const u=n==null?void 0:n.data.reduce((l,g)=>(l[g.columnId]=g.value,l),{});return console.log("====",u,n==null?void 0:n.data),{label:"\u52A8\u6001\u8868\u5355\u793A\u4F8B",defaultActiveId:f.id,model:null,views:[{label:"\u7528\u6237\u6CE8\u518C\u8868\u5355",id:f.id,type:"form",size:"md",formWidth:f.formWidth,formConfig:{layout:f.layout,showReset:!1,showSubmit:!1,formWidth:f.formWidth}}],dataSource:[{id:f.id,fields:f.fields,defaultValues:u||{}}],eventsEmit:E}},[n,z,f]);return o(we,{title:s,placement:"right",width:560,onClose:p,closeIcon:!1,extra:o(xe,{size:20,color:"#888888",onClick:p,className:"cursor-pointer"}),open:B,destroyOnHidden:!0,footer:V("div",{className:"flex justify-end items-center gap-3",children:[o(L,{mode:"default",label:"\u53D6\u6D88",onClick:p}),o(L,{mode:"primary",label:"\u786E\u8BA4",loading:v,onClick:e})]}),children:o(ne,{...a},"example-form")})},{Item:oe}=_,Ve=({modelVisible:s,options:B,eventsEmit:n,replaceModel:p})=>{const[m,S]=h(!1),[i]=_.useForm(),v=_.useWatch("sourceModelId",i),R=O(()=>{const c=B.find(f=>f.value==v);return c?B.filter(A=>A.useType==c.useType&&A.value!==v&&A.status==1):[]},[v]);return re(()=>{v&&i.setFieldValue("targetModelId",void 0)},[v]),V(ce,{open:s,title:"\u6A21\u578B\u66FF\u6362",width:620,destroyOnHidden:!0,onCancel:()=>{i.resetFields(),n&&n("close_model")},footer:V("div",{className:"flex justify-end gap-3",style:{justifyContent:"end",margin:"20px 4px"},children:[o(L,{mode:"default",label:"\u53D6\u6D88",onClick:()=>{i.resetFields(),n&&n("close_model")}}),o(L,{mode:"primary",label:"\u786E\u8BA4",loading:m,onClick:async()=>{try{S(!0);const c=await i.validateFields(),{sourceModelId:f,targetModelId:A}=c;await p(f,A)&&(j.success("\u6A21\u578B\u66FF\u6362\u6210\u529F"),i.resetFields(),n&&n("replace_model"))}catch(c){console.log("e---->",c)}finally{S(!1)}}})]}),children:[V("div",{className:"flex gap-3",style:{margin:"20px 4px"},children:[o("div",{children:o(ke,{size:22,color:"#f4a02a"})}),o("span",{className:"text-[14px]",children:"\u5982\u9700\u66F4\u6362\u6A21\u578B\uFF0C\u5728\u4E00\u952E\u66FF\u6362\u65F6\uFF0C\u7CFB\u7EDF\u5C06\u81EA\u52A8\u66F4\u65B0\u77E5\u8BC6\u89E3\u6790\u914D\u7F6E\u3001\u68C0\u7D22\u6D4B\u8BD5\u548C\u52A9\u624B\u914D\u7F6E\u4E2D\u7684\u6A21\u578B\u3002\u82E5\u66FF\u6362\u7684\u662F\u6587\u6863\u89E3\u6790\u7528\u7684Embedding\u6A21\u578B\uFF0C\u5219\u4F7F\u7528\u8BE5\u6A21\u578B\u7684\u6587\u6863\u5C06\u5168\u90E8\u91CD\u65B0\u6392\u961F\u89E3\u6790\uFF0C\u72B6\u6001\u53D8\u4E3A\u201C\u89E3\u6790\u4E2D\u201D\uFF0C\u4E14\u672A\u89E3\u6790\u5B8C\u6210\u7684\u6587\u6863\u6682\u4E0D\u53EF\u68C0\u7D22\uFF01"})]}),V(_,{form:i,colon:!1,labelCol:{span:5},wrapperCol:{span:18},style:{margin:"40px 60px"},children:[o(oe,{label:"\u6A21\u578B\u540D\u79F0",name:"sourceModelId",rules:[{required:!0,message:""}],children:o(te,{placeholder:"\u8BF7\u9009\u62E9",options:B})}),o(oe,{label:"\u66FF\u6362\u4E3A",name:"targetModelId",rules:[{required:!0,message:""}],children:o(te,{placeholder:"\u8BF7\u9009\u62E9",options:R})})]})]})},X={success:"green",error:"red",warning:"orange",processing:"blue",info:"cyan",default:"default"},J=[{statusType:"success",value:"\u53EF\u7528",status:1},{statusType:"error",value:"\u4E0D\u53EF\u7528",status:0},{statusType:"warning",value:"\u68C0\u6D4B\u4E2D",status:2}],ze=s=>typeof s=="string"&&s in X?X[s]:X.default;var K=(s=>(s[s.DATE=0]="DATE",s[s.VIEW=1]="VIEW",s[s.ERROR=2]="ERROR",s[s.AUTHORIZE=3]="AUTHORIZE",s[s.DELETE=4]="DELETE",s[s.ANALYSIS_OR_EXTRACT=5]="ANALYSIS_OR_EXTRACT",s[s.DOWNLOAD=6]="DOWNLOAD",s[s.EDIT=7]="EDIT",s[s.ADD=8]="ADD",s[s.ANALYSIS_CONFIG=9]="ANALYSIS_CONFIG",s[s.AUTHORIZE_CONFIG=10]="AUTHORIZE_CONFIG",s))(K||{});const{confirm:le}=ce,qe={pageNum:1,pageSize:1e3},Ue=s=>{const{value:B,cell:n}=s,p=ze(s.cell.statusType);return B=="\u4E0D\u53EF\u7528"?o(ee,{title:n.errorMsg,children:o("div",{className:"flex items-center gap-2",children:o(ae,{color:p,text:B})})}):o(ae,{color:p,text:B})};function Qe(s){const{url:B,token:n,role:p,CustomComponents:m,eventsEmit:S,getBtnDisabled:i,showModelReplace:v}=s,[R,z]=h({container:"ready",content:"ready"}),c=Q(null),[f,A]=h(),E=Q(null),[e,a]=h(!1),[u,l]=h(!1),[g,k]=h([]),[x,T]=h(!1),[W,q]=h(""),[I,U]=h(),[Z,ie]=h([]),[P,de]=h([]),{getModelList:Fe,delModelById:me,createModel:pe,updateModelById:fe,getUseTypeList:ye,getModelProtocolsList:Ae,testStatus:Ee,replaceModel:ge,checkModel:Be}=Re({url:B,token:n,role:p,eventsEmit:S});re(()=>(z(r=>({...r,content:"loading"})),G(),be(),()=>{E.current&&(clearTimeout(E.current),E.current=null)}),[]);const De=r=>(r||[]).map((t,F)=>{let d=J.find(w=>w.status==t.status);return{id:t.id,data:[{columnId:"modelName",value:t.modelName},{columnId:"modelProtocol",value:t.modelProtocol,type:"customized"},{columnId:"type",value:t.type,type:"customized"},{columnId:"dec",value:t.dec},{columnId:"status",...d,type:"customized",errorMsg:t.errorMsg},{columnId:"actions",value:"edit",label:"\u7F16\u8F91",status:t.status,type:"action",disabled:i&&i(K.EDIT,t.permission)},{columnId:"actions",value:"auth",label:"\u6388\u6743",type:"action",status:t.status,disabled:i&&i(K.AUTHORIZE,t.permission)},{columnId:"actions",value:"delete",label:"\u5220\u9664",type:"action",status:t.status,disabled:i&&i(K.AUTHORIZE,t.permission)},{columnId:"url",value:t.url},{columnId:"apiKey",value:t.apiKey},{columnId:"modelIde",value:t.modelIde},{columnId:"thinking",value:t.thinking},{columnId:"maxTokens",value:t.maxTokens}]}}),be=async()=>{try{const[r,t]=await Promise.allSettled([ye(),Ae()]);r.status==="fulfilled"&&r.value&&ie((r.value||[]).map(F=>({...F,value:Number(F.value)}))),t.status==="fulfilled"&&t.value&&de((t.value||[]).map(F=>({...F,value:Number(F.value)})))}catch(r){console.error("[TableApiError] getTableList:",r)}},ue=async()=>{try{const r=await Fe(qe);if(r.records){const t=De(r.records),F=(r.records||[]).map(d=>({value:d.id,label:d.modelName,useType:d.type,status:d.status}));return k(F),A(t||[]),z(d=>({...d,content:"ready"})),t||[]}}catch(r){console.error("[TableApiError] getTableList:",r)}},G=async()=>{const r=await ue();he(r||[])?E.current&&(clearTimeout(E.current),E.current=null):(E.current&&(clearTimeout(E.current),E.current=null),E.current=setTimeout(()=>{G()},5e3))};function he(r){if(!Array.isArray(r))return!0;for(const t of r)if(t.data){const F=t.data.find(d=>d.columnId==="status");if(F&&F.status===2)return!1}return!0}const Ce=O(()=>({label:"\u6570\u636E\u5E93\u8868\u683C",defaultActiveId:"model-table",model:null,views:[{label:"\u6A21\u578B",id:"model-table",type:"table",viewBehavior:"pagination",allowMultiSelect:!1,viewPageSize:10,columns:[{id:"modelName",title:"\u6A21\u578B\u540D\u79F0",type:"label"},{id:"modelProtocol",title:"\u6A21\u578B\u4F20\u8F93\u534F\u8BAE",type:"customized",component:r=>{var d;const{value:t}=r,F=(d=P.find(w=>w.value==t))==null?void 0:d.label;return o("span",{children:F})}},{id:"type",title:"\u4F7F\u7528\u7C7B\u578B",type:"customized",component:r=>{var d;const{value:t}=r,F=(d=Z.find(w=>w.value==t))==null?void 0:d.label;return o("span",{children:F})}},{id:"dec",title:"\u8BF4\u660E",type:"paragraph"},{id:"status",title:"\u72B6\u6001",type:"customized",component:o(Ue,{}),helpText:"\u5F53\u524D\u6A21\u578B\u72B6\u6001\u4E3A\u521D\u6B21\u65B0\u589E\u6821\u9A8C\u72B6\u6001\uFF0C\u82E5\u6A21\u578B\u4E0B\u7EBF\uFF0C\u6B64\u72B6\u6001\u4E0D\u4F1A\u4E3B\u52A8\u66F4\u65B0\uFF0C\u9700\u624B\u52A8\u6267\u884C\u6A21\u578B\u5220\u9664"},{id:"actions",title:"\u64CD\u4F5C",type:"customized",component:r=>{const{value:t,cell:F,row:d}=r,{disabled:w,label:N,status:$}=F;return $==2?o(ee,{title:"\u68C0\u6D4B\u4E2D\uFF0C\u8BF7\u7A0D\u540E",children:o(L,{mode:"text",label:N,disabled:!0})}):w?o(ee,{title:"\u89D2\u8272\u65E0\u6743\u9650\u64CD\u4F5C",children:o(L,{mode:"text",label:N,disabled:w})}):o(L,{mode:"text",label:N,onClick:()=>H(`table_action_${t}`,d,void 0)})}}],toolbar:[{type:"button",btnType:"primary",key:"add",label:"\u65B0\u5EFA",icon:o(Le,{})},...v?[{type:"customized",key:"test",render:()=>o(L,{loading:e,mode:"primary",label:"\u6A21\u578B\u72B6\u6001\u68C0\u6D4B",onClick:()=>{H("toolbar_test")}})},{type:"button",btnType:"primary",key:"replace",label:"\u6A21\u578B\u66FF\u6362"}]:[]]}]}),[f,Z,P,e,v]),Me=()=>V("div",{className:"flex flex-col items-center justify-center h-full",children:[o("div",{className:"text-xl font-semibold mb-3",style:{color:"#374151"},children:o("img",{src:Se,width:120})}),o("div",{className:"text-base mb-6",style:{color:"#6b7280"},children:"\u6682\u65E0\u6570\u636E\uFF0C\u8BF7\u5148\u65B0\u5EFA\u6A21\u578B"}),o("div",{className:"flex gap-3",children:o(L,{mode:"primary",label:"\u65B0\u5EFA\u6A21\u578B",onClick:()=>{q("\u65B0\u5EFA"),T(!0)}})})]});async function H(r,t,F){var d,w,N,$;switch(console.log("[adopter] mergedEventsEmit",r,t,F),r){case"toolbar_add":{q("\u65B0\u5EFA"),T(!0);break}case"toolbar_test":{a(!0),await Ee()&&(a(!1),await G(),j.success("\u6A21\u578B\u68C0\u6D4B\u4E2D\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85\u72B6\u6001\u66F4\u65B0\uFF01"));break}case"toolbar_replace":{l(!0);break}case"table_action_delete":{try{const C=t.data.find(b=>b.columnId=="modelName").value;if(await Be(C)>0)le({title:"\u5220\u9664\u6A21\u578B",content:o("div",{style:{marginRight:"20px"},children:"\u5F53\u524D\u6A21\u578B\u5728\u7CFB\u7EDF\u5185\u5DF2\u88AB\u914D\u7F6E\u4F7F\u7528\uFF0C\u5220\u9664\u53EF\u80FD\u5F71\u54CD\u6587\u6863\u89E3\u6790\u3001\u95EE\u7B54\u3001\u591A\u6A21\u6001\u80FD\u529B\u4F7F\u7528\u7B49\uFF0C\u8BF7\u60A8\u5148\u4F7F\u7528\u201C\u6A21\u578B\u4E00\u952E\u66FF\u6362\u201D\u80FD\u529B\u5C06\u8BE5\u6A21\u578B\u66FF\u6362\u4E3A\u540C\u7C7B\u578B\u6A21\u578B\uFF0C\u518D\u5220\u9664\u6A21\u578B"}),okText:"\u786E\u8BA4",cancelText:"\u53D6\u6D88"});else{const b=t.data.find(M=>M.columnId=="modelName").value;le({title:"\u786E\u8BA4\u5220\u9664\uFF1F",content:`\u786E\u5B9A\u8981\u5220\u9664\u6A21\u578B \u201C${b}\u201D \u5417\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002`,okText:"\u5220\u9664",cancelText:"\u53D6\u6D88",async onOk(){await me(t.id)&&(c!=null&&c.current)&&(c==null||c.current.appFn.removeItem(t.id),j.success("\u5220\u9664\u6210\u529F"))}})}}catch(C){console.error("\u5220\u9664\u8868\u6570\u636E\u5931\u8D25",C)}break}case"table_action_edit":{q("\u7F16\u8F91"),T(!0),U(t);break}case"form_submitted_add":{try{const C=t.fields.reduce((b,M)=>(b[M.name]=M.value,b),{}),D=await pe({...C});if(D){let b=J.find(y=>y.status==D.status);const M={id:D.id,data:[...(Object.keys(D)||[]).map(y=>({columnId:y,value:D[y],...(y=="modelProtocol"||y=="type")&&{type:"customized"},...y=="status"&&{...b,type:"customized",errorMsg:D.errorMsg}})),{columnId:"actions",value:"edit",label:"\u7F16\u8F91",type:"action"},{columnId:"actions",value:"auth",label:"\u6388\u6743",type:"action"},{columnId:"actions",value:"delete",label:"\u5220\u9664",type:"action"}]};(w=(d=c==null?void 0:c.current)==null?void 0:d.appFn)==null||w.addItem(M,{animate:!0,position:"start"}),j.success("\u6A21\u578B\u65B0\u589E\u6210\u529F\uFF01")}}catch(C){console.error("\u4FDD\u5B58\u5931\u8D25\uFF01",C)}finally{Y()}break}case"form_submitted_edit":{try{const C=t.fields.reduce((b,M)=>(b[M.name]=M.value,b),{}),D=await fe({...C,id:I.id});if(D){let b=J.find(y=>y.status==D.status);const M={...I,data:I.data.map(y=>{if(D[y.columnId]!==null&&D[y.columnId]!==void 0){if(y.columnId=="status")return{...y,...b};y.value=D[y.columnId]}return y})};($=(N=c==null?void 0:c.current)==null?void 0:N.appFn)==null||$.updateItem(M,I==null?void 0:I.id),j.success("\u6A21\u578B\u7F16\u8F91\u6210\u529F\uFF01")}}catch(C){console.error("\u4FDD\u5B58\u5931\u8D25\uFF01",C)}finally{Y()}break}case"replace_model":{await ue(),l(!1);break}case"close_model":{l(!1);break}default:typeof s.eventsEmit=="function"&&s.eventsEmit(r,t);break}}const Y=()=>{T(!1),U(void 0)};return V(ve,{title:"\u6A21\u578B\u7BA1\u7406",children:[o(ne,{dataSource:f,ref:c,eventsEmit:H,status:R,CustomComponents:{EmptyData:Me,...m},styles:{theme:{...se,colors:{...se.colors,tableFirstColumnBg:"#ffffff",tableLastColumnBg:"#ffffff",paginationBackground:"#ffffff",subTableBackground:"#F5F5F5",tableHeaderBg:"#F5F5F5"}},mode:"light"},...Ce}),o(Te,{drawerTitle:W,drawerVisible:x,handleDrawerClose:Y,modelInfo:I,modelUseTypeOpt:Z,modelProtocolsOpt:P,eventsEmit:H}),o(Ve,{modelVisible:u,options:g,eventsEmit:H,replaceModel:ge})]})}export{Qe as default};
package/package.json CHANGED
@@ -3,11 +3,15 @@
3
3
  "license": "MIT",
4
4
  "style": "assets/style.css",
5
5
  "private": false,
6
- "version": "2.1.34",
6
+ "version": "2.1.36",
7
7
  "author": "hanfeng_Zhang",
8
8
  "type": "module",
9
9
  "main": "index.js",
10
10
  "types": "index.d.ts",
11
+ "scripts": {
12
+ "test": "yarn link",
13
+ "disconnect": "yarn unlink"
14
+ },
11
15
  "peerDependencies": {
12
16
  "react": ">=18",
13
17
  "react-dom": ">=18"
@@ -65,9 +69,5 @@
65
69
  },
66
70
  "./style.css": "./assets/style.css",
67
71
  "./assets/style.css": "./assets/style.css"
68
- },
69
- "scripts": {
70
- "test": "yarn link",
71
- "disconnect": "yarn unlink"
72
72
  }
73
- }
73
+ }
package/sensitive.js CHANGED
@@ -1 +1 @@
1
- import{jsx as c,jsxs as A}from"react/jsx-runtime";import{useState as E,useRef as z,useEffect as N,useMemo as _}from"react";import{O as P}from"./assets/index-BqE1gm_T.js";import{N as T,J as L}from"./assets/index-DD8xyayB.js";import{a as O,b as h,I as W}from"./assets/index-8h59dJlj.js";import{s as F,M as I}from"./assets/index-DoUk2Ei_.js";/* empty css */import{P as j}from"./assets/plus-CnVxGdOo.js";import"react-dom";const q=["10014"],U=({url:D,token:B,role:m})=>{const i=O.create({baseURL:D,timeout:1e6});return i.interceptors.request.use(e=>{let t=B;if(!t&&!["user/login","user/kaptcha","user/regist"].some(a=>e.url.includes(a))){window.location.pathname="/login";return}return e.headers.Authorization=t||"",e.headers.userName=m==="\u672A\u767B\u5F55\u7528\u6237"?"":m,e}),i.interceptors.response.use(e=>{const t=["user/kaptcha"],u=e.data;if(t.some(d=>e.config.url&&e.config.url.includes(d))||u.size&&u.type)return u;const{success:a,errorMsg:r,errorCode:o}=u;return q.includes(o)||a?u:(F.error(r||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5"),!1)},e=>{var t,u,a,r,o,d,y,f,g,C;e.message!=="canceled"&&((((u=(t=e==null?void 0:e.response)==null?void 0:t.data)==null?void 0:u.errorCode)==="30013"||((r=(a=e==null?void 0:e.response)==null?void 0:a.data)==null?void 0:r.errorCode)==="30023")&&F.error((((o=e==null?void 0:e.response)==null?void 0:o.data)||{}).errorMsg||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5"),((d=e==null?void 0:e.response)==null?void 0:d.status)===401&&(console.log("Error url:",(y=e==null?void 0:e.request)==null?void 0:y.responseURL),F.error((((f=e==null?void 0:e.response)==null?void 0:f.data)||{}).errorMsg||"\u6CA1\u6709\u8DB3\u591F\u6743\u9650")),console.log("Error occurs",e),(((g=e==null?void 0:e.response)==null?void 0:g.data)||{}).errorMsg!="\u672A\u8BBE\u7F6E\u9ED8\u8BA4\u914D\u7F6E\uFF01"&&F.error((((C=e==null?void 0:e.response)==null?void 0:C.data)||{}).errorMsg||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5"))}),{getLibraryList:async e=>{try{const t=await i.get(`/library?${new URLSearchParams(e).toString()}`),{success:u,data:a}=t;return u?a:!1}catch(t){return console.log("e",t),!1}},createLibrary:async e=>{try{const t=await i.post("/library",e),{success:u,data:a}=t;return u?a:!1}catch(t){return console.log("e",t),!1}},deleteLibrary:async e=>{try{const t=await i.delete(`/library/${e}`),{success:u,data:a}=t;return u?a:!1}catch(t){return console.log("e",t),!1}}}},{confirm:$}=I,V={pageNo:1,pageSize:999},ee=({url:D,token:B,role:m,eventsEmit:i,CustomComponents:v})=>{const[w,b]=E({container:"ready",content:"ready"}),e=z(null),[t,u]=E(),[a]=h.useForm(),[r,o]=E(!1),{getLibraryList:d,deleteLibrary:y,createLibrary:f}=U({url:D,token:B,role:m});N(()=>{b(s=>({...s,content:"loading"})),g()},[]);const g=async()=>{try{const s=await d({...V});if(s){const n=C(s.records);u(n||[]),b(l=>({...l,content:"ready"}))}}catch(s){console.log("[DatabaseApiError] getSensitiveList:",s)}},C=s=>(s||[]).map(n=>({id:n.id,data:[{columnId:"name",value:n.name,type:"label"},{columnId:"sensitiveWords",value:n.words,type:"tag"},{columnId:"createDate",value:n.gmtCreate,type:"date"},{columnId:"count",value:n.count,type:"text"},{columnId:"actions",value:"edit",label:"\u7F16\u8F91",type:"action"},{columnId:"actions",value:"delete",label:"\u5220\u9664",type:"action"}]})),x=_(()=>({label:"\u654F\u611F\u8BCD\u914D\u7F6E",model:null,defaultActiveId:"sensitive-table",views:[{id:"sensitive-table",label:"\u654F\u611F\u8BCD\u5E93\u5217\u8868",type:"table",viewBehavior:"pagination",allowMultiSelect:!1,viewPageSize:10,columns:[{title:"\u540D\u79F0",id:"name",type:"label"},{title:"\u654F\u611F\u8BCD",id:"sensitiveWords",type:"tag"},{title:"\u521B\u5EFA\u65E5\u671F",id:"createDate",type:"date"},{title:"\u6570\u91CF",id:"count",type:"text"},{title:"\u64CD\u4F5C",id:"actions",type:"action"}],toolbar:[{type:"button",key:"create",label:"\u65B0\u5EFA\u654F\u611F\u8BCD\u5E93",btnType:"primary",icon:c(j,{size:16})},{type:"fuzzy_search",key:"search",label:"\u8BF7\u8F93\u5165\u5185\u5BB9",searchKeys:["name","sensitiveWords"],position:"right"}]}]}),[t]),S=async()=>{var s,n;try{const l=await a.validateFields();if(l){console.log("===val",l);const p=await f({...l,words:[]});if(p&&(e!=null&&e.current)){const M={id:p,data:[{columnId:"name",value:l.name,type:"label"},{columnId:"sensitiveWords",value:[],type:"tag"},{columnId:"createDate",value:new Date().toLocaleString("zh-CN",{year:"2-digit",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).replace(/\//g,"-"),type:"date"},{columnId:"count",value:0,type:"text"},{columnId:"actions",value:"edit",label:"\u7F16\u8F91",type:"action"},{columnId:"actions",value:"delete",label:"\u5220\u9664",type:"action"}]};(n=(s=e==null?void 0:e.current)==null?void 0:s.appFn)==null||n.addItem(M,{animate:!0,position:"start"}),F.success("\u65B0\u589E\u654F\u611F\u8BCD\u6210\u529F!")}}}catch{console.error("\u65B0\u589E\u654F\u611F\u8BCD\u5931\u8D25!")}finally{o(!1),a.resetFields()}};async function k(s,n,l){switch(console.log("[SensitiveView] \u4E8B\u4EF6\u89E6\u53D1:",s,n),s){case"toolbar_create":o(!0);break;case"table_action_delete":{try{$({title:"\u786E\u8BA4\u5220\u9664\u654F\u611F\u8BCD\u5E93\uFF1F",content:"\u5220\u9664\u540E\uFF0C\u8BE5\u654F\u611F\u8BCD\u5E93\u5C06\u65E0\u6CD5\u6062\u590D",okText:"\u5220\u9664",cancelText:"\u53D6\u6D88",async onOk(){await y(n.id)&&(e!=null&&e.current)&&(console.log("=====",e==null?void 0:e.current.appFn),e==null||e.current.appFn.removeItem(n.id),F.success("\u5220\u9664\u6210\u529F"))},onCancel(){console.log("Cancel")}})}catch(p){console.error("\u5220\u9664\u654F\u611F\u8BCD\u5E93\u5931\u8D25",p)}break}default:typeof i=="function"&&i(s,n);break}}return A(T,{title:"\u654F\u611F\u8BCD\u5E93\u7BA1\u7406",children:[c(P,{dataSource:t,ref:e,eventsEmit:k,status:w,CustomComponents:{...v},...x}),c(I,{title:"\u65B0\u5EFA\u654F\u611F\u8BCD\u5E93",open:r,width:520,destroyOnHidden:!0,onCancel:()=>{o(!1),a.resetFields()},footer:A("div",{className:"w-full flex flex-row",style:{justifyContent:"end",gap:"10px"},children:[c(L,{mode:"default",label:"\u53D6\u6D88",onClick:()=>{o(!1),a.resetFields()}}),c(L,{mode:"primary",label:"\u786E\u8BA4",onClick:S})]}),children:c(h,{form:a,children:c(h.Item,{label:null,name:"name",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u654F\u611F\u8BCD\u5E93\u540D\u79F0!"}],children:c(W,{placeholder:"\u8BF7\u8F93\u5165"})})})})]})};export{ee as default};
1
+ import{jsx as c,jsxs as A}from"react/jsx-runtime";import{useState as E,useRef as z,useEffect as N,useMemo as _}from"react";import{O as P}from"./assets/index-w1SriKuR.js";import{N as T,J as L}from"./assets/index-CtPe9ln8.js";import{a as O,b as h,I as W}from"./assets/index-8h59dJlj.js";import{s as F,M as I}from"./assets/index-DoUk2Ei_.js";/* empty css */import{P as j}from"./assets/plus-CnVxGdOo.js";import"react-dom";const q=["10014"],U=({url:D,token:B,role:m})=>{const i=O.create({baseURL:D,timeout:1e6});return i.interceptors.request.use(e=>{let t=B;if(!t&&!["user/login","user/kaptcha","user/regist"].some(a=>e.url.includes(a))){window.location.pathname="/login";return}return e.headers.Authorization=t||"",e.headers.userName=m==="\u672A\u767B\u5F55\u7528\u6237"?"":m,e}),i.interceptors.response.use(e=>{const t=["user/kaptcha"],u=e.data;if(t.some(d=>e.config.url&&e.config.url.includes(d))||u.size&&u.type)return u;const{success:a,errorMsg:r,errorCode:o}=u;return q.includes(o)||a?u:(F.error(r||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5"),!1)},e=>{var t,u,a,r,o,d,y,f,g,C;e.message!=="canceled"&&((((u=(t=e==null?void 0:e.response)==null?void 0:t.data)==null?void 0:u.errorCode)==="30013"||((r=(a=e==null?void 0:e.response)==null?void 0:a.data)==null?void 0:r.errorCode)==="30023")&&F.error((((o=e==null?void 0:e.response)==null?void 0:o.data)||{}).errorMsg||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5"),((d=e==null?void 0:e.response)==null?void 0:d.status)===401&&(console.log("Error url:",(y=e==null?void 0:e.request)==null?void 0:y.responseURL),F.error((((f=e==null?void 0:e.response)==null?void 0:f.data)||{}).errorMsg||"\u6CA1\u6709\u8DB3\u591F\u6743\u9650")),console.log("Error occurs",e),(((g=e==null?void 0:e.response)==null?void 0:g.data)||{}).errorMsg!="\u672A\u8BBE\u7F6E\u9ED8\u8BA4\u914D\u7F6E\uFF01"&&F.error((((C=e==null?void 0:e.response)==null?void 0:C.data)||{}).errorMsg||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5"))}),{getLibraryList:async e=>{try{const t=await i.get(`/library?${new URLSearchParams(e).toString()}`),{success:u,data:a}=t;return u?a:!1}catch(t){return console.log("e",t),!1}},createLibrary:async e=>{try{const t=await i.post("/library",e),{success:u,data:a}=t;return u?a:!1}catch(t){return console.log("e",t),!1}},deleteLibrary:async e=>{try{const t=await i.delete(`/library/${e}`),{success:u,data:a}=t;return u?a:!1}catch(t){return console.log("e",t),!1}}}},{confirm:$}=I,V={pageNo:1,pageSize:999},ee=({url:D,token:B,role:m,eventsEmit:i,CustomComponents:v})=>{const[w,b]=E({container:"ready",content:"ready"}),e=z(null),[t,u]=E(),[a]=h.useForm(),[r,o]=E(!1),{getLibraryList:d,deleteLibrary:y,createLibrary:f}=U({url:D,token:B,role:m});N(()=>{b(s=>({...s,content:"loading"})),g()},[]);const g=async()=>{try{const s=await d({...V});if(s){const n=C(s.records);u(n||[]),b(l=>({...l,content:"ready"}))}}catch(s){console.log("[DatabaseApiError] getSensitiveList:",s)}},C=s=>(s||[]).map(n=>({id:n.id,data:[{columnId:"name",value:n.name,type:"label"},{columnId:"sensitiveWords",value:n.words,type:"tag"},{columnId:"createDate",value:n.gmtCreate,type:"date"},{columnId:"count",value:n.count,type:"text"},{columnId:"actions",value:"edit",label:"\u7F16\u8F91",type:"action"},{columnId:"actions",value:"delete",label:"\u5220\u9664",type:"action"}]})),x=_(()=>({label:"\u654F\u611F\u8BCD\u914D\u7F6E",model:null,defaultActiveId:"sensitive-table",views:[{id:"sensitive-table",label:"\u654F\u611F\u8BCD\u5E93\u5217\u8868",type:"table",viewBehavior:"pagination",allowMultiSelect:!1,viewPageSize:10,columns:[{title:"\u540D\u79F0",id:"name",type:"label"},{title:"\u654F\u611F\u8BCD",id:"sensitiveWords",type:"tag"},{title:"\u521B\u5EFA\u65E5\u671F",id:"createDate",type:"date"},{title:"\u6570\u91CF",id:"count",type:"text"},{title:"\u64CD\u4F5C",id:"actions",type:"action"}],toolbar:[{type:"button",key:"create",label:"\u65B0\u5EFA\u654F\u611F\u8BCD\u5E93",btnType:"primary",icon:c(j,{size:16})},{type:"fuzzy_search",key:"search",label:"\u8BF7\u8F93\u5165\u5185\u5BB9",searchKeys:["name","sensitiveWords"],position:"right"}]}]}),[t]),S=async()=>{var s,n;try{const l=await a.validateFields();if(l){console.log("===val",l);const p=await f({...l,words:[]});if(p&&(e!=null&&e.current)){const M={id:p,data:[{columnId:"name",value:l.name,type:"label"},{columnId:"sensitiveWords",value:[],type:"tag"},{columnId:"createDate",value:new Date().toLocaleString("zh-CN",{year:"2-digit",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).replace(/\//g,"-"),type:"date"},{columnId:"count",value:0,type:"text"},{columnId:"actions",value:"edit",label:"\u7F16\u8F91",type:"action"},{columnId:"actions",value:"delete",label:"\u5220\u9664",type:"action"}]};(n=(s=e==null?void 0:e.current)==null?void 0:s.appFn)==null||n.addItem(M,{animate:!0,position:"start"}),F.success("\u65B0\u589E\u654F\u611F\u8BCD\u6210\u529F!")}}}catch{console.error("\u65B0\u589E\u654F\u611F\u8BCD\u5931\u8D25!")}finally{o(!1),a.resetFields()}};async function k(s,n,l){switch(console.log("[SensitiveView] \u4E8B\u4EF6\u89E6\u53D1:",s,n),s){case"toolbar_create":o(!0);break;case"table_action_delete":{try{$({title:"\u786E\u8BA4\u5220\u9664\u654F\u611F\u8BCD\u5E93\uFF1F",content:"\u5220\u9664\u540E\uFF0C\u8BE5\u654F\u611F\u8BCD\u5E93\u5C06\u65E0\u6CD5\u6062\u590D",okText:"\u5220\u9664",cancelText:"\u53D6\u6D88",async onOk(){await y(n.id)&&(e!=null&&e.current)&&(console.log("=====",e==null?void 0:e.current.appFn),e==null||e.current.appFn.removeItem(n.id),F.success("\u5220\u9664\u6210\u529F"))},onCancel(){console.log("Cancel")}})}catch(p){console.error("\u5220\u9664\u654F\u611F\u8BCD\u5E93\u5931\u8D25",p)}break}default:typeof i=="function"&&i(s,n);break}}return A(T,{title:"\u654F\u611F\u8BCD\u5E93\u7BA1\u7406",children:[c(P,{dataSource:t,ref:e,eventsEmit:k,status:w,CustomComponents:{...v},...x}),c(I,{title:"\u65B0\u5EFA\u654F\u611F\u8BCD\u5E93",open:r,width:520,destroyOnHidden:!0,onCancel:()=>{o(!1),a.resetFields()},footer:A("div",{className:"w-full flex flex-row",style:{justifyContent:"end",gap:"10px"},children:[c(L,{mode:"default",label:"\u53D6\u6D88",onClick:()=>{o(!1),a.resetFields()}}),c(L,{mode:"primary",label:"\u786E\u8BA4",onClick:S})]}),children:c(h,{form:a,children:c(h.Item,{label:null,name:"name",rules:[{required:!0,message:"\u8BF7\u8F93\u5165\u654F\u611F\u8BCD\u5E93\u540D\u79F0!"}],children:c(W,{placeholder:"\u8BF7\u8F93\u5165"})})})})]})};export{ee as default};
@@ -1 +1 @@
1
- import{G as d,B as f}from"./assets/GientechStreamReader-CwcCZLSJ.js";import"react/jsx-runtime";import"react";import"./assets/index-8h59dJlj.js";import"react-dom";import"./assets/index-WQa7_NYu.js";import"./assets/index-DD8xyayB.js";import"./assets/index-C6WKbL3A.js";import"./assets/index-CVis9Agw.js";import"./assets/x-CmbLQ9dc.js";export{d as GientechStreamReader,f as registerPDFWorker};
1
+ import{G as d,B as f}from"./assets/GientechStreamReader-C8rYtUxB.js";import"react/jsx-runtime";import"react";import"./assets/index-8h59dJlj.js";import"react-dom";import"./assets/index-C9ax6WsW.js";import"./assets/index-CtPe9ln8.js";import"./assets/index-C6WKbL3A.js";import"./assets/index-CVis9Agw.js";import"./assets/x-CmbLQ9dc.js";export{d as GientechStreamReader,f as registerPDFWorker};