filecat 6.43.5 → 6.44.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/build/dist/{1472.f20c53a82b6c833b8456.js → 1472.7f06129bac68ad0b2cf3.js} +1 -1
- package/build/dist/{2674.570467c7d8e3378316cc.js → 2674.79672d4369bb7a384e04.js} +1 -1
- package/build/dist/4273.2f3c957012fa1d0c4747.js +1 -0
- package/build/dist/678.440a73a4b64c078cfb94.js +1 -0
- package/build/dist/index.html +1 -1
- package/build/dist/{main.f11583a8a8ed406175ad.js → main.0b5d3cea9208fae2823e.js} +2 -2
- package/build/main.js +1 -1
- package/package.json +1 -1
- package/build/dist/4273.e76b9fa59b4c7cc1c655.js +0 -1
- package/build/dist/678.3cd977536dffed60a0e4.js +0 -1
- /package/build/dist/{main.f11583a8a8ed406175ad.js.LICENSE.txt → main.0b5d3cea9208fae2823e.js.LICENSE.txt} +0 -0
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[4273],{77481(e,n,t){t.d(n,{S:()=>r,X:()=>l});var s=t(96540),i=t(74848);function l(e){const[n,t]=s.useState([]);return(0,s.useEffect)(()=>{e.children?t(Array.isArray(e.children)?e.children:[e.children]):t(e.rows)},[e.rows,e.children]),(0,i.jsxs)("table",{children:[(0,i.jsx)("thead",{children:(0,i.jsx)("tr",{children:e.headers?.map((e,n)=>(0,i.jsx)("th",{children:e},n))})}),(0,i.jsx)("tbody",{children:n.map((n,t)=>(0,i.jsx)("tr",{onContextMenu:()=>{e.handleContextMenu&&e.handleContextMenu(n)},children:n.map((t,s)=>(0,i.jsx)("td",{style:{width:e.width??"auto"},className:s===n.length-1?"small":"",children:t},s))},t))})]})}function r(e){return(0,i.jsx)("div",{style:{display:e.isFlex?"flex":"block"},children:e.columns.map((e,n)=>(0,i.jsx)("div",{children:e},n))})}},94273(e,n,t){t.r(n),t.d(n,{default:()=>K});var s=t(96540),i=t(75725),l=t(22022),r=t(70447),c=t(85997),o=t(77481),a=t(61443),d=t(14284),_=t(53459),x=t(7523),h=t(34843),p=t(82893),u=t(62042),j=(t(23430),t(21499),t(14944)),m=t(92275),v=t(6960),f=t(40505),g=t(57952),y=t(24659),S=t(74848);let w={};function C(){const{t:e,i18n:n}=(0,l.Bd)(),{initUserInfo:t,reloadUserInfo:C}=(0,s.useContext)(x.F),[I,k]=(0,h.fp)(p.AG.user_base_info),[b,A]=(0,s.useState)([]),[P,$]=(0,h.fp)(p.AG.prompt_card),F=(0,y.K)(),[K,U]=(0,s.useState)(),[N,G]=(0,s.useState)(void 0),[B,X]=(0,s.useState)([]),[M,Z]=(0,s.useState)([]),E=[e("序号"),e("名称"),e("在线状态"),e("时间"),e("备注")],V=[e("序号"),e("服务端口"),e("转发ip"),e("转发端口"),e("开启"),e("备注")],q=[e("序号"),e("服务端口"),e("转发Client名称"),e("转发ip"),e("转发端口"),e("开启"),e("备注")],z=e=>null==e?"":(0,v.s)(e),H=async e=>{const n=await d.s9.post("server_bridge_get_one_fig",{server_client_num_id:e});if(n.code===_.m.Success){const e=n.data;for(const n of e)n.client_name=w?.[n.client_num_id]?.client_name??"";Z(e)}},L=async()=>{const e=await d.s9.get("server_client_get");if(e.code===_.m.Success){const n=e.data,t=[],s=[];w={};for(const e of n)N?`${e.index}${e.client_name}${e.note}`.includes(N)&&t.push(e):t.push(e),s.push({label:e.client_name,value:e.client_num_id}),w[e.client_num_id]=e;A(t),X(s)}};(0,s.useEffect)(()=>{j.ws.addMsg(m.HK.tcp_forward_server_load,e=>{L()}),L()},[]);return(0,S.jsxs)(s.Fragment,{children:[(0,S.jsx)(g.A,{children:K&&(0,S.jsx)("span",{children:`${K.client_name}${K.note?`(${K.note})`:""}`})}),(0,S.jsxs)(i.fI,{children:[(0,S.jsx)(i.VP,{widthPer:50,children:(0,S.jsx)(i.xh,{children:(0,S.jsx)(r.uF,{self_title:(0,S.jsx)("span",{className:" div-row ",children:(0,S.jsx)("h2",{children:e("客户端列表")})}),titleCom:(0,S.jsx)(a.Sm,{placeholder:e("过滤"),value:N,handleInputChange:e=>{G(e)},handlerEnter:()=>{L()}}),children:(0,S.jsx)(o.X,{headers:E,rows:b.map((n,t)=>[(0,S.jsx)("p",{children:t}),(0,S.jsx)(r.xP,{children:n.client_name}),(0,S.jsx)(r.fq,{ok:n.status}),(0,S.jsx)(r.xP,{children:z(n.status?n.online_start_time:n.offline_time)}),(0,S.jsx)(r.xP,{children:n.note}),(0,S.jsxs)("div",{children:[(0,S.jsx)(c.rA,{icon:"edit",title:e("编辑"),onClick:()=>{U({...n}),H(n.client_num_id)}}),(0,S.jsx)(c.rA,{icon:"delete",title:e("删除"),onClick:()=>{$({open:!0,title:"share file",confirm:async()=>{$({open:!1}),await(async e=>{(await d.s9.post("server_client_del",{client_num_id:e})).code===_.m.Success&&((0,u.SK)("成功"),L())})(n.client_num_id)},context_div:(0,S.jsx)("div",{className:"card-content",children:e("确定删除这个吗客户端吗?")})})}})]})]),width:"10rem"})})})}),(0,S.jsx)(i.VP,{widthPer:50,children:K?(0,S.jsxs)(i.xh,{children:[(0,S.jsxs)(r.Zp,{self_title:(0,S.jsxs)("span",{className:" div-row ",children:[(0,S.jsx)("h2",{children:e("代理配置")})," "]}),rightBottomCom:(0,S.jsx)("div",{children:(0,S.jsx)(c.rA,{icon:"save",title:e("保存"),onClick:async()=>{(await d.s9.post("server_client_save",K)).code===_.m.Success&&(0,u.SK)("成功")}})}),children:[(0,S.jsx)(i.Yh,{left:e("远程地址"),center:K?.client_remote_address??""}),(0,S.jsx)(i.Yh,{left:e(K?.status?"在线时间":"离线时间"),center:z(K?.status?K?.online_start_time:K?.offline_time)}),(0,S.jsx)(a.Sm,{placeholder:"名称",value:K.client_name,handleInputChange:e=>{K.client_name=e,U({...K})}}),(0,S.jsxs)("form",{children:[e("filecat代理访问"),":",(0,S.jsx)(o.S,{isFlex:!0,columns:[(0,S.jsx)(a.U6,{value:1,context:e("开启"),selected:K.open_filecat,onchange:()=>{K.open_filecat=!K.open_filecat,U({...K})}}),(0,S.jsx)(a.U6,{value:1,context:e("关闭"),selected:!K.open_filecat,onchange:()=>{K.open_filecat=!K.open_filecat,U({...K})}})]})]}),K.open_filecat&&(0,S.jsxs)(s.Fragment,{children:[(0,S.jsxs)("form",{children:[e("filecat代理访问使用服务器前端"),":",(0,S.jsx)(o.S,{isFlex:!0,columns:[(0,S.jsx)(a.U6,{value:1,context:e("开启"),selected:K.filecat_use_local_page,onchange:()=>{K.filecat_use_local_page=!K.filecat_use_local_page,U({...K})}}),(0,S.jsx)(a.U6,{value:1,context:e("关闭"),selected:!K.filecat_use_local_page,onchange:()=>{K.filecat_use_local_page=!K.filecat_use_local_page,U({...K})}})]})]}),(0,S.jsx)(a.Sm,{placeholderOut:e("自定义filecat代理地址"),placeholder:"127.0.0.1:5567",value:K.filecat_proxy_host_port,handleInputChange:e=>{K.filecat_proxy_host_port=e,U({...K})}}),(0,S.jsx)(c.rA,{icon:"content_copy",title:e("复制filecat代理url"),onClick:()=>{const e=`${window.location.origin}?tcp_client_num_id=${K.client_num_id}`;(0,f.lW)(e),(0,u.SK)(e)}})]}),(0,S.jsx)(a.Sm,{placeholder:"备注",value:K.note,handleInputChange:e=>{K.note=e,U({...K})}}),(0,S.jsx)(c.rA,{icon:"add",onClick:()=>{K.proxy_fig_list.push({open:!1}),U({...K})},title:e("添加")}),e("代理"),(0,S.jsx)(o.X,{headers:V,rows:K.proxy_fig_list.map((n,t)=>[(0,S.jsx)("p",{children:t}),(0,S.jsx)(a.Sm,{value:n.server_port,handleInputChange:e=>{n.server_port=parseInt(e)},no_border:!0}),(0,S.jsx)(a.Sm,{value:n.proxy_host,handleInputChange:e=>{n.proxy_host=e},no_border:!0}),(0,S.jsx)(a.Sm,{value:n.proxy_port,handleInputChange:e=>{n.proxy_port=parseInt(e)},no_border:!0}),(0,S.jsx)(a.l6,{value:!!n.open,onChange:e=>{n.open=e,U({...K})},options:F,no_border:!0}),(0,S.jsx)(a.Sm,{value:n.note,handleInputChange:e=>{n.note=e},no_border:!0}),(0,S.jsx)("div",{children:(0,S.jsx)(c.rA,{icon:"delete",title:e("删除"),onClick:()=>{const e=[];for(let n=0;n<(K.proxy_fig_list.length??0);n++)n!==t&&e.push(K.proxy_fig_list[n]);K.proxy_fig_list=e,U({...K})}})})]),width:"10rem"})]}),(0,S.jsxs)(r.Zp,{self_title:(0,S.jsxs)("span",{className:" div-row ",children:[(0,S.jsx)("h2",{children:e("桥接配置")})," "]}),children:[(0,S.jsx)(c.rA,{icon:"add",onClick:()=>{M.push({open:!1,server_client_num_id:K.client_num_id}),Z([...M])},title:e("添加")}),e("代理"),(0,S.jsx)(o.X,{headers:q,rows:M.map((n,t)=>[(0,S.jsx)("p",{children:t}),(0,S.jsx)(a.Sm,{value:n.server_port,handleInputChange:e=>{n.server_port=parseInt(e)},no_border:!0}),(0,S.jsx)(a.Sm,{value:n.client_name,options:B,handleInputChange:e=>{const t=(e=>B.find(n=>String(n.value)===String(e)))(e);n.client_num_id=parseInt(String(t.value)),n.client_name=t.label,Z([...M])},no_border:!0}),(0,S.jsx)(a.Sm,{value:n.client_proxy_host,handleInputChange:e=>{n.client_proxy_host=e},no_border:!0}),(0,S.jsx)(a.Sm,{value:n.client_proxy_port,handleInputChange:e=>{n.client_proxy_port=parseInt(e)},no_border:!0}),(0,S.jsx)(a.l6,{value:!!n.open,onChange:e=>{n.open=e,Z([...M])},options:F,no_border:!0}),(0,S.jsx)(a.Sm,{value:n.note,handleInputChange:e=>{n.note=e},no_border:!0}),(0,S.jsxs)("div",{children:[(0,S.jsx)(c.rA,{icon:"delete",title:e("删除"),onClick:async()=>{if(null==n.id){const e=[];for(let n=0;n<(M.length??0);n++)n!==t&&e.push(M[n]);Z([...e])}else await(async(e,n)=>{(await d.s9.post("server_bridge_del_fig",{id:e})).code===_.m.Success&&((0,u.SK)("成功"),H(n))})(n.id,n.server_client_num_id)}}),null==n.id?(0,S.jsx)(c.rA,{icon:"add",title:e("添加"),onClick:async()=>{await(async e=>{if(null==e.client_num_id)return void(0,u.zN)("未选择转发送 client");(await d.s9.post("server_bridge_add_fig",e)).code===_.m.Success&&((0,u.SK)("成功"),H(e.server_client_num_id))})(n)}}):(0,S.jsx)(c.rA,{icon:"save",title:e("保存"),onClick:async()=>{await(async e=>{if(null==e.client_num_id)return void(0,u.zN)("未选择转发送 client");(await d.s9.post("server_bridge_edit_fig",e)).code===_.m.Success&&((0,u.SK)("成功"),H(e.server_client_num_id))})(n)}})]})]),width:"10rem"})]})]}):(0,S.jsx)(i.xh,{})})]})]})}class I{open;key;option_keys;port}class k{client_name;client_num_id;open=!1;serverIp;serverPort;key="";note;status;is_new;index}function b(e){const{t:n}=(0,l.Bd)(),[t,x]=(0,s.useState)([]),[h,p]=(0,s.useState)([]),[v,f]=(0,s.useState)([]),[g,w]=(0,s.useState)([]),C=[n("序号"),n("服务端口"),n("转发客户端名称")],I=[n("序号"),n("原客户端"),n("目标客户端"),n("待同步文件数量")],b=[n("序号"),n("port"),n("host"),n("名称"),n("key"),n("在线"),n("开启"),n("备注")],A=(0,y.K)(),P=async()=>{const e=await d.s9.get("client_get");if(e.code===_.m.Success){const n=e.data;x(n.list)}const n=await d.s9.get("client_bridge_get_all_fig");n.code===_.m.Success&&f(n.data);const t=await d.s9.get("client_sync_task_get");t.code===_.m.Success&&w(t.data)};(0,s.useEffect)(()=>{P(),j.ws.sendData(m.HK.tcp_proxy_client_status,{}).then(()=>{j.ws.addMsg(m.HK.tcp_proxy_client_status,e=>{P()})})},[]);const $=async e=>{const n=new k;n.index=e.index,n.key=e.key,n.serverIp=e.serverIp,n.serverPort=e.serverPort,n.open=e.open,n.client_name=e.client_name,n.client_num_id=e.client_num_id;(await d.s9.post("client_save",n)).code===_.m.Success?(0,u.SK)("保存成功"):(0,u.zN)("网络错误")};return(0,S.jsx)("div",{children:(0,S.jsxs)(i.fI,{children:[(0,S.jsxs)(i.VP,{widthPer:60,children:[(0,S.jsxs)(r.Zp,{title:"",rightBottomCom:(0,S.jsx)(c.C3,{text:n("保存"),clickFun:()=>{t[0].index=0,$(t[0])}}),titleCom:(0,S.jsxs)("div",{children:[n("连接状态"),(0,S.jsx)(r.fq,{ok:!!t[0]?.status})]}),children:[(0,S.jsx)(a.Sm,{placeholder:`${n("服务器")} ip`,value:t[0]?.serverIp,handleInputChange:e=>{t[0].serverIp=e}}),(0,S.jsx)(a.Sm,{placeholder:`${n("服务器")} port`,value:t[0]?.serverPort,handleInputChange:e=>{t[0].serverPort=parseInt(e)}}),(0,S.jsx)(a.Sm,{placeholder:n("名称"),value:t[0]?.client_name,handleInputChange:e=>{t[0].client_name=e}}),(0,S.jsx)(a.Sm,{type:"password",placeholder:"key ",value:t[0]?.key,handleInputChange:e=>{t[0].key=e}}),(0,S.jsxs)("form",{children:[n("状态"),(0,S.jsx)(o.S,{isFlex:!0,columns:[(0,S.jsx)(a.U6,{value:1,context:n("开启"),selected:t[0]?.open,onchange:()=>{t[0].open=!t[0].open,x([...t])}}),(0,S.jsx)(a.U6,{value:1,context:n("关闭"),selected:!t[0]?.open,onchange:()=>{t[0].open=!t[0].open,x([...t])}})]})]})]}),(0,S.jsxs)(r.Zp,{self_title:(0,S.jsxs)("span",{className:" div-row ",children:[(0,S.jsx)("h2",{children:n("更多服务器")})," "]}),children:[(0,S.jsx)(c.rA,{icon:"add",onClick:()=>{t.push({open:!1,is_new:!0}),x([...t])},title:n("添加")}),n("代理"),(0,S.jsx)(o.X,{headers:b,rows:t.slice(1).map((e,s)=>[(0,S.jsx)("p",{children:s}),(0,S.jsx)(a.Sm,{value:e.serverPort,handleInputChange:n=>{e.serverPort=parseInt(n)},no_border:!0}),(0,S.jsx)(a.Sm,{value:e.serverIp,handleInputChange:n=>{e.serverIp=n},no_border:!0}),(0,S.jsx)(a.Sm,{value:e.client_name,handleInputChange:n=>{e.client_name=n},no_border:!0}),(0,S.jsx)(a.Sm,{value:e.key,handleInputChange:n=>{e.key=n},no_border:!0}),(0,S.jsx)(r.fq,{ok:!!e.status}),(0,S.jsx)(a.l6,{value:!!e.open,onChange:n=>{e.open=n,x([...t])},options:A,no_border:!0}),(0,S.jsx)(a.Sm,{value:e.note,handleInputChange:n=>{e.note=n},no_border:!0}),(0,S.jsxs)("div",{children:[(0,S.jsx)(c.rA,{icon:"delete",title:n("删除"),onClick:async()=>{if(e.is_new){const e=[];for(let n=0;n<(t.length??0);n++)n!==s&&e.push(t[n]);x([...e])}else await(async e=>{(await d.s9.post("client_del",{index:e})).code===_.m.Success?((0,u.SK)("保存成功"),P()):(0,u.zN)("网络错误")})(s+1)}}),e.is_new?(0,S.jsx)(c.rA,{icon:"add",title:n("添加"),onClick:async()=>{e.index=s+1,await $(e)}}):(0,S.jsx)(c.rA,{icon:"save",title:n("保存"),onClick:async()=>{e.index=s+1,await $(e)}})]})]),width:"10rem"})]})]}),(0,S.jsxs)(i.VP,{widthPer:40,children:[v?.length?(0,S.jsx)(r.Zp,{title:n("桥接服务端口列表"),children:(0,S.jsx)(o.X,{headers:C,rows:v.map((e,n)=>[(0,S.jsx)("p",{children:n}),(0,S.jsx)(r.xP,{children:e.server_port}),(0,S.jsx)(r.xP,{children:e.client_name})]),width:"10rem"})}):(0,S.jsx)(S.Fragment,{}),g?.length?(0,S.jsx)(r.Zp,{title:n("文件同步列表"),children:(0,S.jsx)(o.X,{headers:I,rows:g.map((e,n)=>[(0,S.jsx)("p",{children:n}),(0,S.jsx)(r.xP,{children:e.source_client_name}),(0,S.jsx)(r.xP,{children:e.target_client_name}),(0,S.jsx)(r.xP,{children:e.running_num})]),width:"10rem"})}):(0,S.jsx)(S.Fragment,{})]})]})})}function A(){const{t:e,i18n:n}=(0,l.Bd)(),{initUserInfo:t,reloadUserInfo:v}=(0,s.useContext)(x.F),[f,g]=(0,h.fp)(p.AG.user_base_info),[y,w]=(0,h.fp)(p.AG.prompt_card),[C,k]=(0,s.useState)(!1),[b,A]=(0,s.useState)([]),[P,$]=(0,s.useState)(null),[F,K]=(0,s.useState)([]),[U,N]=(0,s.useState)(void 0),[G,B]=(0,s.useState)(void 0),X=(0,s.useMemo)(()=>{const e=[...b];return null!=P?(e.sort((e,n)=>P?e.server_port-n.server_port:n.server_port-e.server_port),e):e},[b,P]),M=async()=>{const e=await d.s9.get("get_all_open_server_client_proxy_fig");if(e.code===_.m.Success){const n=[];for(const t of e.data)G?`${t.server_port}${t.client_name}${t.proxy_host}${t.server_port}${t.server_port_note}`.includes(G)&&n.push(t):n.push(t);A(n)}},Z=async()=>{const e=await d.s9.get("server_get");e.code===_.m.Success&&(N(e.data.port),k(!!e.data.open),K(e.data.option_keys??[])),M()};(0,s.useEffect)(()=>{j.ws.addMsg(m.HK.tcp_forward_server_load,e=>{Z()}),Z()},[]);const E=async e=>{const n=new I;n.port=U,n.open=C,n.option_keys=F;(await d.s9.post("server_save",{fig:n,notice_client:e})).code===_.m.Success&&(0,u.SK)("成功")};return(0,S.jsxs)(i.fI,{children:[(0,S.jsx)(i.VP,{widthPer:50,children:(0,S.jsx)(i.xh,{children:(0,S.jsxs)(r.Zp,{title:e("服务器配置"),rightBottomCom:(0,S.jsxs)("div",{children:[(0,S.jsx)(c.C3,{text:e("保存并通知客户端第一个key和port"),clickFun:()=>{E(!0)}}),(0,S.jsx)(c.C3,{text:e("保存"),clickFun:()=>{E(!1)}})]}),children:[(0,S.jsx)(a.Sm,{placeholder:"port",value:U,handleInputChange:e=>{N(e)}}),(0,S.jsxs)("label",{children:[(0,S.jsx)(c.rA,{icon:"add",onClick:()=>{K([...F,""])},title:e("添加")}),e("key")]}),(F??[]).map((n,t)=>(0,S.jsxs)("div",{style:{display:"flex"},children:[(0,S.jsx)("div",{style:{width:"90%"},children:(0,S.jsx)(a.Sm,{type:"password",value:n,handleInputChange:e=>{F[t]=e,K([...F])}})}),(0,S.jsx)(c.rA,{icon:"delete",onClick:()=>{F.splice(t,1),K([...F])},title:e("删除")})]},t)),(0,S.jsxs)("form",{children:[e("状态"),":",(0,S.jsx)(o.S,{isFlex:!0,columns:[(0,S.jsx)(a.U6,{value:1,context:e("开启"),selected:C,onchange:()=>{k(!C)}}),(0,S.jsx)(a.U6,{value:1,context:e("关闭"),selected:!C,onchange:()=>{k(!C)}})]})]})]})})}),(0,S.jsx)(i.VP,{widthPer:50,children:(0,S.jsx)(i.xh,{children:(0,S.jsx)(r.uF,{self_title:(0,S.jsx)("span",{className:" div-row ",children:(0,S.jsx)("h2",{children:e("服务器")+e("端口映射")})}),titleCom:(0,S.jsx)(a.Sm,{placeholder:e("过滤"),value:G,handleInputChange:e=>{B(e)},handlerEnter:()=>{M()}}),children:(0,S.jsx)(o.X,{headers:[e("序号"),(0,S.jsx)(c.rA,{title:e("服务端口"),onClick:()=>{$(e=>!e)}}),e("转发ip"),e("转发端口"),"client "+e("名称"),e("开启"),e("备注")],rows:X.map((e,n)=>[(0,S.jsx)("p",{children:n}),(0,S.jsx)(r.xP,{children:e.server_port}),(0,S.jsx)(r.xP,{children:e.proxy_host}),(0,S.jsx)(r.xP,{children:e.proxy_port}),(0,S.jsx)(r.xP,{children:e.client_name}),(0,S.jsx)(r.fq,{ok:!!e.open_success}),(0,S.jsx)(r.xP,{children:e.server_port_note})]),width:"10rem"})})})})]})}var P=t(78247);function $(){const{t:e,i18n:n}=(0,l.Bd)(),{initUserInfo:t,reloadUserInfo:j}=(0,s.useContext)(x.F),[m,v]=(0,h.fp)(p.AG.user_base_info),[f,g]=(0,h.fp)(p.AG.prompt_card),[,y]=(0,h.fp)(p.AG.confirm),[w,C]=(0,h.fp)(p.AG.editorSetting),[I,k]=(0,s.useState)([]),b=[e("编号"),e("原客户端"),e("原目录"),e("目标客户端"),e("目标目录"),e("忽略目录"),e("开启"),e("双向同步"),e("全量同步"),e("备注")],[A,$]=(0,s.useState)([]);(0,s.useEffect)(()=>{(async()=>{const e=await d.s9.get("server_client_get");if(e.code===_.m.Success){const n=e.data,t=[];for(const e of n)t.push({label:e.client_name,value:e.client_num_id});$(t),await F()}})()},[]);const F=async()=>{const e=await d.s9.get("sync_task_get");e.code===_.m.Success&&k(e.data)},K=e=>A.find(n=>String(n.value)===String(e)),U=async e=>{const n=e;(await d.s9.post("sync_task_save",n)).code===_.m.Success&&((0,u.SK)("成功"),await F())};return(0,S.jsx)(i.fI,{children:(0,S.jsx)(i.VP,{widthPer:100,children:(0,S.jsx)(i.xh,{children:(0,S.jsxs)(r.Zp,{self_title:(0,S.jsxs)("span",{className:" div-row ",children:[(0,S.jsx)("h2",{children:e("客户端文件同步")}),(0,S.jsx)(c.rA,{icon:"info",onClick:()=>{g({open:!0,title:"信息",context_div:(0,S.jsx)("div",{children:(0,S.jsxs)("ul",{children:[(0,S.jsx)("li",{children:"目前只能同步较小的文件,例如配置文件,代码文件"}),(0,S.jsx)("li",{children:e("默认(没有选中全量同步)不会立即同步两个目录中的文件,而是有文件被修改或者改动后才会同步,如果开启全量同步,每次客户端一上线就会递归的同步全部的文件,如果文件非常多,这会造成很大的执行压力。")}),(0,S.jsx)("li",{children:e("如果开启了双向同步,如果两边初始化的时候各自又有很多文件,这是不太稳定的,暂时不建议这样做。")}),(0,S.jsx)("li",{children:e("同时开启全量同步和双向同步,目前性能也会很差,目前没有提供提供冲突冲突的机制。")}),(0,S.jsx)("li",{children:e("如果想用全量同步,一方的文件是空的,且文件数量比较少,几百这样的数量,效果是不错的,之后会一直走增量更新。")})]})})})},title:"信息"})]}),children:[(0,S.jsx)(c.rA,{icon:"add",onClick:()=>{I.push({open:!1,source_dir:"",target_dir:"",delete_missing:!0}),k([...I])},title:e("添加")}),(0,S.jsx)(o.X,{headers:b,rows:I.map((n,t)=>{const s=K(n.source_client_num_id),i=K(n.target_client_num_id);return[(0,S.jsx)("p",{children:t}),(0,S.jsx)(a.Sm,{value:s?.label??n.source_client_name,options:A,handleInputChange:e=>{const t=K(e);n.source_client_num_id=parseInt(String(t?.value)),n.source_client_name=t?.label,k([...I])},no_border:!0}),(0,S.jsx)(a.Sm,{value:n.source_dir,handleInputChange:e=>{n.source_dir=e},no_border:!0}),(0,S.jsx)(a.Sm,{value:i?.label??n.target_client_name,options:A,handleInputChange:e=>{const t=K(e);n.target_client_num_id=parseInt(String(t?.value)),n.target_client_name=t?.label,k([...I])},no_border:!0}),(0,S.jsx)(a.Sm,{value:n.target_dir,handleInputChange:e=>{n.target_dir=e},no_border:!0}),(0,S.jsx)(c.rA,{icon:"edit",title:"额外参数设置",onClick:()=>{P.xK.set_value_temp(n.ignore_text??"\nnode_modules\n.venv\n.gradle\n.cache\nvendor\n"),C({model:"ace/mode/gitignore",open:!0,fileName:"",save:async e=>{n.ignore_text=e,k([...I]),P.xK.set_value_temp(""),U(n)}})}}),(0,S.jsx)(a.GL,{selected:!!n.open,onchange:()=>{n.open=!n.open,k([...I])}}),(0,S.jsx)(a.GL,{selected:!!n.two_way_sync,onchange:()=>{n.two_way_sync=!n.two_way_sync,k([...I])}}),(0,S.jsx)(a.GL,{selected:!!n.full_sync,onchange:()=>{n.full_sync=!n.full_sync,k([...I])}}),(0,S.jsx)(a.Sm,{value:n.note,handleInputChange:e=>{n.note=e},no_border:!0}),(0,S.jsxs)("div",{children:[(0,S.jsx)(c.rA,{icon:"save",title:e("保存"),onClick:()=>{U(n)}}),(0,S.jsx)(c.rA,{icon:"delete",title:e("删除"),onClick:()=>{n.id?y({open:!0,title:e("确定删除吗"),handle:async()=>{await(async e=>{(await d.s9.post("sync_task_del",{id:e})).code===_.m.Success&&((0,u.SK)("成功"),await F())})(n.id),(0,u.SK)("删除完成"),y({open:!1,handle:null})}}):(I.splice(t,1),k([...I]))}})]})]}),width:"10rem"})]})})})})}var F=t(87361);function K(){const{t:e}=(0,l.Bd)(),n=[{index:1,name:e("客户端"),rto:"tcp_proxy_client/",component:(0,S.jsx)(b,{})},{index:2,name:e("服务端"),rto:"tcp_proxy_server_info/",component:(0,S.jsx)(A,{})},{index:3,name:e("服务端")+"-"+e("客户端列表"),rto:"tcp_proxy_server_client/",component:(0,S.jsx)(C,{})},{index:4,name:e("服务端")+"-"+e("客户端功能"),rto:"tcp_proxy_server_client_setting/",component:(0,S.jsx)($,{})}];return(0,S.jsx)(i.W1,{optionList:n,father_route:F.o.net_proxy})}},6960(e,n,t){t.d(n,{s:()=>r});var s=t(72635);const i=1440,l=525600;function r(e){e=e>1e12?e:1e3*e;const n=Date.now(),t=Math.abs(n-e)/6e4;return t<1?s.Ay.t("小于一分钟"):t<60?`${t.toFixed(0)} ${s.Ay.t("分钟前")}`:t<i?`${(t/60).toFixed(0)} ${s.Ay.t("小时前")}`:t<43200?`${(t/i).toFixed(0)} ${s.Ay.t("天前")}`:t<l?`${(t/43200).toFixed(0)} ${s.Ay.t("月前")}`:`${(t/l).toFixed(0)} ${s.Ay.t("年前")}`}},24659(e,n,t){var s=t(22022);t.d(n,["K",0,()=>{const{t:e}=(0,s.Bd)();return[{title:e("是"),value:!0,color:"#28a745"},{title:e("否"),value:!1,color:"#666666"}]}])}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[678,6010],{83277(e,t,s){s.d(t,{$j:()=>o,Lv:()=>a,qq:()=>i});class n{options_agent_url_list;options_agent_key_list;options_agent_model_list;options_local_file_path_prompt_list}class a{token;open=!1;note;index;url;model;request_type;json_params;sys_prompt;dotenv="";tool_mode=!1;show_options;static get_label_by_v(e,t){if(!e||!t?.length)return e;for(const s of t)if(s.value===e)return s.label;return e}static have_label_by_v(e,t){if(!e||!t?.length)return!1;for(const s of t)if(s.value===e)return!0;return!1}}class i extends n{tool_error_max=50;tool_call_max=300;allow_exec_cmd_directly=!1;proxy_url;open_pick_model;max_recent_messages=12;compress_message_count=16;max_tool_content_chars=200}const c=JSON.stringify({stream:!0,thinking:{type:"disabled"}});function o(e){return"string"==typeof e?e:Array.isArray(e)?e.map(e=>"text"===e.type?e.text:"[图片]").join("\n"):""}s.d(t,["CP",0,'\n\n# 工具报错最大尝试次数\ntool_error_max=50\n# 聊天循环最大次数\ntool_call_max=300\n# 是否允许AI直接执行命令而不需要用户确认,默认为false,需要用户手动确认,如果使用 workflow 这里等价于为 true\nallow_exec_cmd_directly=false\n\n# 可选的代理 url,如果指定了所有访问大模型的请求将会走代理\n#proxy_url=\n\n# 可选的多个url 以数组分割\n# options_agent_url_list=[{"value":"http://..","label":"openai"}]\n\n# 可选的多个 key\n# options_agent_key_list=[{"value":"sh-aaa","label":"option1"}]\n\n# 可选的多个 model\n# options_agent_model_list=[{"value":"gpt-5.5","label":"gpt"}]\n\n# 存放本地的 prompt 文件 用于每次聊天的时候自动读取并加载\n# options_local_file_path_prompt_list=["/prompt/a.txt"]\n\n# 开启切换模型 ,开启以后,你可以自己写 prompt 提供多个模型让 ai 自己根据每次聊天切换下一步调用其他模型的次数\n# open_pick_model=false\n\n# 压缩后仍然完整保留的最近消息数\nmax_recent_messages=12\n# 当单个会话累计消息条数超过该值时,触发历史消息裁剪\ncompress_message_count=16\n# 历史消息中 tool 输出的最大字符数,只保留调用形式让 AI 知道调用了就行\nmax_tool_content_chars=200\n',"cL",0,c])},93583(e,t,s){s.r(t),s.d(t,{default:()=>Y});var n=s(96540),a=s(34843),i=s(22022),c=s(61973),o=s(92275),l=s(14284),r=s(7463),d=s(78247),u=s(40505),m=s(62042),h=s(45907),g=s(53459),p=s(72693),x=s(82893),_=s(61443),f=s(83277);function j(e){return null==e||e<0?"0":e.toLocaleString()}function v(e){const t=(0,f.$j)(e.content);if(t)return t;const s=e.content_list??[];return s.length?s.map(e=>(0,f.$j)(e.content)).filter(Boolean).join("\n\n"):""}const b=/\.(md|txt|json|js|jsx|ts|tsx|css|html?|xml|ya?ml|py|java|go|rs|c|cpp|h|hpp|sh|bat|cmd|ini|toml|csv|log|sql|env|gitignore|dockerfile)$/i;function y(e){return e.type?.startsWith("image/")?"image":e.type?.startsWith("text/")||b.test(e.name)?"text":"binary"}function S(e){return e.text()}function w(e){return new Promise((t,s)=>{const n=new FileReader;n.onload=()=>t(n.result),n.onerror=s,n.readAsDataURL(e)})}async function N(e){const t=[];for(const s of e){const e=y(s);let n="";if("text"===e)try{const e=await S(s),t=12e4;n=e.length>t?`${e.slice(0,t)}\n\n[内容已截断,原始长度 ${e.length} 字符]`:e}catch{n="[文本读取失败]"}else if("image"===e)try{n=await w(s)}catch{n=`[图片文件: ${s.name}]`}else n=`[二进制文件: ${s.name}]`;t.push({name:s.name,mime_type:s.type,size:s.size,kind:e,content:n})}return t}var k=s(14944);var C=s(52035),A=s(85997),I=s(34299),$=s(74848);function M(e){const t=e.attachments&&e.attachments.length>0?(0,$.jsx)("div",{className:"chat-message-attachments",children:e.attachments.map((e,t)=>(0,$.jsxs)("div",{className:"chat-message-attachment",children:[(0,$.jsx)(A.In,{icon:"attach_file"}),(0,$.jsx)("span",{children:e.name}),(0,$.jsxs)("small",{children:[e.size," B"]})]},`${e.name}_${t}`))}):null,s=[];e.images&&"bot"===e.sender&&s.push((0,$.jsx)(n.Fragment,{children:(0,$.jsx)(D,{images:e.images,text:e.text})},"images")),e.audio&&"bot"===e.sender&&s.push((0,$.jsx)(n.Fragment,{children:(0,$.jsx)(R,{audio:e.audio,text:e.text})},"audio")),e.embeddings&&"bot"===e.sender&&s.push((0,$.jsx)(n.Fragment,{children:(0,$.jsx)(P,{embeddings:e.embeddings,text:e.text})},"embeddings"));const a=function(e){if("bot"!==e.sender||!e.content_list?.length)return e.text?(0,$.jsx)(I.default,{context:e.text}):null;return(0,$.jsxs)($.Fragment,{children:[e.content_list.map((e,t)=>{const s=[],a=(0,f.$j)(e.content);return a&&s.push((0,$.jsx)(n.Fragment,{children:(0,$.jsx)(I.default,{context:a})},`content-${t}`)),e.tool_call_ends?.length&&s.push((0,$.jsx)(n.Fragment,{children:(0,$.jsx)(T,{callList:e.tool_call_ends})},`tool-${t}`)),(0,$.jsx)(n.Fragment,{children:s},`part-${t}`)}),!e.content_list.some(e=>e.content)&&e.text?(0,$.jsx)(I.default,{context:e.text}):null]})}(e);return 0===s.length?(0,$.jsxs)($.Fragment,{children:[t,a]}):(0,$.jsxs)($.Fragment,{children:[s,t,a]})}function T({callList:e}){const[t,s]=n.useState(!1);if(!e?.length)return null;e.filter(e=>e.success).length;const a=e.filter(e=>!e.success).length;return(0,$.jsxs)("div",{className:"chat-message-call-list",children:[(0,$.jsxs)("div",{className:"call-list-header",onClick:()=>s(!t),children:[(0,$.jsx)(A.In,{icon:t?"expand_less":"expand_more"}),(0,$.jsxs)("span",{className:"call-list-summary",children:["工具调用 (",e.length,")",a>0&&(0,$.jsx)("span",{className:"call-list-fail",children:" 失败 "})]})]}),t&&(0,$.jsx)("div",{className:"call-list-body",children:e.map((e,t)=>(0,$.jsxs)("div",{className:"call-list-item "+(e.success?"call-success":"call-fail"),children:[(0,$.jsxs)("div",{className:"call-list-item-header",children:[(0,$.jsx)(A.In,{icon:e.success?"check_circle":"error"}),(0,$.jsx)("span",{className:"call-list-tool-name",children:e.tool_display_name||e.tool_name}),(0,$.jsxs)("span",{className:"call-list-duration",children:[e.duration_ms,"ms"]})]}),e.tool_args&&(0,$.jsxs)("details",{className:"call-list-details",children:[(0,$.jsx)("summary",{children:"参数"}),(0,$.jsx)("pre",{className:"call-list-pre",children:JSON.stringify(e.tool_args,null,2)})]}),!e.success&&e.error&&(0,$.jsxs)("details",{className:"call-list-details",children:[(0,$.jsx)("summary",{children:"错误"}),(0,$.jsx)("pre",{className:"call-list-pre call-list-error-text",children:e.error})]}),e.success&&e.tool_result&&(0,$.jsxs)("details",{className:"call-list-details",children:[(0,$.jsx)("summary",{children:"结果"}),(0,$.jsx)("pre",{className:"call-list-pre",children:e.tool_result.length>500?e.tool_result.slice(0,500)+"...":e.tool_result})]})]},t))})]})}function D({images:e,text:t}){let s=e||[];if(!s.length&&t)try{s=JSON.parse(t).data||[]}catch{}return s.length?(0,$.jsxs)("div",{className:"image-generation-result",children:[s.map((e,t)=>(0,$.jsxs)("div",{className:"image-generation-item",children:[e.url&&(0,$.jsx)("div",{className:"image-generation-image-wrapper",children:(0,$.jsx)("img",{src:e.url,alt:e.revised_prompt||`生成的图片 ${t+1}`,loading:"lazy"})}),e.b64_json&&(0,$.jsx)("div",{className:"image-generation-image-wrapper",children:(0,$.jsx)("img",{src:`data:image/png;base64,${e.b64_json}`,alt:`生成的图片 ${t+1}`})}),e.revised_prompt&&(0,$.jsx)("p",{className:"image-generation-prompt",children:(0,$.jsx)("small",{children:e.revised_prompt})})]},t)),t&&!e&&(0,$.jsx)(I.default,{context:t})]}):(0,$.jsx)(I.default,{context:t||""})}function R({audio:e,text:t}){if(e){if(e.url)return(0,$.jsx)("div",{className:"audio-result",children:(0,$.jsx)("audio",{controls:!0,src:e.url,children:"您的浏览器不支持音频播放"})});if(e.data){const t=e.mime_type||"audio/mpeg";return(0,$.jsx)("div",{className:"audio-result",children:(0,$.jsx)("audio",{controls:!0,src:`data:${t};base64,${e.data}`,children:"您的浏览器不支持音频播放"})})}}const s=t||"";if(s.startsWith("http://")||s.startsWith("https://"))return(0,$.jsx)("div",{className:"audio-result",children:(0,$.jsx)("audio",{controls:!0,src:s,children:"您的浏览器不支持音频播放"})});try{const e=JSON.parse(s);if(e?.data||e?.audio_data){const t=e.data||e.audio_data;return(0,$.jsx)("div",{className:"audio-result",children:(0,$.jsx)("audio",{controls:!0,src:`data:audio/mpeg;base64,${t}`,children:"您的浏览器不支持音频播放"})})}}catch{}return(0,$.jsx)(I.default,{context:s})}function H({content:e,label:t}){const[s,a]=n.useState(!1);return(0,$.jsxs)("button",{className:"embeddings-copy-btn",onClick:()=>{(0,u.lW)(e),a(!0),setTimeout(()=>a(!1),1500)},children:[(0,$.jsx)(A.In,{icon:s?"check":"content_copy"}),s?"已复制":t||"复制"]})}function P({embeddings:e,text:t}){let s=e||null;if(!s&&t)try{s=JSON.parse(t)}catch{return(0,$.jsx)(I.default,{context:t})}if(!s)return(0,$.jsx)(I.default,{context:t||""});const n=s?.data||[],a=s?.usage,i=JSON.stringify(s,null,2);return(0,$.jsxs)("div",{className:"embeddings-result",children:[(0,$.jsxs)("div",{className:"embeddings-summary",children:[(0,$.jsx)("strong",{children:"向量嵌入结果"}),(0,$.jsxs)("span",{children:["维度: ",n[0]?.embedding?.length??"N/A"]}),(0,$.jsxs)("span",{children:["数量: ",n.length]}),a&&(0,$.jsxs)("span",{children:["使用 tokens: ",a.total_tokens??"N/A"]})]}),(0,$.jsxs)("div",{className:"embeddings-toolbar",children:[(0,$.jsx)(H,{content:i,label:"复制全部结果"}),n.length>0&&n[0]?.embedding&&(0,$.jsx)(H,{content:JSON.stringify(n[0].embedding,null,2),label:"复制第一条向量"}),n.length>0&&(0,$.jsx)(H,{content:JSON.stringify(n.map(e=>e.embedding),null,2),label:"复制所有向量数据"})]}),n.length>0&&n[0]?.embedding&&(0,$.jsx)("div",{className:"embeddings-preview",children:(0,$.jsxs)("span",{children:["向量预览: [",n[0].embedding.slice(0,5).join(", "),n[0].embedding.length>5?", ...":"","]"]})}),n.length>0&&(0,$.jsxs)("details",{children:[(0,$.jsx)("summary",{children:"查看详细数据"}),(0,$.jsx)("pre",{className:"embeddings-raw",children:i})]})]})}async function F(e,t){const s=function(){try{return(0,C.zp)().get(x.AG.ai_images_extra_params)||{}}catch{return{}}}(),n={prompt:e,n:s.n??1,size:s.size??"1024x1024",session_id:t};if(s.quality&&(n.quality=s.quality),s.style&&(n.style=s.style),s.extra_json)try{const e=JSON.parse(s.extra_json);Object.assign(n,e)}catch(e){console.warn("图片额外参数 JSON 解析失败:",e)}const a=await l.jV.post("images/generations",n);if(0!==a.code)throw new Error(a.message||"图片生成失败");const i=a.data||{},c=(i.data||[]).map(e=>({url:e.url,b64_json:e.b64_json,revised_prompt:e.revised_prompt})),o=c.map((e,t)=>`${e.revised_prompt?`\n> ${e.revised_prompt}`:""}`).join("\n\n");return{session_id:i.session_id||t,images:c,text:o||`生成了 ${c.length} 张图片`}}async function O(e,t,s,n){try{switch(e){case"images":{const e=await F(t,s);return e&&n(e.text,{images:e.images}),!0}case"audio_speech":{const e=await async function(e,t){const s={input:e,session_id:t};try{const e=localStorage.getItem("ai_audio_extra_params");if(e){const t=JSON.parse(e);t.voice&&(s.voice=t.voice),t.speed&&(s.speed=parseFloat(t.speed))}}catch{}const n=localStorage.getItem("token")||"",a=await fetch("/api/ai_agent/audio/speech",{method:"POST",headers:{"Content-Type":"application/json",Authorization:n},body:JSON.stringify(s)});if(!a.ok)throw new Error(`语音合成失败: ${a.statusText}`);const i=a.headers.get("X-Session-Id")||t,c=await a.arrayBuffer();return{session_id:i,audio:{data:btoa(String.fromCharCode(...Array.from(new Uint8Array(c)))),mime_type:a.headers.get("content-type")||"audio/mpeg"},text:`[音频文件: ${e.slice(0,50)}...]`}}(t,s);return e&&n(e.text,{audio:e.audio}),!0}case"embeddings":{const e=await async function(e,t){const s=await l.jV.post("embeddings",{input:e,session_id:t});if(0!==s.code)throw new Error(s.message||"Embeddings 请求失败");const n=s.data||{},a=n?.data??[],i=`向量维度: ${a[0]?.embedding?.length??0}, 数量: ${a.length}`;return{session_id:n.session_id||t,embeddings:n,text:`✅ Embeddings 结果 - ${i}\n\`\`\`json\n${JSON.stringify(n,null,2).slice(0,2e3)}\n\`\`\``}}(t,s);return e&&n(e.text,{embeddings:e.embeddings}),!0}default:return!1}}catch(e){return n(`请求失败: ${e?.message||JSON.stringify(e)}`),!0}}var V=s(57952),q=s(23430),B=s(87361);const E=({currentModelName:e,setCurrentModelName:t,envConfigRef:s,sysPromptList:n,batchMode:o,selectedMsgCount:r,onToggleSessionPanel:u,onCreateSession:h,onToggleBatchMode:p,onBatchDeleteMessages:f,bgProcessVisible:j,bgProcessCount:v,onToggleBgProcess:b,selectedSysPromptId:y,setSelectedSysPromptId:S})=>{const{t:w}=(0,i.Bd)(),N=(0,c.Zp)(),{check_user_auth:k}=(0,d.MH)(),[,C]=(0,a.fp)(x.AG.ai_session_collapsed);return(0,$.jsxs)(V.A,{children:[(0,$.jsx)(A.rA,{icon:"menu",title:w("会话"),onClick:u}),(0,$.jsx)(A.rA,{icon:"add",title:w("新会话"),onClick:()=>h()}),n.length>0&&(0,$.jsx)(_.l6,{value:y,options:[{title:w("选择系统提示词"),value:""},...n.map(e=>({title:e.note||e.prompt.slice(0,30),value:String(e.index)}))],onChange:e=>{S(e)},no_border:!0,width:"10rem"}),(s.current?.ai_config_env?.options_agent_model_list?.length??0)>0&&(0,$.jsx)(_.l6,{value:e,options:s.current.ai_config_env.options_agent_model_list?.map(e=>({title:e.label,value:e.value}))??[],onChange:e=>{t(e),l.jV.post("set_active_model",{model_name:e}).then(()=>{(0,m.SK)("success"),l.XO.get("ai_agent_setting/env").then(e=>{e.code===g.m.Success&&(s.current=e.data)})}).catch(console.error)},no_border:!0,width:"auto"}),o&&r>0&&(0,$.jsx)(A.rA,{icon:"delete",title:w("删除选中消息"),onClick:f}),(0,$.jsx)(A.rA,{icon:"terminal",title:w("后台进程"),onClick:b,selected:j,tip:v||null}),k(q.oV.ai_agent_setting)&&(0,$.jsx)(A.rA,{icon:"smart_toy",title:"机器人配置",onClick:()=>{N(`/${B.o.ai_rebot_setting_page}`)}}),k(q.oV.ai_agent_setting)&&(0,$.jsx)(A.rA,{icon:"settings",title:"ai setting",onClick:()=>{N(`/${B.o.ai_agent_setting_page}`)}})]})};var K=s(27690);function L({sessions:e,activeSessionId:t,onSelectSession:s,onRenameSession:c,onDeleteSession:o,onShowUsageStats:l,batchMode:r,selectedSessionIds:d,onToggleSessionSelect:u,onToggleBatchMode:m,onBatchDeleteSessions:h,onClearAllSessions:g}){const{t:p}=(0,i.Bd)(),[_,f]=(0,a.fp)(x.AG.ai_session_collapsed),[j,v]=(0,n.useState)(""),b=j.trim()?e.filter(e=>(e.title||"").toLowerCase().includes(j.toLowerCase())||(e.summary||"").toLowerCase().includes(j.toLowerCase())||(e.long_term_memory||"").toLowerCase().includes(j.toLowerCase())):e;return(0,$.jsxs)("aside",{className:`chat-session-list ${_?"active":""} ${_?"collapsed":""}`,children:[(0,$.jsx)("div",{className:"chat-session-search",children:(0,$.jsx)("input",{type:"text",className:"chat-session-search-input",placeholder:p("搜索会话"),value:j,onChange:e=>v(e.target.value)})}),(0,$.jsx)("div",{className:"chat-session-items-wrap",children:b.map(e=>{return(0,$.jsx)("div",{children:(0,$.jsxs)("button",{className:`chat-session-item ${t===e.id?"active":""} ${r?"batch-mode":""}`,onClick:()=>{r&&u?u(e.id):s(e.id)},title:e.summary||e.long_term_memory||e.title,children:[r&&(0,$.jsx)("input",{type:"checkbox",className:"chat-session-checkbox",checked:d?.has(e.id)??!1,onChange:()=>u?.(e.id),onClick:e=>e.stopPropagation()}),(0,$.jsx)("span",{children:(n=e.title,n||"新会话")}),(0,$.jsx)("small",{children:e.message_count}),"web"!==e.source&&(0,$.jsx)("em",{className:"chat-session-source",children:e.source}),!r&&(0,$.jsx)(K.MenuSelect,{list:[{name:p("重命名"),click:()=>c(e.id,e.title)},{name:p("字符消耗统计"),click:()=>l(e.id)},{name:p("删除"),click:()=>o(e.id)}],children:(0,$.jsx)(A.In,{icon:"more_horiz"})})]})},e.id);var n})}),(0,$.jsxs)("div",{className:"chat-session-actions",children:[(0,$.jsx)(A.rA,{icon:r?"check_circle":"checklist",title:p(r?"取消批量选择":"批量选择"),onClick:m}),r&&(d?.size??0)>0&&(0,$.jsx)(A.rA,{icon:"delete",title:p("删除选中会话"),onClick:h}),!r&&(0,$.jsx)(A.rA,{icon:"delete_sweep",title:p("删除全部会话"),onClick:g})]})]})}const z=({messages:e,batchMode:t,selectedMsgIds:s,sending:n,chatContainerRef:a,messagesEndRef:i,onToggleMsgSelect:c,onDelete:o,onCopy:l,onToggleBatchMode:r,t:d})=>(0,$.jsxs)("div",{className:"chat-messages",ref:a,"data-sending":n?"true":"false",children:[e.map(e=>(0,$.jsxs)("div",{className:`chat-message ${e.sender} ${t?"batch-mode":""} ${e.is_loading?"is-loading":""}`,children:[t&&(0,$.jsx)("input",{type:"checkbox",className:"chat-message-checkbox",checked:s.has(e.id),onChange:()=>c(e.id)}),e.is_loading?(0,$.jsxs)("div",{className:"ai-loading-bubble",children:[(0,$.jsxs)("div",{className:"ai-loading-dots",children:[(0,$.jsx)("span",{className:"ai-loading-dot"}),(0,$.jsx)("span",{className:"ai-loading-dot"}),(0,$.jsx)("span",{className:"ai-loading-dot"})]}),(0,$.jsx)("span",{className:"ai-loading-text",children:e.text})]}):(0,$.jsxs)($.Fragment,{children:[M(e),(0,$.jsx)("div",{className:"message-actions",children:t?(0,$.jsx)("button",{onClick:()=>c(e.id),children:s.has(e.id)?d("取消选择"):d("选择")}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)("button",{onClick:()=>o(e.id),children:d("删除")}),(0,$.jsx)("button",{onClick:()=>l(e.text),children:d("复制")}),(0,$.jsx)("button",{onClick:r,children:d("多选")})]})})]})]},e.id)),(0,$.jsx)("div",{ref:i})]});function J({onClose:e}){const{t}=(0,i.Bd)(),[s,c]=(0,a.fp)(x.AG.ai_images_extra_params),[o,l]=(0,n.useState)(s.size||"1024x1024"),[r,d]=(0,n.useState)(String(s.n??1)),[u,m]=(0,n.useState)(s.quality||""),[h,g]=(0,n.useState)(s.style||""),[p,f]=(0,n.useState)(s.extra_json||"");return(0,$.jsxs)("div",{className:"card floating",children:[(0,$.jsx)("div",{className:"card-title",children:(0,$.jsx)("h2",{children:t("图片生成参数设置")})}),(0,$.jsxs)("div",{className:"card-content",children:[(0,$.jsx)(_.Sm,{placeholderOut:t("图片尺寸 (size)"),value:o,handleInputChange:l,placeholder:"1024x1024"}),(0,$.jsx)(_.Sm,{placeholderOut:t("生成数量 (n)"),value:r,handleInputChange:d,type:"number"}),(0,$.jsx)(_.Sm,{placeholderOut:t("画质 (quality)"),value:u,handleInputChange:m,placeholder:"standard / hd"}),(0,$.jsx)(_.Sm,{placeholderOut:t("风格 (style)"),value:h,handleInputChange:g,placeholder:"vivid / natural"}),(0,$.jsx)(_.Sm,{placeholderOut:t("额外参数 JSON"),value:p,handleInputChange:f,placeholder:'{"key":"value"}'})]}),(0,$.jsxs)("div",{className:"card-action",children:[(0,$.jsx)("button",{className:"button button--flat button--grey",onClick:e,children:t("取消")}),(0,$.jsx)("button",{className:"button button--flat",onClick:()=>{const t={size:o,n:parseInt(r)||1};u&&(t.quality=u),h&&(t.style=h),p&&(t.extra_json=p),c(t),e()},children:t("确定")})]})]})}function G({requestType:e}){const{t}=(0,i.Bd)(),[s,a]=(0,n.useState)(!1);return"completions"===e?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(A.rA,{icon:"tune",title:t("模型参数设置"),onClick:()=>a(!0)}),s&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)("div",{className:"overlay",onClick:()=>a(!1)}),"images"===e&&(0,$.jsx)(J,{onClose:()=>a(!1)})]})]})}const W=(0,n.forwardRef)(function({placeholder:e="",disabled:t=!1,className:s,style:a,onEnter:i,onPaste:c,onChange:o},l){const r=(0,n.useRef)(null),[d,u]=(0,n.useState)(!0),[m,h]=(0,n.useState)(!1),g=(0,n.useCallback)(()=>{const e=r.current;return e?(e.textContent??"").replace(/\u00A0/g," ").trimEnd():""},[]);(0,n.useImperativeHandle)(l,()=>({getValue:()=>g(),setValue:e=>{const t=r.current;if(!t)return;t.textContent=e,u(!e);const s=document.createRange();s.selectNodeContents(t),s.collapse(!1);const n=window.getSelection();n?.removeAllRanges(),n?.addRange(s)},clear:()=>{const e=r.current;e&&(e.textContent="",u(!0))},focus:()=>r.current?.focus()})),(0,n.useEffect)(()=>{const e=r.current;if(!e)return;const t=()=>u(!e.textContent);return e.addEventListener("input",t),()=>e.removeEventListener("input",t)},[]);return(0,$.jsx)("div",{ref:r,contentEditable:!t,suppressContentEditableWarning:!0,className:"rich-textarea"+(s?" "+s:""),style:a,onKeyDown:e=>{m||"Enter"!==e.key||e.shiftKey||e.ctrlKey||e.metaKey||e.altKey||(e.preventDefault(),i?.())},onPaste:c,onInput:()=>o?.(g()),onCompositionStart:()=>h(!0),onCompositionEnd:()=>h(!1),"data-placeholder":d?e:void 0})});function Q({pendingAttachments:e,onRemove:t}){return 0===e.length?null:(0,$.jsx)("div",{className:"chat-attachment-strip",children:e.map((e,s)=>(0,$.jsxs)("div",{className:"chat-attachment-chip",children:[(0,$.jsx)(A.In,{icon:"attach_file"}),(0,$.jsx)("span",{title:e.name,children:e.name}),(0,$.jsx)("button",{type:"button",onClick:()=>t(s),children:(0,$.jsx)(A.In,{icon:"close"})})]},`${e.name}_${s}`))})}const U=(0,n.forwardRef)(({onSend:e,sending:t,onAbort:s,pendingAttachments:a,onRemoveAttachment:c,onOpenFilePicker:o,onAddFiles:l,onDrop:r,onDragOver:d,fileInputRef:u,requestType:m},h)=>{const{t:g}=(0,i.Bd)(),p=(0,n.useRef)(null);return(0,n.useImperativeHandle)(h,()=>({getValue:()=>p.current?.getValue()??"",setValue:e=>p.current?.setValue(e),clear:()=>p.current?.clear()})),(0,$.jsxs)("div",{className:"chat-input-area",onDrop:r,onDragOver:d,children:[(0,$.jsx)("input",{ref:u,type:"file",multiple:!0,style:{display:"none"},onChange:e=>{e.target.files?.length&&(l(e.target.files),e.currentTarget.value="")}}),(0,$.jsxs)("div",{className:"chat-input-shell",children:[(0,$.jsx)(Q,{pendingAttachments:a,onRemove:c}),(0,$.jsx)(W,{ref:p,placeholder:g("输入消息"),onEnter:()=>e(),onPaste:e=>{const t=e.clipboardData?.files;t&&t.length>0&&(e.preventDefault(),l(t))},className:"chat-input"})]}),(0,$.jsx)(A.rA,{title:g("添加文件"),icon:"attach_file",onClick:o}),(0,$.jsx)(G,{requestType:m}),t?(0,$.jsx)(A.Vi,{color:"var( --icon-red)",text:g("暂停"),clickFun:s}):(0,$.jsx)(A.Vi,{text:g("发送"),clickFun:e})]})}),X={},Z=function(){const{t:e}=(0,i.Bd)(),[t,s]=(0,n.useState)([]),[c,l]=(0,n.useState)(!1),[r,d]=(0,n.useState)(null),[u,h]=(0,n.useState)(null),[g,p]=(0,n.useState)(!1),[_,f]=(0,a.fp)(x.AG.ai_bg_expanded),[,j]=(0,a.fp)(x.AG.ai_session_collapsed),v=()=>{f(!1)},b=(0,n.useCallback)(async()=>{l(!0);try{const e=new o.hf(o.HK.ai_bg_process_list_req);e.context={};const t=await k.ws.send(e);t?.context?.processes&&(s(t.context.processes),X.onCountChange?.(t.context.processes.length))}catch(e){console.error("获取后台进程列表失败",e)}finally{l(!1)}},[]);X.refresh=b;const y=(0,n.useCallback)(async e=>{p(!0),d(e);try{const t=new o.hf(o.HK.ai_bg_process_output_req);t.context={pid:e};const s=await k.ws.send(t);h(s.context)}catch(e){console.error("获取进程输出失败",e),(0,m.zN)("获取进程输出失败")}finally{p(!1)}},[]),S=(0,n.useCallback)(async e=>{try{const t=new o.hf(o.HK.ai_bg_process_kill_req);t.context={pid:e};const s=await k.ws.send(t);s?.context?.success?((0,m.SK)("进程已终止"),b(),r===e&&(d(null),h(null))):(0,m.zN)(s?.context?.message||"终止失败")}catch(e){console.error("终止进程失败",e),(0,m.zN)("终止进程失败")}},[b,r]);(0,n.useEffect)(()=>{b();const e=setInterval(b,5e3);return()=>clearInterval(e)},[b]);const w=t.filter(e=>e.running),N=t.filter(e=>!e.running);return(0,$.jsxs)($.Fragment,{children:[_&&(0,$.jsx)("div",{className:"chat-session-overlay",onClick:v}),(0,$.jsxs)("aside",{className:"chat-bg-process-panel "+(_?"expanded":""),children:[(0,$.jsxs)("div",{className:"chat-bg-process-header",children:[(0,$.jsx)("span",{className:"chat-bg-process-title",children:e("后台进程")}),(0,$.jsx)(A.rA,{icon:"close",title:e("关闭"),onClick:v})]}),(0,$.jsxs)("div",{className:"chat-bg-process-toolbar",children:[(0,$.jsx)(A.rA,{icon:"refresh",title:e("刷新"),onClick:b}),(0,$.jsxs)("span",{className:"chat-bg-process-count",children:[w.length," ",e("个运行中"),N.length>0&&` / ${N.length} ${e("个已退出")}`]})]}),(0,$.jsxs)("div",{className:"chat-bg-process-list",children:[c&&0===t.length&&(0,$.jsx)("div",{className:"chat-bg-process-empty",children:e("加载中...")}),!c&&0===t.length&&(0,$.jsx)("div",{className:"chat-bg-process-empty",children:e("暂无后台进程")}),w.map(t=>(0,$.jsxs)("div",{className:`chat-bg-process-item ${r===t.pid?"active":""} running`,children:[(0,$.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(t.pid),children:[(0,$.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",t.pid]}),(0,$.jsx)("span",{className:"chat-bg-process-cmd",title:t.cmd,children:t.cmd.length>40?t.cmd.slice(0,40)+"...":t.cmd}),(0,$.jsx)("span",{className:"chat-bg-process-time",children:new Date(t.start_time).toLocaleTimeString()}),(0,$.jsx)("span",{className:"chat-bg-process-status running-dot",title:e("运行中"),children:"●"})]}),(0,$.jsxs)("div",{className:"chat-bg-process-item-actions",children:[(0,$.jsx)(A.rA,{icon:"terminal",title:e("查看输出"),onClick:()=>y(t.pid)}),(0,$.jsx)(A.rA,{icon:"stop",title:e("终止进程"),onClick:()=>S(t.pid)})]})]},t.pid)),N.map(e=>(0,$.jsx)("div",{className:`chat-bg-process-item ${r===e.pid?"active":""} finished`,children:(0,$.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(e.pid),children:[(0,$.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,$.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>30?e.cmd.slice(0,30)+"...":e.cmd}),(0,$.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,$.jsxs)("span",{className:"chat-bg-process-exit-code",children:["exit: ",e.exit_code]})]})},e.pid))]}),null!==r&&(0,$.jsxs)("div",{className:"chat-bg-process-output",children:[(0,$.jsxs)("div",{className:"chat-bg-process-output-header",children:[(0,$.jsxs)("span",{children:["PID: ",r," ",e("输出")]}),(0,$.jsx)(A.rA,{icon:"close",title:e("关闭"),onClick:()=>{d(null),h(null)}})]}),(0,$.jsx)("div",{className:"chat-bg-process-output-content",children:g?(0,$.jsx)("div",{className:"chat-bg-process-empty",children:e("加载中...")}):u?(0,$.jsx)("pre",{className:"chat-bg-process-output-pre",children:u.output||e("(无输出)")}):null})]})]})]})};function Y(){const{t:e}=(0,i.Bd)(),t=((0,c.Zp)(),(0,h.y)()),{check_user_auth:s}=(0,d.MH)();(0,p.w)();const[b,y]=(0,n.useState)([]),[S,w]=(0,n.useState)([]),[C,A]=(0,n.useState)(""),[I,M]=(0,n.useState)(!1),T=(0,n.useRef)(null),[D,R]=(0,n.useState)([]),[H,P]=(0,a.fp)(x.AG.ai_session_collapsed),[F,V]=(0,a.fp)(x.AG.ai_bg_expanded),[q,B]=(0,a.fp)(x.AG.prompt_card),[K,J]=(0,n.useState)(!1),[G,W]=(0,n.useState)(new Set),[Q,Y]=(0,n.useState)(new Set),[ee,te]=(0,n.useState)(""),se=(0,n.useRef)(null),ne=(0,n.useRef)(null),ae=(0,n.useRef)(null),ie=(0,n.useRef)(!0),ce=(0,n.useRef)(new f.qq),[oe,le]=(0,n.useState)([]),[re,de]=(0,n.useState)(""),[ue,me]=(0,n.useState)(0),he=()=>ce?.current?.ai_config?.request_type||"completions",ge=(0,n.useRef)((0,r.sg)(e=>{y(e),ie.current&&pe(!1)},50)).current,pe=(e=!1)=>{const t=ae.current;t&&t.scrollTo({top:t.scrollHeight,behavior:e?"smooth":"auto"})},xe=async()=>{const e=await l.jV.get("sessions");e.code===g.m.Success&&w(e.data??[])},_e=function(e){const{getMessages:t,setMessages:s,setMessagesDebounced:a,setSending:i,getActiveSessionId:c,setActiveSessionId:l,refreshSessions:r,scrollToBottom:d,buildRequestMessages:u,getSelectedSysPromptId:m}=e,h=(0,n.useRef)([]),g=(0,n.useRef)(null),p=(e,n,c)=>{const l=[...t(),n];s(l),i(!0),g.current={abort:()=>{}};const h={id:n.id+1,sender:"bot",text:"AI思考中...",is_loading:!0};l.push(h),s([...l]);const p=new Map;let x=!0,_=h;const f=e=>{const t=e.context||{},s=t.text||"",n=t.tool_call_ends,i=t.chunk_index??0;if("[DONE]"!==s)if(x)x=!1,_.text=s,n&&(_.content_list=[{tool_call_ends:n,content:_.text,role:"assistant"}]),_.is_loading=!1,_.chunk_index=i,p.set(i,_),a([...l]);else{const e=p.get(i);if(e)e.text+=s,n&&(e.content_list=[{tool_call_ends:n,content:e.text,role:"assistant"}]),a([...l]);else{const e={id:Date.now()+Math.random(),sender:"bot",text:s,chunk_index:i};n&&(e.content_list=[{tool_call_ends:n,content:e.text,role:"assistant"}]),l.push(e),p.set(i,e),a([...l])}}},j=e=>{b(),g.current=null,i(!1),_.is_loading=!1,r(),d(!0),c()},v=e=>{b(),g.current=null,i(!1);const t=e.context||{};_.text="AI请求出错: "+(t.message||"未知错误"),_.is_loading=!1,s([...l]),c()},b=()=>{k.ws.off_message(`message_${o.HK.ai_chat_msg}`,f),k.ws.off_message(`message_${o.HK.ai_chat_end}`,j),k.ws.off_message(`message_${o.HK.ai_chat_error}`,v)};k.ws.addMsg(o.HK.ai_chat_msg,f),k.ws.addMsg(o.HK.ai_chat_end,j),k.ws.addMsg(o.HK.ai_chat_error,v),k.ws.sendData(o.HK.ai_chat_req,{messages:u(n),session_id:e,sys_prompt_id:m()})},x=()=>{const e=h.current;if(0===e.length)return;const t=e.shift();if(!t)return;s(e=>e.map(e=>"user"===e.sender&&e.text.includes("⏳(排队中...)")?{...e,text:e.text.replace(" ⏳(排队中...)","")}:e));const n={id:Date.now(),sender:"user",text:t.text,attachments:t.attachments};p(c(),n,x)};return{startChatStream:p,processPendingQueue:x,enqueueMessage:(e,t)=>{h.current.push({text:e,attachments:t})},getQueueLength:()=>h.current.length,abort:()=>{g.current&&(k.ws.sendData(o.HK.ai_chat_abort,{session_id:c()}),g.current=null,i(!1))}}}({getMessages:()=>b,setMessages:y,setMessagesDebounced:ge,setSending:M,getActiveSessionId:()=>C,setActiveSessionId:A,refreshSessions:xe,scrollToBottom:pe,buildRequestMessages:e=>{const t=(e.attachments??[]).filter(e=>"image"===e.kind);if(t.length>0){const s=[];e.text&&s.push({type:"text",text:e.text});for(const e of t)s.push({type:"image_url",image_url:{url:e.content}});return[{content:s,role:"user",attachments:e.attachments??[]}]}return[{content:e.text,role:"bot"===e.sender?"assistant":"user",attachments:e.attachments??[]}]},getSelectedSysPromptId:()=>ee}),fe=async e=>{const t=await l.jV.get("sessions");if(t.code!==g.m.Success)return;const s=t.data??[];w(s);const n=null===e?s[0]?.id??"":e||C||s[0]?.id||"";n?await je(n):(y([]),A(""))},je=async(e,t=!1)=>{const s=await l.jV.post("session/get",{session_id:e});if(s.code!==g.m.Success||!s.data)return;const n=s.data;A(n.id),y(function(e=[]){return e.filter(e=>"user"===e.role||"assistant"===e.role).map((e,t)=>({id:Date.now()+t,sender:"assistant"===e.role?"bot":"user",text:v(e),attachments:e.attachments??[],content_list:e.content_list,images:e.images,audio:e.audio,embeddings:e.embeddings}))}(n.messages)),t&&P(!1),X.refresh?.(),requestAnimationFrame(()=>pe(!1))},ve=e=>{const t=Array.from(e??[]).filter(Boolean);t.length&&R(e=>[...e,...t])},be=()=>{K&&(W(new Set),Y(new Set)),J(e=>!e)};(0,n.useEffect)(()=>((async()=>{const e=await l.XO.get("ai_agent_setting/env");if(e.code===g.m.Success){ce.current=e.data;const t=e.data.ai_config?.model||"",s=(e.data.ai_config_env?.options_agent_model_list??[]).find(e=>e.label===t);de(s?s.value:t)}await fe();const t=await l.jV.get("system_prompts");t.code===g.m.Success&&le(t.data??[])})(),requestAnimationFrame(()=>pe(!1)),X.onCountChange=me,X.refresh?.(),k.ws.addMsg(o.HK.ai_bg_process_count_notify,e=>{const t=e?.context?.count;"number"==typeof t&&me(t)}),()=>{k.ws.removeMsg(o.HK.ai_bg_process_count_notify)}),[]),(0,n.useEffect)(()=>{const e=ae.current;if(!e)return;const t=()=>{ie.current=((e,t=120)=>{const{scrollTop:s,scrollHeight:n,clientHeight:a}=e;return n-(s+a)<t})(e)};return e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)},[]),(0,n.useLayoutEffect)(()=>{ie.current&&pe(!1)},[b]);return(0,$.jsxs)(n.Fragment,{children:[(0,$.jsx)(E,{currentModelName:re,setCurrentModelName:de,envConfigRef:ce,sysPromptList:oe,batchMode:K,selectedMsgCount:G.size,onToggleSessionPanel:()=>{P(e=>!e)},onCreateSession:async e=>{const t=await l.jV.post("session",{title:"新会话"});if(t.code!==g.m.Success)return;const s=t.data;A(s.id),y([]),P(!1),await fe(s.id),requestAnimationFrame(()=>{const e=document.querySelector(".chat-input");e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,200)+"px")})},onBatchDeleteMessages:()=>{0!==G.size&&t({sub_title:e("确认删除选中的聊天消息吗?"),confirm_fun:async()=>{const e=[];b.forEach((t,s)=>{G.has(t.id)&&e.push(s)}),y(b.filter(e=>!G.has(e.id))),W(new Set),J(!1),C&&e.length>0&&l.jV.post("session/message/delete",{session_id:C,indices:e}).catch(console.error)}})},bgProcessVisible:F,bgProcessCount:ue,onToggleBgProcess:()=>V(e=>!e),selectedSysPromptId:ee,setSelectedSysPromptId:te}),(0,$.jsxs)("div",{className:"chat-page chat-page-with-sessions",children:[H&&(0,$.jsx)("div",{className:"chat-session-overlay",onClick:()=>P(!1)}),(0,$.jsx)(L,{sessions:S,activeSessionId:C,onSelectSession:e=>je(e,!1),onRenameSession:(e,s)=>{let n=s;t({confirm_fun:async()=>{await l.jV.post("sessions/update/meta",{id:e,title:n}),await fe(C)},context_div:(0,$.jsx)("div",{className:"card-content",children:(0,$.jsx)(_.Sm,{value:n,handleInputChange:e=>{n=e}})})})},onDeleteSession:e=>{t({sub_title:"确认删除这个会话吗?",confirm_fun:async()=>{await l.jV.post("session/delete",{session_id:e}),C===e?(A(""),await fe(null)):await fe(C)}})},onShowUsageStats:async t=>{B({open:!0,title:e("Token消耗统计"),context_div:(0,$.jsx)("div",{className:"usage-stats-loading",children:e("加载中...")}),cancel:()=>B({open:!1})});try{const s=await l.jV.post("session/usage_stats",{session_id:t});if(s.code===g.m.Success&&s.data){const t=s.data;B({open:!0,title:e("Token消耗统计"),context_div:(0,$.jsxs)("div",{className:"usage-stats-panel",children:[[{l:e("对话轮次"),v:(t.turns??0).toString()},{l:e("AI输入Token"),v:j(t.input_tokens)},{l:e("AI输出Token"),v:j(t.output_tokens)},{l:e("AI输入Token(最近一轮)"),v:j(t.recent_input_tokens)},{l:e("AI输出Token(最近一轮)"),v:j(t.recent_output_tokens)}].map((e,t)=>(0,$.jsxs)("div",{className:"usage-stats-row",children:[(0,$.jsx)("span",{className:"usage-stats-label",children:e.l}),(0,$.jsx)("span",{className:"usage-stats-value",children:e.v})]},t)),(0,$.jsxs)("div",{className:"usage-stats-row usage-stats-total",children:[(0,$.jsx)("span",{className:"usage-stats-label",children:e("AI Token总计消耗")}),(0,$.jsx)("span",{className:"usage-stats-value",children:j((t.input_tokens||0)+(t.output_tokens||0))})]})]}),cancel:()=>B({open:!1})})}else B({open:!0,title:e("Token消耗统计"),context_div:(0,$.jsx)("div",{className:"usage-stats-empty",children:e("暂无统计数据")}),cancel:()=>B({open:!1})})}catch{B({open:!0,title:e("Token消耗统计"),context_div:(0,$.jsx)("div",{className:"usage-stats-empty",children:e("暂无统计数据")}),cancel:()=>B({open:!1})})}},batchMode:K,selectedSessionIds:Q,onToggleSessionSelect:e=>{Y(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},onToggleBatchMode:be,onBatchDeleteSessions:()=>{0!==Q.size&&t({sub_title:e("确认删除选中的会话吗?"),confirm_fun:async()=>{for(const e of Q)await l.jV.post("session/delete",{session_id:e});Y(new Set),J(!1),Q.has(C)?(A(""),await fe(null)):await fe(C)}})},onClearAllSessions:()=>{t({sub_title:e("确认删除全部聊天会话吗?"),confirm_fun:async()=>{await l.jV.post("sessions/clear",{}),A(""),y([]),await fe(null)}})}}),(0,$.jsx)(Z,{}),(0,$.jsxs)("section",{className:"chat-main",children:[0===b?.length&&(0,$.jsx)("div",{className:"chat-header",children:(0,$.jsx)("div",{children:e("询问服务器的一切")})}),(0,$.jsx)(z,{messages:b,batchMode:K,selectedMsgIds:G,sending:I,chatContainerRef:ae,messagesEndRef:ne,onToggleMsgSelect:e=>{W(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},onDelete:s=>{t({sub_title:e("确认删除这条消息吗?"),confirm_fun:async()=>{const e=b.findIndex(e=>e.id===s);if(e<0)return;const t=b.filter(e=>e.id!==s);y(t),C&&l.jV.post("session/message/delete",{session_id:C,indices:[e]}).catch(console.error)}})},onCopy:async e=>{(0,u.lW)(e),(0,m.SK)("复制成功")},onToggleBatchMode:be,t:e}),(0,$.jsx)(U,{ref:T,onSend:async()=>{const e=(T.current?.getValue()??"").trim();if(!e&&0===D.length)return;if(I){const t=await N(D);_e.enqueueMessage(e,t),T.current?.clear(),R([]);const s={id:Date.now(),sender:"user",text:e+(_e.getQueueLength()>1?" ⏳(排队中...)":""),attachments:t};return void y(e=>[...e,s])}let t=C;if(!t){const s=await l.jV.post("session",{title:(e||D[0]?.name||"新会话").slice(0,28)});if(s.code!==g.m.Success)return;t=s.data.id,A(t),await fe(t)}const s=await N(D),n={id:Date.now(),sender:"user",text:e,attachments:s};T.current?.clear(),R([]);const a=he();if("completions"!==a){const s={id:n.id+1,sender:"bot",text:"处理中...",is_loading:!0},i=[...b,n,s];y(i),M(!0);return void(await O(a,e,t,async(e,t)=>{s.text=e,s.is_loading=!1,t?.images&&(s.images=t.images),t?.audio&&(s.audio=t.audio),t?.embeddings&&(s.embeddings=t.embeddings),y([...i]),M(!1),xe(),pe(!0),_e.processPendingQueue()})||(s.text=`请求类型 "${a}" 的专用处理器尚未实现,请使用 completions 类型。`,s.is_loading=!1,y([...i]),M(!1),_e.processPendingQueue()))}_e.startChatStream(t,n,()=>_e.processPendingQueue())},sending:I,onAbort:_e.abort,pendingAttachments:D,onRemoveAttachment:e=>{R(t=>t.filter((t,s)=>s!==e))},onOpenFilePicker:()=>{se.current?.click()},onAddFiles:ve,onDrop:e=>{const t=e.dataTransfer?.files;t&&t.length>0&&(e.preventDefault(),ve(t))},onDragOver:e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},fileInputRef:se,requestType:he()})]})]})]})}},72693(e,t,s){s.d(t,{w:()=>u});var n=s(96540),a=s(22022),i=s(14944),c=s(92275),o=s(34843),l=s(82893),r=s(85997),d=s(74848);function u(){const[e,t]=(0,o.fp)(l.AG.prompt_card),{t:s}=(0,a.Bd)(),u=(0,n.useRef)([]),m=(0,n.useRef)(!1),h=(0,n.useCallback)(()=>{if(m.current)return;if(0===u.current.length)return m.current=!1,void t({open:!1});m.current=!0;const e=u.current.shift();e?t({open:!0,title:s("命令确认"),cancel:()=>{i.ws.sendData(c.HK.ai_confirm_cmd,{askId:e.askId,approved:!1}),t({open:!1}),m.current=!1,h()},context_div:(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{style:{maxHeight:"60vh",overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-all",background:"var(--surfaceSecondary)",padding:"0.75em",borderRadius:"0.5em",marginBottom:"0.75em",fontFamily:"monospace",fontSize:"0.9em",lineHeight:"1.5"},children:e.cmd}),(0,d.jsxs)("div",{style:{display:"flex",gap:"0.5em",justifyContent:"flex-end"},children:[(0,d.jsx)(r.$n,{text:s("拒绝"),color:"var(--red)",clickFun:()=>{i.ws.sendData(c.HK.ai_confirm_cmd,{askId:e.askId,approved:!1}),t({open:!1}),m.current=!1,h()}}),(0,d.jsx)(r.$n,{text:s("允许"),clickFun:()=>{i.ws.sendData(c.HK.ai_confirm_cmd,{askId:e.askId,approved:!0}),t({open:!1}),m.current=!1,h()}})]})]})}):m.current=!1},[s]),g=(0,n.useCallback)(e=>{u.current.push(e),h()},[h]);(0,n.useEffect)(()=>(i.ws.addMsg(c.HK.ai_confirm_cmd,e=>{const s=e.context||{};if(s.dismiss&&s.askId)return u.current=u.current.filter(e=>e.askId!==s.askId),void(m.current&&(m.current=!1,t({open:!1}),h()));s.askId&&s.cmd&&g({askId:s.askId,cmd:s.cmd})}),()=>{i.ws.removeMsg(c.HK.ai_confirm_cmd)}),[g]),(0,n.useEffect)(()=>()=>{u.current=[],m.current=!1},[])}},34299(e,t,s){s.r(t),s.d(t,{default:()=>p});s(96540);var n=s(73557),a=s(53995),i=s(18569),c=s(77979),o=s(8263),l=s(69428),r=s.n(l),d=(s(3775),s(21499)),u=s(99214),m=s(19878),h=(s(72411),s(74848));const g=new n.A({html:!0,highlight:function(e,t){if(t&&m.A.getLanguage(t))try{return`<pre class="hljs code-block-with-copy"><code class="hljs language-${t}">${m.A.highlight(e,{language:t}).value}</code></pre>`}catch(e){}try{return`<pre class="hljs code-block-with-copy"><code class="hljs">${m.A.highlightAuto(e).value}</code></pre>`}catch(e){}return`<pre class="hljs code-block-with-copy"><code>${g.utils.escapeHtml(e)}</code></pre>`}});function p(e){return(0,u.VD)(),(0,h.jsx)("div",{dangerouslySetInnerHTML:{__html:g.render(e.context)}})}g.use(a.A).use(i.A).use(c.A).use(o.A).use(r()).use(e=>{e.renderer.rules.fence;e.renderer.rules.fence=(t,s,n,a,i)=>{const c=t[s],o=c.content.trim(),l=c.info.trim();let r="";if(l&&m.A.getLanguage(l))try{r=m.A.highlight(o,{language:l}).value}catch(t){r=e.utils.escapeHtml(o)}else try{r=m.A.highlightAuto(o).value}catch(t){r=e.utils.escapeHtml(o)}return`\n <div class="code-block-with-copy">\n <div class="code-header">\n <span class="code-language">${l||"code"}</span>\n <button class="copy-btn" data-code="${e.utils.escapeHtml(o)}">复制</button>\n </div>\n <pre><code class="hljs ${l?`language-${l}`:""}">${r}</code></pre>\n </div>`}}).use(e=>{const t=e.renderer.rules.link_open||function(e,t,s,n,a){return a.renderToken(e,t,s)};e.renderer.rules.link_open=(e,s,n,a,i)=>{const c=e[s],o=c.attrIndex("href");if(o>=0){const e=c.attrs[o][1];c.attrs[o][1]=(0,d.bi)(window.location.href,e)}return t(e,s,n,a,i)}})},45907(e,t,s){s.d(t,{y:()=>i});var n=s(34843),a=s(82893);function i(){const[e,t]=(0,n.fp)(a.AG.confirm);return({sub_title:e,confirm_fun:s,title:n,context_div:a})=>{t({open:!0,sub_title:e,handle:()=>{s(),t({open:!1,handle:null})},title:n,context_div:a})}}},60840(e){e.exports="data:image/svg+xml,<svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 16 16%27 version=%271.1%27 aria-hidden=%27true%27><path fill-rule=%27evenodd%27 d=%27M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z%27></path></svg>"}}]);
|
|
File without changes
|