@gientech/modual 1.8.9 → 1.9.0
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/README.md +643 -643
- package/assets/GientechStreamReader-DqJjNXCO.js +449 -0
- package/assets/{mysql.svg → MySQL.svg} +14 -14
- package/assets/database.svg +11 -11
- package/assets/database_add.svg +53 -53
- package/assets/database_connect.svg +66 -66
- package/assets/database_upload.svg +29 -29
- package/assets/databse.svg +6 -6
- package/assets/defaultWeLogo.svg +14 -14
- package/assets/graph.svg +4 -4
- package/assets/{index-CPOAXITM.js → index-BKe5FgcC.js} +1 -1
- package/assets/index-BO-w4FPz.js +1088 -0
- package/assets/index-CIwaLPGb.js +6 -0
- package/assets/{index-DnJqVq9Q.js → index-D72cKELw.js} +1 -1
- package/assets/index-DdVFXD_y.js +6 -0
- package/assets/{index-CuySCBtZ.js → index-DwoTKC3G.js} +1 -1
- package/assets/{index-CCjG4bD0.js → index-FiuM-Chj.js} +1 -1
- package/assets/{index-BbHMAb8g.js → index-g-SUxfJH.js} +1 -1
- package/assets/{index-Wjs4Vb6x.js → index-j0kQJd0a.js} +1 -1
- package/assets/{index-fhKUis2J.js → index-x8IlxRuv.js} +2 -2
- package/assets/knowledge.svg +4 -4
- package/assets/{plus-Dmpl3gd8.js → plus-V9zUoSq6.js} +1 -1
- package/assets/sensitive.svg +5 -5
- package/assets/{style-CNIDlcUL.js → style-CGmZ5osp.js} +1 -1
- package/assets/style.css +1 -1
- package/assets/{x-BjRa5XLp.js → x-CnaaLGJF.js} +1 -1
- package/assistantConfig.js +1 -1
- package/chat.js +2 -2
- package/database.js +2 -2
- package/databaseId.js +1 -1
- package/databaseTable.js +1 -1
- package/index.js +1 -1
- package/modelManage.js +1 -1
- package/package.json +6 -6
- package/sensitive.js +1 -1
- package/streamFilesReader.js +1 -1
- package/worker/pdf.worker.min.js +21 -21
- package/assets/GientechStreamReader-BnMJn-0g.js +0 -449
- package/assets/index-3eb9O5m7.js +0 -1393
- package/assets/index-DKBFsnpa.js +0 -11
- package/assets/index-Dkwp9YpO.js +0 -1
package/assistantConfig.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"react/jsx-runtime";import"react";import{C as l}from"./assets/index-
|
|
1
|
+
import"react/jsx-runtime";import"react";import{C as l}from"./assets/index-FiuM-Chj.js";import"./assets/style-CGmZ5osp.js";import"./assets/index-g-SUxfJH.js";import"./assets/x-CnaaLGJF.js";import"./assets/plus-V9zUoSq6.js";import"./assets/index-j0kQJd0a.js";import"react-dom";export{l as default};
|
package/chat.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{jsx as Z,jsxs as et,Fragment as hp}from"react/jsx-runtime";import*as C from"react";import ke,{useRef as tt,useEffect as vt,Component as AC,forwardRef as Ai,createElement as Jl,createContext as fs,version as $H,useMemo as Vt,useContext as or,useState as at,Children as aI,useCallback as o3,useImperativeHandle as Sc,useLayoutEffect as sI,cloneElement as lI,isValidElement as cI,PureComponent as AH}from"react";import{a as Ji,g as OC,au as uI,l as $c,an as dI,aN as fI,B as So,aB as OH,f as sr,u as hI,a5 as pI,aF as NC,H as NH,aE as MH,ad as ql,J as r2,y as gI,A as Yi,bT as o2,T as MC,m as mI,r as vI,k as xo,K as i2,b5 as DH,av as TH,ay as PH,aw as IH,bU as FH,ac as xd,G as RH,bV as La,bW as eo,_ as Fi,bz as yI,bA as bI,aW as xI,L as Er,bN as Lr,aV as EI,E as BH,aJ as wI,bh as CI,bX as i3,bC as _H,bY as jH,p as kI,bu as LH,bE as zH,ap as HH,o as a3,at as s3,aZ as WH,bZ as VH,aP as SI,b as Ur,I as Wu,i as DC,F as Ra,aK as pp,b_ as $I,bR as GH,h as qH,b$ as sm}from"./assets/index-
|
|
1
|
+
import{jsx as Z,jsxs as et,Fragment as hp}from"react/jsx-runtime";import*as C from"react";import ke,{useRef as tt,useEffect as vt,Component as AC,forwardRef as Ai,createElement as Jl,createContext as fs,version as $H,useMemo as Vt,useContext as or,useState as at,Children as aI,useCallback as o3,useImperativeHandle as Sc,useLayoutEffect as sI,cloneElement as lI,isValidElement as cI,PureComponent as AH}from"react";import{a as Ji,g as OC,au as uI,l as $c,an as dI,aN as fI,B as So,aB as OH,f as sr,u as hI,a5 as pI,aF as NC,H as NH,aE as MH,ad as ql,J as r2,y as gI,A as Yi,bT as o2,T as MC,m as mI,r as vI,k as xo,K as i2,b5 as DH,av as TH,ay as PH,aw as IH,bU as FH,ac as xd,G as RH,bV as La,bW as eo,_ as Fi,bz as yI,bA as bI,aW as xI,L as Er,bN as Lr,aV as EI,E as BH,aJ as wI,bh as CI,bX as i3,bC as _H,bY as jH,p as kI,bu as LH,bE as zH,ap as HH,o as a3,at as s3,aZ as WH,bZ as VH,aP as SI,b as Ur,I as Wu,i as DC,F as Ra,aK as pp,b_ as $I,bR as GH,h as qH,b$ as sm}from"./assets/index-g-SUxfJH.js";import{I as ar,d as l3,c as AI,T as UH,e as YH}from"./assets/index-x8IlxRuv.js";import*as XH from"react-dom";import c3,{flushSync as Vu,createPortal as OI,unstable_batchedUpdates as KH}from"react-dom";import{D as ZH,T as QH,F as JH,q as u3}from"./assets/index-BO-w4FPz.js";import{u as pa}from"./assets/index-CpW6Dhpp.js";/* empty css */import{A as eW,i as tW,s as rr,M as gp,S as Xd}from"./assets/style-CGmZ5osp.js";import{P as NI}from"./assets/plus-V9zUoSq6.js";import{S as a2}from"./assets/index-FiuM-Chj.js";import{X as mp}from"./assets/x-CnaaLGJF.js";import{g as d3,P as nW,a as MI}from"./assets/index-CIwaLPGb.js";import{C as rW,G as DI,c as oW,r as iW}from"./assets/GientechStreamReader-DqJjNXCO.js";import{B as oCe}from"./assets/GientechStreamReader-DqJjNXCO.js";import{P as aW}from"./assets/index-BKe5FgcC.js";import"./database.js";import"./databaseTable.js";import"./modelManage.js";import"./sensitive.js";import{D as sW}from"./assets/index-D72cKELw.js";import"./assets/index-j0kQJd0a.js";import"./assets/index-DwoTKC3G.js";import"./assets/index-DdVFXD_y.js";/**
|
|
2
2
|
* @license lucide-react v0.456.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -604,7 +604,7 @@ ${v.substring(Y)}`;y(J),requestAnimationFrame(()=>{U.selectionStart=U.selectionE
|
|
|
604
604
|
border-color: ${n.primary};
|
|
605
605
|
box-shadow: 0 0 0 2px ${n.primary}1A;
|
|
606
606
|
}
|
|
607
|
-
`};function tse({config:e,styles:t}){if(!e)return null;const n=JSON.parse(e.configJson),r=Vt(()=>{var o;return{...DC.colors,...(o=t==null?void 0:t.theme)==null?void 0:o.colors}},[t]);return et("div",{className:"w-[340px] rounded-xl p-4 animate-fade-in bg-white",children:[et("div",{className:"flex items-center mb-2",children:[Z("span",{className:"text-md font-bold truncate mr-2",style:{color:r.primary},children:n.config_name||"\u52A9\u624B\u914D\u7F6E"}),Z("span",{className:"text-xs truncate rounded px-2 py-0.5",style:{backgroundColor:`${r.primary}1A`,color:r.disabled},children:n.model_name})]}),Z("div",{className:"border-b my-2",style:{borderColor:r.border}}),et("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-gray-700 mb-2",style:{color:r.text},children:[et("div",{children:["\u4E0A\u4E0B\u6587\u6700\u5927\u8F6E\u6570\uFF1A",Z("span",{className:"font-semibold",children:n.max_round})]}),et("div",{children:["\u6700\u5927\u4EE4\u724C\u6570\uFF1A",Z("span",{className:"font-semibold",children:n.max_tokens})]}),et("div",{children:["\u6E29\u5EA6\uFF1A",Z("span",{className:"font-semibold",children:n.temperature})]}),et("div",{children:["\u53EC\u56DE\u6570\uFF1A",Z("span",{className:"font-semibold",children:n.top_k})]}),et("div",{children:["\u591A\u6837\u6027\uFF1A",Z("span",{className:"font-semibold",children:n.top_p})]}),et("div",{children:["\u76F8\u4F3C\u5EA6\u9608\u503C\uFF1A",Z("span",{className:"font-semibold",children:n.score_threshold})]})]}),et("div",{className:"mb-2",children:[Z("div",{className:"text-xs text-gray-400 mb-1",style:{color:r.disabled},children:"\u5173\u8054\u77E5\u8BC6\u5E93\uFF1A"}),Z("div",{className:"flex flex-wrap gap-1",children:n.knowledge_base_name?n.knowledge_base_name.split(";").map((o,i)=>Z("span",{className:"px-2 py-0.5 rounded-full text-xs",style:{backgroundColor:`${r.primary}1A`,color:r.primary},children:o},i)):Z("span",{className:"text-gray-300",style:{color:r.disabled},children:"\u65E0"})})]}),et("div",{className:"mb-2",children:[Z("div",{className:"text-xs text-gray-400 mb-1",style:{color:r.disabled},children:"\u5F00\u542F\u529F\u80FD:"}),et("div",{className:"flex flex-wrap gap-2 text-xs mt-2",children:[!!n.enabled_faq&&Z("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"FAQ"}),!!n.enabled_graph&&Z("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u56FE\u8C31"}),!!n.dependOnKb&&Z("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u5F3A\u77E5\u8BC6\u4F9D\u8D56"}),!!n.enabled_table_select&&Z("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u8868\u683C\u7B5B\u9009"}),!!n.enabled_rerank&&Z("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u7CBE\u6392\u6A21\u5F0F"}),!!n.need_trace_source&&Z("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u6EAF\u6E90"}),!!n.is_download&&Z("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u4E0B\u8F7D\u6EAF\u6E90"})]})]})]})}function nse(e,t=[],n=60){const[r,o]=at("");return vt(()=>{o("");let i=0;const a=setInterval(()=>{o(s=>i>=e.length?(clearInterval(a),s):(i++,e.slice(0,i)))},n);return()=>clearInterval(a)},[e,...t]),r}function rse(e){const{assistantList:t,eventsEmit:n,styles:r,selectedId:o,onSelectAssistant:i,productLogo:a}=e,[s,l]=at(1),[c,u]=at(!1),[d,f]=at(""),h=c||d.trim()?6:12,m=tt(),g=tt(!1),p=tt(null),v=tt(null),y=tt("");vt(()=>{o&&m.current!==o&&(n==null||n("conversation:new_assistant_change",{assistantId:o}),m.current=o)},[o,n]);const b=Vt(()=>pa(),[]);vt(()=>{var A;if((A=r==null?void 0:r.theme)!=null&&A.colors){const N=document.createElement("style");return N.innerHTML=ese(r.theme.colors,b),N.id=`g-welcome-styles-${b}`,document.head.appendChild(N),()=>{const M=document.getElementById(N.id);M&&M.remove()}}},[r,b]);const E=Vt(()=>t.find(A=>A.id===o),[t,o]),x=Vt(()=>JSON.parse((E==null?void 0:E.configJson)||"{}"),[E]),w=Vt(()=>{if(!d.trim())return t||[];const A=d.toLowerCase().trim();return(t||[]).filter(N=>{var D,P;const M=((D=N.name)==null?void 0:D.toLowerCase())||"";try{const R=((P=JSON.parse(N.configJson||"{}").config_name)==null?void 0:P.toLowerCase())||"";return M.includes(A)||R.includes(A)}catch{return M.includes(A)}})},[t,d]),k=Math.ceil(((w==null?void 0:w.length)||0)/h),S=(w==null?void 0:w.slice((s-1)*h,s*h))||[];vt(()=>{if(o&&o!==v.current){if(g.current&&p.current!==null){v.current=o;return}const A=d.trim()?w:t;if(A&&A.length>0){const N=A.findIndex(M=>M.id===o);if(N!==-1){const M=Math.floor(N/h)+1;l(M),v.current=o}}}},[o,t,w,h,d]),vt(()=>{if(d!==y.current){if(g.current&&p.current!==null){l(p.current),g.current=!1,p.current=null,y.current=d;return}if(v.current===o){y.current=d;return}g.current||(d.trim()&&(v.current=null),l(1)),y.current=d}},[d,o]),vt(()=>{k>0&&s>k&&l(k)},[k,s]);const O=x.prologue||"\u60A8\u597D\uFF0C\u6B22\u8FCE\u4F7F\u7528\u5C0F\u9CB8\u667A\u80FD\u95EE\u7B54",$=nse(O,[o],30);return et("div",{className:`flex flex-col relative items-center justify-center h-full w-full g-welcome-${b}`,children:[Z("img",{src:a||Qae,alt:"logo",className:"mb-4",style:{width:68,height:68}}),Z("div",{className:"text-3xl font-bold mb-2 g-welcome-title",children:$}),!o&&Z("div",{className:"flex mb-2 g-welcome-subtitle",children:"\u8BF7\u9009\u62E9\u4E00\u4E2A\u667A\u80FD\u52A9\u624B"}),et("div",{style:{maxWidth:"1200px"},className:`flex mt-8 flex-wrap gap-3
|
|
607
|
+
`};function tse({config:e,styles:t}){if(!e)return null;const n=JSON.parse(e.configJson),r=Vt(()=>{var o;return{...DC.colors,...(o=t==null?void 0:t.theme)==null?void 0:o.colors}},[t]);return et("div",{className:"w-[340px] rounded-xl p-4 animate-fade-in bg-white",children:[et("div",{className:"flex items-center mb-2",children:[Z("span",{className:"text-md font-bold truncate mr-2",style:{color:r.primary},children:n.config_name||"\u52A9\u624B\u914D\u7F6E"}),Z("span",{className:"text-xs truncate rounded px-2 py-0.5",style:{backgroundColor:`${r.primary}1A`,color:r.disabled},children:n.model_name})]}),Z("div",{className:"border-b my-2",style:{borderColor:r.border}}),et("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs text-gray-700 mb-2",style:{color:r.text},children:[et("div",{children:["\u4E0A\u4E0B\u6587\u6700\u5927\u8F6E\u6570\uFF1A",Z("span",{className:"font-semibold",children:n.max_round})]}),et("div",{children:["\u6700\u5927\u4EE4\u724C\u6570\uFF1A",Z("span",{className:"font-semibold",children:n.max_tokens})]}),et("div",{children:["\u6E29\u5EA6\uFF1A",Z("span",{className:"font-semibold",children:n.temperature})]}),et("div",{children:["\u53EC\u56DE\u6570\uFF1A",Z("span",{className:"font-semibold",children:n.top_k})]}),et("div",{children:["\u591A\u6837\u6027\uFF1A",Z("span",{className:"font-semibold",children:n.top_p})]}),et("div",{children:["\u76F8\u4F3C\u5EA6\u9608\u503C\uFF1A",Z("span",{className:"font-semibold",children:n.score_threshold})]})]}),et("div",{className:"mb-2",children:[Z("div",{className:"text-xs text-gray-400 mb-1",style:{color:r.disabled},children:"\u5173\u8054\u77E5\u8BC6\u5E93\uFF1A"}),Z("div",{className:"flex flex-wrap gap-1",children:n.knowledge_base_name?n.knowledge_base_name.split(";").map((o,i)=>Z("span",{className:"px-2 py-0.5 rounded-full text-xs",style:{backgroundColor:`${r.primary}1A`,color:r.primary},children:o},i)):Z("span",{className:"text-gray-300",style:{color:r.disabled},children:"\u65E0"})})]}),et("div",{className:"mb-2",children:[Z("div",{className:"text-xs text-gray-400 mb-1",style:{color:r.disabled},children:"\u5F00\u542F\u529F\u80FD:"}),et("div",{className:"flex flex-wrap gap-2 text-xs mt-2",children:[!!n.enabled_faq&&Z("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"FAQ"}),!!n.enabled_graph&&Z("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u56FE\u8C31"}),!!n.dependOnKb&&Z("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u5F3A\u77E5\u8BC6\u4F9D\u8D56"}),!!n.enabled_table_select&&Z("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u8868\u683C\u7B5B\u9009"}),!!n.enabled_rerank&&Z("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u7CBE\u6392\u6A21\u5F0F"}),!!n.need_trace_source&&Z("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u6EAF\u6E90"}),!!n.is_download&&Z("span",{className:"px-2 py-0.5 rounded",style:{backgroundColor:`${r.success}1A`,color:r.success},children:"\u4E0B\u8F7D\u6EAF\u6E90"})]})]})]})}function nse(e,t=[],n=60){const[r,o]=at("");return vt(()=>{o("");let i=0;const a=setInterval(()=>{o(s=>i>=e.length?(clearInterval(a),s):(i++,e.slice(0,i)))},n);return()=>clearInterval(a)},[e,...t]),r}function rse(e){const{assistantList:t,eventsEmit:n,styles:r,selectedId:o,onSelectAssistant:i,productLogo:a}=e,[s,l]=at(1),[c,u]=at(!1),[d,f]=at(""),h=c||d.trim()?6:12,m=tt(),g=tt(!1),p=tt(null),v=tt(null),y=tt("");vt(()=>{o&&m.current!==o&&(n==null||n("conversation:new_assistant_change",{assistantId:o}),m.current=o)},[o,n]);const b=Vt(()=>pa(),[]);vt(()=>{var A;if((A=r==null?void 0:r.theme)!=null&&A.colors){const N=document.createElement("style");return N.innerHTML=ese(r.theme.colors,b),N.id=`g-welcome-styles-${b}`,document.head.appendChild(N),()=>{const M=document.getElementById(N.id);M&&M.remove()}}},[r,b]);const E=Vt(()=>t.find(A=>A.id===o),[t,o]),x=Vt(()=>JSON.parse((E==null?void 0:E.configJson)||"{}"),[E]),w=Vt(()=>{if(!d.trim())return t||[];const A=d.toLowerCase().trim();return(t||[]).filter(N=>{var D,P;const M=((D=N.name)==null?void 0:D.toLowerCase())||"";try{const R=((P=JSON.parse(N.configJson||"{}").config_name)==null?void 0:P.toLowerCase())||"";return M.includes(A)||R.includes(A)}catch{return M.includes(A)}})},[t,d]),k=Math.ceil(((w==null?void 0:w.length)||0)/h),S=(w==null?void 0:w.slice((s-1)*h,s*h))||[];vt(()=>{if(o&&o!==v.current){if(g.current&&p.current!==null){v.current=o;return}const A=d.trim()?w:t;if(A&&A.length>0){const N=A.findIndex(M=>M.id===o);if(N!==-1){const M=Math.floor(N/h)+1;l(M),v.current=o}}}},[o,t,w,h,d]),vt(()=>{if(d!==y.current){if(g.current&&p.current!==null){l(p.current),g.current=!1,p.current=null,y.current=d;return}if(v.current===o){y.current=d;return}g.current||(d.trim()&&(v.current=null),l(1)),y.current=d}},[d,o]),vt(()=>{k>0&&s>k&&l(k)},[k,s]);const O=x.prologue||"\u60A8\u597D\uFF0C\u6B22\u8FCE\u4F7F\u7528\u5C0F\u9CB8\u667A\u80FD\u95EE\u7B54",$=nse(O,[o],30);return et("div",{className:`flex flex-col relative items-center justify-center h-full w-full g-welcome-${b}`,children:[Z("img",{src:a||Qae,alt:"logo",className:"mb-4",style:{width:68,height:68}}),Z("div",{className:"text-3xl font-bold mb-2 g-welcome-title",children:$}),!o&&Z("div",{className:"flex mb-2 g-welcome-subtitle",children:"\u8BF7\u9009\u62E9\u4E00\u4E2A\u667A\u80FD\u52A9\u624B"}),et("div",{style:{maxWidth:"1200px"},className:`flex mt-8 flex-wrap gap-3
|
|
608
608
|
max-w-[1200px] px-8 w-full mx-auto justify-center mb-4`,children:[c?Z("div",{className:"flex items-center gap-2 px-5 w-full",style:{flexBasis:"100%"},children:Z(Wu,{className:"g-welcome-search-input w-full",placeholder:"\u641C\u7D22\u52A9\u624B\u540D\u79F0",prefix:Z(a2,{size:16}),suffix:Z("button",{type:"button",onClick:()=>{u(!1),f("")},style:{background:"transparent",border:"none",cursor:"pointer"},children:Z(mp,{size:14})}),value:d,onChange:A=>f(A.target.value),autoFocus:!0})}):Z("button",{type:"button",className:"g-welcome-search-btn",onClick:()=>u(!0),children:Z(a2,{size:16})}),S&&S.length>0?Z(hp,{children:S.map(A=>{const N=o===A.id;let M=A.icon;try{const D=JSON.parse(A.configJson||"{}");M=M||D.icon||D.avatar||D.logo}catch{}return M=M||Jae,Z(MI,{content:()=>Z(tse,{config:t.find(D=>D.id===A.id),styles:r}),trigger:"hover",placement:"bottom",children:et("button",{type:"button",className:`g-welcome-btn px-3 cursor-pointer rounded-full border font-medium min-w-[160px] text-sm transition-all flex items-center gap-2 ${N?"active":""}`,onClick:()=>{i==null||i(A.id);const D=c||d.trim(),I=(D?t:d.trim()?w:t).findIndex(R=>R.id===A.id);if(I!==-1){const j=Math.floor(I/(D?12:h))+1;l(j),v.current=A.id,D&&(p.current=j,g.current=!0,setTimeout(()=>{f(""),u(!1)},100))}},title:A.name,children:[Z("span",{className:"icon-badge",children:Z("img",{src:M,alt:"icon",style:{width:16,height:16,borderRadius:4}})}),Z("span",{className:"truncate max-w-[180px]",children:A.name})]})},A.id)})}):Z("div",{className:"g-welcome-subtitle",children:"\u6682\u65E0\u53EF\u7528\u52A9\u624B"})]}),k>1&&et("div",{className:"flex items-center gap-2",children:[Z("button",{type:"button",className:"g-welcome-pagination-btn",onClick:()=>l(A=>Math.max(1,A-1)),disabled:s===1,children:Z(rW,{size:16})}),Z("div",{className:"flex items-center gap-1",children:(()=>{const A=[];if(k<=7)for(let M=1;M<=k;M++)A.push(M);else if(A.push(1),s<=4){for(let M=2;M<=5;M++)A.push(M);A.push("..."),A.push(k)}else if(s>=k-3){A.push("...");for(let M=k-4;M<=k;M++)A.push(M)}else{A.push("...");for(let M=s-1;M<=s+1;M++)A.push(M);A.push("..."),A.push(k)}return A.map((M,D)=>{if(M==="...")return Z("span",{className:"g-welcome-pagination-text px-1",children:"..."},`ellipsis-${D}`);const P=M;return Z("button",{type:"button",className:`g-welcome-pagination-btn ${s===P?"active":""}`,onClick:()=>l(P),children:P},P)})})()}),Z("button",{type:"button",className:"g-welcome-pagination-btn",onClick:()=>l(A=>Math.min(k,A+1)),disabled:s===k,children:Z(AI,{size:16})})]})]})}async function ose(e,t){const n=e.getReader();let r;for(;!(r=await n.read()).done;)t(r.value)}function ise(e){let t,n,r,o=!1;return function(a){t===void 0?(t=a,n=0,r=-1):t=sse(t,a);const s=t.length;let l=0;for(;n<s;){o&&(t[n]===10&&(l=++n),o=!1);let c=-1;for(;n<s&&c===-1;++n)switch(t[n]){case 58:r===-1&&(r=n-l);break;case 13:o=!0;case 10:c=n;break}if(c===-1)break;e(t.subarray(l,c),r),l=n,r=-1}l===s?t=void 0:l!==0&&(t=t.subarray(l),n-=l)}}function ase(e,t,n){let r=k6();const o=new TextDecoder;return function(a,s){if(a.length===0)n==null||n(r),r=k6();else if(s>0){const l=o.decode(a.subarray(0,s)),c=s+(a[s+1]===32?2:1),u=o.decode(a.subarray(c));switch(l){case"data":r.data=r.data?r.data+`
|
|
609
609
|
`+u:u;break;case"event":r.event=u;break;case"id":e(r.id=u);break;case"retry":const d=parseInt(u,10);isNaN(d)||t(r.retry=d);break}}}}function sse(e,t){const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function k6(){return{data:"",event:"",id:"",retry:void 0}}var lse=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n};const Mw="text/event-stream",cse=1e3,S6="last-event-id";function use(e,t){var{signal:n,headers:r,onopen:o,onmessage:i,onclose:a,onerror:s,openWhenHidden:l,fetch:c}=t,u=lse(t,["signal","headers","onopen","onmessage","onclose","onerror","openWhenHidden","fetch"]);return new Promise((d,f)=>{const h=Object.assign({},r);h.accept||(h.accept=Mw);let m;function g(){m.abort(),document.hidden||x()}l||document.addEventListener("visibilitychange",g);let p=cse,v=0;function y(){document.removeEventListener("visibilitychange",g),window.clearTimeout(v),m.abort()}n==null||n.addEventListener("abort",()=>{y(),d()});const b=c??window.fetch,E=o??dse;async function x(){var w;m=new AbortController;try{const k=await b(e,Object.assign(Object.assign({},u),{headers:h,signal:m.signal}));await E(k),await ose(k.body,ise(ase(S=>{S?h[S6]=S:delete h[S6]},S=>{p=S},i))),a==null||a(),y(),d()}catch(k){if(!m.signal.aborted)try{const S=(w=s==null?void 0:s(k))!==null&&w!==void 0?w:p;window.clearTimeout(v),v=window.setTimeout(x,S)}catch(S){y(),f(S)}}}x()})}function dse(e){const t=e.headers.get("content-type");if(!(t!=null&&t.startsWith(Mw)))throw new Error(`Expected content-type to be ${Mw}, Actual: ${t}`)}class rv extends Error{}let Po=null,ia=null;const fse=({baseUrl:e,token:t,CSRFToken:n,setChatData:r,activeSessionId:o,setAppStatus:i,setConversationList:a})=>{const s=p=>{if(!p)return!1;if(typeof p=="string"){const v=p.trim();return v!==""&&v!=="[]"&&v!=="null"}return!0},l=({content:p,status:v,respTime:y,filePaths:b,reference:E,webReference:x,graphReference:w,databaseReference:k,llmType:S,resultType:O,queryId:$,tokens:A})=>{r(N=>{var L;if(!N[0])return N;const M=N[0],D=M.messages||[],P=D.length-1;if(P<0)return N;const I=D[P];if(I.istype!=="ai")return N;let R=D.slice();if(b!=null&&b.length){const _=D.length-2;if(_>=0&&((L=D[_])==null?void 0:L.istype)==="user"){const F={...D[_],filePaths:b};R[_]=F}}const j=w!==void 0&&s(w)?w:I.graphReference;v===2&&w!==void 0&&console.log("[AichatUseController] reset_chat status=2 \u65F6\u7684 graphReference:",{graphReference:w,isValid:s(w),lastMessageGraphReference:I.graphReference,finalGraphReference:j});const z={...I,content:(I.content||"")+p,status:v,respTime:y,filePaths:b,reference:E,webReference:x,graphReference:j,databaseReference:k??I.databaseReference,resultType:O,llmType:S,tokens:A,queryId:$||I.queryId||pa(32)};return z.clientSideId=z.clientSideId||z.queryId+"-ai",R[P]=z,[{...M,isNew:!1,messages:R},...N.slice(1)]})},c=p=>{if(p instanceof rv)throw i(v=>({...v,display:"error",sender:"ready"})),Po&&(Po.abort(),Po=null),ia=null,p};return{updateUserFilesMessage:({currentFiles:p})=>{r(v=>{if(!v[0])return v;const y=v[0],b=y.messages||[];if(!b.length)return v;const E=b.length-2;if(E<0||b[E].istype!=="user")return v;const w=b.slice();return w[E]={...b[E],currentFiles:p},[{...y,messages:w},...v.slice(1)]})},api_startChat_re:(p,v)=>{Po&&Po.abort(),Po=new AbortController,ia=p.sessionId;const y=`${e}/qa/ai/question_re`;console.log("data",p);const b={...p};use(y,{method:"post",signal:Po.signal,headers:{"Content-Type":"application/json",Accept:"text/event-stream",Authorization:t||"","X-CSRF-TOKEN-IN":n||""},openWhenHidden:!0,body:JSON.stringify(b),onopen:async E=>{if(E.status===500)throw new rv("Internal Server Error");if(!E.ok)throw new rv(`HTTP error: ${E.status}`)},onmessage:E=>{const x=JSON.parse(E.data);if(ia!==x.sessionId){console.log("[AichatUseController] \u6D41\u5F0F\u8BF7\u6C42\u7684 sessionId \u5DF2\u4E0D\u5339\u914D\uFF0C\u5FFD\u7565\u6570\u636E",{currentStreamSessionId:ia,receivedSessionId:x.sessionId,activeSessionId:o});return}if(o!==x.sessionId)return;const{reply:w,resultType:k,respTime:S,reference:O,webReference:$,graphReference:A,filePaths:N,status:M,docs:D,llmType:P,databaseReference:I}=x,R=N?JSON.parse(N):[];M===2&&w&&w.content&&(w.content.includes("\u6A21\u578B\u6682\u65E0\u6CD5\u8FD4\u56DE")||w.content.includes("\u5931\u8D25")||w.content.includes("\u9519\u8BEF")||w.content.includes("\u8BF7\u7A0D\u540E\u518D\u8BD5"))&&i(z=>({...z,display:"ready",sender:"ready"}));const j=s(A)?A:void 0;if(M===2&&console.log("[AichatUseController] status=2 \u65F6\u7684 graphReference:",{graphReference:A,type:typeof A,isValid:s(A),finalGraphReference:j}),M===2){if(l({content:w.content||"",status:2,respTime:S,filePaths:R,reference:O||D||"",webReference:$||"",graphReference:j,databaseReference:I,llmType:P,resultType:k,queryId:x.queryId,tokens:x.tokens}),i(z=>({...z,display:"ready",sender:"ready"})),v){const z=S||Date.now();console.log("[AichatUseController] \u6D88\u606F\u53D1\u9001\u6210\u529F\uFF0CgmtModified:",z),v(z)}}else l({content:w.content||"",status:M,respTime:S,filePaths:R,reference:O||D||"",webReference:$||"",graphReference:j,databaseReference:I,llmType:P,resultType:k,queryId:x.queryId,tokens:x.tokens})},onerror:c,onclose:()=>{ia===p.sessionId&&(ia=null)}})},addEmptyMessage:({queryId:p,content:v,filePaths:y,currentFiles:b})=>{r(E=>{const x=new Date().toISOString(),w=p||pa(32),k={istype:"user",content:v,time:x,queryId:w,clientSideId:w+"-user",filePaths:y||"",currentFiles:b||[]},S={istype:"ai",content:"",time:new Date(Date.now()+1).toISOString(),streaming:!0,status:0,queryId:w,clientSideId:w+"-ai"},O=E.find($=>$.id===o);return O?O.messages.push(k,S):console.warn("addEmptyMessage called without an active session."),[...E]})},setLastEmptyMessage:({now:p})=>{r(v=>{if(!v[0])return v;const y=v[0],b=y.messages||[];if(!b.length)return v;const E=b.length-1;if(E<0)return v;const x=b[E];if(x.istype!=="ai")return v;const w=b.slice();return w[E]={...x,istype:"ai",content:"",time:p,streaming:!0,status:0},[{...y,messages:w},...v.slice(1)]})},stopStream:()=>{Po&&(Po.abort(),Po=null),ia=null,i(p=>({...p,display:"ready",sender:"ready"}))},cancelStreamBySessionId:p=>Po&&ia===p?(console.log("[AichatUseController] \u5207\u6362\u4F1A\u8BDD\uFF0C\u53D6\u6D88\u6B63\u5728\u8FDB\u884C\u7684\u6D41\u5F0F\u8BF7\u6C42",p),Po.abort(),Po=null,ia=null,i(v=>({...v,display:"ready",sender:"ready"})),!0):!1}},hse="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAACRSURBVHgB7ZJBCsQgDEWTmQvMncT7dOuqmY3iai6kMN31UmIjdNFFKuk+DwKahP9ABDAMQyTnvHCtT/ZjjIs0e0nN1hr03kkjGTu8+0PEjzR/S81a6+6cQz6S9x5KKdsknLi+IQRSC07JfybRhE8FM4k2fICgIKVE/MYrF427NlwtuEpOgSr8MUNy9x0Nw7jnAFsnZ7Uu5CkqAAAAAElFTkSuQmCC",{TextArea:$6}=Wu,{useForm:pse}=Ra,f9={\u56DE\u7B54\u4E0D\u4F73:"ansPoor",\u683C\u5F0F\u95EE\u9898:"formatError",\u7406\u89E3\u95EE\u9898\u6709\u8BEF:"harmfulInfo",\u5176\u4ED6:"othres"},gse=({open:e,setOpen:t,feedBackList:n,handleConfirm:r})=>{const o={header:{padding:"20px 24px",borderBottom:"1px solid #F0F0F0",margin:0},body:{padding:"16px 24px 20px 24px",borderBottom:"1px solid #F0F0F0"},mask:{},footer:{padding:"16px 24px",margin:0},content:{padding:0,borderRadius:"4px",width:"563px"}},[i]=pse(),[a,s]=at({}),l=async()=>{try{const c=await i.validateFields();t(!1);const u={...c};Object.entries(a||{}).forEach(d=>{const[f,h]=d;h&&(u[f9[f]]=h)}),r(u)}catch(c){console.log(c);return}};return vt(()=>{e||(i.resetFields(),s(null))},[e]),Z(pp,{modal:{styles:o},children:et(gp,{open:e,onCancel:()=>t(!1),title:Z("div",{className:"text-[16px] text-[#2A2A2A] font-bold leading-[1]",children:"\u611F\u8C22\u60A8\u7684\u53CD\u9988\uFF01\u8FD9\u5C06\u5E2E\u52A9\u6211\u4EEC\u4E0D\u65AD\u4F18\u5316\u4E0E\u63D0\u5347\u3002"}),footer:et("div",{children:[Z(So,{className:"mr-[16px] w-[76px]",onClick:()=>{t(!1)},children:"\u53D6\u6D88"}),Z(So,{type:"primary",className:"w-[76px] border-none",onClick:l,children:"\u786E\u8BA4"})]}),children:[Z(mse,{feedBackList:n,treeSelectResult:a,setTreeSelectResult:s}),et(Ra,{form:i,layout:"vertical",children:[Z(Ra.Item,{name:"supplementExplain",label:"\u8865\u5145\u63CF\u8FF0",children:Z($6,{})})," ",Z(Ra.Item,{name:"idealAnswer",label:"\u60A8\u89C9\u5F97\u66F4\u597D\u7684\u56DE\u7B54\u662F\u4EC0\u4E48\uFF1F",children:Z($6,{})}),Z(Ra.Item,{name:"userPhone",label:"\u8054\u7CFB\u7535\u8BDD",children:Z(Wu,{})}),Z(Ra.Item,{name:"deptName",label:"\u90E8\u95E8",children:Z(Wu,{})})]})]})})},mse=({feedBackList:e,treeSelectResult:t,setTreeSelectResult:n})=>{const[r,o]=at(!1),[i,a]=at([]),[s,l]=at([]),[c,u]=at([]),[d,f]=at(null),h=Vt(()=>(l([]),d!=null&&d.items?[{title:"\u5168\u9009",key:"\u5168\u9009",children:d.items.map(g=>({title:g,key:g}))}]:[]),[d]),m=g=>{u(p=>Array.isArray(p)&&Array.isArray(s)?Object.entries(t).reduce((y,b)=>{const[E,x]=b,k=(x?x.split(";"):[]).filter(S=>S!==g);return n(S=>({...S||{},[E]:k.join(";")})),[...y,...k]},[]):p)};return vt(()=>{if(a(["\u5168\u9009"]),!t||!(d!=null&&d.que_name))return;const g=t[d.que_name]||"",p=g?g.split(";"):[];l(p)},[h,r]),vt(()=>{t===null&&(u([]),f(null),l([]))},[t]),vt(()=>{console.log("treeSelectResult",t),console.log("selectedValue",c),console.log("feedBackList",e),console.log("pKey",f9),console.log("selectedParent",d)},[t,c]),et("div",{className:"relative mb-[24px] z-20",children:[et("div",{className:"absolute w-full z-10",children:[et("div",{className:"h-[32px] box-border flex items-center justify-between border-[1px] border-solid border-[#D9D9D9] rounded-[4px] cursor-pointer",onClick:()=>o(!r),children:[Z("div",{className:"ml-[16px]",children:"\u95EE\u9898\u7C7B\u578B"}),Z("img",{src:hse,width:24,height:24,className:"mr-[16px]"})]}),et("div",{style:{display:r?"":"none"},className:"h-[288px] rounded-[4px] shadow-md mt-[4px] bg-white",children:[et("div",{className:"h-[248px] flex",style:{borderBottom:"1px solid #F0F0F0"},children:[Z("div",{className:"w-[203px] px-[8px] py-[8px]",style:{borderRight:"1px solid #F0F0F0"},children:e.map((g,p)=>{var v;return et("div",{className:"rounded-[4px] h-[32px] cursor-pointer flex items-center",style:{backgroundColor:(d==null?void 0:d.que_name)===g.que_name?"#E6F4FF":""},children:[Z("div",{className:"h-full w-full leading-[32px]",onClick:()=>{f(g)},children:et("div",{className:"ml-[8px] text-[14px] text-[#2A2A2A]",children:[g.que_name,"(",t&&t[g.que_name]?t[g.que_name].split(";").length:0,"/",(v=g==null?void 0:g.items)==null?void 0:v.length,")"]})}),Z(AI,{className:"mr-[8px] w-3 h-3 text-[rgba(0,0,0,0.45)]"})]},p)})}),Z("div",{className:"selfTree h-full flex-1 mt-[8px] ml-[16px]",children:Z(QH,{checkable:!0,defaultSelectedKeys:["0-1"],treeData:h,blockNode:!0,checkedKeys:s,expandedKeys:i,onCheck:g=>{Array.isArray(g)&&n(p=>({...p||{},[(d==null?void 0:d.que_name)||""]:(g||[]).filter(v=>v!=="\u5168\u9009").join(";")})),l(g)}})})]}),et("div",{className:"flex justify-end h-[40px] items-center",children:[Z(So,{size:"small",className:"mr-[8px]",onClick:()=>o(!1),children:"\u53D6\u6D88"}),Z(So,{size:"small",type:"primary",className:"border-none mr-[16px]",onClick:()=>{u(g=>Array.isArray(g)&&Array.isArray(s)?Object.values(t).reduce((v,y)=>[...v,...y?y.split(";"):[]],[]):g),o(!1)},children:"\u786E\u8BA4"})]})]})]}),Z("div",{className:"h-[32px]"}),!!(c!=null&&c.length)&&et("div",{children:[et("div",{className:"mt-[5px] text-[12px] text-[#555555]",children:["\u5DF2\u9009\u62E9 ",c.length," \u4E2A"]}),(c||[]).map(g=>{let p="";return Object.entries(t||{}).forEach(v=>{const[y,b]=v;b.indexOf(g)>-1&&(p=y)}),et(UH,{closable:!0,className:"mt-[5px]",onClose:()=>m(g),children:[p,"\uFF08",g,"\uFF09"]},g)})]})]})},A6=e=>e?Array.isArray(e)?e.map(r=>"/minio/"+r.split("/").slice(3).join("/")):"/minio/"+e.split("/").slice(3).join("/"):"",O6="http://10.15.12.13:9000/",vse=e=>{if(typeof e=="string"){const t=e.split(".");return t.length?t[t.length-1]:""}else return""},yse=e=>{var x,w,k,S,O,$,A,N;const{file_type:t,file_name:n,url:r,parse_url:o,retrieve_tags:i,file_id:a,parsed_file_type:s,onlyDownloadTypes:l,references:c,eventsEmit:u,styles:d,isUploadFile:f,type:h,collectionItems:m,pdfPages:g=0,fileManagerData:p}=e;if(h==="collection"&&Array.isArray(m)){const P=`calc(90% - ${.5}px)`,I=m.slice(0,4),R=m.length>4,j="\u6253\u5F00\u5408\u96C6",z=()=>{if(p&&t==="pdf"&&!e.pdfPages){const V=((p==null?void 0:p.uploadedFiles)||[]).find(L=>{var _;return((L==null?void 0:L.name)||((_=L==null?void 0:L.file)==null?void 0:_.name))===n});if(!(V!=null&&V.pdfPages)){rr.warning("\u8BE5PDF\u6587\u4EF6\u672A\u89E3\u6790\u5B8C\u6210\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");return}u==null||u("reference_file:click",{...e,pdfPages:(V==null?void 0:V.pdfPages)||0})}else u==null||u("reference_file:click",e)};return et("div",{className:"user-file relative group flex flex-col items-center justify-center cursor-pointer backdrop-blur-sm rounded-lg border p-2 text-sm transition-all bg-white shadow",style:{width:94,height:94,minWidth:94,minHeight:94,borderColor:(w=(x=d==null?void 0:d.theme)==null?void 0:x.colors)==null?void 0:w.border},onClick:z,children:[Z("div",{className:"grid grid-cols-2 items-center justify-center grid-rows-2 gap-1 w-full h-full",style:{width:"100%",height:"100%",gap:1},children:I.map((V,L)=>{var T,B,H,G;if(R&&L===3)return Z("div",{className:"flex items-center justify-center bg-gray-100 rounded",style:{width:P,height:P},children:Z("span",{className:"text-xl text-gray-300 font-bold scale-75",children:"..."})},"ellipsis");if(V.file_type==="image"||V.file_type==="jpg"||V.file_type==="jpeg"||V.file_type==="png"||V.file_type==="gif"||V.file_type==="bmp"||V.file_type==="webp")return Z("div",{className:"relative flex items-center justify-center bg-white rounded-lg border overflow-hidden",style:{width:P,height:P,borderColor:(B=(T=d==null?void 0:d.theme)==null?void 0:T.colors)==null?void 0:B.border},children:Z("div",{className:"flex items-center justify-center w-full h-full scale-75",children:Z("img",{src:String(V.url||V.file_path||""),alt:V.file_name||"",className:"object-contain max-w-full max-h-full"})})},V.file_name||L);const F=Dw(String(V.file_type||""),d);return Z("div",{className:"user-file flex flex-col items-center justify-center rounded-lg border bg-gray-50 p-1 text-sm",title:V.file_name,style:{width:P,height:P,borderColor:(G=(H=d==null?void 0:d.theme)==null?void 0:H.colors)==null?void 0:G.border},children:Z("div",{className:"flex items-center justify-center w-full h-full scale-75",children:F})},V.file_name||L)})}),Z("div",{className:"absolute inset-0 bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-lg pointer-events-none",children:et("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[Z(lm,{size:20,className:"mb-1 text-white"}),Z("span",{className:"text-white text-center",style:{fontSize:12},children:j})]})})]})}const v=()=>{if(console.log(o,"parse_url",r,"url"),p&&t==="pdf"&&!g){const M=((p==null?void 0:p.uploadedFiles)||[]).find(D=>{var P;return((D==null?void 0:D.name)||((P=D==null?void 0:D.file)==null?void 0:P.name))===(n||"").replace(/\s+/g,"")});if(!(M!=null&&M.pdfPages)){rr.warning("\u8BE5PDF\u6587\u4EF6\u672A\u89E3\u6790\u5B8C\u6210\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5");return}u==null||u("reference_file:click",{file:n,file_type:t,url:r,parse_url:o,retrieve_tags:i,file_id:a,parsed_file_type:s,references:c,type:y,isUploadFile:f,pdfPages:M.pdfPages||0})}else u==null||u("reference_file:click",{file:n,file_type:t,url:r,parse_url:o,retrieve_tags:i,file_id:a,parsed_file_type:s,references:c,type:y,isUploadFile:f,pdfPages:g})},y=Vt(()=>(n||"").split(".").pop()||"",[n]),b=Dw(y,d),E=async()=>{if(r){const M=A6(r.indexOf("http")>-1?r:`${O6}/${r}`);if(y.toLowerCase()==="json"){try{const I=await fetch(M);if(!I.ok)throw new Error("\u4E0B\u8F7D\u5931\u8D25");const R=await I.blob(),j=document.createElement("a");j.href=URL.createObjectURL(R),j.download=n||"",document.body.appendChild(j),j.click(),document.body.removeChild(j),setTimeout(()=>URL.revokeObjectURL(j.href),1e3)}catch{alert("\u6587\u4EF6\u4E0B\u8F7D\u5931\u8D25")}return}const P=document.createElement("a");P.href=M,P.download=n||"",document.body.appendChild(P),P.click(),document.body.removeChild(P)}};return l&&l.includes(y.toLowerCase())?et("div",{className:"user-file relative group w-24 h-24 flex flex-col items-center justify-center cursor-pointer backdrop-blur-sm rounded-lg border p-2 text-sm transition-all",title:n,onClick:E,style:{borderColor:(S=(k=d==null?void 0:d.theme)==null?void 0:k.colors)==null?void 0:S.border},children:[b,Z("span",{className:"file-name font-medium truncate text-center px-2 pt-1",style:{fontSize:10,maxWidth:"5.5rem"},children:n}),Z("div",{className:"absolute text-center inset-0 cursor-pointer bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-lg",children:et("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[Z(lm,{className:"text-white opacity-0 group-hover:opacity-100 transition-opacity mx-auto"}),Z("div",{className:"text-white text-center",style:{fontSize:10},children:"\u4E0B\u8F7D\u6587\u4EF6"})]})})]},n):y==="image"||y==="jpg"||y==="jpeg"||y==="png"||y==="gif"||y==="bmp"||y==="webp"?et("div",{className:"relative group w-24 h-24 cursor-pointer flex items-center justify-center",onClick:()=>v(),children:[r?Z("img",{src:String(A6(r&&r.indexOf("http")>-1?r:`${O6}/${r}`)||""),alt:n||"",className:"w-full h-full object-cover rounded-md border",style:{borderColor:($=(O=d==null?void 0:d.theme)==null?void 0:O.colors)==null?void 0:$.border}}):Z("div",{className:"w-full h-full flex items-center justify-center",children:Z("span",{className:"animate-spin rounded-full border-2 border-gray-300 border-t-blue-500 w-8 h-8 inline-block"})}),Z("div",{className:"absolute inset-0 bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-md",children:et("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[Z(cW,{className:"text-white opacity-0 group-hover:opacity-100 transition-opacity mx-auto"}),Z("div",{className:"text-white text-center",children:"\u67E5\u770B\u56FE\u7247"})]})})]},n):et("div",{className:"user-file relative group w-24 h-24 flex flex-col items-center justify-center cursor-pointer backdrop-blur-sm rounded-lg border p-2 text-sm transition-all",title:n,onClick:v,style:{borderColor:(N=(A=d==null?void 0:d.theme)==null?void 0:A.colors)==null?void 0:N.border},children:[b,Z("span",{className:"file-name font-medium truncate text-center px-2 pt-1",style:{fontSize:10,maxWidth:"5.5rem"},children:n}),Z("div",{className:"absolute text-center inset-0 cursor-pointer bg-transparent group-hover:bg-black/40 transition-all duration-300 flex items-center justify-center rounded-lg",children:et("div",{className:"flex flex-col items-center text-xs justify-center text-white opacity-0 group-hover:opacity-100 transition-opacity",children:[Z(lm,{className:"text-white opacity-0 group-hover:opacity-100 transition-opacity mx-auto"}),Z("div",{className:"text-white text-center",style:{fontSize:10},children:"\u6253\u5F00\u6587\u4EF6"})]})})]},n)},bse=e=>e?e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/1024/1024).toFixed(1)}MB`:"",xse=({fileName:e,fileSize:t,icon:n,statusText:r,statusColor:o="text-gray-400",statusIcon:i,onRemove:a,themeColors:s={},cardId:l,showRemove:c=!0,disabledRemove:u=!1,onRemoveWithAnim:d,extra:f,style:h})=>et("div",{id:l,className:"group gap-x-2.5 items-center file-display-card relative flex w-[210px] bg-white border border-gray-200 rounded-md shadow-sm px-2 py-1 transition-all hover:shadow-md hover:border-blue-300",style:h,children:[Z("div",{className:"pt-1",children:n}),et("div",{className:"flex-1 min-w-0 flex flex-col justify-center",children:[et("div",{className:"flex items-center justify-between gap-1",children:[Z("span",{className:"text-[12px] font-medium truncate max-w-[120px]",title:e,children:e}),Z("span",{className:"ml-1 text-[11px] text-gray-400",children:bse(t)})]}),et("div",{className:`text-[10px] mt-0.5 flex items-center gap-3 ${o}`,children:[i,Z("span",{children:r})]})]}),f,c&&!u&&Z("button",{className:"absolute top-0.5 right-0.5 opacity-0 group-hover:opacity-100 transition-opacity text-gray-300 hover:text-red-400 text-xs p-0.5 rounded-full bg-white shadow-sm z-10",onClick:()=>{d&&l?d(l):a&&a()},title:"\u79FB\u9664",style:{lineHeight:0,color:s.error||"#FF0000"},children:Z(mp,{className:"w-3.5 h-3.5"})})]});function Dw(e,t){var r;const n=((r=t==null?void 0:t.theme)==null?void 0:r.icons)||{};switch(e.toLowerCase()){case"docx":case"doc":return n.docx?Z("img",{src:n.docx,alt:"docx",style:{width:20,height:20}}):Z(ar,{type:"rag/word",size:18});case"image":case"jpg":case"jpeg":case"png":case"gif":case"bmp":case"webp":case"svg":case"ico":return n.image?Z("img",{src:n.image,alt:"image",style:{width:20,height:20}}):Z(ar,{type:"rag/pic",size:18});case"pptx":case"ppt":return n.pptx?Z("img",{src:n.pptx,alt:"pptx",style:{width:20,height:20}}):Z(ar,{type:"rag/ppt",size:18});case"sheets":case"excel":case"xls":case"csv":case"xlsx":case"xlsm":case"xlsb":case"xltx":case"xltm":case"xlt":case"xlam":return n.sheets?Z("img",{src:n.sheets,alt:"sheets",style:{width:20,height:20}}):Z(ar,{type:"rag/excel",size:18});case"pdf":return n.pdf?Z("img",{src:n.pdf,alt:"pdf",style:{width:20,height:20}}):Z(ar,{type:"rag/pdf",size:18});case"txt":return n.txt?Z("img",{src:n.txt,alt:"txt",style:{width:20,height:20}}):Z(ar,{type:"rag/txt",size:18});case"md":return n.md?Z("img",{src:n.md,alt:"txt",style:{width:20,height:20}}):Z(ar,{type:"rag/document",size:18});case"json":return n.json?Z("img",{src:n.json,alt:"json",style:{width:20,height:20}}):Z(ar,{type:"rag/json",size:18});case"html":case"htm":return n.html?Z("img",{src:n.html,alt:"html",style:{width:20,height:20}}):Z(ar,{type:"rag/url",size:18});case"xml":default:return Z(ar,{type:"rag/file",size:18})}}const Ese=[{file:{name:"\u4EA7\u54C1\u9700\u6C42\u6587\u6863.pdf",size:1024*1024*2.5,type:"application/pdf"},type:"pdf",status:"uploaded",url:"https://example.com/file1.pdf"},{file:{name:"\u6570\u636E\u5206\u6790\u62A5\u544A.xlsx",size:1024*1024*1.2,type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},type:"excel",status:"uploaded",url:"https://example.com/file3.xlsx"},{file:{name:"\u7CFB\u7EDF\u67B6\u6784\u56FE.png",size:1024*512,type:"image/png"},type:"image",status:"uploaded",url:"https://example.com/file2.png"}];function wse({open:e,onCancel:t,files:n=Ese,currentFiles:r=[],onUpload:o,onRemoveFile:i,styles:a,eventsEmit:s}){const l={pending:"\u5F85\u4E0A\u4F20",uploading:"\u4E0A\u4F20\u4E2D",uploaded:"\u5DF2\u4E0A\u4F20",analyzing:"\u89E3\u6790\u4E2D",analyze_failed:"\u89E3\u6790\u5931\u8D25",error:"\u5931\u8D25"},[c,u]=at([]),d=(g,p)=>{s&&s("uploaded_file:removeFromTemp",{file:g,idx:p})},f=a&&a.theme&&a.theme.colors?a.theme.colors:{primary:"#007bff",secondary:"#6c757d",success:"#008000",warning:"#FFA500",error:"#FF0000",info:"#0000FF",background:"#f8f9fa",text:"#343a40",border:"#dee2e6",disabled:"#808080",disabledBackground:"#F5F5F5",disabledText:"#808080",shadow:"#000000",appBackground:"#fff"},h=n.map((g,p)=>et("div",{className:"relative flex flex-col gap-2.5 items-center justify-center",children:[Z("div",{className:"absolute right-1 top-1 z-10",children:Z(FI,{title:"\u786E\u8BA4\u4ECE\u4E34\u65F6\u5BF9\u8BDD\u77E5\u8BC6\u5E93\u79FB\u9664\u8BE5\u6587\u4EF6\uFF1F",onConfirm:()=>d(g,p),okText:"\u786E\u8BA4",cancelText:"\u53D6\u6D88",children:Z("button",{className:"bg-white cursor-pointer rounded-full p-0.5",style:{lineHeight:0,color:f&&f.text?f.text:"#FF0000",transition:"background 0.2s, color 0.2s"},onMouseOver:v=>{v.currentTarget.style.color=f&&f.error?f.error:"#FF0000"},onMouseOut:v=>{v.currentTarget.style.color=f.text},title:"\u79FB\u9664",children:Z(mp,{className:"w-3 h-3"})})})}),Z(yse,{file_type:vse(g.file.name||g.name),file_name:g.name||g.file.name,url:g.url,retrieve_tags:[],styles:a,isUploadFile:!0,eventsEmit:s,parse_url:g.convertedFilePath,pdfPages:g.pdfPages||0})]},g.file.name+p)),m=r.map((g,p)=>{const v=g.file.name.split(".").pop()||"",y=Dw(v,a);return Z(xse,{cardId:`pending-file-card-${p}`,fileName:g.file.name,fileSize:g.file.size,icon:y,statusText:l[g.status||"pending"],statusColor:"text-gray-400",showRemove:!0,onRemove:()=>i&&i(g,p,"pending"),themeColors:f,style:{boxShadow:"none",height:55,background:"#f8fafc"}},g.file.name+p)});return c.length>0?(f&&f.error&&f.error,f&&f.error&&f.error+"",f&&f.error&&f.error):(f&&f.disabledText&&f.disabledText,f&&f.disabledBackground&&f.disabledBackground,f&&f.disabledText&&f.disabledText),et(gp,{open:e,onCancel:t,footer:null,title:"\u5BF9\u8BDD\u4E34\u65F6\u6587\u4EF6\u77E5\u8BC6\u5E93",closable:!1,width:800,styles:{body:{padding:"0",maxHeight:"70vh",overflow:"auto"}},children:[et("div",{className:"file-manager-modal space-y-6 px-4 py-4",children:[et("div",{className:"",children:[Z("div",{className:"flex items-center mb-2 justify-between",children:et("div",{className:"flex items-center",children:[Z("span",{className:"text-xs font-semibold text-gray-700",children:"\u5DF2\u4E0A\u4F20\u6587\u4EF6"}),et("span",{className:"ml-2 text-xs text-gray-400",children:[n.length," \u4E2A"]})]})}),Z("div",{className:"w-full relative min-h-[200px] max-h-[260px] p-2 overflow-y-auto",style:{overflowX:"hidden"},children:Z("div",{className:"flex flex-wrap gap-1",children:h.length>0?h:Z("div",{className:"flex items-center w-full h-full py-10 justify-center text-gray-400 text-sm",children:"\u6682\u65E0\u5DF2\u4E0A\u4F20\u6587\u4EF6"})})})]}),et("div",{children:[et("div",{className:"flex items-center mb-2",children:[Z("span",{className:"text-xs font-semibold text-gray-700",children:"\u5F85\u4E0A\u4F20\u6587\u4EF6"}),et("span",{className:"ml-2 text-xs text-gray-400",children:[r.length," \u4E2A"]})]}),et("div",{className:"flex gap-2 overflow-x-auto pb-2",children:[m,Z(TC.Dragger,{multiple:!0,showUploadList:!1,beforeUpload:(g,p)=>(g===p[0]&&(o==null||o(p)),!1),className:"!bg-gray-50 !border-dashed !border-gray-300 hover:!border-blue-400 cursor-pointer min-w-[160px] max-w-[220px] flex flex-row items-center justify-center border-2 rounded-lg transition-all",style:{height:45,boxShadow:"none",padding:0},children:et("div",{className:"flex flex-row items-center pb-8 justify-center",children:[Z(NI,{size:20,className:"text-blue-400 mr-2"}),Z("div",{className:"text-xs text-gray-500",children:"\u4E0A\u4F20\u6587\u4EF6"})]})})]})]}),Z("div",{className:"flex justify-end gap-2",children:Z(So,{type:"primary",onClick:t,children:"\u786E\u8BA4"})})]}),Z("style",{children:`
|
|
610
610
|
.file-manager-modal .ant-upload-wrapper,
|
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,m as ye}from"./assets/index-fhKUis2J.js";import{b as Fe,T as Ie,d as ge,i as O}from"./assets/index-BbHMAb8g.js";import{O as K}from"./assets/index-CuySCBtZ.js";import{M as ee,s as R}from"./assets/style-CNIDlcUL.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 l,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,m as be}from"./assets/index-x8IlxRuv.js";import{b as ye,T as Ee,d as Fe,i as O}from"./assets/index-g-SUxfJH.js";import{O as $}from"./assets/index-DwoTKC3G.js";import{M as ee,s as H}from"./assets/style-CGmZ5osp.js";/* empty css */import"react-dom";const pe=({url:m,token:z,role:B,eventsEmit:F})=>{const c=ye.create({baseURL:m,timeout:1e6});return c.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)}),c.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 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: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 c.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 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",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:c,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,c]),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:!!c,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:[l("img",{src:x,width:24}),l("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}]}]}),[n,c,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:{...c}}],eventsEmit:A}},[n,g,D,z,c]),v=T(()=>n=="DirectDB"?c?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:[l(Q,{mode:"default",label:"\u53D6\u6D88",onClick:()=>{F(),u(!1)}}),l(Q,{mode:"primary",label:"\u786E\u8BA4",loading:G,disabled:v,onClick:h})]}),children:[l($,{...d},"example-form"),n==="DirectDB"&&l(De,{children:m=="\u7F16\u8F91\u6570\u636E\u5E93"&&!r?l(Q,{mode:"primary",className:"mt-[10px]",label:"\u4FEE\u6539\u5BC6\u7801",onClick:()=>{u(!0),p.current.setValues({dbPassword:void 0})}}):l(Ee,{title:"\u9700\u901A\u8FC7\u6D4B\u8BD5\u624D\u53EF\u521B\u5EFA\u6210\u529F",children:l(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
|
-
`,
|
|
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}],Re=m=>{const{url:z,token:B,role:F,CustomComponents:c,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:()=>l(ge,{mode:"primary",label:"\u521B\u5EFA\u6570\u636E\u5E93",actions:Se.map(o=>({key:o.key,component:l(xe,{children:Z("div",{className:"flex flex-grow",children:[l("div",{className:"mr-[6px]",children:l("img",{src:o.icon})}),Z("div",{children:[l("div",{className:"text-base font-bold mb-1 text-[14px]",children:o.label}),l("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 L=[];if(C.status==="fulfilled"&&C.value&&(o=C.value)!=null&&o.records){const S=Y((s=C.value)==null?void 0:s.records);L.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);L.push({id:"shared-db",data:S||[]})}r(L),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:[l("div",{className:"text-xl font-semibold mb-3",style:{color:"#374151"},children:l("img",{src:Ne,width:120})}),l("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)||[]},ce=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)},le=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,L,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((P,E)=>(P[E.name]=E.value,P),{}),ne=d?{id:d==null?void 0:d.id,...k}:k,V=await ue(ne,h);if(V){if(d){const P={...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(P,d==null?void 0:d.id),H.success("\u6570\u636E\u5E93\u7F16\u8F91\u6210\u529F\uFF01")}else{const P={...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}))};(L=(j=u==null?void 0:u.current)==null?void 0:j.appFn)==null||L.addItem(P,{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 le(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:[l($,{ref:u,label:"",model:"tabs",defaultActiveId:f,views:J,dataSource:ce,eventsEmit:_,status:W,CustomComponents:{EmptyData:oe,...c},styles:{theme:{...O,colors:{...O.colors,listBackground:"#ffffff"}},mode:"light"}},"db"),l(we,{drawerTitle:p,drawerVisible:g,isConnectSuccess:a,dbType:h,dbInfo:d,handleDrawerClose:X,eventsEmit:_})]})};export{Re as default};
|
package/databaseId.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"react/jsx-runtime";import"react";import"./assets/index-CpW6Dhpp.js";import"./assets/index-
|
|
1
|
+
import"react/jsx-runtime";import"react";import"./assets/index-CpW6Dhpp.js";import"./assets/index-x8IlxRuv.js";import"./assets/index-g-SUxfJH.js";import"./assets/index-DwoTKC3G.js";/* empty css */import"./assets/style-CGmZ5osp.js";import{D as g}from"./assets/index-CIwaLPGb.js";import"./assets/index-DdVFXD_y.js";import"react-dom";import"./assets/index-BO-w4FPz.js";import"./assets/index-BKe5FgcC.js";import"./assets/index-j0kQJd0a.js";import"./assets/index-D72cKELw.js";import"./assets/x-CnaaLGJF.js";export{g 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 k,useRef as Le,useEffect as Ne,useMemo as Pe}from"react";import{u as ce}from"./assets/index-CpW6Dhpp.js";import{a as ze,l as ge,f as G,o as Fe,q as ue,g as Me,m as Te,k as E,r as _e,u as Oe,s as Ae,v as je,_ as ye,w as Re,x as be,R as xe,D as He,b as qe,I as We,B as ke}from"./assets/index-
|
|
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 k,useRef as Le,useEffect as Ne,useMemo as Pe}from"react";import{u as ce}from"./assets/index-CpW6Dhpp.js";import{a as ze,l as ge,f as G,o as Fe,q as ue,g as Me,m as Te,k as E,r as _e,u as Oe,s as Ae,v as je,_ as ye,w as Re,x as be,R as xe,D as He,b as qe,I as We,B as ke}from"./assets/index-g-SUxfJH.js";import{J as Se,m as Ge}from"./assets/index-x8IlxRuv.js";import{D as Ve}from"./assets/index-D72cKELw.js";import{P as Xe,S as Ue}from"./assets/index-BKe5FgcC.js";import{X as Je}from"./assets/x-CnaaLGJF.js";import{O as Ke}from"./assets/index-DwoTKC3G.js";/* empty css */import{M as Ye,s as Ce}from"./assets/style-CGmZ5osp.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 y}from"./chat.js";import"./database.js";import"./assets/index-
|
|
1
|
+
import{DrawerType as y}from"./chat.js";import"./database.js";import"./assets/index-CIwaLPGb.js";import"./databaseTable.js";import"react/jsx-runtime";import"react";import"./modelManage.js";import"./sensitive.js";import{G as F,B as P}from"./assets/GientechStreamReader-DqJjNXCO.js";import"./assets/index-FiuM-Chj.js";import{i as S}from"./assets/index-g-SUxfJH.js";import"./assets/index-x8IlxRuv.js";import"react-dom";import"./assets/index-BO-w4FPz.js";import"./assets/index-BKe5FgcC.js";import"./assets/index-j0kQJd0a.js";import"./assets/index-CpW6Dhpp.js";/* empty css */import"./assets/style-CGmZ5osp.js";import"./assets/plus-V9zUoSq6.js";import"./assets/x-CnaaLGJF.js";import"./assets/index-D72cKELw.js";import"./assets/index-DwoTKC3G.js";import"./assets/index-DdVFXD_y.js";export{y as DrawerType,F as GientechStreamReader,S as defaultTheme,P as registerPDFWorker};
|
package/modelManage.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as l,jsxs as Z}from"react/jsx-runtime";import{useState as w,useMemo as P,useRef as O,useEffect as ae}from"react";import{J as z,m as le}from"./assets/index-fhKUis2J.js";import{b as re,T as Y}from"./assets/index-BbHMAb8g.js";import{O as X}from"./assets/index-CuySCBtZ.js";import{D as ne}from"./assets/index-DnJqVq9Q.js";import{X as ie}from"./assets/x-BjRa5XLp.js";import{s as j,M as ce}from"./assets/style-CNIDlcUL.js";/* empty css */import{P as de}from"./assets/plus-Dmpl3gd8.js";import{B as G}from"./assets/index-Dkwp9YpO.js";import"react-dom";const me=""+new URL("assets/empty.png",import.meta.url).href,pe=({url:u,token:C,role:p,eventsEmit:F})=>{const y=re.create({baseURL:u,timeout:1e6});return y.interceptors.request.use(e=>{let t=C;return!t&&!["user/login","user/kaptcha","user/regist"].some(i=>e.url.includes(i))?(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=p==="\u672A\u767B\u5F55\u7528\u6237"?"":p,e)}),y.interceptors.response.use(e=>{const t=["user/kaptcha"],o=e.data;if(t.some(m=>e.config.url&&e.config.url.includes(m))||o.size&&o.type)return o;const{success:i,errorMsg:h,errorCode:a}=o;return i?o:(F&&F("request:error_business",{errorCode:a,errorMsg:h||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",response:o}),!1)},e=>{var t,o,i,h,a,m,E,M,B;if(e.message==="canceled")return Promise.reject(e);if(F){let S="request:error_network",R={errorMsg:"\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25",error:e};((t=e==null?void 0:e.response)==null?void 0:t.status)===401?(S="request:error_auth",R={errorMsg:"\u6CA1\u6709\u8DB3\u591F\u6743\u9650",error:e,redirect:"/login"}):(((i=(o=e==null?void 0:e.response)==null?void 0:o.data)==null?void 0:i.errorCode)==="30013"||((a=(h=e==null?void 0:e.response)==null?void 0:h.data)==null?void 0:a.errorCode)==="30023")&&(S="request:error_business",R={errorCode:(E=(m=e==null?void 0:e.response)==null?void 0:m.data)==null?void 0:E.errorCode,errorMsg:((B=(M=e==null?void 0:e.response)==null?void 0:M.data)==null?void 0:B.message)||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",error:e}),F(S,R)}return Promise.reject(e)}),{getModelList:async e=>{try{const t=await y.get(`/allPage?${new URLSearchParams(e).toString()}`),{success:o,data:i}=t;if(o)return i}catch(t){return console.log("getModelList error:",t),!1}},delModelById:async e=>{try{const t=await y.delete(`/delete?id=${e}`),{success:o,data:i}=t;if(o)return i}catch(t){console.log("delModelById error:",t)}},createModel:async e=>{try{const t=await y.post("/create",e),{success:o,data:i}=t;if(o)return i}catch(t){console.log("createModel error:",t)}},updateModelById:async e=>{try{const t=await y.put("/update",e),{success:o,data:i}=t;if(o)return i}catch(t){console.log("updateModelById error:",t)}},getUseTypeList:async()=>{try{const e=await y.get("/getModelTypes"),{success:t,data:o}=e;if(t)return o}catch(e){return console.log("getUseTypeList error:",e),!1}},getModelProtocolsList:async()=>{try{const e=await y.get("/getModelProtocols"),{success:t,data:o}=e;if(t)return o}catch(e){return console.log("getModelProtocolsList error:",e),!1}}}},Fe=({drawerTitle:u,drawerVisible:C,modelInfo:p,handleDrawerClose:F,modelUseTypeOpt:y,modelProtocolsOpt:k,eventsEmit:g})=>{const[q,L]=w(!1),[d,x]=w(!1),e=P(()=>({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:k},{id:"type",name:"type",label:"\u4F7F\u7528\u7C7B\u578B",type:"select",required:!0,options:y,defaultValue:1,controlledItems:{1:["thinking"]}},{id:"dec",name:"dec",label:"\u8BF4\u660E",type:"textarea",required:!1},{id:"thinking",name:"thinking",label:"\u63A8\u7406\u601D\u8003\u5F00\u5173",type:"switch",required:!1,helpText:"\u5982\u679C\u60A8\u90E8\u7F72\u7684\u6A21\u578B\u672C\u8EAB\u5177\u6709\u63A8\u7406\u601D\u8003\u7684\u5F00\u5173\uFF0C\u60A8\u53EF\u4EE5\u6253\u5F00\u5F53\u524D\u5F00\u5173\u652F\u6301\u63A8\u7406\u601D\u8003\u80FD\u529B\uFF0C\u5982Qwen3"}]}),[p,y,k]),t=O(null),o=async(a,m,E)=>{var M;switch(console.log("[Form] eventsEmit:",a,m,E),a){case"form:ready":m.formRef&&(t.current=m.formRef);break;case"form:change":if(!((M=t.current)!=null&&M.getValue)){console.log("\u8868\u5355\u5F15\u7528\u672A\u5C31\u7EEA\uFF0C\u8DF3\u8FC7 formdata_onchange \u4E8B\u4EF6");return}const B=await t.current.getValue("type");B==2||B==3?x(!0):x(!1);break;default:console.log("\u672A\u5904\u7406\u7684\u4E8B\u4EF6:",a,m)}g==null||g(a,m,E)},i=async()=>{try{L(!0);const a=await t.current.getAllData();a.isValid&&(p!=null&&p.id?await g("form_submitted_edit",a,void 0):await g("form_submitted_add",a,void 0))}catch(a){console.error("\u274C \u63D0\u4EA4\u8868\u5355\u6570\u636E\u5931\u8D25:",a)}finally{L(!1)}},h=P(()=>{const a=p==null?void 0:p.data.reduce((m,E)=>(m[E.columnId]=E.value,m),{});return{label:"\u52A8\u6001\u8868\u5355\u793A\u4F8B",defaultActiveId:e.id,model:null,views:[{label:"\u7528\u6237\u6CE8\u518C\u8868\u5355",id:e.id,type:"form",size:"md",formWidth:e.formWidth,formConfig:{layout:e.layout,showReset:!1,showSubmit:!1,formWidth:e.formWidth}}],dataSource:[{id:e.id,fields:e.fields,defaultValues:a||{}}],eventsEmit:o}},[p,d,e]);return l(ne,{title:u,placement:"right",width:560,onClose:F,closeIcon:!1,extra:l(ie,{size:20,color:"#888888",onClick:F,className:"cursor-pointer"}),open:C,destroyOnHidden:!0,footer:Z("div",{className:"flex justify-end items-center gap-3",children:[l(z,{mode:"default",label:"\u53D6\u6D88",onClick:F}),l(z,{mode:"primary",label:"\u786E\u8BA4",loading:q,onClick:i})]}),children:l(X,{...h},"example-form")})},K={success:"green",error:"red",warning:"orange",processing:"blue",info:"cyan",default:"default"},N=[{statusType:"success",value:"\u53EF\u7528",status:1},{statusType:"error",value:"\u4E0D\u53EF\u7528",status:0}],fe=u=>typeof u=="string"&&u in K?K[u]:K.default;var V=(u=>(u[u.DATE=0]="DATE",u[u.VIEW=1]="VIEW",u[u.ERROR=2]="ERROR",u[u.AUTHORIZE=3]="AUTHORIZE",u[u.DELETE=4]="DELETE",u[u.ANALYSIS_OR_EXTRACT=5]="ANALYSIS_OR_EXTRACT",u[u.DOWNLOAD=6]="DOWNLOAD",u[u.EDIT=7]="EDIT",u[u.ADD=8]="ADD",u[u.ANALYSIS_CONFIG=9]="ANALYSIS_CONFIG",u[u.AUTHORIZE_CONFIG=10]="AUTHORIZE_CONFIG",u))(V||{});const{confirm:ye}=ce,ge={pageNum:1,pageSize:1e3},Ae=u=>{const{value:C,cell:p}=u,F=fe(u.cell.statusType);return C=="\u4E0D\u53EF\u7528"?l(Y,{title:p.errorMsg,children:l("div",{className:"flex items-center gap-2",children:l(G,{color:F,text:C})})}):l(G,{color:F,text:C})};function ke(u){const{url:C,token:p,role:F,CustomComponents:y,eventsEmit:k,getBtnDisabled:g}=u,[q,L]=w({container:"ready",content:"ready"}),d=O(null),[x,e]=w(),[t,o]=w(!1),[i,h]=w(""),[a,m]=w(),[E,M]=w([]),[B,S]=w([]),{getModelList:R,delModelById:J,createModel:Q,updateModelById:_,getUseTypeList:T,getModelProtocolsList:ee}=pe({url:C,token:p,role:F,eventsEmit:k});ae(()=>{L(n=>({...n,content:"loading"})),te()},[]);const ue=n=>(n||[]).map((s,b)=>{let r=N.find(A=>A.status==s.status);return{id:s.id,data:[{columnId:"modelName",value:s.modelName},{columnId:"modelProtocol",value:s.modelProtocol,type:"customized"},{columnId:"type",value:s.type,type:"customized"},{columnId:"dec",value:s.dec},{columnId:"status",...r,type:"customized",errorMsg:s.errorMsg},{columnId:"actions",value:"edit",label:"\u7F16\u8F91",type:"action",disabled:g&&g(V.EDIT,s.permission)},{columnId:"actions",value:"auth",label:"\u6388\u6743",type:"action",disabled:g&&g(V.AUTHORIZE,s.permission)},{columnId:"actions",value:"delete",label:"\u5220\u9664",type:"action",disabled:g&&g(V.AUTHORIZE,s.permission)},{columnId:"url",value:s.url},{columnId:"apiKey",value:s.apiKey},{columnId:"modelIde",value:s.modelIde},{columnId:"thinking",value:s.thinking}]}}),te=async()=>{try{const[n,s,b]=await Promise.allSettled([R(ge),T(),ee()]);if(n.status==="fulfilled"&&n.value){const r=ue(n.value.records);e(r||[]),L(A=>({...A,content:"ready"}))}s.status==="fulfilled"&&s.value&&M((s.value||[]).map(r=>({...r,value:Number(r.value)}))),b.status==="fulfilled"&&b.value&&S((b.value||[]).map(r=>({...r,value:Number(r.value)})))}catch(n){console.error("[TableApiError] getTableList:",n)}},se=P(()=>({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:n=>{var r;const{value:s}=n,b=(r=B.find(A=>A.value==s))==null?void 0:r.label;return l("span",{children:b})}},{id:"type",title:"\u4F7F\u7528\u7C7B\u578B",type:"customized",component:n=>{var r;const{value:s}=n,b=(r=E.find(A=>A.value==s))==null?void 0:r.label;return l("span",{children:b})}},{id:"dec",title:"\u8BF4\u660E",type:"paragraph"},{id:"status",title:"\u72B6\u6001",type:"customized",component:l(Ae,{}),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:n=>{const{value:s,cell:b,row:r}=n,{disabled:A,label:U}=b;return A?l(Y,{title:"\u89D2\u8272\u65E0\u6743\u9650\u64CD\u4F5C",children:l(z,{mode:"text",label:U,disabled:A})}):l(z,{mode:"text",label:U,onClick:()=>H(`table_action_${s}`,r,void 0)})}}],toolbar:[{type:"button",btnType:"primary",key:"add",label:"\u65B0\u5EFA",icon:l(de,{})}]}]}),[x,E,B]),oe=()=>Z("div",{className:"flex flex-col items-center justify-center h-full",children:[l("div",{className:"text-xl font-semibold mb-3",style:{color:"#374151"},children:l("img",{src:me,width:120})}),l("div",{className:"text-base mb-6",style:{color:"#6b7280"},children:"\u6682\u65E0\u6570\u636E\uFF0C\u8BF7\u5148\u65B0\u5EFA\u6A21\u578B"}),l("div",{className:"flex gap-3",children:l(z,{mode:"primary",label:"\u65B0\u5EFA\u6A21\u578B",onClick:()=>{h("\u65B0\u5EFA"),o(!0)}})})]});async function H(n,s,b){var r,A,U,$;switch(console.log("[adopter] mergedEventsEmit",n,s,b),n){case"toolbar_add":{h("\u65B0\u5EFA"),o(!0);break}case"table_action_delete":{try{const D=s.data.find(f=>f.columnId=="modelName").value;ye({title:"\u786E\u8BA4\u5220\u9664\uFF1F",content:`\u786E\u5B9A\u8981\u5220\u9664\u6A21\u578B \u201C${D}\u201D \u5417\uFF1F\u6B64\u64CD\u4F5C\u4E0D\u53EF\u6062\u590D\u3002`,okText:"\u5220\u9664",cancelText:"\u53D6\u6D88",async onOk(){await J(s.id)&&(d!=null&&d.current)&&(d==null||d.current.appFn.removeItem(s.id),j.success("\u5220\u9664\u6210\u529F"))}})}catch(D){console.error("\u5220\u9664\u8868\u6570\u636E\u5931\u8D25",D)}break}case"table_action_edit":{h("\u7F16\u8F91"),o(!0),m(s);break}case"form_submitted_add":{try{const D=s.fields.reduce((v,I)=>(v[I.name]=I.value,v),{}),f=await Q({...D});if(f){let v=N.find(c=>c.status==f.status);const I={id:f.id,data:[...(Object.keys(f)||[]).map(c=>({columnId:c,value:f[c],...(c=="modelProtocol"||c=="type")&&{type:"customized"},...c=="status"&&{...v,type:"customized",errorMsg:f.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"}]};(A=(r=d==null?void 0:d.current)==null?void 0:r.appFn)==null||A.addItem(I,{animate:!0,position:"start"}),j.success("\u6A21\u578B\u65B0\u589E\u6210\u529F\uFF01")}}catch(D){console.error("\u4FDD\u5B58\u5931\u8D25\uFF01",D)}finally{W()}break}case"form_submitted_edit":{try{const D=s.fields.reduce((v,I)=>(v[I.name]=I.value,v),{}),f=await _({...D,id:a.id});if(f){let v=N.find(c=>c.status==f.status);const I={...a,data:a.data.map(c=>{if(f[c.columnId]!==null&&f[c.columnId]!==void 0){if(c.columnId=="status")return{...c,...v};c.value=f[c.columnId]}return c})};($=(U=d==null?void 0:d.current)==null?void 0:U.appFn)==null||$.updateItem(I,a==null?void 0:a.id),j.success("\u6A21\u578B\u7F16\u8F91\u6210\u529F\uFF01")}}catch(D){console.error("\u4FDD\u5B58\u5931\u8D25\uFF01",D)}finally{W()}break}default:typeof u.eventsEmit=="function"&&u.eventsEmit(n,s);break}}const W=()=>{o(!1),m(void 0)};return Z(le,{title:"\u6A21\u578B\u7BA1\u7406",children:[l(X,{dataSource:x,ref:d,eventsEmit:H,status:q,CustomComponents:{EmptyData:oe,...y},...se}),l(Fe,{drawerTitle:i,drawerVisible:t,handleDrawerClose:W,modelInfo:a,modelUseTypeOpt:E,modelProtocolsOpt:B,eventsEmit:H})]})}export{ke as default};
|
|
1
|
+
import{jsx as o,jsxs as V}from"react/jsx-runtime";import{useState as h,useMemo as O,useRef as J,useEffect as Q}from"react";import{J as L,m as Ie}from"./assets/index-x8IlxRuv.js";import{b as Me,F as $,S as te,T as ee,i as se}from"./assets/index-g-SUxfJH.js";import{O as re}from"./assets/index-DwoTKC3G.js";import{D as ve}from"./assets/index-D72cKELw.js";import{X as we}from"./assets/x-CnaaLGJF.js";import{M as ne,s as j}from"./assets/style-CGmZ5osp.js";import{T as ke,B as ae}from"./assets/index-DdVFXD_y.js";/* empty css */import{P as xe}from"./assets/plus-V9zUoSq6.js";import"react-dom";const Le=""+new URL("assets/empty.png",import.meta.url).href,Se=({url:s,token:B,role:n,eventsEmit:p})=>{const m=Me.create({baseURL:s,timeout:1e6});return m.interceptors.request.use(e=>{let a=B;return!a&&!["user/login","user/kaptcha","user/regist"].some(r=>e.url.includes(r))?(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(C=>e.config.url&&e.config.url.includes(C))||u.size&&u.type)return u;const{success:r,errorMsg:A,errorCode:k}=u;return r?u:(p&&p("request:error_business",{errorCode:k,errorMsg:A||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",response:u}),!1)},e=>{var a,u,r,A,k,C,W,U,x;if(e.message==="canceled")return Promise.reject(e);if(p){let N="request:error_network",z={errorMsg:"\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25",error:e};((a=e==null?void 0:e.response)==null?void 0:a.status)===401?(N="request:error_auth",z={errorMsg:"\u6CA1\u6709\u8DB3\u591F\u6743\u9650",error:e,redirect:"/login"}):(((r=(u=e==null?void 0:e.response)==null?void 0:u.data)==null?void 0:r.errorCode)==="30013"||((k=(A=e==null?void 0:e.response)==null?void 0:A.data)==null?void 0:k.errorCode)==="30023")&&(N="request:error_business",z={errorCode:(W=(C=e==null?void 0:e.response)==null?void 0:C.data)==null?void 0:W.errorCode,errorMsg:((x=(U=e==null?void 0:e.response)==null?void 0:U.data)==null?void 0:x.message)||"\u8BF7\u6C42\u51FA\u9519\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5",error:e}),p(N,z)}return Promise.reject(e)}),{getModelList:async e=>{try{const a=await m.get(`/allPage?${new URLSearchParams(e).toString()}`),{success:u,data:r}=a;if(u)return r}catch(a){return console.log("getModelList error:",a),!1}},delModelById:async e=>{try{const a=await m.delete(`/delete?id=${e}`),{success:u,data:r}=a;if(u)return r}catch(a){console.log("delModelById error:",a)}},createModel:async e=>{try{const a=await m.post("/create",e),{success:u,data:r}=a;if(u)return r}catch(a){console.log("createModel error:",a)}},updateModelById:async e=>{try{const a=await m.put("/update",e),{success:u,data:r}=a;if(u)return r}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:r,data:A}=u;if(r)return A}catch(u){console.log("replaceModel error:",u)}},checkModel:async e=>{try{const a=await m.get(`/checkModelReference?modelName=${e}`),{success:u,data:r}=a;if(u)return r}catch(a){console.log("checkModelReference error:",a)}}}},Re=({drawerTitle:s,drawerVisible:B,modelInfo:n,handleDrawerClose:p,modelUseTypeOpt:m,modelProtocolsOpt:S,eventsEmit:c})=>{const[w,R]=h(!1),[f,E]=h(!1),g=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,controlledItems:{1:["thinking"]}},{id:"dec",name:"dec",label:"\u8BF4\u660E",type:"textarea",required:!1},{id:"thinking",name:"thinking",label:"\u63A8\u7406\u601D\u8003\u5F00\u5173",type:"switch",required:!1,helpText:"\u5982\u679C\u60A8\u90E8\u7F72\u7684\u6A21\u578B\u672C\u8EAB\u5177\u6709\u63A8\u7406\u601D\u8003\u7684\u5F00\u5173\uFF0C\u60A8\u53EF\u4EE5\u6253\u5F00\u5F53\u524D\u5F00\u5173\u652F\u6301\u63A8\u7406\u601D\u8003\u80FD\u529B\uFF0C\u5982Qwen3"}]}),[n,m,S]),d=J(null),q=async(u,r,A)=>{var k;switch(console.log("[Form] eventsEmit:",u,r,A),u){case"form:ready":r.formRef&&(d.current=r.formRef);break;case"form:change":if(!((k=d.current)!=null&&k.getValue)){console.log("\u8868\u5355\u5F15\u7528\u672A\u5C31\u7EEA\uFF0C\u8DF3\u8FC7 formdata_onchange \u4E8B\u4EF6");return}const C=await d.current.getValue("type");C==2||C==3?E(!0):E(!1);break;default:console.log("\u672A\u5904\u7406\u7684\u4E8B\u4EF6:",u,r)}c==null||c(u,r,A)},e=async()=>{try{R(!0);const u=await d.current.getAllData();u.isValid&&(n!=null&&n.id?await c("form_submitted_edit",u,void 0):await c("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((r,A)=>(r[A.columnId]=A.value,r),{});return{label:"\u52A8\u6001\u8868\u5355\u793A\u4F8B",defaultActiveId:g.id,model:null,views:[{label:"\u7528\u6237\u6CE8\u518C\u8868\u5355",id:g.id,type:"form",size:"md",formWidth:g.formWidth,formConfig:{layout:g.layout,showReset:!1,showSubmit:!1,formWidth:g.formWidth}}],dataSource:[{id:g.id,fields:g.fields,defaultValues:u||{}}],eventsEmit:q}},[n,f,g]);return o(ve,{title:s,placement:"right",width:560,onClose:p,closeIcon:!1,extra:o(we,{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:w,onClick:e})]}),children:o(re,{...a},"example-form")})},{Item:oe}=$,ze=({modelVisible:s,options:B,eventsEmit:n,replaceModel:p})=>{const[m,S]=h(!1),[c]=$.useForm(),w=$.useWatch("sourceModelId",c),R=O(()=>{const E=B.find(g=>g.value==w);return E?B.filter(d=>d.useType==E.useType&&d.value!==w&&d.status==1):[]},[w]);return Q(()=>{w&&c.setFieldValue("targetModelId",void 0)},[w]),V(ne,{open:s,title:"\u6A21\u578B\u66FF\u6362",width:620,destroyOnHidden:!0,onCancel:()=>{c.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:()=>{c.resetFields(),n&&n("close_model")}}),o(L,{mode:"primary",label:"\u786E\u8BA4",loading:m,onClick:async()=>{try{S(!0);const E=await c.validateFields(),{sourceModelId:g,targetModelId:d}=E;await p(g,d)&&(j.success("\u6A21\u578B\u66FF\u6362\u6210\u529F"),c.resetFields(),n&&n("replace_model"))}catch(E){console.log("e---->",E)}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:c,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})})]})]})},Y={success:"green",error:"red",warning:"orange",processing:"blue",info:"cyan",default:"default"},X=[{statusType:"success",value:"\u53EF\u7528",status:1},{statusType:"error",value:"\u4E0D\u53EF\u7528",status:0},{statusType:"warning",value:"\u68C0\u6D4B\u4E2D",status:2}],Ve=s=>typeof s=="string"&&s in Y?Y[s]:Y.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}=ne,qe={pageNum:1,pageSize:1e3},Ue=s=>{const{value:B,cell:n}=s,p=Ve(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 Ye(s){const{url:B,token:n,role:p,CustomComponents:m,eventsEmit:S,getBtnDisabled:c}=s,[w,R]=h({container:"ready",content:"ready"}),f=J(null),[E,g]=h(),d=J(null),[q,e]=h(!1),[a,u]=h(!1),[r,A]=h([]),[k,C]=h(!1),[W,U]=h(""),[x,N]=h(),[z,ce]=h([]),[Z,ie]=h([]),{getModelList:de,delModelById:Fe,createModel:me,updateModelById:pe,getUseTypeList:fe,getModelProtocolsList:ye,testStatus:ge,replaceModel:Ae,checkModel:Be}=Se({url:B,token:n,role:p,eventsEmit:S});Q(()=>{R(l=>({...l,content:"loading"})),P(),De()},[]),Q(()=>{},[k]);const Ee=l=>(l||[]).map((t,F)=>{let i=X.find(v=>v.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",...i,type:"customized",errorMsg:t.errorMsg},{columnId:"actions",value:"edit",label:"\u7F16\u8F91",status:t.status,type:"action",disabled:c&&c(K.EDIT,t.permission)},{columnId:"actions",value:"auth",label:"\u6388\u6743",type:"action",status:t.status,disabled:c&&c(K.AUTHORIZE,t.permission)},{columnId:"actions",value:"delete",label:"\u5220\u9664",type:"action",status:t.status,disabled:c&&c(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[l,t]=await Promise.allSettled([fe(),ye()]);l.status==="fulfilled"&&l.value&&ce((l.value||[]).map(F=>({...F,value:Number(F.value)}))),t.status==="fulfilled"&&t.value&&ie((t.value||[]).map(F=>({...F,value:Number(F.value)})))}catch(l){console.error("[TableApiError] getTableList:",l)}},ue=async()=>{try{const l=await de(qe);if(l.records){const t=Ee(l.records),F=(l.records||[]).map(i=>({value:i.id,label:i.modelName,useType:i.type,status:i.status}));return A(F),g(t||[]),R(i=>({...i,content:"ready"})),t||[]}}catch(l){console.error("[TableApiError] getTableList:",l)}},P=async()=>{const l=await ue();be(l||[])?d.current&&(clearTimeout(d.current),d.current=null):(d.current&&(clearTimeout(d.current),d.current=null),d.current=setTimeout(()=>{P()},5e3))};function be(l){if(!Array.isArray(l))return!0;for(const t of l)if(t.data){const F=t.data.find(i=>i.columnId==="status");if(F&&F.status===2)return!1}return!0}const he=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:l=>{var i;const{value:t}=l,F=(i=Z.find(v=>v.value==t))==null?void 0:i.label;return o("span",{children:F})}},{id:"type",title:"\u4F7F\u7528\u7C7B\u578B",type:"customized",component:l=>{var i;const{value:t}=l,F=(i=z.find(v=>v.value==t))==null?void 0:i.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:l=>{const{value:t,cell:F,row:i}=l,{disabled:v,label:T,status:_}=F;return _==2?o(ee,{title:"\u68C0\u6D4B\u4E2D\uFF0C\u8BF7\u7A0D\u540E",children:o(L,{mode:"text",label:T,disabled:!0})}):v?o(ee,{title:"\u89D2\u8272\u65E0\u6743\u9650\u64CD\u4F5C",children:o(L,{mode:"text",label:T,disabled:v})}):o(L,{mode:"text",label:T,onClick:()=>H(`table_action_${t}`,i,void 0)})}}],toolbar:[{type:"button",btnType:"primary",key:"add",label:"\u65B0\u5EFA",icon:o(xe,{})},{type:"customized",key:"test",render:()=>o(L,{loading:q,mode:"primary",label:"\u6A21\u578B\u72B6\u6001\u68C0\u6D4B",onClick:()=>{H("toolbar_test")}})},{type:"button",btnType:"primary",key:"replace",label:"\u6A21\u578B\u66FF\u6362"}]}]}),[E,z,Z,q]),Ce=()=>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:Le,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:()=>{U("\u65B0\u5EFA"),C(!0)}})})]});async function H(l,t,F){var i,v,T,_;switch(console.log("[adopter] mergedEventsEmit",l,t,F),l){case"toolbar_add":{U("\u65B0\u5EFA"),C(!0);break}case"toolbar_test":{e(!0),await ge()&&(e(!1),await P(),j.success("\u6A21\u578B\u68C0\u6D4B\u4E2D\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85\u72B6\u6001\u66F4\u65B0\uFF01"));break}case"toolbar_replace":{u(!0);break}case"table_action_delete":{try{const I=t.data.find(b=>b.columnId=="modelName").value;if(await Be(I)>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 Fe(t.id)&&(f!=null&&f.current)&&(f==null||f.current.appFn.removeItem(t.id),j.success("\u5220\u9664\u6210\u529F"))}})}}catch(I){console.error("\u5220\u9664\u8868\u6570\u636E\u5931\u8D25",I)}break}case"table_action_edit":{U("\u7F16\u8F91"),C(!0),N(t);break}case"form_submitted_add":{try{const I=t.fields.reduce((b,M)=>(b[M.name]=M.value,b),{}),D=await me({...I});if(D){let b=X.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"}]};(v=(i=f==null?void 0:f.current)==null?void 0:i.appFn)==null||v.addItem(M,{animate:!0,position:"start"}),j.success("\u6A21\u578B\u65B0\u589E\u6210\u529F\uFF01")}}catch(I){console.error("\u4FDD\u5B58\u5931\u8D25\uFF01",I)}finally{G()}break}case"form_submitted_edit":{try{const I=t.fields.reduce((b,M)=>(b[M.name]=M.value,b),{}),D=await pe({...I,id:x.id});if(D){let b=X.find(y=>y.status==D.status);const M={...x,data:x.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})};(_=(T=f==null?void 0:f.current)==null?void 0:T.appFn)==null||_.updateItem(M,x==null?void 0:x.id),j.success("\u6A21\u578B\u7F16\u8F91\u6210\u529F\uFF01")}}catch(I){console.error("\u4FDD\u5B58\u5931\u8D25\uFF01",I)}finally{G()}break}case"replace_model":{await ue(),u(!1);break}case"close_model":{u(!1);break}default:typeof s.eventsEmit=="function"&&s.eventsEmit(l,t);break}}const G=()=>{C(!1),N(void 0)};return V(Ie,{title:"\u6A21\u578B\u7BA1\u7406",children:[o(re,{dataSource:E,ref:f,eventsEmit:H,status:w,CustomComponents:{EmptyData:Ce,...m},styles:{theme:{...se,colors:{...se.colors,tableFirstColumnBg:"#ffffff",tableLastColumnBg:"#ffffff",paginationBackground:"#ffffff",subTableBackground:"#F5F5F5",tableHeaderBg:"#F5F5F5"}},mode:"light"},...he}),o(Re,{drawerTitle:W,drawerVisible:k,handleDrawerClose:G,modelInfo:x,modelUseTypeOpt:z,modelProtocolsOpt:Z,eventsEmit:H}),o(ze,{modelVisible:a,options:r,eventsEmit:H,replaceModel:Ae})]})}export{Ye 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": "1.
|
|
6
|
+
"version": "1.9.0",
|
|
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"
|
|
@@ -60,9 +64,5 @@
|
|
|
60
64
|
},
|
|
61
65
|
"./style.css": "./assets/style.css",
|
|
62
66
|
"./assets/style.css": "./assets/style.css"
|
|
63
|
-
},
|
|
64
|
-
"scripts": {
|
|
65
|
-
"test": "yarn link",
|
|
66
|
-
"disconnect": "yarn unlink"
|
|
67
67
|
}
|
|
68
|
-
}
|
|
68
|
+
}
|
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 _,useMemo as P}from"react";import{O as T}from"./assets/index-
|
|
1
|
+
import{jsx as c,jsxs as A}from"react/jsx-runtime";import{useState as E,useRef as z,useEffect as _,useMemo as P}from"react";import{O as T}from"./assets/index-DwoTKC3G.js";import{m as N,J as L}from"./assets/index-x8IlxRuv.js";import{b as O,F as h,I as W}from"./assets/index-g-SUxfJH.js";import{s as F,M as I}from"./assets/style-CGmZ5osp.js";import{P as j}from"./assets/plus-V9zUoSq6.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},R=({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});_(()=>{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=P(()=>({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(N,{title:"\u654F\u611F\u8BCD\u5E93\u7BA1\u7406",children:[c(T,{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{R as default};
|
package/streamFilesReader.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{G as d,B as f}from"./assets/GientechStreamReader-
|
|
1
|
+
import{G as d,B as f}from"./assets/GientechStreamReader-DqJjNXCO.js";import"react/jsx-runtime";import"react";import"./assets/index-g-SUxfJH.js";import"react-dom";import"./assets/index-BO-w4FPz.js";import"./assets/index-x8IlxRuv.js";import"./assets/index-BKe5FgcC.js";import"./assets/index-j0kQJd0a.js";import"./assets/x-CnaaLGJF.js";export{d as GientechStreamReader,f as registerPDFWorker};
|