bi-sdk-react 0.0.16 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/es/js/bi-sdk.es.js
CHANGED
|
@@ -316,7 +316,7 @@ import*as e from"react";import t,{css as l}from"styled-components";import{AlignC
|
|
|
316
316
|
.send-btn.send-btn-active {
|
|
317
317
|
background-color: var(--ant-color-primary);
|
|
318
318
|
}
|
|
319
|
-
`,tE=[],tD=[],tA=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","audio/wav"],tB=[".xlsx",".wav"],tR=e=>{let{open:t,onCancel:l,onOk:n,allowedExtensions:r,allowedMimeTypes:a}=e,[o,s]=(0,eO.useState)([]);(0,eO.useEffect)(()=>{t&&s([])},[t]);let d=[...tB,...tA].join(",");return(0,eN.jsxs)(q,{title:"上传文件",open:t,okText:"上传",cancelText:"取消",onOk:()=>{n(o),l()},onCancel:l,width:600,children:[(0,eN.jsx)("div",{style:{marginBottom:16},children:(0,eN.jsxs)(ec.Text,{type:"secondary",children:["支持的文件类型:",r.join(", "),(0,eN.jsx)("br",{}),"单次支持上传多个文件,请确保文件内容合规。",(0,eN.jsx)("br",{}),"Excel 暂不支持加密文件。",(0,eN.jsx)("br",{}),"不支持 xls 电子表格,请自行转换为 xlsx 格式。",(0,eN.jsx)("br",{}),"Excel 仅支持第一行为表头、第二行开始为数据,不支持合并单元格。"]})}),(0,eN.jsxs)(eu.Dragger,{...{name:"file",multiple:!0,accept:d,fileList:[],beforeUpload:e=>{let t=a.includes(e.type)||!e.type,l=(e.name||"").substring(e.name.lastIndexOf(".")).toLowerCase(),n=r.includes(l);return t||n?(s(t=>[...t,e]),!1):(ep.error(`不支持的文件类型: ${e.name}`),eu.LIST_IGNORE)}},children:[(0,eN.jsx)("p",{className:"ant-upload-drag-icon",children:(0,eN.jsx)(v,{})}),(0,eN.jsx)("p",{className:"ant-upload-text",children:"点击或将文件拖拽到此处上传"}),(0,eN.jsx)("p",{className:"ant-upload-hint",children:"支持上传Excel表格数据或音频文件进行分析"})]}),o.length>0&&(0,eN.jsxs)("div",{style:{marginTop:16},children:[(0,eN.jsxs)(ec.Title,{level:5,style:{fontSize:14,marginBottom:8},children:["已选文件 (",o.length,")"]}),(0,eN.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8,maxHeight:200,overflowY:"auto"},children:o.map((e,t)=>(0,eN.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",background:"#f5f5f5",borderRadius:4},children:[(0,eN.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[e.name.endsWith(".xlsx")?(0,eN.jsx)(h,{style:{color:"#52c41a"}}):(0,eN.jsx)(i,{style:{color:"#1890ff"}}),(0,eN.jsx)(ec.Text,{ellipsis:!0,style:{maxWidth:300},children:e.name}),(0,eN.jsxs)(ec.Text,{type:"secondary",style:{fontSize:12},children:["(",(e.size/1024).toFixed(1)," KB)"]})]}),(0,eN.jsx)(_,{type:"text",size:"small",icon:(0,eN.jsx)(c,{}),onClick:()=>{s(e=>e.filter((e,l)=>l!==t))},danger:!0})]},`${e.name}-${t}`))})]})]})},tL=eO.default.forwardRef((e,t)=>{let{value:l="",placeholder:n="请输入需求,例如:分析 2025 年人口结构并生成可视化报告",disabled:r=!1,sending:a=!1,rows:i=6,agentList:o=tE,agentId:s=null,attachments:d=tD,onInput:u,onSubmit:p,onUpdateAgentId:x,onUpdateAttachments:m,onUploading:h,style:f={}}=e,g=(0,eO.useRef)(null),[v,j]=(0,eO.useState)([]),[y,b]=(0,eO.useState)(l||""),[w,C]=(0,eO.useState)(0),[S,z]=(0,eO.useState)(Array.isArray(d)?d:[]),[k,I]=(0,eO.useState)(!1),N=(0,eO.useMemo)(()=>!1,[]);(0,eO.useImperativeHandle)(t,()=>({focus(){var e;null==(e=g.current)||e.focus()}})),(0,eO.useEffect)(()=>b(l||""),[l]),(0,eO.useEffect)(()=>{u&&u(y)},[y]),(0,eO.useEffect)(()=>z(Array.isArray(d)?d:[]),[d]);let T=!!(y&&y.trim()),E=async e=>{if(I(!1),!h||!e.length)return;let t=[];for(let l of e)try{let e=await h(l);e&&t.push({id:e.id,name:l.name,size:l.size})}catch(e){console.error(e)}z([...S,...t]),m&&m([...S,...t])},D=()=>{if(!T||a)return;let e=Date.now();if(e-w<400)return;C(e);let t=(y||"").trim();if(!t)return;let l={message:t,agents:v.map(e=>({id:e.id,name:e.name})),files:S.map(e=>({id:e.id,name:e.name,extension:e.name.substring(e.name.lastIndexOf("."))}))};p&&p(l),b("")},A=(0,eN.jsx)(tO,{children:(0,eN.jsx)("ul",{className:"agent-list",children:o.map(e=>(0,eN.jsx)("li",{children:(0,eN.jsx)("a",{onClick:()=>{let t;return t=e.id||null,void(x&&x(t),j(t=>[...t,e]))},children:e.name})},String(e.id)))})});return(0,eN.jsx)(tT,{style:f,children:(0,eN.jsxs)("div",{className:"chat-input",children:[(0,eN.jsxs)("div",{className:"input-stack",children:[S.length>0&&(0,eN.jsx)("div",{className:"attachment-bar",children:S.map(e=>(0,eN.jsxs)("div",{className:"attachment-card",children:[e.name.endsWith(".xlsx")?(0,eN.jsx)(tS,{type:"icon-excel"}):(0,eN.jsx)(tS,{type:"icon-audio"}),(0,eN.jsx)(ec.Text,{className:"name",ellipsis:{tooltip:e.name},children:e.name}),(0,eN.jsx)("a",{className:"remove",onClick:()=>{var t;let l;return t=e.id,void(z(l=S.filter(e=>e.id!==t)),m&&m(l))},children:(0,eN.jsx)(c,{})})]},e.id))}),v.length>0&&(0,eN.jsx)("div",{className:"agent-info",children:v.map((e,t)=>(0,eN.jsxs)("div",{children:[(0,eN.jsxs)("span",{className:"name",children:[(0,eN.jsx)(tS,{type:"icon-at"}),e.name]}),(0,eN.jsx)("a",{className:"remove",onClick:()=>{x&&x(null),j(e=>e.filter((e,l)=>l!==t))},children:"\xd7"})]},String(e.id)))}),(0,eN.jsx)(J.TextArea,{ref:g,className:"input textarea-stacked",placeholder:n,disabled:r||a,autoSize:{minRows:i,maxRows:i},value:y,onPressEnter:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),D()))},onChange:e=>b(e.target.value)})]}),(0,eN.jsxs)("div",{className:"footer",children:[(0,eN.jsxs)("div",{className:"left",children:[!!(null==o?void 0:o.length)&&(0,eN.jsx)(W,{trigger:["click"],popupRender:()=>A,placement:"topLeft",styles:{root:{boxShadow:"var(--ant-box-shadow-card)"}},children:(0,eN.jsx)(es,{title:"选择助理",children:(0,eN.jsx)(_,{className:"agent-trigger",onClick:e=>e.preventDefault(),children:(0,eN.jsx)(tS,{type:"icon-at"})})})}),h&&(0,eN.jsxs)(eN.Fragment,{children:[(0,eN.jsx)(es,{title:"上传文件",children:(0,eN.jsx)(_,{className:"attach-upload",onClick:()=>I(!0),disabled:r||a,children:(0,eN.jsx)(tS,{type:"icon-paper-clip"})})}),(0,eN.jsx)(tR,{open:k,onCancel:()=>I(!1),onOk:E,allowedExtensions:tB,allowedMimeTypes:tA})]})]}),(0,eN.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!N&&(0,eN.jsx)("div",{className:"tips",children:"按 Enter 发送,Shift+Enter 换行"}),(0,eN.jsx)("a",{className:`send-btn ${!a&&(null==y?void 0:y.length)>0?"send-btn-active":""}`,onClick:D,children:(0,eN.jsx)(O,{})})]})]})]})})}),t_=t.div`
|
|
319
|
+
`,tE=[],tD=[],tA=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","audio/wav"],tB=[".xlsx",".wav"],tR=e=>{let{open:t,onCancel:l,onOk:n,allowedExtensions:r,allowedMimeTypes:a}=e,[o,s]=(0,eO.useState)([]);(0,eO.useEffect)(()=>{t&&s([])},[t]);let d=[...tB,...tA].join(",");return(0,eN.jsxs)(q,{title:"上传文件",open:t,okText:"上传",cancelText:"取消",onOk:()=>{n(o),l()},onCancel:l,width:600,children:[(0,eN.jsx)("div",{style:{marginBottom:16},children:(0,eN.jsxs)(ec.Text,{type:"secondary",children:["支持的文件类型:",r.join(", "),(0,eN.jsx)("br",{}),"单次支持上传多个文件,请确保文件内容合规。",(0,eN.jsx)("br",{}),"Excel 暂不支持加密文件。",(0,eN.jsx)("br",{}),"不支持 xls 电子表格,请自行转换为 xlsx 格式。",(0,eN.jsx)("br",{}),"Excel 仅支持第一行为表头、第二行开始为数据,不支持合并单元格。"]})}),(0,eN.jsxs)(eu.Dragger,{...{name:"file",multiple:!0,accept:d,fileList:[],beforeUpload:e=>{let t=a.includes(e.type)||!e.type,l=(e.name||"").substring(e.name.lastIndexOf(".")).toLowerCase(),n=r.includes(l);return t||n?(s(t=>[...t,e]),!1):(ep.error(`不支持的文件类型: ${e.name}`),eu.LIST_IGNORE)}},children:[(0,eN.jsx)("p",{className:"ant-upload-drag-icon",children:(0,eN.jsx)(v,{})}),(0,eN.jsx)("p",{className:"ant-upload-text",children:"点击或将文件拖拽到此处上传"}),(0,eN.jsx)("p",{className:"ant-upload-hint",children:"支持上传Excel表格数据或音频文件进行分析"})]}),o.length>0&&(0,eN.jsxs)("div",{style:{marginTop:16},children:[(0,eN.jsxs)(ec.Title,{level:5,style:{fontSize:14,marginBottom:8},children:["已选文件 (",o.length,")"]}),(0,eN.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8,maxHeight:200,overflowY:"auto"},children:o.map((e,t)=>(0,eN.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",background:"#f5f5f5",borderRadius:4},children:[(0,eN.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[e.name.endsWith(".xlsx")?(0,eN.jsx)(h,{style:{color:"#52c41a"}}):(0,eN.jsx)(i,{style:{color:"#1890ff"}}),(0,eN.jsx)(ec.Text,{ellipsis:!0,style:{maxWidth:300},children:e.name}),(0,eN.jsxs)(ec.Text,{type:"secondary",style:{fontSize:12},children:["(",(e.size/1024).toFixed(1)," KB)"]})]}),(0,eN.jsx)(_,{type:"text",size:"small",icon:(0,eN.jsx)(c,{}),onClick:()=>{s(e=>e.filter((e,l)=>l!==t))},danger:!0})]},`${e.name}-${t}`))})]})]})},tL=eO.default.forwardRef((e,t)=>{let{value:l="",placeholder:n="请输入需求,例如:分析 2025 年人口结构并生成可视化报告",disabled:r=!1,sending:a=!1,rows:i=6,agentList:o=tE,agentId:s=null,attachments:d=tD,onInput:u,onSubmit:p,onUpdateAgentId:x,onUpdateAttachments:m,onUploading:h,style:f={}}=e,g=(0,eO.useRef)(null),[v,j]=(0,eO.useState)([]),[y,b]=(0,eO.useState)(l||""),[w,C]=(0,eO.useState)(0),[S,z]=(0,eO.useState)(Array.isArray(d)?d:[]),[k,I]=(0,eO.useState)(!1),N=(0,eO.useMemo)(()=>!1,[]);(0,eO.useImperativeHandle)(t,()=>({focus(){var e;null==(e=g.current)||e.focus()}})),(0,eO.useEffect)(()=>b(l||""),[l]),(0,eO.useEffect)(()=>{u&&u(y)},[y]),(0,eO.useEffect)(()=>z(Array.isArray(d)?d:[]),[d]);let T=!!(y&&y.trim()),E=async e=>{if(I(!1),!h||!e.length)return;let t=[];for(let l of e)try{let e=await h(l);e&&t.push({id:e.id,name:l.name,size:l.size})}catch(e){console.error(e)}z([...S,...t]),m&&m([...S,...t])},D=()=>{if(!T||a)return;let e=Date.now();if(e-w<400)return;C(e);let t=(y||"").trim();if(!t)return;let l={message:t,agents:v.map(e=>({id:e.id,name:e.name})),files:S.map(e=>({id:e.id,name:e.name,extension:e.name.substring(e.name.lastIndexOf("."))}))};p&&p(l),b(""),z([])},A=(0,eN.jsx)(tO,{children:(0,eN.jsx)("ul",{className:"agent-list",children:o.map(e=>(0,eN.jsx)("li",{children:(0,eN.jsx)("a",{onClick:()=>{let t;return t=e.id||null,void(x&&x(t),j(t=>[...t,e]))},children:e.name})},String(e.id)))})});return(0,eN.jsx)(tT,{style:f,children:(0,eN.jsxs)("div",{className:"chat-input",children:[(0,eN.jsxs)("div",{className:"input-stack",children:[S.length>0&&(0,eN.jsx)("div",{className:"attachment-bar",children:S.map(e=>(0,eN.jsxs)("div",{className:"attachment-card",children:[e.name.endsWith(".xlsx")?(0,eN.jsx)(tS,{type:"icon-excel"}):(0,eN.jsx)(tS,{type:"icon-audio"}),(0,eN.jsx)(ec.Text,{className:"name",ellipsis:{tooltip:e.name},children:e.name}),(0,eN.jsx)("a",{className:"remove",onClick:()=>{var t;let l;return t=e.id,void(z(l=S.filter(e=>e.id!==t)),m&&m(l))},children:(0,eN.jsx)(c,{})})]},e.id))}),v.length>0&&(0,eN.jsx)("div",{className:"agent-info",children:v.map((e,t)=>(0,eN.jsxs)("div",{children:[(0,eN.jsxs)("span",{className:"name",children:[(0,eN.jsx)(tS,{type:"icon-at"}),e.name]}),(0,eN.jsx)("a",{className:"remove",onClick:()=>{x&&x(null),j(e=>e.filter((e,l)=>l!==t))},children:"\xd7"})]},String(e.id)))}),(0,eN.jsx)(J.TextArea,{ref:g,className:"input textarea-stacked",placeholder:n,disabled:r||a,autoSize:{minRows:i,maxRows:i},value:y,onPressEnter:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),D()))},onChange:e=>b(e.target.value)})]}),(0,eN.jsxs)("div",{className:"footer",children:[(0,eN.jsxs)("div",{className:"left",children:[!!(null==o?void 0:o.length)&&(0,eN.jsx)(W,{trigger:["click"],popupRender:()=>A,placement:"topLeft",styles:{root:{boxShadow:"var(--ant-box-shadow-card)"}},children:(0,eN.jsx)(es,{title:"选择助理",children:(0,eN.jsx)(_,{className:"agent-trigger",onClick:e=>e.preventDefault(),children:(0,eN.jsx)(tS,{type:"icon-at"})})})}),h&&(0,eN.jsxs)(eN.Fragment,{children:[(0,eN.jsx)(es,{title:"上传文件",children:(0,eN.jsx)(_,{className:"attach-upload",onClick:()=>I(!0),disabled:r||a,children:(0,eN.jsx)(tS,{type:"icon-paper-clip"})})}),(0,eN.jsx)(tR,{open:k,onCancel:()=>I(!1),onOk:E,allowedExtensions:tB,allowedMimeTypes:tA})]})]}),(0,eN.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!N&&(0,eN.jsx)("div",{className:"tips",children:"按 Enter 发送,Shift+Enter 换行"}),(0,eN.jsx)("a",{className:`send-btn ${!a&&(null==y?void 0:y.length)>0?"send-btn-active":""}`,onClick:D,children:(0,eN.jsx)(O,{})})]})]})]})})}),t_=t.div`
|
|
320
320
|
width: 100%;
|
|
321
321
|
padding: 0 12px;
|
|
322
322
|
border-bottom: solid 1px #e8e8e8;
|
|
@@ -316,7 +316,7 @@
|
|
|
316
316
|
.send-btn.send-btn-active {
|
|
317
317
|
background-color: var(--ant-color-primary);
|
|
318
318
|
}
|
|
319
|
-
`,eR=[],eF=[],eD=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","audio/wav"],eE=[".xlsx",".wav"],eA=e=>{let{open:t,onCancel:l,onOk:n,allowedExtensions:r,allowedMimeTypes:a}=e,[i,o]=(0,p.useState)([]);(0,p.useEffect)(()=>{t&&o([])},[t]);let s=[...eE,...eD].join(",");return(0,d.jsxs)(ey.Modal,{title:"上传文件",open:t,okText:"上传",cancelText:"取消",onOk:()=>{n(i),l()},onCancel:l,width:600,children:[(0,d.jsx)("div",{style:{marginBottom:16},children:(0,d.jsxs)(ey.Typography.Text,{type:"secondary",children:["支持的文件类型:",r.join(", "),(0,d.jsx)("br",{}),"单次支持上传多个文件,请确保文件内容合规。",(0,d.jsx)("br",{}),"Excel 暂不支持加密文件。",(0,d.jsx)("br",{}),"不支持 xls 电子表格,请自行转换为 xlsx 格式。",(0,d.jsx)("br",{}),"Excel 仅支持第一行为表头、第二行开始为数据,不支持合并单元格。"]})}),(0,d.jsxs)(ey.Upload.Dragger,{...{name:"file",multiple:!0,accept:s,fileList:[],beforeUpload:e=>{let t=a.includes(e.type)||!e.type,l=(e.name||"").substring(e.name.lastIndexOf(".")).toLowerCase(),n=r.includes(l);return t||n?(o(t=>[...t,e]),!1):(ey.message.error(`不支持的文件类型: ${e.name}`),ey.Upload.LIST_IGNORE)}},children:[(0,d.jsx)("p",{className:"ant-upload-drag-icon",children:(0,d.jsx)(ej.InboxOutlined,{})}),(0,d.jsx)("p",{className:"ant-upload-text",children:"点击或将文件拖拽到此处上传"}),(0,d.jsx)("p",{className:"ant-upload-hint",children:"支持上传Excel表格数据或音频文件进行分析"})]}),i.length>0&&(0,d.jsxs)("div",{style:{marginTop:16},children:[(0,d.jsxs)(ey.Typography.Title,{level:5,style:{fontSize:14,marginBottom:8},children:["已选文件 (",i.length,")"]}),(0,d.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8,maxHeight:200,overflowY:"auto"},children:i.map((e,t)=>(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",background:"#f5f5f5",borderRadius:4},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[e.name.endsWith(".xlsx")?(0,d.jsx)(ej.FileExcelOutlined,{style:{color:"#52c41a"}}):(0,d.jsx)(ej.AudioOutlined,{style:{color:"#1890ff"}}),(0,d.jsx)(ey.Typography.Text,{ellipsis:!0,style:{maxWidth:300},children:e.name}),(0,d.jsxs)(ey.Typography.Text,{type:"secondary",style:{fontSize:12},children:["(",(e.size/1024).toFixed(1)," KB)"]})]}),(0,d.jsx)(ey.Button,{type:"text",size:"small",icon:(0,d.jsx)(ej.DeleteOutlined,{}),onClick:()=>{o(e=>e.filter((e,l)=>l!==t))},danger:!0})]},`${e.name}-${t}`))})]})]})},eB=m().forwardRef((e,t)=>{let{value:l="",placeholder:n="请输入需求,例如:分析 2025 年人口结构并生成可视化报告",disabled:r=!1,sending:a=!1,rows:i=6,agentList:o=eR,agentId:s=null,attachments:c=eF,onInput:u,onSubmit:m,onUpdateAgentId:x,onUpdateAttachments:h,onUploading:f,style:g={}}=e,v=(0,p.useRef)(null),[j,y]=(0,p.useState)([]),[b,w]=(0,p.useState)(l||""),[C,S]=(0,p.useState)(0),[I,z]=(0,p.useState)(Array.isArray(c)?c:[]),[k,O]=(0,p.useState)(!1),N=(0,p.useMemo)(()=>!1,[]);(0,p.useImperativeHandle)(t,()=>({focus(){var e;null==(e=v.current)||e.focus()}})),(0,p.useEffect)(()=>w(l||""),[l]),(0,p.useEffect)(()=>{u&&u(b)},[b]),(0,p.useEffect)(()=>z(Array.isArray(c)?c:[]),[c]);let T=!!(b&&b.trim()),R=async e=>{if(O(!1),!f||!e.length)return;let t=[];for(let l of e)try{let e=await f(l);e&&t.push({id:e.id,name:l.name,size:l.size})}catch(e){console.error(e)}z([...I,...t]),h&&h([...I,...t])},F=()=>{if(!T||a)return;let e=Date.now();if(e-C<400)return;S(e);let t=(b||"").trim();if(!t)return;let l={message:t,agents:j.map(e=>({id:e.id,name:e.name})),files:I.map(e=>({id:e.id,name:e.name,extension:e.name.substring(e.name.lastIndexOf("."))}))};m&&m(l),w("")},D=(0,d.jsx)(eN,{children:(0,d.jsx)("ul",{className:"agent-list",children:o.map(e=>(0,d.jsx)("li",{children:(0,d.jsx)("a",{onClick:()=>{let t;return t=e.id||null,void(x&&x(t),y(t=>[...t,e]))},children:e.name})},String(e.id)))})});return(0,d.jsx)(eT,{style:g,children:(0,d.jsxs)("div",{className:"chat-input",children:[(0,d.jsxs)("div",{className:"input-stack",children:[I.length>0&&(0,d.jsx)("div",{className:"attachment-bar",children:I.map(e=>(0,d.jsxs)("div",{className:"attachment-card",children:[e.name.endsWith(".xlsx")?(0,d.jsx)(ew,{type:"icon-excel"}):(0,d.jsx)(ew,{type:"icon-audio"}),(0,d.jsx)(ey.Typography.Text,{className:"name",ellipsis:{tooltip:e.name},children:e.name}),(0,d.jsx)("a",{className:"remove",onClick:()=>{var t;let l;return t=e.id,void(z(l=I.filter(e=>e.id!==t)),h&&h(l))},children:(0,d.jsx)(ej.DeleteOutlined,{})})]},e.id))}),j.length>0&&(0,d.jsx)("div",{className:"agent-info",children:j.map((e,t)=>(0,d.jsxs)("div",{children:[(0,d.jsxs)("span",{className:"name",children:[(0,d.jsx)(ew,{type:"icon-at"}),e.name]}),(0,d.jsx)("a",{className:"remove",onClick:()=>{x&&x(null),y(e=>e.filter((e,l)=>l!==t))},children:"\xd7"})]},String(e.id)))}),(0,d.jsx)(ey.Input.TextArea,{ref:v,className:"input textarea-stacked",placeholder:n,disabled:r||a,autoSize:{minRows:i,maxRows:i},value:b,onPressEnter:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),F()))},onChange:e=>w(e.target.value)})]}),(0,d.jsxs)("div",{className:"footer",children:[(0,d.jsxs)("div",{className:"left",children:[!!(null==o?void 0:o.length)&&(0,d.jsx)(ey.Dropdown,{trigger:["click"],popupRender:()=>D,placement:"topLeft",styles:{root:{boxShadow:"var(--ant-box-shadow-card)"}},children:(0,d.jsx)(ey.Tooltip,{title:"选择助理",children:(0,d.jsx)(ey.Button,{className:"agent-trigger",onClick:e=>e.preventDefault(),children:(0,d.jsx)(ew,{type:"icon-at"})})})}),f&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ey.Tooltip,{title:"上传文件",children:(0,d.jsx)(ey.Button,{className:"attach-upload",onClick:()=>O(!0),disabled:r||a,children:(0,d.jsx)(ew,{type:"icon-paper-clip"})})}),(0,d.jsx)(eA,{open:k,onCancel:()=>O(!1),onOk:R,allowedExtensions:eE,allowedMimeTypes:eD})]})]}),(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!N&&(0,d.jsx)("div",{className:"tips",children:"按 Enter 发送,Shift+Enter 换行"}),(0,d.jsx)("a",{className:`send-btn ${!a&&(null==b?void 0:b.length)>0?"send-btn-active":""}`,onClick:F,children:(0,d.jsx)(ej.SendOutlined,{})})]})]})]})})}),eM=h().div`
|
|
319
|
+
`,eR=[],eF=[],eD=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","audio/wav"],eE=[".xlsx",".wav"],eA=e=>{let{open:t,onCancel:l,onOk:n,allowedExtensions:r,allowedMimeTypes:a}=e,[i,o]=(0,p.useState)([]);(0,p.useEffect)(()=>{t&&o([])},[t]);let s=[...eE,...eD].join(",");return(0,d.jsxs)(ey.Modal,{title:"上传文件",open:t,okText:"上传",cancelText:"取消",onOk:()=>{n(i),l()},onCancel:l,width:600,children:[(0,d.jsx)("div",{style:{marginBottom:16},children:(0,d.jsxs)(ey.Typography.Text,{type:"secondary",children:["支持的文件类型:",r.join(", "),(0,d.jsx)("br",{}),"单次支持上传多个文件,请确保文件内容合规。",(0,d.jsx)("br",{}),"Excel 暂不支持加密文件。",(0,d.jsx)("br",{}),"不支持 xls 电子表格,请自行转换为 xlsx 格式。",(0,d.jsx)("br",{}),"Excel 仅支持第一行为表头、第二行开始为数据,不支持合并单元格。"]})}),(0,d.jsxs)(ey.Upload.Dragger,{...{name:"file",multiple:!0,accept:s,fileList:[],beforeUpload:e=>{let t=a.includes(e.type)||!e.type,l=(e.name||"").substring(e.name.lastIndexOf(".")).toLowerCase(),n=r.includes(l);return t||n?(o(t=>[...t,e]),!1):(ey.message.error(`不支持的文件类型: ${e.name}`),ey.Upload.LIST_IGNORE)}},children:[(0,d.jsx)("p",{className:"ant-upload-drag-icon",children:(0,d.jsx)(ej.InboxOutlined,{})}),(0,d.jsx)("p",{className:"ant-upload-text",children:"点击或将文件拖拽到此处上传"}),(0,d.jsx)("p",{className:"ant-upload-hint",children:"支持上传Excel表格数据或音频文件进行分析"})]}),i.length>0&&(0,d.jsxs)("div",{style:{marginTop:16},children:[(0,d.jsxs)(ey.Typography.Title,{level:5,style:{fontSize:14,marginBottom:8},children:["已选文件 (",i.length,")"]}),(0,d.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8,maxHeight:200,overflowY:"auto"},children:i.map((e,t)=>(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",background:"#f5f5f5",borderRadius:4},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[e.name.endsWith(".xlsx")?(0,d.jsx)(ej.FileExcelOutlined,{style:{color:"#52c41a"}}):(0,d.jsx)(ej.AudioOutlined,{style:{color:"#1890ff"}}),(0,d.jsx)(ey.Typography.Text,{ellipsis:!0,style:{maxWidth:300},children:e.name}),(0,d.jsxs)(ey.Typography.Text,{type:"secondary",style:{fontSize:12},children:["(",(e.size/1024).toFixed(1)," KB)"]})]}),(0,d.jsx)(ey.Button,{type:"text",size:"small",icon:(0,d.jsx)(ej.DeleteOutlined,{}),onClick:()=>{o(e=>e.filter((e,l)=>l!==t))},danger:!0})]},`${e.name}-${t}`))})]})]})},eB=m().forwardRef((e,t)=>{let{value:l="",placeholder:n="请输入需求,例如:分析 2025 年人口结构并生成可视化报告",disabled:r=!1,sending:a=!1,rows:i=6,agentList:o=eR,agentId:s=null,attachments:c=eF,onInput:u,onSubmit:m,onUpdateAgentId:x,onUpdateAttachments:h,onUploading:f,style:g={}}=e,v=(0,p.useRef)(null),[j,y]=(0,p.useState)([]),[b,w]=(0,p.useState)(l||""),[C,S]=(0,p.useState)(0),[I,z]=(0,p.useState)(Array.isArray(c)?c:[]),[k,O]=(0,p.useState)(!1),N=(0,p.useMemo)(()=>!1,[]);(0,p.useImperativeHandle)(t,()=>({focus(){var e;null==(e=v.current)||e.focus()}})),(0,p.useEffect)(()=>w(l||""),[l]),(0,p.useEffect)(()=>{u&&u(b)},[b]),(0,p.useEffect)(()=>z(Array.isArray(c)?c:[]),[c]);let T=!!(b&&b.trim()),R=async e=>{if(O(!1),!f||!e.length)return;let t=[];for(let l of e)try{let e=await f(l);e&&t.push({id:e.id,name:l.name,size:l.size})}catch(e){console.error(e)}z([...I,...t]),h&&h([...I,...t])},F=()=>{if(!T||a)return;let e=Date.now();if(e-C<400)return;S(e);let t=(b||"").trim();if(!t)return;let l={message:t,agents:j.map(e=>({id:e.id,name:e.name})),files:I.map(e=>({id:e.id,name:e.name,extension:e.name.substring(e.name.lastIndexOf("."))}))};m&&m(l),w(""),z([])},D=(0,d.jsx)(eN,{children:(0,d.jsx)("ul",{className:"agent-list",children:o.map(e=>(0,d.jsx)("li",{children:(0,d.jsx)("a",{onClick:()=>{let t;return t=e.id||null,void(x&&x(t),y(t=>[...t,e]))},children:e.name})},String(e.id)))})});return(0,d.jsx)(eT,{style:g,children:(0,d.jsxs)("div",{className:"chat-input",children:[(0,d.jsxs)("div",{className:"input-stack",children:[I.length>0&&(0,d.jsx)("div",{className:"attachment-bar",children:I.map(e=>(0,d.jsxs)("div",{className:"attachment-card",children:[e.name.endsWith(".xlsx")?(0,d.jsx)(ew,{type:"icon-excel"}):(0,d.jsx)(ew,{type:"icon-audio"}),(0,d.jsx)(ey.Typography.Text,{className:"name",ellipsis:{tooltip:e.name},children:e.name}),(0,d.jsx)("a",{className:"remove",onClick:()=>{var t;let l;return t=e.id,void(z(l=I.filter(e=>e.id!==t)),h&&h(l))},children:(0,d.jsx)(ej.DeleteOutlined,{})})]},e.id))}),j.length>0&&(0,d.jsx)("div",{className:"agent-info",children:j.map((e,t)=>(0,d.jsxs)("div",{children:[(0,d.jsxs)("span",{className:"name",children:[(0,d.jsx)(ew,{type:"icon-at"}),e.name]}),(0,d.jsx)("a",{className:"remove",onClick:()=>{x&&x(null),y(e=>e.filter((e,l)=>l!==t))},children:"\xd7"})]},String(e.id)))}),(0,d.jsx)(ey.Input.TextArea,{ref:v,className:"input textarea-stacked",placeholder:n,disabled:r||a,autoSize:{minRows:i,maxRows:i},value:b,onPressEnter:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),F()))},onChange:e=>w(e.target.value)})]}),(0,d.jsxs)("div",{className:"footer",children:[(0,d.jsxs)("div",{className:"left",children:[!!(null==o?void 0:o.length)&&(0,d.jsx)(ey.Dropdown,{trigger:["click"],popupRender:()=>D,placement:"topLeft",styles:{root:{boxShadow:"var(--ant-box-shadow-card)"}},children:(0,d.jsx)(ey.Tooltip,{title:"选择助理",children:(0,d.jsx)(ey.Button,{className:"agent-trigger",onClick:e=>e.preventDefault(),children:(0,d.jsx)(ew,{type:"icon-at"})})})}),f&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ey.Tooltip,{title:"上传文件",children:(0,d.jsx)(ey.Button,{className:"attach-upload",onClick:()=>O(!0),disabled:r||a,children:(0,d.jsx)(ew,{type:"icon-paper-clip"})})}),(0,d.jsx)(eA,{open:k,onCancel:()=>O(!1),onOk:R,allowedExtensions:eE,allowedMimeTypes:eD})]})]}),(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!N&&(0,d.jsx)("div",{className:"tips",children:"按 Enter 发送,Shift+Enter 换行"}),(0,d.jsx)("a",{className:`send-btn ${!a&&(null==b?void 0:b.length)>0?"send-btn-active":""}`,onClick:F,children:(0,d.jsx)(ej.SendOutlined,{})})]})]})]})})}),eM=h().div`
|
|
320
320
|
width: 100%;
|
|
321
321
|
padding: 0 12px;
|
|
322
322
|
border-bottom: solid 1px #e8e8e8;
|
package/package.json
CHANGED