filecat 7.19.0 → 7.20.1
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/{1075.1b51ec4165a736f17167.js → 1075.d1c52b0474a02deca2a7.js} +1 -1
- package/build/dist/1636.f2a1d2c8cdfb4d88cd65.js +1 -0
- package/build/dist/2334.01508a16bdae8e884919.js +1 -0
- package/build/dist/2547.4594e21c13d748e832bd.js +1 -0
- package/build/dist/2674.9ee06a379b79d961ec80.js +1 -0
- package/build/dist/{3402.b6dc28d2f9bace7cde85.js → 3402.30e70a3fe5d2c355bae5.js} +1 -1
- package/build/dist/3528.f4bf3684610c3ce28c08.js +1 -0
- package/build/dist/3659.a257153b5a0947e81b3c.js +1 -0
- package/build/dist/4903.a4194ec784a0ff517e93.js +1 -0
- package/build/dist/6404.a22a232695feabc4ced4.js +1 -0
- package/build/dist/6805.d46e56ad021c3bdf31c3.js +1 -0
- package/build/dist/7181.2403d6d75f9d4ea6917d.js +1 -0
- package/build/dist/735.3ad00d641e954426413e.js +1 -0
- package/build/dist/8358.3390335b191e2d9c6d0f.js +1 -0
- package/build/dist/{8649.bc1338c32cdf89b1ef37.js → 8649.079b2b71e5ff82a51690.js} +1 -1
- package/build/dist/9857.2bc49ff0432a7ec15da5.js +1 -0
- package/build/dist/index.html +1 -1
- package/build/dist/main.b3a24ee626d321ee67fc.js +2 -0
- package/build/dist/{main.04042464d0cefb1813fa.js.LICENSE.txt → main.b3a24ee626d321ee67fc.js.LICENSE.txt} +2 -0
- package/build/main.js +1 -1
- package/package.json +2 -2
- package/build/dist/1636.b6a17252dfd0d22f09a7.js +0 -1
- package/build/dist/2626.05d1faa293e0a3318b9b.js +0 -1
- package/build/dist/2674.ce785310ebf36a69df86.js +0 -1
- package/build/dist/3528.fde2729943266724c34a.js +0 -1
- package/build/dist/3659.51d135c7d39971353f38.js +0 -1
- package/build/dist/4903.cac82807407e7342b5ad.js +0 -1
- package/build/dist/4946.c95d4f426146e0180172.js +0 -2
- package/build/dist/4946.c95d4f426146e0180172.js.LICENSE.txt +0 -1
- package/build/dist/6010.5400c344149450c83284.js +0 -1
- package/build/dist/6104.05cd833b0fa8c283023e.js +0 -1
- package/build/dist/6404.b92b1aa07125d981f50d.js +0 -1
- package/build/dist/6805.c5a415cdd8bcf6b813fe.js +0 -1
- package/build/dist/7181.76f4ac3d5107cd7966a3.js +0 -1
- package/build/dist/735.a026520268d567d61074.js +0 -1
- package/build/dist/8302.77e6bff8cda76307dc51.js +0 -1
- package/build/dist/8358.6c06132151ac5a4d5e1a.js +0 -1
- package/build/dist/892.866405af488ffd431596.js +0 -1
- package/build/dist/9299.a90b11a4eaf6fb241b97.js +0 -1
- package/build/dist/9334.8b01c2817e89e4e7b38a.js +0 -1
- package/build/dist/main.04042464d0cefb1813fa.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[8649],{8694(e,t,s){s.d(t,{$K:()=>a,RB:()=>l,l5:()=>i,vo:()=>o,vr:()=>r});let n=function(e){return e[e.tcp=0]="tcp",e[e.udp=1]="udp",e}({});class a{open=!1;port;key="";async_ips=[]}class o{client_num_id;client_name;open=!1;ip;mask;serverIp;serverPort;key="";model=n.udp}let l=function(e){return e[e.row=1]="row",e[e.json=2]="json",e[e.form=3]="form",e}({});class r{body_type;header_type;url;method;headers;data;form_data_list;local_download_path}class i{enabled;ip;port;bypass;useForLocal;type}},47996(e,t,s){s.d(t,{d:()=>a});s(96540);var n=s(74848);function a(e){return(0,n.jsxs)("div",{className:"instance-item",children:[(0,n.jsxs)("div",{className:"instance-item__toolbar",children:[(0,n.jsx)("span",{className:"instance-item__label",children:e.title}),e.toolbar]}),e.children]})}},77481(e,t,s){s.d(t,{S:()=>r,X:()=>l});var n=s(96540),a=s(61443),o=s(74848);function l(e){const[t,s]=n.useState([]),l=(0,n.useRef)(-1),[r,i]=(0,n.useState)(-1),[c,d]=(0,n.useState)(-1);(0,n.useEffect)(()=>{e.children?s(Array.isArray(e.children)?e.children:[e.children]):s(e.rows)},[e.rows,e.children]);const p=()=>{l.current=-1,i(-1),d(-1)};return(0,o.jsxs)("table",{children:[(0,o.jsx)("thead",{children:(0,o.jsx)("tr",{children:e.headers?.map((t,s)=>{const n=!!e.filter&&(e.filter.column??0)===s;let l=t;if(n){const s=e.filter,n=s.options.find(e=>e.value===s.value);null!=s.value&&n&&(l=`${t} (${n.label})`)}return(0,o.jsx)("th",{className:n?"table-filter-col":"",children:n?(0,o.jsx)(a.l6,{value:e.filter.value,options:e.filter.options,onChange:e.filter.onChange,bare:!0,trigger_label:l}):t},s)})})}),(0,o.jsx)("tbody",{children:t.map((t,s)=>{const n=!!e.onRowDrag;return(0,o.jsx)("tr",{className:n?(r===s?"row-dragging":"")+(c===s?" row-drop-target":""):"",draggable:n,onContextMenu:()=>{e.handleContextMenu&&e.handleContextMenu(t)},onDragStart:e=>{n&&(l.current=s,i(s),e.dataTransfer.effectAllowed="move")},onDragOver:e=>{!n||l.current<0||(e.preventDefault(),e.dataTransfer.dropEffect="move",d(s))},onDrop:t=>{n&&(t.preventDefault(),(()=>{const t=l.current,s=c;p(),t<0||s<0||t===s||e.onRowDrag?.(t,s)})())},onDragEnd:p,children:t.map((s,n)=>{const a=n===t.length-1?"small":"";return(0,o.jsx)("td",{className:a,style:{width:e.width??"auto"},children:s},n)})},s)})})]})}function r(e){return(0,o.jsx)("div",{style:{display:e.isFlex?"flex":"block"},children:e.columns.map((e,t)=>(0,o.jsx)("div",{children:e},t))})}},88649(e,t,s){s.r(t),s.d(t,{default:()=>H});var n=s(96540),a=s(75725),o=s(14284),l=s(62042),r=s(53459),i=s(70447),c=s(61443),d=s(85997),p=s(77481),u=s(8694),h=s(14944),x=s(92275),v=s(22022),m=s(4412),j=s(74848);function f(e){const{t}=(0,v.Bd)(),[s,f]=(0,n.useState)(void 0),[y,S]=(0,n.useState)(!1),[g,w]=(0,n.useState)(""),[_,b]=(0,n.useState)([t(`${t("名称")}`),t(`${t("虚拟")}ip`),`${t("物理")}`,t("在线状态"),t("选择")]),[I,k]=(0,n.useState)([]),[C,P]=(0,n.useState)({}),[N,D]=(0,n.useState)(!1);(0,n.useEffect)(()=>{(async()=>{const e=new x.hf(x.HK.vir_net_serverIno_get);h.ws.addMsg(x.HK.vir_net_serverIno_get,e=>{(e=>{for(const s of e){const e=s[s.length-1];s[s.length-1]=(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.fq,{ok:e}),t(e?"在线":"离线")]}),s[0]=(0,j.jsx)(i.xP,{context:s[0],tip_context:s[0]}),s[2]=(0,j.jsx)(i.xP,{context:s[2],tip_context:s[2]})}})(e.context),k(e.context)}),await h.ws.send(e)})();return(async()=>{const e=await o._U.get("vir/server/get");if(e.code!==r.m.Success)return;const t=e.data;f(t.port),w(t.key),S(t.open)})(),()=>{}},[]);return(0,j.jsxs)("div",{children:[(0,j.jsxs)(m.aZ,{position:"right",children:[!!Object.keys(C).length&&C[0],!!Object.keys(C).length&&(0,j.jsx)(d.rA,{icon:"delete",title:"删除",onClick:async()=>{await o._U.post("vir/server/delete/client",{ips:Object.keys(C)}),P({})}})]}),(0,j.jsx)(a.fI,{children:(0,j.jsxs)(a.VP,{children:[(0,j.jsxs)(i.Zp,{title:"",rightBottomCom:(0,j.jsx)(d.C3,{text:t("保存"),clickFun:async()=>{const e=new u.$K;e.open=y,e.key=g,N&&(e.async_ips=Object.keys(C)),s&&(e.port=parseInt(s));(await o._U.post("vir/server/save",e)).code===r.m.Success?((0,l.SK)("保存成功"),D(!1)):(0,l.zN)("网络错误")}}),children:[(0,j.jsx)(c.Sm,{placeholder:"port",value:s,handleInputChange:e=>{f(e)}}),(0,j.jsx)(c.Sm,{type:"password",placeholder:"key ",value:g,handleInputChange:e=>{w(e)}}),(0,j.jsxs)("form",{children:[t("状态"),":",(0,j.jsx)(p.S,{isFlex:!0,columns:[(0,j.jsx)(c.U6,{value:1,context:t("开启"),selected:y,onchange:()=>{S(!y)}}),(0,j.jsx)(c.U6,{value:1,context:t("关闭"),selected:!y,onchange:()=>{S(!y)}})]})]}),!!Object.keys(C).length&&(0,j.jsx)(c.GL,{context:t("sync_sv"),selected:N,onchange:()=>{D(!N)}})]}),(0,j.jsx)(i.Zp,{title:"",children:(0,j.jsx)(p.X,{headers:_,rows:I.map(e=>[...e,(0,j.jsx)(c.GL,{context:t(""),selected:C[e[1]],onchange:()=>{const t={...C};t[e[1]]?delete t[e[1]]:t[e[1]]=e,P(t)}})]),width:"10rem"})})]})})]})}function y(e){const{t}=(0,v.Bd)(),[s,m]=(0,n.useState)(""),[f,y]=(0,n.useState)(void 0),[S,g]=(0,n.useState)(""),[w,_]=(0,n.useState)(""),[b,I]=(0,n.useState)(void 0),[k,C]=(0,n.useState)(!1),[P,N]=(0,n.useState)(""),[D,A]=(0,n.useState)(!1);(0,n.useEffect)(()=>{(async()=>{const e=await o._U.get("vir/client/get");if(e.code!==r.m.Success)return;const t=e.data;if(I(t.serverPort),g(t.serverIp),m(t.ip),y(t.mask),N(t.key),C(t.open),_(t.client_name),t.open){const e=new x.hf(x.HK.vir_net_client_get),t=(await h.ws.send(e)).context.state;A(t),h.ws.addMsg(x.HK.vir_net_client_get,e=>{A(e.context.state)})}})()},[]);return(0,j.jsx)("div",{children:(0,j.jsx)(a.fI,{children:(0,j.jsxs)(a.VP,{children:[(0,j.jsxs)(i.Zp,{title:"",rightBottomCom:(0,j.jsx)(d.C3,{text:t("保存"),clickFun:async()=>{const e=new u.vo;e.ip=s,e.mask=parseInt(f),e.key=P,e.serverIp=S,e.serverPort=parseInt(b),e.open=k,e.client_name=w;(await o._U.post("vir/client/save",e)).code===r.m.Success?(0,l.SK)("保存成功"):(0,l.zN)("网络错误")}}),rightTopCom:(0,j.jsxs)("div",{children:[t("连接状态"),(0,j.jsx)(i.fq,{ok:D})]}),children:[(0,j.jsx)(c.Sm,{placeholder:"ip ",value:s,handleInputChange:e=>{m(e)}}),(0,j.jsx)(c.Sm,{placeholder:"mask",value:f,handleInputChange:e=>{y(e)}}),(0,j.jsx)(c.Sm,{placeholder:`${t("服务器")} ip`,value:S,handleInputChange:e=>{g(e)}}),(0,j.jsx)(c.Sm,{placeholder:`${t("服务器")} part`,value:b,handleInputChange:e=>{I(e)}}),(0,j.jsx)(c.Sm,{placeholder:"名称 ",value:w,handleInputChange:e=>{_(e)}}),(0,j.jsx)(c.Sm,{type:"password",placeholder:"key ",value:P,handleInputChange:e=>{N(e)}}),(0,j.jsxs)("form",{children:[t("状态"),(0,j.jsx)(p.S,{isFlex:!0,columns:[(0,j.jsx)(c.U6,{value:1,context:t("开启"),selected:k,onchange:()=>{C(!k)}}),(0,j.jsx)(c.U6,{value:1,context:t("关闭"),selected:!k,onchange:()=>{C(!k)}})]})]})]}),(0,j.jsxs)(i.Zp,{title:"",children:[(0,j.jsx)("div",{children:"ip: 虚拟ip, “10.0.0.0 - 10.255.255.255”和“172.16.0.0 - 172.31.255.255”和“192.168.0.0 - 192.168.255.255”这三个网段属于内网ip"}),(0,j.jsx)("div",{children:"mask: 一些常见的子网掩码网段/8:255.0.0.0;/16:255.255.0.0 ;/24:255.255.255.0"}),(0,j.jsx)("div",{children:"key:用于验证身份信息并加密的和服务器设置的一样"})]})]})})})}var S=s(47996),g=s(34843),w=s(82893),_=s(23430),b=s(78247),I=s(21499),k=s(24659),C=s(64694);function P(e){const{t}=(0,v.Bd)(),[s,h]=(0,n.useState)(""),[x,m]=(0,n.useState)(""),[f,y]=(0,n.useState)(""),[P,N]=(0,n.useState)(!1),[D,A]=(0,n.useState)(!1),[$,K]=(0,n.useState)({list:[]}),[T,O]=(0,g.fp)(w.AG.editorSetting),[U,F]=(0,g.fp)(w.AG.user_base_info),z=[t("端口"),t("目标地址"),t("目标端口"),t("开启"),t("备注"),t("删除")],[B,M]=(0,n.useState)([]),H=[t("port"),t("ip"),t("type"),t("开启")],[W,V]=(0,n.useState)([]),G=[t("编辑"),t("开启"),t("备注"),t("删除")],q=(0,k.K)(),X=async()=>{const e=[o._U.post("vir/client/tcp_proxy/get"),o._U.post("http/proxy/server/get")];let t;U.sys===_.XM.mac?t=(async()=>{const e=await o._U.post("http/proxy/get/mac");if(e.code!==r.m.Success)return;const t=[],s=[];for(const n of e.data)"Wi-Fi"===n.name?t.push(n):s.push(n);V([...t,...s])})():U.sys===_.XM.win&&(t=(async()=>{const e=await o._U.post("http/proxy/get/win");if(e.code===r.m.Success){const t=e.data;h(t.ip),m(t.port),N(t.enabled),y(t.bypass),A(t.useForLocal)}})()),t&&e.push(t);const[s,n]=await Promise.all(e);s.code===r.m.Success&&M(s.data),n.code===r.m.Success&&K(n.data)};(0,n.useEffect)(()=>{X()},[]);return(0,j.jsx)("div",{children:(0,j.jsxs)(a.fI,{children:[U.sys===_.XM.win&&(0,j.jsx)(a.VP,{widthPer:33,children:(0,j.jsxs)(i.Zp,{title:"Http Proxy",rightBottomCom:(0,j.jsx)(d.C3,{text:t("保存"),clickFun:async()=>{const e=new u.l5;e.port=parseInt(x),e.enabled=P,e.useForLocal=D,e.ip=s,e.bypass=f;(await o._U.post("http/proxy/set/win",e)).code===r.m.Success&&(X(),(0,l.SK)("保存成功"))}}),children:[(0,j.jsx)(c.Sm,{placeholder:"ip (default localhost) ",value:s,handleInputChange:e=>{h(e)}}),(0,j.jsx)(c.Sm,{placeholder:"port ",value:x,handleInputChange:e=>{m(e)}}),(0,j.jsx)(c.Sm,{placeholder:t("忽略ip"),value:f,handleInputChange:e=>{y(e)}}),(0,j.jsxs)("form",{children:[t("pxy_nln"),(0,j.jsx)(p.S,{isFlex:!0,columns:[(0,j.jsx)(c.U6,{value:1,context:t("开启"),selected:D,onchange:()=>{A(!D)}}),(0,j.jsx)(c.U6,{value:1,context:t("关闭"),selected:!D,onchange:()=>{A(!D)}})]})]}),(0,j.jsxs)("form",{children:[t("状态"),(0,j.jsx)(p.S,{isFlex:!0,columns:[(0,j.jsx)(c.U6,{value:1,context:t("开启"),selected:P,onchange:()=>{N(!P)}}),(0,j.jsx)(c.U6,{value:1,context:t("关闭"),selected:!P,onchange:()=>{N(!P)}})]})]})]})}),U.sys===_.XM.mac&&(0,j.jsx)(a.VP,{children:W.map((e,s)=>(0,j.jsxs)(i.uF,{self_title:(0,j.jsxs)("span",{className:" div-row ",children:[(0,j.jsx)("h2",{children:e.name})," "]}),rightTopCom:(0,j.jsx)("div",{children:(0,j.jsx)(d.rA,{icon:"save",title:t("保存"),onClick:()=>{(async e=>{const t=W[e];(await o._U.post("http/proxy/set/mac",[t])).code===r.m.Success&&(X(),(0,l.SK)("保存成功"))})(s)}})}),children:[(0,j.jsx)(p.X,{headers:H,rows:e.proxies.map((e,t)=>{const n=[(0,j.jsx)(c.Sm,{value:e.port,handleInputChange:t=>{e.port=parseInt(t)},no_border:!0}),(0,j.jsx)(c.Sm,{value:e.ip,handleInputChange:t=>{e.ip=t},no_border:!0}),(0,j.jsx)("div",{children:1===e.type?"http":"https"}),(0,j.jsx)(c.l6,{value:e.enabled,onChange:e=>{((e,t,s)=>{const n=[...W];n[e].proxies[t].enabled=s,V(n)})(s,t,e)},options:q,no_border:!0})];return n}),width:"10rem"}),"ignore ips",(0,j.jsx)(c.Sm,{value:e.bypass,handleInputChange:e=>{W[s].bypass=e},no_border:!0})]},s))}),(0,j.jsxs)(a.VP,{children:[(0,j.jsx)(i.uF,{self_title:(0,j.jsxs)("span",{className:" div-row ",children:[(0,j.jsx)("h2",{children:t("Tcp Proxy")})," "]}),rightTopCom:(0,j.jsxs)("div",{children:[(0,j.jsx)(d.rA,{icon:"add",title:t("添加"),onClick:()=>{M([...B,{note:"",open:!1,port:0,target_port:0,target_ip:""}])}}),(0,j.jsx)(d.rA,{icon:"save",title:t("保存"),onClick:async()=>{const e=[];for(let t=0;t<B.length;t++)B[t].index=t,e.push(B[t]);(await o._U.post("vir/client/tcp_proxy/save",e)).code===r.m.Success&&((0,l.SK)("保存成功"),X())}})]}),children:(0,j.jsx)(p.X,{headers:z,rows:B.map((e,s)=>{const n=[(0,j.jsx)(c.Sm,{value:e.port,handleInputChange:t=>{e.port=parseInt(t)},no_border:!0}),(0,j.jsx)(c.Sm,{value:e.target_ip,handleInputChange:t=>{e.target_ip=t},no_border:!0}),(0,j.jsx)(c.Sm,{value:e.target_port,handleInputChange:t=>{e.target_port=parseInt(t)},no_border:!0}),(0,j.jsx)(c.l6,{value:e.open,onChange:e=>{B[s].open=e,M([...B])},options:q,no_border:!0}),(0,j.jsx)(c.Sm,{value:e.note,handleInputChange:t=>{e.note=t},no_border:!0}),(0,j.jsx)("div",{children:(0,j.jsx)(d.rA,{icon:"delete",title:t("删除"),onClick:()=>(e=>{B.splice(e,1),M([...B])})(s)})})];return n}),width:"10rem",onRowDrag:(e,t)=>{M((0,C.TI)(B,e,t))}})}),(0,j.jsx)(i.uF,{self_title:(0,j.jsxs)("span",{className:" div-row ",children:[(0,j.jsx)("h2",{children:t("Http Proxy Server")})," "]}),rightTopCom:(0,j.jsxs)("div",{children:[(0,j.jsx)(d.rA,{icon:"add",title:t("添加端口实例"),onClick:()=>{$.list.push({open:!1,port:0,note:"",list:[]}),K({...$})}}),(0,j.jsx)(d.rA,{icon:"save",title:t("保存"),onClick:async()=>{(await o._U.post("http/proxy/server/save",$)).code===r.m.Success&&(0,l.SK)("保存成功")}})]}),children:$.list.map((e,s)=>(0,j.jsx)(S.d,{title:`${t("端口实例")} #${s+1}`,toolbar:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)("span",{children:t("状态")}),(0,j.jsx)(c.l6,{value:e.open,width:"15%",onChange:t=>{e.open=t,K({...$})},options:q,no_border:!0}),(0,j.jsx)("span",{children:t("端口")}),(0,j.jsx)(c.Sm,{value:e.port||"",handleInputChange:t=>{e.port=t?parseInt(t):0,K({...$})},no_border:!0,width:"80px"}),(0,j.jsx)(d.rA,{icon:"add",title:t("添加规则"),onClick:()=>{e.list.push({note:"",open:!1}),K({...$})}}),(0,j.jsx)(d.rA,{icon:"delete",title:t("删除端口实例"),onClick:()=>{$.list.splice(s,1),K({...$})}}),(0,j.jsx)(c.Sm,{placeholder:t("备注"),width:"100%",value:e.note,handleInputChange:t=>{e.note=t,K({...$})},no_border:!0})]}),children:(0,j.jsx)(p.X,{headers:G,rows:e.list.map((n,a)=>{const l=[(0,j.jsx)("div",{children:(0,j.jsx)(d.rA,{icon:"edit",title:t("编辑"),onClick:()=>{(async(e,t)=>{const s=$.list[e];if(!s)return;const n=s.list[t];if(!n)return;n.random_key||(n.random_key=(0,I.hU)(),K({...$}));const a=await o._U.post("http/proxy/server/code/get",{key:n.random_key,name:n.random_key});O({model:"ace/mode/javascript",open:!0,fileName:"",can_format:!0,save:async e=>{await o._U.post("http/proxy/server/code/save",{context:e,key:n.random_key})}}),b.xK.set_value_temp(a.data)})(s,a)}})}),(0,j.jsx)(c.l6,{value:n.open,onChange:t=>{e.list[a].open=t,K({...$})},options:q,no_border:!0}),(0,j.jsx)(c.Sm,{value:n.note,handleInputChange:e=>{n.note=e},no_border:!0}),(0,j.jsx)("div",{children:(0,j.jsx)(d.rA,{icon:"delete",title:t("删除"),onClick:()=>{e.list.splice(a,1),K({...$})}})})];return l}),width:"10rem"})},s))})]})]})})}var N=s(87361);let D=function(e){return e.physics="物理",e.http_get="http_get",e.fixed="fixed",e}({}),A=function(e){return e.unverified="unverified",e.ok="ok",e.fail="fail",e}({}),$=function(e){return e.dnspod="dnspod",e.tengxun="tengxun",e.ali="ali",e.cloudflare="cloudflare",e.godaddy="godaddy",e.namesilo="namesilo",e.namecheap="namecheap",e.vercel="vercel",e.duckdns="duckdns",e.noip="noip",e.easydns="easydns",e.freedns="freedns",e.dynv6="dynv6",e.oray="oray",e.dyn="dyn",e.custom="custom",e}({});const K=[{provider:$.dnspod,label:"DNSPod(腾讯)",fields:[{label:"ID",placeholder:"ID"},{label:"Token",placeholder:"在密钥管理中生成",password:!0}],info:"DNSPod 老版 API。在 dnspod.cn 控制台「用户中心 - 密钥管理」创建 API Token,分别填入 ID 与 Token。"},{provider:$.tengxun,label:"腾讯云 DNSPod",fields:[{label:"SecretId",placeholder:"云 API 密钥 ID"},{label:"SecretKey",placeholder:"云 API 密钥 Key",password:!0}],info:"腾讯云新版云 API。在腾讯云控制台「访问管理 - API 密钥管理」创建密钥,分别填入 SecretId 与 SecretKey。"},{provider:$.ali,label:"阿里云解析",fields:[{label:"AccessKeyId",placeholder:"AccessKey ID"},{label:"AccessKeySecret",placeholder:"AccessKey Secret",password:!0}],info:"在阿里云控制台「AccessKey 管理」创建密钥,分别填入 AccessKeyId 与 AccessKeySecret。"},{provider:$.cloudflare,label:"Cloudflare",fields:[{label:"API Token",placeholder:"Cloudflare API 令牌",password:!0}],info:"在 Cloudflare「我的个人资料 - API 令牌」创建令牌,权限需包含「编辑区域 DNS」。"},{provider:$.godaddy,label:"GoDaddy",fields:[{label:"API Key",placeholder:"GoDaddy API Key"},{label:"API Secret",placeholder:"GoDaddy API Secret",password:!0}],info:"在 GoDaddy 开发者后台创建 API Key(生产环境),分别填入 Key 与 Secret。"},{provider:$.namesilo,label:"NameSilo",fields:[{label:"API Key",placeholder:"NameSilo API Key",password:!0}],info:"在 NameSilo「账号 - API Manager」生成 API Key。"},{provider:$.namecheap,label:"Namecheap",fields:[{label:"Dynamic DNS 密码",placeholder:"Namecheap DDNS 密码",password:!0}],info:"在 Namecheap 域名管理页「Advanced DNS」开启 Dynamic DNS,复制其中的密码。不支持 IPv6。"},{provider:$.vercel,label:"Vercel",fields:[{label:"API Token",placeholder:"Vercel API Token",password:!0}],info:"在 Vercel「账号设置 - Tokens」创建 Token,需具备 DNS 权限。"},{provider:$.duckdns,label:"DuckDNS",fields:[{label:"Token",placeholder:"DuckDNS Token",password:!0}],info:"DuckDNS 首页登录后即可看到 Token。域名需为 xxx.duckdns.org 形式。"},{provider:$.dynv6,label:"dynv6",fields:[{label:"Token",placeholder:"dynv6 Token",password:!0}],info:"在 dynv6 域名详情页复制 HTTP 更新 token 填入。"},{provider:$.freedns,label:"FreeDNS(afraid.org)",fields:[{label:"更新 Token",placeholder:"FreeDNS 更新 Token",password:!0}],info:"在 FreeDNS 域名管理页的 Dynamic DNS 链接中复制 update token 填入。"},{provider:$.noip,label:"No-IP",fields:[{label:"用户名",placeholder:"No-IP 用户名"},{label:"密码",placeholder:"No-IP 密码",password:!0}],info:"No-IP 官网账号的用户名与密码。"},{provider:$.easydns,label:"easyDNS",fields:[{label:"用户名",placeholder:"easyDNS 用户名"},{label:"密码",placeholder:"easyDNS 密码",password:!0}],info:"easyDNS 账号的用户名与密码。"},{provider:$.oray,label:"花生壳 Oray",fields:[{label:"账号",placeholder:"花生壳账号"},{label:"密码",placeholder:"花生壳密码",password:!0}],info:"花生壳官网账号与密码。更新地址:ddns.oray.com/ph/update。"},{provider:$.dyn,label:"通用 DynDNS2",fields:[{label:"用户名",placeholder:"DynDNS 用户名"},{label:"密码",placeholder:"DynDNS 密码",password:!0}],info:"适用于兼容 DynDNS2 协议的服务(更新地址 members.dyndns.org)。"},{provider:$.custom,label:"自定义 HTTP",fields:[{label:"URL 模板",placeholder:"https://example.com/update?domain={host}&ip={ip}"}],info:"任意支持 HTTP 更新的 DDNS 服务,模板中可用 {host} {ip} {family} 占位。"}];function T(e){return K.find(t=>t.provider===e)}function O(e,t){const s=(e??"").split(","),n=[];for(let e=0;e<t;e++)n.push((s[e]??"").trim());return n}function U(e){if(!e)return"-";const t=new Date(e),s=e=>String(e).padStart(2,"0");return`${t.getFullYear()}-${s(t.getMonth()+1)}-${s(t.getDate())} ${s(t.getHours())}:${s(t.getMinutes())}:${s(t.getSeconds())}`}function F(e){if(!e)return"-";const t=Date.now()-e;if(t<6e4)return"刚刚";if(t<36e5)return`${Math.floor(t/6e4)} 分钟前`;if(t<864e5)return`${Math.floor(t/36e5)} 小时前`;const s=new Date(e),n=e=>String(e).padStart(2,"0");return`${n(s.getMonth()+1)}-${n(s.getDate())} ${n(s.getHours())}:${n(s.getMinutes())}`}function z(e){const{t}=(0,v.Bd)();return e.status===A.ok?(0,j.jsx)(i.fq,{success:!0,text:t("成功")}):e.status===A.fail?(0,j.jsx)(i.fq,{success:!1,text:t("失败")}):(0,j.jsx)(i.fq,{text:t("未验证")})}function B(){const{t:e}=(0,v.Bd)(),[,t]=(0,g.fp)(w.AG.confirm),[s,u]=(0,g.fp)(w.AG.prompt_card),[h,x]=(0,n.useState)([]),[m,f]=(0,n.useState)(null),[y,_]=(0,n.useState)([]),[b,I]=(0,n.useState)(60),[k,C]=(0,n.useState)(!1),P=async()=>{const e=await o.ez.get("ip_options");e.code===r.m.Success&&_(e.data??[])};(0,n.useEffect)(()=>{(async()=>{const e=await o.ez.get("list");e.code===r.m.Success&&x(e.data??[])})(),P(),(async()=>{const e=await o.ez.get("interval");e.code===r.m.Success&&I(e.data?.interval??60)})()},[]);const N=K.map(e=>({label:e.label,value:e.provider})),B=y.map(t=>({label:t.source_type===D.fixed?`${e("IP")} ${t.ifaceOrWww} (${t.isIPv4?"IPv4":"IPv6"})`:`${t.ifaceOrWww} (${t.isIPv4?"IPv4":"IPv6"}) ${t.ip??""}`,value:H(t)}));function H(e){return`${e.ifaceOrWww}#${e.scopeid??""}#${e.isIPv4?"4":"6"}`}const W=(e,t)=>{m&&f({...m,[e]:t})},V=m?T(m.provider):void 0,G=m?O(m.account,V?.fields.length??1):[];return(0,j.jsxs)(a.fI,{children:[(0,j.jsx)(a.VP,{widthPer:50,maxWidth:"60rem",children:(0,j.jsx)(a.xh,{children:(0,j.jsxs)(i.uF,{self_title:(0,j.jsxs)("span",{className:" div-row ",children:[(0,j.jsx)("h2",{children:e("动态域名解析")}),(0,j.jsx)(d.rA,{icon:"info",onClick:()=>{u({open:!0,title:e("信息"),context_div:(0,j.jsxs)("div",{children:[(0,j.jsx)("p",{children:e("ddns_help_1")}),(0,j.jsx)("p",{children:e("ddns_help_2")})]})})},title:e("信息")})]}),rightTopCom:(0,j.jsxs)("div",{children:[(0,j.jsx)(d.rA,{icon:"sync",title:e("立即同步"),selected:k,onClick:async()=>{C(!0);try{const t=await o.ez.post("sync_now",{});t.code===r.m.Success?((0,l.SK)(e("同步完成")),x(t.data??[])):(0,l.zN)(t.message??e("操作失败"))}finally{C(!1)}}}),(0,j.jsx)(d.rA,{icon:"dns",title:e("IP 来源管理"),onClick:()=>{u({open:!0,title:e("IP 来源管理"),context_div:(0,j.jsx)(M,{on_refresh:P})})}}),(0,j.jsx)(d.rA,{icon:"add",title:e("添加"),onClick:()=>{f({id:"",provider:$.dnspod,account:"",isOpen:!1,note:"",ips:[],account_status:A.unverified,account_message:"",is_new:!0})}})]}),children:[(0,j.jsxs)(c.BC,{label:e("同步间隔"),label_width:"5rem",row:!0,children:[(0,j.jsx)(c.Sm,{value:String(b),type:"number",width:"6rem",handleInputChange:e=>I(Number(e))}),(0,j.jsx)("span",{children:e("秒")}),(0,j.jsx)(d.rA,{icon:"save",title:e("保存"),onClick:()=>(async t=>{if(!t||t<10)return void(0,l.zN)(e("间隔不能小于 10 秒"));const s=await o.ez.post("interval",{interval:t});s.code===r.m.Success?((0,l.SK)(e("保存成功")),I(s.data?.interval??t)):(0,l.zN)(s.message??e("操作失败"))})(b)})]}),(0,j.jsx)(p.X,{headers:[e("编号"),e("平台"),e("开启"),e("账号状态"),e("上次同步"),e("备注"),e("操作")],rows:h.map((s,n)=>{return[(0,j.jsx)("p",{children:n}),(0,j.jsx)(i.xP,{context:(a=s.provider,T(a)?.label??a)}),(0,j.jsx)(i.fq,{success:!!s.isOpen,text:s.isOpen?e("开启"):e("关闭")}),(0,j.jsx)(i.xP,{tip_context:s.account_message,children:(0,j.jsx)(z,{status:s.account_status})}),(0,j.jsx)(i.xP,{tip_context:`${U(s.time)} ${s.message??""}`,children:F(s.time)}),(0,j.jsx)(i.xP,{context:s.note}),(0,j.jsxs)("div",{className:"div-row",children:[(0,j.jsx)(d.rA,{icon:"check",title:e("验证"),onClick:()=>(async t=>{const s=await o.ez.post("verify",{id:t});if(s.code===r.m.Success){x(s.data??[]);const n=(s.data??[]).find(e=>e.id===t);n?.account_status===A.ok?(0,l.SK)(n.account_message||e("验证成功")):(0,l.zN)(n?.account_message||e("验证失败"))}})(s.id)}),(0,j.jsx)(d.rA,{icon:"edit",title:e("编辑"),onClick:()=>(e=>f(JSON.parse(JSON.stringify(e))))(s)}),(0,j.jsx)(d.rA,{icon:"delete",title:e("删除"),onClick:()=>{return n=s.id,void t({open:!0,title:e("确定删除吗"),handle:async()=>{const s=await o.ez.post("del",{id:n});s.code===r.m.Success&&((0,l.SK)(e("成功")),x(s.data??[]),m?.id===n&&f(null)),t({open:!1,handle:null})}});var n}})]})];var a})})]})})}),(0,j.jsx)(a.VP,{widthPer:50,children:m&&(0,j.jsx)(a.xh,{children:(0,j.jsxs)(i.Zp,{self_title:(0,j.jsx)("span",{className:" div-row ",children:(0,j.jsx)("h2",{children:e(""+(m.is_new?"添加":"编辑"))})}),rightTopCom:(0,j.jsx)(d.rA,{icon:"info",title:e("信息"),onClick:()=>{if(!m)return;const t=T(m.provider);u({open:!0,title:t?.label??e("信息"),context_div:(0,j.jsx)("div",{children:t?.info&&(0,j.jsx)("p",{children:t.info})})})}}),rightBottomCom:(0,j.jsxs)("div",{children:[(0,j.jsx)(d.rA,{icon:"cancel",title:e("取消"),onClick:()=>f(null)}),(0,j.jsx)(d.rA,{icon:"save",title:e("保存"),onClick:async()=>{if(!m)return;const t=T(m.provider);if(O(m.account,t?.fields.length??1).some(e=>!e))return void(0,l.zN)(e("请填写完整的账号凭证"));const{is_new:s,...n}=m,a=await o.ez.post("save",n);a.code===r.m.Success?((0,l.SK)(e("保存成功")),f(null),x(a.data??[]),P()):(0,l.zN)(a.message??e("操作失败"))}})]}),children:[(0,j.jsx)(c.BC,{label:e("开启"),label_width:"5rem",children:(0,j.jsx)(c.GL,{selected:!!m.isOpen,onchange:()=>W("isOpen",!m.isOpen)})}),(0,j.jsx)(c.BC,{label:e("备注"),label_width:"5rem",children:(0,j.jsx)(c.Sm,{value:m.note,handleInputChange:e=>W("note",e)})}),(0,j.jsx)(c.BC,{label:e("平台"),label_width:"5rem",required:!0,children:(0,j.jsx)(c.l6,{options:N,value:m.provider,onChange:e=>{f({...m,provider:e,account:"",account_status:A.unverified,account_message:""})}})}),V?.fields.map((e,t)=>(0,j.jsx)(c.BC,{label:e.label,label_width:"5rem",required:!0,children:(0,j.jsx)(c.Sm,{value:G[t]??"",type:e.password?"password":"text",placeholder:e.placeholder,handleInputChange:e=>((e,t,s)=>{if(!m)return;const n=O(m.account,s);n[e]=t,W("account",n.map(e=>(e??"").trim()).join(","))})(t,e,V.fields.length)})},t)),m.account_status===A.fail&&(0,j.jsx)("p",{className:"text-red",children:m.account_message}),(0,j.jsxs)("div",{className:"div-row",children:[(0,j.jsx)("label",{children:e("域名绑定")}),(0,j.jsx)(d.rA,{icon:"add",title:e("添加"),onClick:()=>{if(!m)return;const e=[...m.ips??[],{isIPv4:!0,ifaceOrWww:"",ddnsHost:"",source_type:D.physics}];f({...m,ips:e})}})]}),(m.ips??[]).map((t,s)=>{const n=`${t.ifaceOrWww}#${t.scopeid??""}#${t.isIPv4?"4":"6"}`,a=B.find(e=>e.value===n);return(0,j.jsxs)(S.d,{title:`${e("绑定")}${s+1}`,toolbar:(0,j.jsx)(d.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{if(!m?.ips)return;const t=[...m.ips];t.splice(e,1),f({...m,ips:t})})(s)}),children:[(0,j.jsx)(c.BC,{label:e("IP 来源"),label_width:"5rem",required:!0,children:(0,j.jsx)(c.Sm,{value:a?.label??"",options:B,handleInputChange:e=>((e,t)=>{const s=y.find(e=>H(e)===t)??y.find(e=>`${e.ifaceOrWww} (${e.isIPv4?"IPv4":"IPv6"}) ${e.ip??""}`===t);if(!s||!m?.ips)return;const n=[...m.ips];n[e]={...n[e],ifaceOrWww:s.ifaceOrWww,scopeid:s.scopeid,isIPv4:s.isIPv4,source_type:s.source_type},f({...m,ips:n})})(s,e)})}),(0,j.jsx)(c.BC,{label:e("域名"),label_width:"5rem",required:!0,children:(0,j.jsx)(c.Sm,{value:t.ddnsHost,placeholder:e("多个域名用空格分隔"),handleInputChange:e=>((e,t,s)=>{if(!m?.ips)return;const n=[...m.ips];n[e]={...n[e],[t]:s},f({...m,ips:n})})(s,"ddnsHost",e)})}),t.time&&(0,j.jsxs)(c.BC,{label:e("上次同步"),label_width:"5rem",row:!0,children:[(0,j.jsx)(z,{status:t.status}),(0,j.jsx)("span",{children:U(t.time)})]})]},s)})]})})})]})}function M(e){const{t}=(0,v.Bd)(),[s,a]=(0,n.useState)([]),[i,p]=(0,n.useState)(""),[u,h]=(0,n.useState)("ipv4"),x=async()=>{const t=await o.ez.get("http/list");t.code===r.m.Success&&a(t.data??[]),await e.on_refresh()};(0,n.useEffect)(()=>{x()},[]);return(0,j.jsxs)("div",{children:[(0,j.jsx)("p",{children:t("http_source_tip")}),(0,j.jsxs)("div",{className:"div-row",children:[(0,j.jsx)(c.l6,{options:[{label:"IPv4",value:"ipv4"},{label:"IPv6",value:"ipv6"},{label:t("IP"),value:D.fixed}],value:u,width:"6rem",onChange:e=>{h(e),p("")}}),(0,j.jsx)(c.Sm,{value:i,placeholder:u===D.fixed?"1.1.1.1":"ipv6"===u?"https://6.ipw.cn":"https://4.ipw.cn",handleInputChange:e=>p(e)}),(0,j.jsx)(d.rA,{icon:"add",title:t("添加"),onClick:async()=>{if(!i.trim())return void(0,l.zN)(t("请输入地址"));const e=await o.ez.post("http/add",{ifaceOrWww:i.trim(),isIPv4:"ipv6"!==u,ip:"",source_type:u===D.fixed?D.fixed:D.http_get});e.code===r.m.Success?((0,l.SK)(t("成功")),p(""),await x()):(0,l.zN)(e.message??t("操作失败"))}})]}),(0,j.jsxs)("div",{children:[0===s.length&&(0,j.jsx)("p",{children:t("暂无数据")}),s.map((e,s)=>(0,j.jsxs)("div",{className:"div-row",children:[(0,j.jsxs)("span",{children:[e.ifaceOrWww,"(",e.isIPv4?"IPv4":"IPv6",e.source_type===D.fixed?` / ${t("IP")}`:"",")"]}),(0,j.jsx)(d.rA,{icon:"delete",title:t("删除"),onClick:()=>(async e=>{(await o.ez.post("http/del",e)).code===r.m.Success&&((0,l.SK)(t("成功")),await x())})(e)})]},s))]})]})}function H(){const{t:e}=(0,v.Bd)(),{check_user_auth:t}=(0,b.MH)(),s=[];return t(_.oV.vir_net)&&s.push({index:1,name:e("系统代理"),rto:"proxy_sys/",component:(0,j.jsx)(P,{})},{index:3,name:"Tun proxy "+e("客户端"),rto:"client/",component:(0,j.jsx)(y,{})},{index:4,name:"Tun proxy "+e("服务端"),rto:"server/",component:(0,j.jsx)(f,{})}),t(_.oV.ddns)&&s.push({index:2,name:"DDNS",rto:"ddns/",component:(0,j.jsx)(B,{})}),(0,j.jsx)(a.W1,{optionList:s,father_route:N.o.net})}},24659(e,t,s){s.d(t,{K:()=>a});var n=s(22022);const a=()=>{const{t:e}=(0,n.Bd)();return[{title:e("是"),value:!0,color:"#28a745"},{title:e("否"),value:!1,color:"#666666"}]}}}]);
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[8649],{8694(e,t,s){s.d(t,{$K:()=>a,RB:()=>l,l5:()=>i,vo:()=>o,vr:()=>r});let n=function(e){return e[e.tcp=0]="tcp",e[e.udp=1]="udp",e}({});class a{open=!1;port;key="";async_ips=[]}class o{client_num_id;client_name;open=!1;ip;mask;serverIp;serverPort;key="";model=n.udp}let l=function(e){return e[e.row=1]="row",e[e.json=2]="json",e[e.form=3]="form",e}({});class r{body_type;header_type;url;method;headers;data;form_data_list;local_download_path}class i{enabled;ip;port;bypass;useForLocal;type}},47996(e,t,s){s.d(t,{d:()=>a});s(96540);var n=s(74848);function a(e){return(0,n.jsxs)("div",{className:"instance-item",children:[(0,n.jsxs)("div",{className:"instance-item__toolbar",children:[(0,n.jsx)("span",{className:"instance-item__label",children:e.title}),e.toolbar]}),e.children]})}},77481(e,t,s){s.d(t,{S:()=>r,X:()=>l});var n=s(96540),a=s(61443),o=s(74848);function l(e){const[t,s]=n.useState([]),l=(0,n.useRef)(-1),[r,i]=(0,n.useState)(-1),[c,d]=(0,n.useState)(-1);(0,n.useEffect)(()=>{e.children?s(Array.isArray(e.children)?e.children:[e.children]):s(e.rows)},[e.rows,e.children]);const p=()=>{l.current=-1,i(-1),d(-1)};return(0,o.jsxs)("table",{children:[(0,o.jsx)("thead",{children:(0,o.jsx)("tr",{children:e.headers?.map((t,s)=>{const n=!!e.filter&&(e.filter.column??0)===s;let l=t;if(n){const s=e.filter,n=s.options.find(e=>e.value===s.value);null!=s.value&&n&&(l=`${t} (${n.label})`)}return(0,o.jsx)("th",{className:n?"table-filter-col":"",children:n?(0,o.jsx)(a.l6,{value:e.filter.value,options:e.filter.options,onChange:e.filter.onChange,bare:!0,trigger_label:l}):t},s)})})}),(0,o.jsx)("tbody",{children:t.map((t,s)=>{const n=!!e.onRowDrag;return(0,o.jsx)("tr",{className:n?(r===s?"row-dragging":"")+(c===s?" row-drop-target":""):"",draggable:n,onContextMenu:()=>{e.handleContextMenu&&e.handleContextMenu(t)},onDragStart:e=>{n&&(l.current=s,i(s),e.dataTransfer.effectAllowed="move")},onDragOver:e=>{!n||l.current<0||(e.preventDefault(),e.dataTransfer.dropEffect="move",d(s))},onDrop:t=>{n&&(t.preventDefault(),(()=>{const t=l.current,s=c;p(),t<0||s<0||t===s||e.onRowDrag?.(t,s)})())},onDragEnd:p,children:t.map((s,n)=>{const a=n===t.length-1?"small":"";return(0,o.jsx)("td",{className:a,style:{width:e.width??"auto"},children:s},n)})},s)})})]})}function r(e){return(0,o.jsx)("div",{style:{display:e.isFlex?"flex":"block"},children:e.columns.map((e,t)=>(0,o.jsx)("div",{children:e},t))})}},88649(e,t,s){s.r(t),s.d(t,{default:()=>H});var n=s(96540),a=s(75725),o=s(14284),l=s(62042),r=s(53459),i=s(70447),c=s(61443),d=s(85997),p=s(77481),u=s(8694),h=s(14944),x=s(92275),v=s(22022),m=s(4412),j=s(74848);function f(e){const{t}=(0,v.Bd)(),[s,f]=(0,n.useState)(void 0),[y,g]=(0,n.useState)(!1),[S,w]=(0,n.useState)(""),[_,b]=(0,n.useState)([t(`${t("名称")}`),t(`${t("虚拟")}ip`),`${t("物理")}`,t("在线状态"),t("选择")]),[I,k]=(0,n.useState)([]),[C,P]=(0,n.useState)({}),[N,D]=(0,n.useState)(!1);(0,n.useEffect)(()=>{(async()=>{const e=new x.hf(x.HK.vir_net_serverIno_get);h.ws.addMsg(x.HK.vir_net_serverIno_get,e=>{(e=>{for(const s of e){const e=s[s.length-1];s[s.length-1]=(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(i.fq,{ok:e}),t(e?"在线":"离线")]}),s[0]=(0,j.jsx)(i.xP,{context:s[0],tip_context:s[0]}),s[2]=(0,j.jsx)(i.xP,{context:s[2],tip_context:s[2]})}})(e.context),k(e.context)}),await h.ws.send(e)})();return(async()=>{const e=await o._U.get("vir/server/get");if(e.code!==r.m.Success)return;const t=e.data;f(t.port),w(t.key),g(t.open)})(),()=>{}},[]);return(0,j.jsxs)("div",{children:[(0,j.jsxs)(m.aZ,{position:"right",children:[!!Object.keys(C).length&&C[0],!!Object.keys(C).length&&(0,j.jsx)(d.rA,{icon:"delete",title:"删除",onClick:async()=>{await o._U.post("vir/server/delete/client",{ips:Object.keys(C)}),P({})}})]}),(0,j.jsx)(a.fI,{children:(0,j.jsxs)(a.VP,{children:[(0,j.jsxs)(i.Zp,{title:"",rightBottomCom:(0,j.jsx)(d.C3,{text:t("保存"),clickFun:async()=>{const e=new u.$K;e.open=y,e.key=S,N&&(e.async_ips=Object.keys(C)),s&&(e.port=parseInt(s));(await o._U.post("vir/server/save",e)).code===r.m.Success?((0,l.SK)("保存成功"),D(!1)):(0,l.zN)("网络错误")}}),children:[(0,j.jsx)(c.Sm,{placeholder:"port",value:s,handleInputChange:e=>{f(e)}}),(0,j.jsx)(c.Sm,{type:"password",placeholder:"key ",value:S,handleInputChange:e=>{w(e)}}),(0,j.jsxs)("form",{children:[t("状态"),":",(0,j.jsx)(p.S,{isFlex:!0,columns:[(0,j.jsx)(c.U6,{value:1,context:t("开启"),selected:y,onchange:()=>{g(!y)}}),(0,j.jsx)(c.U6,{value:1,context:t("关闭"),selected:!y,onchange:()=>{g(!y)}})]})]}),!!Object.keys(C).length&&(0,j.jsx)(c.GL,{context:t("sync_sv"),selected:N,onchange:()=>{D(!N)}})]}),(0,j.jsx)(i.Zp,{title:"",children:(0,j.jsx)(p.X,{headers:_,rows:I.map(e=>[...e,(0,j.jsx)(c.GL,{context:t(""),selected:C[e[1]],onchange:()=>{const t={...C};t[e[1]]?delete t[e[1]]:t[e[1]]=e,P(t)}})]),width:"10rem"})})]})})]})}function y(e){const{t}=(0,v.Bd)(),[s,m]=(0,n.useState)(""),[f,y]=(0,n.useState)(void 0),[g,S]=(0,n.useState)(""),[w,_]=(0,n.useState)(""),[b,I]=(0,n.useState)(void 0),[k,C]=(0,n.useState)(!1),[P,N]=(0,n.useState)(""),[D,A]=(0,n.useState)(!1);(0,n.useEffect)(()=>{(async()=>{const e=await o._U.get("vir/client/get");if(e.code!==r.m.Success)return;const t=e.data;if(I(t.serverPort),S(t.serverIp),m(t.ip),y(t.mask),N(t.key),C(t.open),_(t.client_name),t.open){const e=new x.hf(x.HK.vir_net_client_get),t=(await h.ws.send(e)).context.state;A(t),h.ws.addMsg(x.HK.vir_net_client_get,e=>{A(e.context.state)})}})()},[]);return(0,j.jsx)("div",{children:(0,j.jsx)(a.fI,{children:(0,j.jsxs)(a.VP,{children:[(0,j.jsxs)(i.Zp,{title:"",rightBottomCom:(0,j.jsx)(d.C3,{text:t("保存"),clickFun:async()=>{const e=new u.vo;e.ip=s,e.mask=parseInt(f),e.key=P,e.serverIp=g,e.serverPort=parseInt(b),e.open=k,e.client_name=w;(await o._U.post("vir/client/save",e)).code===r.m.Success?(0,l.SK)("保存成功"):(0,l.zN)("网络错误")}}),rightTopCom:(0,j.jsxs)("div",{children:[t("连接状态"),(0,j.jsx)(i.fq,{ok:D})]}),children:[(0,j.jsx)(c.Sm,{placeholder:"ip ",value:s,handleInputChange:e=>{m(e)}}),(0,j.jsx)(c.Sm,{placeholder:"mask",value:f,handleInputChange:e=>{y(e)}}),(0,j.jsx)(c.Sm,{placeholder:`${t("服务器")} ip`,value:g,handleInputChange:e=>{S(e)}}),(0,j.jsx)(c.Sm,{placeholder:`${t("服务器")} part`,value:b,handleInputChange:e=>{I(e)}}),(0,j.jsx)(c.Sm,{placeholder:"名称 ",value:w,handleInputChange:e=>{_(e)}}),(0,j.jsx)(c.Sm,{type:"password",placeholder:"key ",value:P,handleInputChange:e=>{N(e)}}),(0,j.jsxs)("form",{children:[t("状态"),(0,j.jsx)(p.S,{isFlex:!0,columns:[(0,j.jsx)(c.U6,{value:1,context:t("开启"),selected:k,onchange:()=>{C(!k)}}),(0,j.jsx)(c.U6,{value:1,context:t("关闭"),selected:!k,onchange:()=>{C(!k)}})]})]})]}),(0,j.jsxs)(i.Zp,{title:"",children:[(0,j.jsx)("div",{children:"ip: 虚拟ip, “10.0.0.0 - 10.255.255.255”和“172.16.0.0 - 172.31.255.255”和“192.168.0.0 - 192.168.255.255”这三个网段属于内网ip"}),(0,j.jsx)("div",{children:"mask: 一些常见的子网掩码网段/8:255.0.0.0;/16:255.255.0.0 ;/24:255.255.255.0"}),(0,j.jsx)("div",{children:"key:用于验证身份信息并加密的和服务器设置的一样"})]})]})})})}var g=s(47996),S=s(34843),w=s(82893),_=s(23430),b=s(78247),I=s(21499),k=s(24659),C=s(64694);function P(e){const{t}=(0,v.Bd)(),[s,h]=(0,n.useState)(""),[x,m]=(0,n.useState)(""),[f,y]=(0,n.useState)(""),[P,N]=(0,n.useState)(!1),[D,A]=(0,n.useState)(!1),[$,K]=(0,n.useState)({list:[]}),[T,O]=(0,S.fp)(w.AG.editorSetting),[U,z]=(0,S.fp)(w.AG.user_base_info),F=[t("端口"),t("目标地址"),t("目标端口"),t("开启"),t("备注"),t("删除")],[B,M]=(0,n.useState)([]),H=[t("port"),t("ip"),t("type"),t("开启")],[W,V]=(0,n.useState)([]),G=[t("编辑"),t("开启"),t("备注"),t("删除")],q=(0,k.K)(),X=async()=>{const e=[o._U.post("vir/client/tcp_proxy/get"),o._U.post("http/proxy/server/get")];let t;U.sys===_.XM.mac?t=(async()=>{const e=await o._U.post("http/proxy/get/mac");if(e.code!==r.m.Success)return;const t=[],s=[];for(const n of e.data)"Wi-Fi"===n.name?t.push(n):s.push(n);V([...t,...s])})():U.sys===_.XM.win&&(t=(async()=>{const e=await o._U.post("http/proxy/get/win");if(e.code===r.m.Success){const t=e.data;h(t.ip),m(t.port),N(t.enabled),y(t.bypass),A(t.useForLocal)}})()),t&&e.push(t);const[s,n]=await Promise.all(e);s.code===r.m.Success&&M(s.data),n.code===r.m.Success&&K(n.data)};(0,n.useEffect)(()=>{X()},[]);return(0,j.jsx)("div",{children:(0,j.jsxs)(a.fI,{children:[U.sys===_.XM.win&&(0,j.jsx)(a.VP,{widthPer:33,children:(0,j.jsxs)(i.Zp,{title:"Http Proxy",rightBottomCom:(0,j.jsx)(d.C3,{text:t("保存"),clickFun:async()=>{const e=new u.l5;e.port=parseInt(x),e.enabled=P,e.useForLocal=D,e.ip=s,e.bypass=f;(await o._U.post("http/proxy/set/win",e)).code===r.m.Success&&(X(),(0,l.SK)("保存成功"))}}),children:[(0,j.jsx)(c.Sm,{placeholder:"ip (default localhost) ",value:s,handleInputChange:e=>{h(e)}}),(0,j.jsx)(c.Sm,{placeholder:"port ",value:x,handleInputChange:e=>{m(e)}}),(0,j.jsx)(c.Sm,{placeholder:t("忽略ip"),value:f,handleInputChange:e=>{y(e)}}),(0,j.jsxs)("form",{children:[t("pxy_nln"),(0,j.jsx)(p.S,{isFlex:!0,columns:[(0,j.jsx)(c.U6,{value:1,context:t("开启"),selected:D,onchange:()=>{A(!D)}}),(0,j.jsx)(c.U6,{value:1,context:t("关闭"),selected:!D,onchange:()=>{A(!D)}})]})]}),(0,j.jsxs)("form",{children:[t("状态"),(0,j.jsx)(p.S,{isFlex:!0,columns:[(0,j.jsx)(c.U6,{value:1,context:t("开启"),selected:P,onchange:()=>{N(!P)}}),(0,j.jsx)(c.U6,{value:1,context:t("关闭"),selected:!P,onchange:()=>{N(!P)}})]})]})]})}),U.sys===_.XM.mac&&(0,j.jsx)(a.VP,{children:W.map((e,s)=>(0,j.jsxs)(i.uF,{self_title:(0,j.jsxs)("span",{className:" div-row ",children:[(0,j.jsx)("h2",{children:e.name})," "]}),rightTopCom:(0,j.jsx)("div",{children:(0,j.jsx)(d.rA,{icon:"save",title:t("保存"),onClick:()=>{(async e=>{const t=W[e];(await o._U.post("http/proxy/set/mac",[t])).code===r.m.Success&&(X(),(0,l.SK)("保存成功"))})(s)}})}),children:[(0,j.jsx)(p.X,{headers:H,rows:e.proxies.map((e,t)=>{const n=[(0,j.jsx)(c.Sm,{value:e.port,handleInputChange:t=>{e.port=parseInt(t)},no_border:!0}),(0,j.jsx)(c.Sm,{value:e.ip,handleInputChange:t=>{e.ip=t},no_border:!0}),(0,j.jsx)("div",{children:1===e.type?"http":"https"}),(0,j.jsx)(c.l6,{value:e.enabled,onChange:e=>{((e,t,s)=>{const n=[...W];n[e].proxies[t].enabled=s,V(n)})(s,t,e)},options:q,no_border:!0})];return n}),width:"10rem"}),"ignore ips",(0,j.jsx)(c.Sm,{value:e.bypass,handleInputChange:e=>{W[s].bypass=e},no_border:!0})]},s))}),(0,j.jsxs)(a.VP,{children:[(0,j.jsx)(i.uF,{self_title:(0,j.jsxs)("span",{className:" div-row ",children:[(0,j.jsx)("h2",{children:t("Tcp Proxy")})," "]}),rightTopCom:(0,j.jsxs)("div",{children:[(0,j.jsx)(d.rA,{icon:"add",title:t("添加"),onClick:()=>{M([...B,{note:"",open:!1,port:0,target_port:0,target_ip:""}])}}),(0,j.jsx)(d.rA,{icon:"save",title:t("保存"),onClick:async()=>{const e=[];for(let t=0;t<B.length;t++)B[t].index=t,e.push(B[t]);(await o._U.post("vir/client/tcp_proxy/save",e)).code===r.m.Success&&((0,l.SK)("保存成功"),X())}})]}),children:(0,j.jsx)(p.X,{headers:F,rows:B.map((e,s)=>{const n=[(0,j.jsx)(c.Sm,{value:e.port,handleInputChange:t=>{e.port=parseInt(t)},no_border:!0}),(0,j.jsx)(c.Sm,{value:e.target_ip,handleInputChange:t=>{e.target_ip=t},no_border:!0}),(0,j.jsx)(c.Sm,{value:e.target_port,handleInputChange:t=>{e.target_port=parseInt(t)},no_border:!0}),(0,j.jsx)(c.l6,{value:e.open,onChange:e=>{B[s].open=e,M([...B])},options:q,no_border:!0}),(0,j.jsx)(c.Sm,{value:e.note,handleInputChange:t=>{e.note=t},no_border:!0}),(0,j.jsx)("div",{children:(0,j.jsx)(d.rA,{icon:"delete",title:t("删除"),onClick:()=>(e=>{B.splice(e,1),M([...B])})(s)})})];return n}),width:"10rem",onRowDrag:(e,t)=>{M((0,C.TI)(B,e,t))}})}),(0,j.jsx)(i.uF,{self_title:(0,j.jsxs)("span",{className:" div-row ",children:[(0,j.jsx)("h2",{children:t("Http Proxy Server")})," "]}),rightTopCom:(0,j.jsxs)("div",{children:[(0,j.jsx)(d.rA,{icon:"add",title:t("添加端口实例"),onClick:()=>{$.list.push({open:!1,port:0,note:"",list:[]}),K({...$})}}),(0,j.jsx)(d.rA,{icon:"save",title:t("保存"),onClick:async()=>{(await o._U.post("http/proxy/server/save",$)).code===r.m.Success&&(0,l.SK)("保存成功")}})]}),children:$.list.map((e,s)=>(0,j.jsx)(g.d,{title:`${t("端口实例")} #${s+1}`,toolbar:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)("span",{children:t("状态")}),(0,j.jsx)(c.l6,{value:e.open,width:"15%",onChange:t=>{e.open=t,K({...$})},options:q,no_border:!0}),(0,j.jsx)("span",{children:t("端口")}),(0,j.jsx)(c.Sm,{value:e.port||"",handleInputChange:t=>{e.port=t?parseInt(t):0,K({...$})},no_border:!0,width:"80px"}),(0,j.jsx)(d.rA,{icon:"add",title:t("添加规则"),onClick:()=>{e.list.push({note:"",open:!1}),K({...$})}}),(0,j.jsx)(d.rA,{icon:"delete",title:t("删除端口实例"),onClick:()=>{$.list.splice(s,1),K({...$})}}),(0,j.jsx)(c.Sm,{placeholder:t("备注"),width:"100%",value:e.note,handleInputChange:t=>{e.note=t,K({...$})},no_border:!0})]}),children:(0,j.jsx)(p.X,{headers:G,rows:e.list.map((n,a)=>{const l=[(0,j.jsx)("div",{children:(0,j.jsx)(d.rA,{icon:"edit",title:t("编辑"),onClick:()=>{(async(e,t)=>{const s=$.list[e];if(!s)return;const n=s.list[t];if(!n)return;n.random_key||(n.random_key=(0,I.hU)(),K({...$}));const a=await o._U.post("http/proxy/server/code/get",{key:n.random_key,name:n.random_key});O({model:"ace/mode/javascript",open:!0,fileName:"",can_format:!0,save:async e=>{await o._U.post("http/proxy/server/code/save",{context:e,key:n.random_key})}}),b.xK.set_value_temp(a.data)})(s,a)}})}),(0,j.jsx)(c.l6,{value:n.open,onChange:t=>{e.list[a].open=t,K({...$})},options:q,no_border:!0}),(0,j.jsx)(c.Sm,{value:n.note,handleInputChange:e=>{n.note=e},no_border:!0}),(0,j.jsx)("div",{children:(0,j.jsx)(d.rA,{icon:"delete",title:t("删除"),onClick:()=>{e.list.splice(a,1),K({...$})}})})];return l}),width:"10rem"})},s))})]})]})})}var N=s(87361);let D=function(e){return e.physics="物理",e.http_get="http_get",e.fixed="fixed",e}({}),A=function(e){return e.unverified="unverified",e.ok="ok",e.fail="fail",e}({}),$=function(e){return e.dnspod="dnspod",e.tengxun="tengxun",e.ali="ali",e.cloudflare="cloudflare",e.godaddy="godaddy",e.namesilo="namesilo",e.namecheap="namecheap",e.vercel="vercel",e.duckdns="duckdns",e.noip="noip",e.easydns="easydns",e.freedns="freedns",e.dynv6="dynv6",e.oray="oray",e.dyn="dyn",e.custom="custom",e}({});const K=[{provider:$.dnspod,label:"DNSPod(腾讯)",fields:[{label:"ID",placeholder:"ID"},{label:"Token",placeholder:"在密钥管理中生成",password:!0}],info:"DNSPod 老版 API。在 dnspod.cn 控制台「用户中心 - 密钥管理」创建 API Token,分别填入 ID 与 Token。"},{provider:$.tengxun,label:"腾讯云 DNSPod",fields:[{label:"SecretId",placeholder:"云 API 密钥 ID"},{label:"SecretKey",placeholder:"云 API 密钥 Key",password:!0}],info:"腾讯云新版云 API。在腾讯云控制台「访问管理 - API 密钥管理」创建密钥,分别填入 SecretId 与 SecretKey。"},{provider:$.ali,label:"阿里云解析",fields:[{label:"AccessKeyId",placeholder:"AccessKey ID"},{label:"AccessKeySecret",placeholder:"AccessKey Secret",password:!0}],info:"在阿里云控制台「AccessKey 管理」创建密钥,分别填入 AccessKeyId 与 AccessKeySecret。"},{provider:$.cloudflare,label:"Cloudflare",fields:[{label:"API Token",placeholder:"Cloudflare API 令牌",password:!0}],info:"在 Cloudflare「我的个人资料 - API 令牌」创建令牌,权限需包含「编辑区域 DNS」。"},{provider:$.godaddy,label:"GoDaddy",fields:[{label:"API Key",placeholder:"GoDaddy API Key"},{label:"API Secret",placeholder:"GoDaddy API Secret",password:!0}],info:"在 GoDaddy 开发者后台创建 API Key(生产环境),分别填入 Key 与 Secret。"},{provider:$.namesilo,label:"NameSilo",fields:[{label:"API Key",placeholder:"NameSilo API Key",password:!0}],info:"在 NameSilo「账号 - API Manager」生成 API Key。"},{provider:$.namecheap,label:"Namecheap",fields:[{label:"Dynamic DNS 密码",placeholder:"Namecheap DDNS 密码",password:!0}],info:"在 Namecheap 域名管理页「Advanced DNS」开启 Dynamic DNS,复制其中的密码。不支持 IPv6。"},{provider:$.vercel,label:"Vercel",fields:[{label:"API Token",placeholder:"Vercel API Token",password:!0}],info:"在 Vercel「账号设置 - Tokens」创建 Token,需具备 DNS 权限。"},{provider:$.duckdns,label:"DuckDNS",fields:[{label:"Token",placeholder:"DuckDNS Token",password:!0}],info:"DuckDNS 首页登录后即可看到 Token。域名需为 xxx.duckdns.org 形式。"},{provider:$.dynv6,label:"dynv6",fields:[{label:"Token",placeholder:"dynv6 Token",password:!0}],info:"在 dynv6 域名详情页复制 HTTP 更新 token 填入。"},{provider:$.freedns,label:"FreeDNS(afraid.org)",fields:[{label:"更新 Token",placeholder:"FreeDNS 更新 Token",password:!0}],info:"在 FreeDNS 域名管理页的 Dynamic DNS 链接中复制 update token 填入。"},{provider:$.noip,label:"No-IP",fields:[{label:"用户名",placeholder:"No-IP 用户名"},{label:"密码",placeholder:"No-IP 密码",password:!0}],info:"No-IP 官网账号的用户名与密码。"},{provider:$.easydns,label:"easyDNS",fields:[{label:"用户名",placeholder:"easyDNS 用户名"},{label:"密码",placeholder:"easyDNS 密码",password:!0}],info:"easyDNS 账号的用户名与密码。"},{provider:$.oray,label:"花生壳 Oray",fields:[{label:"账号",placeholder:"花生壳账号"},{label:"密码",placeholder:"花生壳密码",password:!0}],info:"花生壳官网账号与密码。更新地址:ddns.oray.com/ph/update。"},{provider:$.dyn,label:"通用 DynDNS2",fields:[{label:"用户名",placeholder:"DynDNS 用户名"},{label:"密码",placeholder:"DynDNS 密码",password:!0}],info:"适用于兼容 DynDNS2 协议的服务(更新地址 members.dyndns.org)。"},{provider:$.custom,label:"自定义 HTTP",fields:[{label:"URL 模板",placeholder:"https://example.com/update?domain={host}&ip={ip}"}],info:"任意支持 HTTP 更新的 DDNS 服务,模板中可用 {host} {ip} {family} 占位。"}];function T(e){return K.find(t=>t.provider===e)}function O(e,t){const s=(e??"").split(","),n=[];for(let e=0;e<t;e++)n.push((s[e]??"").trim());return n}function U(e){if(!e)return"-";const t=new Date(e),s=e=>String(e).padStart(2,"0");return`${t.getFullYear()}-${s(t.getMonth()+1)}-${s(t.getDate())} ${s(t.getHours())}:${s(t.getMinutes())}:${s(t.getSeconds())}`}function z(e){if(!e)return"-";const t=Date.now()-e;if(t<6e4)return"刚刚";if(t<36e5)return`${Math.floor(t/6e4)} 分钟前`;if(t<864e5)return`${Math.floor(t/36e5)} 小时前`;const s=new Date(e),n=e=>String(e).padStart(2,"0");return`${n(s.getMonth()+1)}-${n(s.getDate())} ${n(s.getHours())}:${n(s.getMinutes())}`}function F(e){const{t}=(0,v.Bd)();return e.status===A.ok?(0,j.jsx)(i.fq,{success:!0,text:t("成功")}):e.status===A.fail?(0,j.jsx)(i.fq,{success:!1,text:t("失败")}):(0,j.jsx)(i.fq,{text:t("未验证")})}function B(){const{t:e}=(0,v.Bd)(),[,t]=(0,S.fp)(w.AG.confirm),[s,u]=(0,S.fp)(w.AG.prompt_card),[h,x]=(0,n.useState)([]),[m,f]=(0,n.useState)(null),[y,_]=(0,n.useState)([]),[b,I]=(0,n.useState)(60),[k,C]=(0,n.useState)(!1),P=async()=>{const e=await o.ez.get("ip_options");e.code===r.m.Success&&_(e.data??[])};(0,n.useEffect)(()=>{(async()=>{const e=await o.ez.get("list");e.code===r.m.Success&&x(e.data??[])})(),P(),(async()=>{const e=await o.ez.get("interval");e.code===r.m.Success&&I(e.data?.interval??60)})()},[]);const N=K.map(e=>({label:e.label,value:e.provider})),B=y.map(t=>({label:t.source_type===D.fixed?`${e("IP")} ${t.ifaceOrWww} (${t.isIPv4?"IPv4":"IPv6"})`:`${t.ifaceOrWww} (${t.isIPv4?"IPv4":"IPv6"}) ${t.ip??""}`,value:H(t)}));function H(e){return`${e.ifaceOrWww}#${e.scopeid??""}#${e.isIPv4?"4":"6"}`}const W=(e,t)=>{m&&f({...m,[e]:t})},V=m?T(m.provider):void 0,G=m?O(m.account,V?.fields.length??1):[];return(0,j.jsxs)(a.fI,{children:[(0,j.jsx)(a.VP,{widthPer:50,maxWidth:"60rem",children:(0,j.jsx)(a.xh,{children:(0,j.jsxs)(i.uF,{self_title:(0,j.jsxs)("span",{className:" div-row ",children:[(0,j.jsx)("h2",{children:e("动态域名解析")}),(0,j.jsx)(d.rA,{icon:"info",onClick:()=>{u({open:!0,title:e("信息"),context_div:(0,j.jsxs)("div",{children:[(0,j.jsx)("p",{children:e("ddns_help_1")}),(0,j.jsx)("p",{children:e("ddns_help_2")})]})})},title:e("信息")})]}),rightTopCom:(0,j.jsxs)("div",{children:[(0,j.jsx)(d.rA,{icon:"sync",title:e("立即同步"),selected:k,onClick:async()=>{C(!0);try{const t=await o.ez.post("sync_now",{});t.code===r.m.Success?((0,l.SK)(e("同步完成")),x(t.data??[])):(0,l.zN)(t.message??e("操作失败"))}finally{C(!1)}}}),(0,j.jsx)(d.rA,{icon:"dns",title:e("IP 来源管理"),onClick:()=>{u({open:!0,title:e("IP 来源管理"),context_div:(0,j.jsx)(M,{on_refresh:P})})}}),(0,j.jsx)(d.rA,{icon:"add",title:e("添加"),onClick:()=>{f({id:"",provider:$.dnspod,account:"",isOpen:!1,note:"",ips:[],account_status:A.unverified,account_message:"",is_new:!0})}})]}),children:[(0,j.jsxs)(c.BC,{label:e("同步间隔"),label_width:"5rem",row:!0,children:[(0,j.jsx)(c.Sm,{value:String(b),type:"number",width:"6rem",handleInputChange:e=>I(Number(e))}),(0,j.jsx)("span",{children:e("秒")}),(0,j.jsx)(d.rA,{icon:"save",title:e("保存"),onClick:()=>(async t=>{if(!t||t<10)return void(0,l.zN)(e("间隔不能小于 10 秒"));const s=await o.ez.post("interval",{interval:t});s.code===r.m.Success?((0,l.SK)(e("保存成功")),I(s.data?.interval??t)):(0,l.zN)(s.message??e("操作失败"))})(b)})]}),(0,j.jsx)(p.X,{headers:[e("编号"),e("平台"),e("开启"),e("账号状态"),e("上次同步"),e("备注"),e("操作")],rows:h.map((s,n)=>{return[(0,j.jsx)("p",{children:n}),(0,j.jsx)(i.xP,{context:(a=s.provider,T(a)?.label??a)}),(0,j.jsx)(i.fq,{success:!!s.isOpen,text:s.isOpen?e("开启"):e("关闭")}),(0,j.jsx)(i.xP,{tip_context:s.account_message,children:(0,j.jsx)(F,{status:s.account_status})}),(0,j.jsx)(i.xP,{tip_context:`${U(s.time)} ${s.message??""}`,children:z(s.time)}),(0,j.jsx)(i.xP,{context:s.note}),(0,j.jsxs)("div",{className:"div-row",children:[(0,j.jsx)(d.rA,{icon:"check",title:e("验证"),onClick:()=>(async t=>{const s=await o.ez.post("verify",{id:t});if(s.code===r.m.Success){x(s.data??[]);const n=(s.data??[]).find(e=>e.id===t);n?.account_status===A.ok?(0,l.SK)(n.account_message||e("验证成功")):(0,l.zN)(n?.account_message||e("验证失败"))}})(s.id)}),(0,j.jsx)(d.rA,{icon:"edit",title:e("编辑"),onClick:()=>(e=>f(JSON.parse(JSON.stringify(e))))(s)}),(0,j.jsx)(d.rA,{icon:"delete",title:e("删除"),onClick:()=>{return n=s.id,void t({open:!0,title:e("确定删除吗"),handle:async()=>{const s=await o.ez.post("del",{id:n});s.code===r.m.Success&&((0,l.SK)(e("成功")),x(s.data??[]),m?.id===n&&f(null)),t({open:!1,handle:null})}});var n}})]})];var a})})]})})}),(0,j.jsx)(a.VP,{widthPer:50,children:m&&(0,j.jsx)(a.xh,{children:(0,j.jsxs)(i.Zp,{self_title:(0,j.jsx)("span",{className:" div-row ",children:(0,j.jsx)("h2",{children:e(""+(m.is_new?"添加":"编辑"))})}),rightTopCom:(0,j.jsx)(d.rA,{icon:"info",title:e("信息"),onClick:()=>{if(!m)return;const t=T(m.provider);u({open:!0,title:t?.label??e("信息"),context_div:(0,j.jsx)("div",{children:t?.info&&(0,j.jsx)("p",{children:t.info})})})}}),rightBottomCom:(0,j.jsxs)("div",{children:[(0,j.jsx)(d.rA,{icon:"cancel",title:e("取消"),onClick:()=>f(null)}),(0,j.jsx)(d.rA,{icon:"save",title:e("保存"),onClick:async()=>{if(!m)return;const t=T(m.provider);if(O(m.account,t?.fields.length??1).some(e=>!e))return void(0,l.zN)(e("请填写完整的账号凭证"));const{is_new:s,...n}=m,a=await o.ez.post("save",n);a.code===r.m.Success?((0,l.SK)(e("保存成功")),f(null),x(a.data??[]),P()):(0,l.zN)(a.message??e("操作失败"))}})]}),children:[(0,j.jsx)(c.BC,{label:e("开启"),label_width:"5rem",children:(0,j.jsx)(c.GL,{selected:!!m.isOpen,onchange:()=>W("isOpen",!m.isOpen)})}),(0,j.jsx)(c.BC,{label:e("备注"),label_width:"5rem",children:(0,j.jsx)(c.Sm,{value:m.note,handleInputChange:e=>W("note",e)})}),(0,j.jsx)(c.BC,{label:e("平台"),label_width:"5rem",required:!0,children:(0,j.jsx)(c.l6,{options:N,value:m.provider,onChange:e=>{f({...m,provider:e,account:"",account_status:A.unverified,account_message:""})}})}),V?.fields.map((e,t)=>(0,j.jsx)(c.BC,{label:e.label,label_width:"5rem",required:!0,children:(0,j.jsx)(c.Sm,{value:G[t]??"",type:e.password?"password":"text",placeholder:e.placeholder,handleInputChange:e=>((e,t,s)=>{if(!m)return;const n=O(m.account,s);n[e]=t,W("account",n.map(e=>(e??"").trim()).join(","))})(t,e,V.fields.length)})},t)),m.account_status===A.fail&&(0,j.jsx)("p",{className:"text-red",children:m.account_message}),(0,j.jsxs)("div",{className:"div-row",children:[(0,j.jsx)("label",{children:e("域名绑定")}),(0,j.jsx)(d.rA,{icon:"add",title:e("添加"),onClick:()=>{if(!m)return;const e=[...m.ips??[],{isIPv4:!0,ifaceOrWww:"",ddnsHost:"",source_type:D.physics}];f({...m,ips:e})}})]}),(m.ips??[]).map((t,s)=>{const n=`${t.ifaceOrWww}#${t.scopeid??""}#${t.isIPv4?"4":"6"}`,a=B.find(e=>e.value===n);return(0,j.jsxs)(g.d,{title:`${e("绑定")}${s+1}`,toolbar:(0,j.jsx)(d.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{if(!m?.ips)return;const t=[...m.ips];t.splice(e,1),f({...m,ips:t})})(s)}),children:[(0,j.jsx)(c.BC,{label:e("IP 来源"),label_width:"5rem",required:!0,children:(0,j.jsx)(c.Sm,{value:a?.label??"",options:B,handleInputChange:e=>((e,t)=>{const s=y.find(e=>H(e)===t)??y.find(e=>`${e.ifaceOrWww} (${e.isIPv4?"IPv4":"IPv6"}) ${e.ip??""}`===t);if(!s||!m?.ips)return;const n=[...m.ips];n[e]={...n[e],ifaceOrWww:s.ifaceOrWww,scopeid:s.scopeid,isIPv4:s.isIPv4,source_type:s.source_type},f({...m,ips:n})})(s,e)})}),(0,j.jsx)(c.BC,{label:e("域名"),label_width:"5rem",required:!0,children:(0,j.jsx)(c.Z2,{style:{minHeight:"7rem",resize:"vertical"},placeholder:e("多个域名用空格分隔"),value:t.ddnsHost,onChange:e=>{((e,t,s)=>{if(!m?.ips)return;const n=[...m.ips];n[e]={...n[e],[t]:s},f({...m,ips:n})})(s,"ddnsHost",e.target.value)}})}),t.time&&(0,j.jsxs)(c.BC,{label:e("上次同步"),label_width:"5rem",row:!0,children:[(0,j.jsx)(F,{status:t.status}),(0,j.jsx)("span",{children:U(t.time)})]})]},s)})]})})})]})}function M(e){const{t}=(0,v.Bd)(),[s,a]=(0,n.useState)([]),[i,p]=(0,n.useState)(""),[u,h]=(0,n.useState)("ipv4"),x=async()=>{const t=await o.ez.get("http/list");t.code===r.m.Success&&a(t.data??[]),await e.on_refresh()};(0,n.useEffect)(()=>{x()},[]);return(0,j.jsxs)("div",{children:[(0,j.jsx)("p",{children:t("http_source_tip")}),(0,j.jsxs)("div",{className:"div-row",children:[(0,j.jsx)(c.l6,{options:[{label:"IPv4",value:"ipv4"},{label:"IPv6",value:"ipv6"},{label:t("IP"),value:D.fixed}],value:u,width:"6rem",onChange:e=>{h(e),p("")}}),(0,j.jsx)(c.Sm,{value:i,placeholder:u===D.fixed?"1.1.1.1":"ipv6"===u?"https://6.ipw.cn":"https://4.ipw.cn",handleInputChange:e=>p(e)}),(0,j.jsx)(d.rA,{icon:"add",title:t("添加"),onClick:async()=>{if(!i.trim())return void(0,l.zN)(t("请输入地址"));const e=await o.ez.post("http/add",{ifaceOrWww:i.trim(),isIPv4:"ipv6"!==u,ip:"",source_type:u===D.fixed?D.fixed:D.http_get});e.code===r.m.Success?((0,l.SK)(t("成功")),p(""),await x()):(0,l.zN)(e.message??t("操作失败"))}})]}),(0,j.jsxs)("div",{children:[0===s.length&&(0,j.jsx)("p",{children:t("暂无数据")}),s.map((e,s)=>(0,j.jsxs)("div",{className:"div-row",children:[(0,j.jsxs)("span",{children:[e.ifaceOrWww,"(",e.isIPv4?"IPv4":"IPv6",e.source_type===D.fixed?` / ${t("IP")}`:"",")"]}),(0,j.jsx)(d.rA,{icon:"delete",title:t("删除"),onClick:()=>(async e=>{(await o.ez.post("http/del",e)).code===r.m.Success&&((0,l.SK)(t("成功")),await x())})(e)})]},s))]})]})}function H(){const{t:e}=(0,v.Bd)(),{check_user_auth:t}=(0,b.MH)(),s=[];return t(_.oV.vir_net)&&s.push({index:1,name:e("系统代理"),rto:"proxy_sys/",component:(0,j.jsx)(P,{})},{index:3,name:"Tun proxy "+e("客户端"),rto:"client/",component:(0,j.jsx)(y,{})},{index:4,name:"Tun proxy "+e("服务端"),rto:"server/",component:(0,j.jsx)(f,{})}),t(_.oV.ddns)&&s.push({index:2,name:"DDNS",rto:"ddns/",component:(0,j.jsx)(B,{})}),(0,j.jsx)(a.W1,{optionList:s,father_route:N.o.net})}},24659(e,t,s){s.d(t,{K:()=>a});var n=s(22022);const a=()=>{const{t:e}=(0,n.Bd)();return[{title:e("是"),value:!0,color:"#28a745"},{title:e("否"),value:!1,color:"#666666"}]}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[9857],{83277(e,s,t){t.d(s,{$j:()=>o,CP:()=>i,Lv:()=>n,cL:()=>a});class n{token;open=!1;note;index;url;model;request_type;json_params;sys_prompt;dotenv="";yaml_env="";tool_mode=!1;show_options;static get_label_by_v(e,s){if(!e||!s?.length)return e;for(const t of s)if(t.value===e)return t.label;return e}static have_label_by_v(e,s){if(!e||!s?.length)return!1;for(const t of s)if(t.value===e)return!0;return!1}}const i="\n# 聊天循环最大次数\ntool_call_max: 500\n\n# 是否允许AI直接执行命令而不需要用户确认。\n# 默认为 false,需要用户手动确认;使用 workflow 时等价于 true。\nallow_exec_cmd_directly: false\n\n# 可选的大模型请求代理地址\n# proxy_url: http://127.0.0.1:7890\n\n# 可选的多个 url\n# options_agent_url_list:\n# - value: http://...\n# label: openai\n\n# 可选的多个 key\n# options_agent_key_list:\n# - value: sk-aaa\n# label: option1\n\n# 可选的多个 model\n# options_agent_model_list:\n# - value: gpt-5.5\n# label: gpt\n\n# 本地 prompt 文件列表,每次聊天时自动读取并加载\n# options_local_file_path_prompt_list:\n# - /prompt/a.txt\n\n# 开启切换模型,AI 可以根据 prompt 自己决定下一步调用哪个模型\n# open_pick_model: false\n\n# 历史消息裁剪相关\nmax_recent_messages: 12\ncompress_message_count: 16\nmax_tool_content_chars: 200\n\n# ===== 模型类型(request_type)=====\n# 默认 completions,可选值:\n# completions 标准对话/聊天补全 (chat/completions)\n# images 图片生成 (images/generations)\n# audio_speech 文本转语音 (audio/speech)\n# audio_transcription 语音转文字 (audio/transcriptions)\n# audio_translation 语音翻译 (audio/translations)\n# embeddings 向量嵌入 (embeddings)\n# request_type: completions\n\n# ===== 成为 tool(tool_mode)=====\n# 开启后该模型会作为一个工具被加载,供 AI agent 动态调用。\n# 注意:不能与「是否开启」(open) 同时为 true。\n# tool_mode: false\n\n# ===== 图片理解(image_understanding)=====\n# 开启后注册 read_image 工具,工具读到的图片会以 image_url 多模态格式随消息发给模型。\nimage_understanding: true\n\n# ===== 命令环境变量(command_env)=====\n# AI 调用内置命令工具(exec_cmd / exec_cmd_background)执行命令时,\n# 这里配置的变量会覆盖到子进程的环境变量上。\n# command_env:\n# NODE_ENV: production\n# HTTP_PROXY: http://127.0.0.1:7890\n\n# 是否允许 AI 通过 set_command_env 工具修改上面的 command_env\ncommand_env_tool: false\n";const a=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"):""}},69857(e,s,t){t.r(s),t.d(s,{default:()=>le});var n=t(96540),i=t(34843),a=t(22022),o=t(52671),c=t(14284),r=t(7463),l=t(78247),d=t(53459),u=t(72693),m=t(82893),g=t(61443),_=t(83277);function h(e){return null==e||e<0?"0":e.toLocaleString()}var p=t(14944),f=t(92275),x=t(62042);function j(e){const s=[];if(e.attachments?.length&&s.push(e.attachments.map(e=>`[附件] ${e.name}`).join("\n")),e.content_list?.length)for(const t of e.content_list){const e=(0,_.$j)(t.content);if(e&&s.push(e),t.tool_call_ends?.length){const e=t.tool_call_ends.map(e=>{const s=e.tool_display_name||e.tool_name;return e.success?`[工具] ${s} 成功`:`[工具] ${s} 失败`});s.push(e.join("\n"))}}return e.text&&!s.length&&s.push(e.text),e.images?.length&&s.push(`[生成图片 ${e.images.length} 张]`),e.audio&&s.push("[音频]"),s.join("\n\n")}function v(e){const s=(0,_.$j)(e.content);if(s)return s;const t=e.content_list??[];return t.length?t.map(e=>(0,_.$j)(e.content)).filter(Boolean).join("\n\n"):""}let b=0;function w(){return-++b}function S(e=[]){let s=0;return e.filter(e=>"user"===e.role||"assistant"===e.role).map(e=>({id:++s,sender:"assistant"===e.role?"bot":"user",text:v(e),attachments:e.attachments??[],content_list:e.content_list??(e.tool_call_ends?.length?[{tool_call_ends:e.tool_call_ends,content:v(e),role:"assistant"}]:void 0),images:e.images,audio:e.audio,embeddings:e.embeddings,elapsed_ms:e.elapsed_ms}))}const y=/\.(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 N(e){return e.type?.startsWith("image/")?"image":e.type?.startsWith("text/")||y.test(e.name)?"text":"binary"}function k(e){return e.text()}function C(e){return new Promise((s,t)=>{const n=new FileReader;n.onload=()=>s(n.result),n.onerror=t,n.readAsDataURL(e)})}async function A(e){const s=[];for(const t of e){const e=N(t);let n="";if("text"===e)try{const e=await k(t),s=12e4;n=e.length>s?`${e.slice(0,s)}\n\n[内容已截断,原始长度 ${e.length} 字符]`:e}catch{n="[文本读取失败]"}else if("image"===e)try{n=await C(t)}catch{n=`[图片文件: ${t.name}]`}else n=`[二进制文件: ${t.name}]`;s.push({name:t.name,mime_type:t.type,size:t.size,kind:e,content:n})}return s}function M(e){return"bot"!==e.sender||!!(e.text||e.content_list?.length||e.attachments?.length)}var I=t(21499),R=t(64694),$=t(45907),B=t(74848);var D=t(40505);function T(e){const{active_session_id_ref:s,local_owner_ref:t,subscribed_ref:i,set_messages:a,scroll_to_bottom:o,follow_ref:c,mark_session_running:r,refresh_sessions:l,reload_session:d,set_active_session_running:u,on_chat_end:m}=e,g=(0,n.useRef)(new Map);return(0,n.useEffect)(()=>{const e=()=>s.current,n=(s,n)=>{if(m?.(s),r(s,!1),e()&&e()===s){if(g.current.clear(),u(!1),i.current===s&&(p.ws.sendData(f.HK.ai_chat_subscribe,{session_id:s,subscribe:!1}),i.current=null),t.current===s)return void(t.current=null);n?.length?a(e=>{let s=e.length;for(;s>0&&"bot"===e[s-1].sender;)s--;return[...e.slice(0,s),...S(n)].map((e,s)=>({...e,id:s+1}))}):d(s).catch(()=>{})}l()},_=s=>{const n=s?.context||{};n.session_id&&(((s,n,i,r,l=0)=>{e()&&e()===s&&t.current!==s&&a(e=>{const s=g.current,t=r?-(l+1):l;let a=e;if(!r){const e=-(l+1),t=s.get(e);void 0!==t&&(a=a.filter(e=>e.id!==t),s.delete(e))}const d=s.get(t),u=void 0===d?-1:a.findIndex(e=>e.id===d),m=-1===u?{id:w(),sender:"bot",text:""}:{...a[u]};if(-1===u&&s.set(t,m.id),r)m.text=n,m.is_loading=!0;else if(n){m.text=m.text+n;const e=m.content_list?.[0];e&&(e.content=m.text),m.is_loading=!1}if(i&&(m.content_list=[{tool_call_ends:i,content:m.text,role:"assistant"}],m.is_loading=!1),c.current&&requestAnimationFrame(()=>o()),-1===u)return[...a,m];const _=a.slice();return _[u]=m,_})})(n.session_id,n.text||"",n.tool_call_ends,n.notice,n.chunk_index),r(n.session_id,!0))},h=e=>{const s=e?.context||{};s.session_id&&n(s.session_id,s.once_messages_list)},x=e=>{const s=e?.context||{};s.session_id&&n(s.session_id,s.once_messages_list)};return p.ws.addMsg(f.HK.ai_chat_msg,_),p.ws.addMsg(f.HK.ai_chat_end,h),p.ws.addMsg(f.HK.ai_chat_error,x),()=>{p.ws.off_message(`message_${f.HK.ai_chat_msg}`,_),p.ws.off_message(`message_${f.HK.ai_chat_end}`,h),p.ws.off_message(`message_${f.HK.ai_chat_error}`,x),i.current&&(p.ws.sendData(f.HK.ai_chat_subscribe,{session_id:i.current,subscribe:!1}),i.current=null)}},[]),{chunkBubbleRef:g,bind_live_bubbles:(e,s)=>{g.current.clear();for(let t=0;t<s;t++){const n=e[e.length-s+t];n&&g.current.set(t,n.id)}},clear_bubbles:()=>g.current.clear()}}var V=t(85997),E=t(50260);function H(e){const s=e.attachments&&e.attachments.length>0?(0,B.jsx)("div",{className:"chat-message-attachments",children:e.attachments.map((e,s)=>(0,B.jsxs)("div",{className:"chat-message-attachment",children:[(0,B.jsx)(V.In,{icon:"attach_file"}),(0,B.jsx)("span",{children:e.name}),(0,B.jsxs)("small",{children:[e.size," B"]})]},`${e.name}_${s}`))}):null,t=[];e.images&&"bot"===e.sender&&t.push((0,B.jsx)(n.Fragment,{children:(0,B.jsx)(K,{images:e.images,text:e.text})},"images")),e.audio&&"bot"===e.sender&&t.push((0,B.jsx)(n.Fragment,{children:(0,B.jsx)(F,{audio:e.audio,text:e.text})},"audio")),e.embeddings&&"bot"===e.sender&&t.push((0,B.jsx)(n.Fragment,{children:(0,B.jsx)(L,{embeddings:e.embeddings,text:e.text})},"embeddings"));const i=function(e){if("bot"!==e.sender||!e.content_list?.length)return e.text?(0,B.jsx)(E.default,{context:e.text}):null;return(0,B.jsxs)(B.Fragment,{children:[e.content_list.map((e,s)=>{const t=[],i=(0,_.$j)(e.content);return i&&t.push((0,B.jsx)(n.Fragment,{children:(0,B.jsx)(E.default,{context:i})},`content-${s}`)),e.tool_call_ends?.length&&t.push((0,B.jsx)(n.Fragment,{children:(0,B.jsx)(P,{callList:e.tool_call_ends})},`tool-${s}`)),(0,B.jsx)(n.Fragment,{children:t},`part-${s}`)}),!e.content_list.some(e=>e.content)&&e.text?(0,B.jsx)(E.default,{context:e.text}):null]})}(e);return 0===t.length?(0,B.jsxs)(B.Fragment,{children:[s,i]}):(0,B.jsxs)(B.Fragment,{children:[t,s,i]})}function P({callList:e}){const[s,t]=n.useState(!1);if(!e?.length)return null;e.filter(e=>e.success).length;const i=e.filter(e=>!e.success).length;return(0,B.jsxs)("div",{className:"chat-message-call-list",children:[(0,B.jsxs)("div",{className:"call-list-header",onClick:()=>t(!s),children:[(0,B.jsx)(V.In,{icon:s?"expand_less":"expand_more"}),(0,B.jsxs)("span",{className:"call-list-summary",children:["工具调用 (",e.length,")",i>0&&(0,B.jsx)("span",{className:"call-list-fail",children:" 失败 "})]})]}),s&&(0,B.jsx)("div",{className:"call-list-body",children:e.map((e,s)=>(0,B.jsxs)("div",{className:"call-list-item "+(e.success?"call-success":"call-fail"),children:[(0,B.jsxs)("div",{className:"call-list-item-header",children:[(0,B.jsx)(V.In,{icon:e.success?"check_circle":"error"}),(0,B.jsx)("span",{className:"call-list-tool-name",children:e.tool_display_name||e.tool_name}),(0,B.jsxs)("span",{className:"call-list-duration",children:[e.duration_ms,"ms"]})]}),e.tool_args&&(0,B.jsxs)("details",{className:"call-list-details",children:[(0,B.jsx)("summary",{children:"参数"}),(0,B.jsx)("pre",{className:"call-list-pre",children:JSON.stringify(e.tool_args,null,2)})]}),!e.success&&e.error&&(0,B.jsxs)("details",{className:"call-list-details",children:[(0,B.jsx)("summary",{children:"错误"}),(0,B.jsx)("pre",{className:"call-list-pre call-list-error-text",children:e.error})]}),e.success&&e.tool_result&&(0,B.jsxs)("details",{className:"call-list-details",children:[(0,B.jsx)("summary",{children:"结果"}),(0,B.jsx)("pre",{className:"call-list-pre",children:e.tool_result.length>500?e.tool_result.slice(0,500)+"...":e.tool_result})]})]},s))})]})}function K({images:e,text:s}){let t=e||[];if(!t.length&&s)try{t=JSON.parse(s).data||[]}catch{}return t.length?(0,B.jsxs)("div",{className:"image-generation-result",children:[t.map((e,s)=>(0,B.jsxs)("div",{className:"image-generation-item",children:[e.url&&(0,B.jsx)("div",{className:"image-generation-image-wrapper",children:(0,B.jsx)("img",{src:e.url,alt:e.revised_prompt||`生成的图片 ${s+1}`,loading:"lazy"})}),e.b64_json&&(0,B.jsx)("div",{className:"image-generation-image-wrapper",children:(0,B.jsx)("img",{src:`data:image/png;base64,${e.b64_json}`,alt:`生成的图片 ${s+1}`})}),e.revised_prompt&&(0,B.jsx)("p",{className:"image-generation-prompt",children:(0,B.jsx)("small",{children:e.revised_prompt})})]},s)),s&&!e&&(0,B.jsx)(E.default,{context:s})]}):(0,B.jsx)(E.default,{context:s||""})}function F({audio:e,text:s}){if(e){if(e.url)return(0,B.jsx)("div",{className:"audio-result",children:(0,B.jsx)("audio",{controls:!0,src:e.url,children:"您的浏览器不支持音频播放"})});if(e.data){const s=e.mime_type||"audio/mpeg";return(0,B.jsx)("div",{className:"audio-result",children:(0,B.jsx)("audio",{controls:!0,src:`data:${s};base64,${e.data}`,children:"您的浏览器不支持音频播放"})})}}const t=s||"";if(t.startsWith("http://")||t.startsWith("https://"))return(0,B.jsx)("div",{className:"audio-result",children:(0,B.jsx)("audio",{controls:!0,src:t,children:"您的浏览器不支持音频播放"})});try{const e=JSON.parse(t);if(e?.data||e?.audio_data){const s=e.data||e.audio_data;return(0,B.jsx)("div",{className:"audio-result",children:(0,B.jsx)("audio",{controls:!0,src:`data:audio/mpeg;base64,${s}`,children:"您的浏览器不支持音频播放"})})}}catch{}return(0,B.jsx)(E.default,{context:t})}function z({content:e,label:s}){const[t,i]=n.useState(!1);return(0,B.jsxs)("button",{className:"embeddings-copy-btn",onClick:()=>{(0,D.lW)(e),i(!0),setTimeout(()=>i(!1),1500)},children:[(0,B.jsx)(V.In,{icon:t?"check":"content_copy"}),t?"已复制":s||"复制"]})}function L({embeddings:e,text:s}){let t=e||null;if(!t&&s)try{t=JSON.parse(s)}catch{return(0,B.jsx)(E.default,{context:s})}if(!t)return(0,B.jsx)(E.default,{context:s||""});const n=t?.data||[],i=t?.usage,a=JSON.stringify(t,null,2);return(0,B.jsxs)("div",{className:"embeddings-result",children:[(0,B.jsxs)("div",{className:"embeddings-summary",children:[(0,B.jsx)("strong",{children:"向量嵌入结果"}),(0,B.jsxs)("span",{children:["维度: ",n[0]?.embedding?.length??"N/A"]}),(0,B.jsxs)("span",{children:["数量: ",n.length]}),i&&(0,B.jsxs)("span",{children:["使用 tokens: ",i.total_tokens??"N/A"]})]}),(0,B.jsxs)("div",{className:"embeddings-toolbar",children:[(0,B.jsx)(z,{content:a,label:"复制全部结果"}),n.length>0&&n[0]?.embedding&&(0,B.jsx)(z,{content:JSON.stringify(n[0].embedding,null,2),label:"复制第一条向量"}),n.length>0&&(0,B.jsx)(z,{content:JSON.stringify(n.map(e=>e.embedding),null,2),label:"复制所有向量数据"})]}),n.length>0&&n[0]?.embedding&&(0,B.jsx)("div",{className:"embeddings-preview",children:(0,B.jsxs)("span",{children:["向量预览: [",n[0].embedding.slice(0,5).join(", "),n[0].embedding.length>5?", ...":"","]"]})}),n.length>0&&(0,B.jsxs)("details",{children:[(0,B.jsx)("summary",{children:"查看详细数据"}),(0,B.jsx)("pre",{className:"embeddings-raw",children:a})]})]})}async function O(e,s,t,n){try{switch(e){case"images":{const e=await async function(e,s){const t={prompt:e,session_id:s},n=await c.jV.post("images/generations",t);if(0!==n.code)throw new Error(n.message||"图片生成失败");const i=n.data||{},a=(i.data||[]).map(e=>({url:e.url,b64_json:e.b64_json,revised_prompt:e.revised_prompt})),o=a.map((e,s)=>`${e.revised_prompt?`\n> ${e.revised_prompt}`:""}`).join("\n\n");return{session_id:i.session_id||s,images:a,text:o||`生成了 ${a.length} 张图片`}}(s,t);return e&&n(e.text,{images:e.images}),!0}case"audio_speech":{const e=await async function(e,s){const t={input:e,session_id:s};try{const e=localStorage.getItem("ai_audio_extra_params");if(e){const s=JSON.parse(e);s.voice&&(t.voice=s.voice),s.speed&&(t.speed=parseFloat(s.speed))}}catch{}const n=localStorage.getItem("token")||"",i=await fetch("/api/ai_agent/audio/speech",{method:"POST",headers:{"Content-Type":"application/json",Authorization:n},body:JSON.stringify(t)});if(!i.ok)throw new Error(`语音合成失败: ${i.statusText}`);const a=i.headers.get("X-Session-Id")||s,o=await i.arrayBuffer();return{session_id:a,audio:{data:btoa(String.fromCharCode(...Array.from(new Uint8Array(o)))),mime_type:i.headers.get("content-type")||"audio/mpeg"},text:`[音频文件: ${e.slice(0,50)}...]`}}(s,t);return e&&n(e.text,{audio:e.audio}),!0}case"embeddings":{const e=await async function(e,s){const t=await c.jV.post("embeddings",{input:e,session_id:s});if(0!==t.code)throw new Error(t.message||"Embeddings 请求失败");const n=t.data||{},i=n?.data??[],a=`向量维度: ${i[0]?.embedding?.length??0}, 数量: ${i.length}`;return{session_id:n.session_id||s,embeddings:n,text:`✅ Embeddings 结果 - ${a}\n\`\`\`json\n${JSON.stringify(n,null,2).slice(0,2e3)}\n\`\`\``}}(s,t);return e&&n(e.text,{embeddings:e.embeddings}),!0}default:return!1}}catch(e){return n(`请求失败: ${e?.message||JSON.stringify(e)}`),!0}}var q=t(4412),G=t(23430),U=t(87361),J=t(80389),W=t(7523),Q=t(23496);const X=({currentModelName:e,setCurrentModelName:s,modelGroups:t,onModelChanged:r,batchMode:u,selectedMsgCount:_,sessionVisible:h,onToggleSessionPanel:p,onCreateSession:f,onToggleBatchMode:j,onBatchDeleteMessages:v,bgProcessVisible:b,bgProcessCount:w,onToggleBgProcess:S,inline:y})=>{const{t:N}=(0,a.Bd)(),k=(0,o.Zp)(),{check_user_auth:C}=(0,l.MH)(),[,A]=(0,i.fp)(m.AG.ai_session_collapsed),{open:M}=function(){const{t:e}=(0,a.Bd)(),[,s]=(0,i.fp)(m.AG.prompt_card),[t,o]=(0,i.fp)(m.AG.ai_chat_zoom),{initUserInfo:r}=(0,n.useContext)(W.F);return{open:()=>{const n=t,i=()=>s({open:!1});s({open:!0,title:e("缩放调整"),context_div:(0,B.jsx)(J.p,{defaultValue:t,onChange:o,min:30,max:200}),cancel:()=>{o(n),i()},confirm:async()=>{let s=100;o(e=>(s=e<30||e>200?100:e,s)),await c.wm.post(Q.s.user_save_private_attr,{is_ai_chat_zoom:!0,ai_chat_zoom:s}),(0,x.SK)(e("缩放调整成功")),r(),i()}})}}}(),I=C(G.oV.ai_model_switch)||C(G.oV.ai_agent_setting),R=[];for(const e of t)for(const s of e.models)R.push({title:s.label||s.value,value:`${e.index}::${s.value}`,group:e.note});const $=t.find(e=>e.active),D=$?`${$.index}::${e}`:"",T=(0,B.jsxs)(n.Fragment,{children:[(0,B.jsx)(V.rA,{icon:"menu",title:N("会话"),onClick:p,selected:h}),(0,B.jsx)(V.rA,{icon:"add",title:N("新会话"),onClick:()=>f()}),I&&R.length>0&&(0,B.jsx)(g.l6,{value:D,options:[{title:N("选择模型"),value:""},...R],margin:"0 0 0 1em",onChange:e=>{const t=String(e??"");if(!t.includes("::"))return;const[n,...i]=t.split("::"),a=i.join("::");a&&(s(a),c.jV.post("set_active_model",{index:Number(n),model_name:a}).then(e=>{e?.code===d.m.Success?((0,x.SK)("success"),r()):(0,x.zN)(e?.message||"fail")}).catch(console.error))},no_border:!0,width:"auto"}),u&&(0,B.jsx)(V.rA,{icon:"done",title:N("完成"),onClick:j}),u&&_>0&&(0,B.jsx)(V.rA,{icon:"delete",title:N("删除选中消息"),onClick:v}),(0,B.jsx)(V.rA,{icon:"zoom_in",title:N("缩放调整"),onClick:M}),(0,B.jsx)(V.rA,{icon:"terminal",title:N("后台进程"),onClick:S,selected:b,tip:w||null}),C(G.oV.ai_agent_setting)&&(0,B.jsx)(V.rA,{icon:"smart_toy",title:"机器人配置",onClick:()=>{k(U.o.ai_rebot_setting_page)}}),C(G.oV.ai_agent_setting)&&(0,B.jsx)(V.rA,{icon:"settings",title:"ai setting",onClick:()=>{k(U.o.ai_agent_setting_page)}})]});return y?(0,B.jsx)("div",{className:"chat-inline-header",children:T}):(0,B.jsx)(q.aZ,{position:"right",children:T})};var Y=t(75725);function Z({items:e}){const s=e.filter(e=>!!e.text);return 0===s.length?null:(0,B.jsx)("div",{className:"chat-session-meta",children:s.map((e,s)=>(0,B.jsx)("small",{className:e.className,title:e.title,children:e.text},s))})}function ee(e){return e||"新会话"}function se({sessions:e,activeSessionId:s,onSelectSession:t,onReorderSessions:i,onRenameSession:o,onDeleteSession:c,onToggleCmdAuto:r,onShowUsageStats:l,onShowSessionSetting:d,batchMode:u,selectedSessionIds:m,onToggleSessionSelect:g,onToggleBatchMode:_,onBatchDeleteSessions:h,onClearAllSessions:p,allUsersMode:f,onToggleAllUsersMode:x,showAllUsersEntry:j,sysPromptList:v,onChangeSysPrompt:b}){const{t:w}=(0,a.Bd)(),[S,y]=(0,n.useState)(""),N=(0,n.useRef)(null),[k,C]=(0,n.useState)(null),[A,M]=(0,n.useState)(null),[I,R]=(0,n.useState)(null),$=!!i&&!f,D=e=>{if(!e)return"";const s=v?.find(s=>String(s.index)===String(e));return s?s.note||s.prompt.slice(0,20):""},T=e=>[{text:String(e.message_count??""),className:"chat-session-meta__count",title:w("消息数")},{text:D(e.sys_prompt_id),className:"chat-session-meta__prompt",title:w("系统提示词")},{text:"web"!==e.source?e.source:"",className:"chat-session-meta__source",title:w("来源")},{text:f&&e.owner_name||"",className:"chat-session-meta__owner",title:e.owner_name}],E=S.trim()?e.filter(e=>(e.title||"").toLowerCase().includes(S.toLowerCase())||(e.summary||"").toLowerCase().includes(S.toLowerCase())||(e.long_term_memory||"").toLowerCase().includes(S.toLowerCase())||f&&(e.owner_name||"").toLowerCase().includes(S.toLowerCase())):e,H=e.find(e=>e.id===s);return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)("aside",{className:"chat-session-list",children:[(0,B.jsxs)("div",{className:"chat-session-search",children:[(0,B.jsx)("input",{type:"text",className:"chat-session-search-input",placeholder:w("搜索会话"),value:S,onChange:e=>y(e.target.value)}),H&&(0,B.jsx)("button",{className:"chat-session-current",title:ee(H.title),onClick:()=>(e=>{const s=()=>{const s=N.current,t=s?.querySelector(`[data-session-id="${e}"]`);t&&t.scrollIntoView({block:"center",behavior:"smooth"})};if(!E.some(s=>s.id===e))return y(""),void requestAnimationFrame(()=>requestAnimationFrame(s));s()})(H.id),children:(0,B.jsx)("span",{children:ee(H.title)})})]}),(0,B.jsx)("div",{className:"chat-session-items-wrap",ref:N,children:E.map((e,n)=>(0,B.jsx)("div",{"data-session-id":e.id,children:(0,B.jsxs)("button",{className:`chat-session-item ${s===e.id?"active":""} ${u?"batch-mode":""} ${e.running?"is-running":""} ${k===n?"row-dragging":""} ${A===n&&null!==k&&k!==n?"row-drop-target":""}`,draggable:$,onDragStart:()=>C(n),onDragOver:e=>{null!==k&&(e.preventDefault(),A!==n&&M(n))},onDragEnd:()=>{C(null),M(null)},onDrop:e=>{e.preventDefault(),(e=>{const s=k;if(C(null),M(null),null===s||s===e||!i)return;const t=E[s]?.id,n=E[e]?.id;t&&n&&i(t,n)})(n)},onClick:()=>{u&&g?g(e.id):t(e.id)},title:e.summary||e.long_term_memory||e.title,children:[u&&(0,B.jsx)("input",{type:"checkbox",className:"chat-session-checkbox",checked:m?.has(e.id)??!1,onChange:()=>g?.(e.id),onClick:e=>e.stopPropagation()}),(0,B.jsx)("span",{children:ee(e.title)}),e.running&&(0,B.jsx)("span",{className:"chat-session-running",title:w("正在执行中")}),(0,B.jsx)(Z,{items:T(e)}),!u&&(0,B.jsx)("i",{className:"chat-session-more material-icons",title:w("更多操作"),onClick:s=>{s.stopPropagation();const t=s.currentTarget.getBoundingClientRect();R({x:t.right,y:t.bottom,session:e})},children:"more_horiz"})]})},e.id))}),(0,B.jsxs)("div",{className:"chat-session-actions",children:[(0,B.jsx)(V.rA,{icon:u?"check_circle":"checklist",title:w(u?"取消批量选择":"批量选择"),onClick:_}),j&&!u&&(0,B.jsx)(V.rA,{icon:f?"person":"groups",title:w(f?"仅看我的会话":"查看所有用户会话"),onClick:x}),u&&(m?.size??0)>0&&(0,B.jsx)(V.rA,{icon:"delete",title:w("删除选中会话"),onClick:h}),!u&&p&&(0,B.jsx)(V.rA,{icon:"delete_sweep",title:w("删除全部会话"),onClick:p})]})]}),I&&(0,B.jsx)(Y.rY,{click:()=>R(null),children:(0,B.jsx)(Y.sw,{x:I.x,y:I.y,items:(e=>{const s=[{r:w("重命名"),v:"rename",run:()=>o(e.id,e.title)},...f?[]:[{r:w("移动到最上"),v:"to_top",run:()=>{const s=E[0];s&&s.id!==e.id&&i?.(e.id,s.id)}},{r:w("移动到最下"),v:"to_bottom",run:()=>{const s=E[E.length-1];s&&s.id!==e.id&&i?.(e.id,s.id)}}],{r:e.cmd_auto_allow?w("命令检测关闭"):w("命令检测开启"),v:"cmd_auto",run:()=>r?.(e.id,!e.cmd_auto_allow)}];return v?.length&&s.push({r:w("系统提示词"),items:[{r:w("不使用"),v:"",run:()=>b?.(e.id,"")},...v.map(s=>({r:D(String(s.index)),v:String(s.index),run:()=>b?.(e.id,String(s.index))}))]}),s.push({r:w("字符消耗统计"),v:"usage",run:()=>l(e.id)},{r:w("设置"),v:"setting",run:()=>d?.(e.id)},{r:w("删除"),v:"delete",run:()=>c(e.id)}),s})(I.session),pre_value:I.session.sys_prompt_id?String(I.session.sys_prompt_id):"",click:(e,s)=>{R(null),s?.run?.()}})})]})}function te(e){const s=(e.text||"").split("\n").map(e=>e.trim()).find(Boolean)||"";return s.length>80?s.slice(0,80)+"…":s}const ne=({messages:e,batchMode:s,selectedMsgIds:t,sending:i,chatContainerRef:a,messagesEndRef:o,onToggleMsgSelect:c,onDelete:r,onCopy:l,onCopyAll:d,onToggleBatchMode:u,onBatchCopy:m,onBatchDelete:g,showBatchBar:_,t:h})=>{const[p,f]=(0,n.useState)(new Set),x=(0,n.useMemo)(()=>e.filter(e=>!e.is_loading).map(e=>e.id),[e]),j=e=>{f(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},v=()=>{f(e=>e.size>0&&x.every(s=>e.has(s))?new Set:new Set(x))};return(0,B.jsxs)("div",{className:"chat-messages",ref:a,"data-sending":i?"true":"false",children:[_&&(0,B.jsxs)("div",{className:"chat-message-batch-bar",children:[(0,B.jsxs)("span",{className:"batch-bar-count",children:[h("已选")," ",t.size]}),(0,B.jsx)("button",{onClick:m,children:h("复制所选")}),(0,B.jsx)("button",{onClick:g,className:"danger",children:h("删除所选")}),(0,B.jsx)("button",{onClick:u,children:h("取消")})]}),e.map(e=>{const n=p.has(e.id);return(0,B.jsxs)("div",{className:`chat-message ${e.sender} ${s?"batch-mode":""} ${e.is_loading?"is-loading":""} ${n?"collapsed":""}`,children:[s&&(0,B.jsx)("input",{type:"checkbox",className:"chat-message-checkbox",checked:t.has(e.id),onChange:()=>c(e.id)}),e.is_loading?(0,B.jsxs)("div",{className:"ai-loading-bubble",children:[(0,B.jsxs)("div",{className:"ai-loading-dots",children:[(0,B.jsx)("span",{className:"ai-loading-dot"}),(0,B.jsx)("span",{className:"ai-loading-dot"}),(0,B.jsx)("span",{className:"ai-loading-dot"})]}),(0,B.jsx)("span",{className:"ai-loading-text",children:e.text})]}):(0,B.jsxs)(B.Fragment,{children:[n?(0,B.jsxs)("div",{className:"chat-message-summary",title:e.text,onClick:()=>j(e.id),children:[(0,B.jsx)("span",{className:"chat-message-summary-icon",children:"▸"}),(0,B.jsx)("span",{className:"chat-message-summary-text",children:te(e)||h("(无内容)")})]}):(0,B.jsx)("div",{className:"chat-message-body",children:H(e)}),(0,B.jsxs)("div",{className:"message-actions",children:[(0,B.jsx)("button",{onClick:()=>r(e.id),children:h("删除")}),(0,B.jsx)("button",{onClick:()=>l(e),children:h("复制")}),(0,B.jsx)("button",{onClick:d,children:h("全部复制")}),(0,B.jsx)("button",{onClick:u,children:h("多选")})]}),(0,B.jsxs)("div",{className:"message-collapse-bar",children:[(0,B.jsx)("button",{onClick:()=>j(e.id),children:h(n?"展开":"折叠")}),(0,B.jsx)("button",{onClick:v,children:h("全部折叠")}),"bot"===e.sender&&null!=e.elapsed_ms&&(0,B.jsx)("span",{className:"message-elapsed",children:(0,I.kf)(e.elapsed_ms)})]})]})]},e.id)}),(0,B.jsx)("div",{ref:o})]})},ie=(0,n.forwardRef)(function({placeholder:e="",disabled:s=!1,className:t,style:i,onEnter:a,onPaste:o,onChange:c},r){const l=(0,n.useRef)(null),[d,u]=(0,n.useState)(!0),[m,g]=(0,n.useState)(!1),_=(0,n.useCallback)(()=>{const e=l.current;return e?(e.textContent??"").replace(/\u00A0/g," ").trimEnd():""},[]);(0,n.useImperativeHandle)(r,()=>({getValue:()=>_(),setValue:e=>{const s=l.current;if(!s)return;s.textContent=e,u(!e);const t=document.createRange();t.selectNodeContents(s),t.collapse(!1);const n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)},clear:()=>{const e=l.current;e&&(e.textContent="",u(!0))},focus:()=>l.current?.focus()})),(0,n.useEffect)(()=>{const e=l.current;if(!e)return;const s=()=>u(!e.textContent);return e.addEventListener("input",s),()=>e.removeEventListener("input",s)},[]);return(0,B.jsx)("div",{ref:l,contentEditable:!s,suppressContentEditableWarning:!0,className:"rich-textarea"+(t?" "+t:""),style:i,onKeyDown:e=>{m||"Enter"!==e.key||e.shiftKey||e.ctrlKey||e.metaKey||e.altKey||(e.preventDefault(),a?.())},onPaste:o,onInput:()=>c?.(_()),onCompositionStart:()=>g(!0),onCompositionEnd:()=>g(!1),"data-placeholder":d?e:void 0})});var ae=t(84369);function oe({pendingAttachments:e,onRemove:s}){return 0===e.length?null:(0,B.jsx)("div",{className:"chat-attachment-strip",children:e.map((e,t)=>(0,B.jsxs)("div",{className:"chat-attachment-chip",children:[(0,B.jsx)(V.In,{icon:"attach_file"}),(0,B.jsx)("span",{title:e.name,children:e.name}),(0,B.jsx)("button",{type:"button",onClick:()=>s(t),children:(0,B.jsx)(V.In,{icon:"close"})})]},`${e.name}_${t}`))})}const ce=(0,n.forwardRef)(({onSend:e,sending:s,pausing:t=!1,onAbort:o,pendingAttachments:c,onRemoveAttachment:r,onOpenFilePicker:l,onAddFiles:d,onDrop:u,onDragOver:g,fileInputRef:_,readonly:h=!1},p)=>{const{t:f}=(0,a.Bd)(),x=(0,n.useRef)(null),j=(0,n.useRef)(null),[v,b]=(0,i.fp)(m.AG.ai_chat_input_height);(0,n.useImperativeHandle)(p,()=>({getValue:()=>x.current?.getValue()??"",setValue:e=>x.current?.setValue(e),clear:()=>x.current?.clear()}));const{dragging:w,on_pointer_down:S,on_pointer_up:y}=(0,ae.y)({direction:"vertical",get_start_size:()=>v,px_to_unit:e=>e/(()=>{const e=j.current;return e&&parseFloat(getComputedStyle(e).fontSize)||16})(),min:2,on_change:e=>b(e)}),N={minHeight:`${v}em`,maxHeight:`${v}em`};return(0,B.jsxs)("div",{ref:j,className:"chat-input-area"+(h?" readonly":""),onDrop:h?void 0:u,onDragOver:h?void 0:g,children:[!h&&(0,B.jsx)("div",{className:"chat-input-resize-handle"+(w?" dragging":""),onPointerDown:S}),(0,B.jsx)("input",{ref:_,type:"file",multiple:!0,style:{display:"none"},onChange:e=>{e.target.files?.length&&(d(e.target.files),e.currentTarget.value="")}}),(0,B.jsxs)("div",{className:"chat-input-shell",children:[(0,B.jsx)(oe,{pendingAttachments:c,onRemove:r}),(0,B.jsx)(ie,{ref:x,placeholder:f(h?"查看全部会话时不可发送消息":"输入消息"),disabled:h,onEnter:()=>e(),onPaste:e=>{const s=e.clipboardData?.files;s&&s.length>0&&(e.preventDefault(),d(s))},className:"chat-input",style:N})]}),!h&&(0,B.jsx)(V.rA,{title:f("添加文件"),icon:"attach_file",onClick:l}),h?(0,B.jsx)("button",{className:"little-button button",disabled:!0,children:f("发送")}):t?(0,B.jsx)(V.Vi,{color:"var( --icon-yellow)",text:f("暂停中"),clickFun:()=>{}}):s?(0,B.jsx)(V.Vi,{color:"var( --icon-red)",text:f("暂停"),clickFun:o}):(0,B.jsx)(V.Vi,{text:f("发送"),clickFun:e}),w&&(0,B.jsx)("div",{className:"chat-input-overlay",onPointerUp:y})]})}),re=function(e){const{t:s}=(0,a.Bd)(),[t,o]=(0,n.useState)([]),[c,r]=(0,n.useState)(!1),[l,d]=(0,n.useState)(null),[u,g]=(0,n.useState)(null),[_,h]=(0,n.useState)(!1),[j,v]=(0,i.fp)(m.AG.ai_bg_expanded),[,b]=(0,i.fp)(m.AG.ai_session_collapsed),w=()=>{v(!1)},S=(0,n.useCallback)(async()=>{r(!0);try{const s=new f.hf(f.HK.ai_bg_process_list_req);s.context={};const t=await p.ws.send(s);t?.context?.processes&&(o(t.context.processes),e.panelRef?.current?.onCountChange?.(t.context.processes.length))}catch(e){console.error("获取后台进程列表失败",e)}finally{r(!1)}},[]);e.panelRef&&(e.panelRef.current.refresh=S);const y=(0,n.useCallback)(async e=>{h(!0),d(e);try{const s=new f.hf(f.HK.ai_bg_process_output_req);s.context={pid:e};const t=await p.ws.send(s);g(t.context)}catch(e){console.error("获取进程输出失败",e),(0,x.zN)("获取进程输出失败")}finally{h(!1)}},[]),N=(0,n.useCallback)(async e=>{try{const s=new f.hf(f.HK.ai_bg_process_kill_req);s.context={pid:e};const t=await p.ws.send(s);t?.context?.success?((0,x.SK)("进程已终止"),S(),l===e&&(d(null),g(null))):(0,x.zN)(t?.context?.message||"终止失败")}catch(e){console.error("终止进程失败",e),(0,x.zN)("终止进程失败")}},[S,l]);(0,n.useEffect)(()=>{S();const e=setInterval(S,5e3);return()=>clearInterval(e)},[S]);const k=t.filter(e=>e.running),C=t.filter(e=>!e.running);return(0,B.jsxs)(B.Fragment,{children:[j&&(0,B.jsx)("div",{className:"chat-session-overlay",onClick:w}),(0,B.jsxs)("aside",{className:"chat-bg-process-panel "+(j?"expanded":""),children:[(0,B.jsxs)("div",{className:"chat-bg-process-header",children:[(0,B.jsx)("span",{className:"chat-bg-process-title",children:s("后台进程")}),(0,B.jsx)(V.rA,{icon:"close",title:s("关闭"),onClick:w})]}),(0,B.jsxs)("div",{className:"chat-bg-process-toolbar",children:[(0,B.jsx)(V.rA,{icon:"refresh",title:s("刷新"),onClick:S}),(0,B.jsxs)("span",{className:"chat-bg-process-count",children:[k.length," ",s("个运行中"),C.length>0&&` / ${C.length} ${s("个已退出")}`]})]}),(0,B.jsxs)("div",{className:"chat-bg-process-list",children:[c&&0===t.length&&(0,B.jsx)("div",{className:"chat-bg-process-empty",children:s("加载中...")}),!c&&0===t.length&&(0,B.jsx)("div",{className:"chat-bg-process-empty",children:s("暂无后台进程")}),k.map(e=>(0,B.jsxs)("div",{className:`chat-bg-process-item ${l===e.pid?"active":""} running`,children:[(0,B.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(e.pid),children:[(0,B.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,B.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>40?e.cmd.slice(0,40)+"...":e.cmd}),(0,B.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,B.jsx)("span",{className:"chat-bg-process-status running-dot",title:s("运行中"),children:"●"})]}),(0,B.jsxs)("div",{className:"chat-bg-process-item-actions",children:[(0,B.jsx)(V.rA,{icon:"terminal",title:s("查看输出"),onClick:()=>y(e.pid)}),(0,B.jsx)(V.rA,{icon:"stop",title:s("终止进程"),onClick:()=>N(e.pid)})]})]},e.pid)),C.map(e=>(0,B.jsx)("div",{className:`chat-bg-process-item ${l===e.pid?"active":""} finished`,children:(0,B.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(e.pid),children:[(0,B.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,B.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>30?e.cmd.slice(0,30)+"...":e.cmd}),(0,B.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,B.jsxs)("span",{className:"chat-bg-process-exit-code",children:["exit: ",e.exit_code]})]})},e.pid))]}),null!==l&&(0,B.jsxs)("div",{className:"chat-bg-process-output",children:[(0,B.jsxs)("div",{className:"chat-bg-process-output-header",children:[(0,B.jsxs)("span",{children:["PID: ",l," ",s("输出")]}),(0,B.jsx)(V.rA,{icon:"close",title:s("关闭"),onClick:()=>{d(null),g(null)}})]}),(0,B.jsx)("div",{className:"chat-bg-process-output-content",children:_?(0,B.jsx)("div",{className:"chat-bg-process-empty",children:s("加载中...")}):u?(0,B.jsx)("pre",{className:"chat-bg-process-output-pre",children:u.output||s("(无输出)")}):null})]})]})]})};function le(e={}){const{inline_header:s=!1,session_id:t,file_cwd_path:_,sync_url:v=!0,on_session_change:b}=e,{t:y}=(0,a.Bd)(),[N,k]=(0,o.ok)(),C=v&&N.get("session")||"",{check_user_auth:V}=(0,l.MH)();(0,u.w)();const[E]=(0,i.fp)(m.AG.user_base_info),H=!!E?.user_data?.is_root,[P,K]=(0,i.fp)(m.AG.ai_session_collapsed),[F,z]=(0,i.fp)(m.AG.ai_bg_expanded),[L,q]=(0,i.fp)(m.AG.prompt_card),[G]=(0,i.fp)(m.AG.ai_chat_zoom),[U,J]=(0,n.useState)(null),[W,Q]=(0,n.useState)([]),[Y,Z]=(0,n.useState)(new Set),[ee,te]=(0,n.useState)([]),[ie,ae]=(0,n.useState)(""),[oe,le]=(0,n.useState)([]),[de,ue]=(0,n.useState)(0),me=(0,n.useRef)(null),ge=(0,n.useRef)(null),_e=(0,n.useRef)(null),he=(0,n.useRef)({}),pe=(0,n.useRef)({}),fe=(0,n.useRef)(null);(0,n.useEffect)(()=>{fe.current=U},[U]);const xe=(0,n.useRef)(null),je=(0,n.useRef)(()=>{}),ve=(0,n.useRef)([]),be=(0,n.useRef)(""),we=(0,n.useRef)(!1),Se=(0,n.useRef)(null),ye=(0,n.useRef)(()=>{}),Ne=(0,n.useRef)(null),ke=function(e){const{admin_call:s,owner_of_session:t,get_sessions:i,activeSessionId:o,admin_mode_ref:r}=e,{t:l}=(0,a.Bd)(),u=(0,$.y)(),[m,g]=(0,n.useState)([]),[_,h]=(0,n.useState)(!1),[p,f]=(0,n.useState)(new Set),v=(0,n.useRef)(null),b=(0,n.useRef)(!0),w=(0,n.useRef)(!1),y=(e=!1)=>{const s=v.current;if(!s||!b.current)return;s.scrollTo({top:s.scrollHeight,behavior:e?"smooth":"auto"});let t=0;const n=()=>{const s=v.current;s&&b.current&&(s.scrollTo({top:s.scrollHeight,behavior:e&&0===t?"smooth":"auto"}),++t<6&&requestAnimationFrame(n))};requestAnimationFrame(n)},N=()=>{w.current=!0};return(0,n.useLayoutEffect)(()=>{w.current&&(w.current=!1,b.current=!0),b.current&&y(!1)},[m]),(0,n.useEffect)(()=>{const e=v.current;if(!e)return;const s=s=>{s.deltaY<0?b.current=!1:e.scrollHeight-(e.scrollTop+e.clientHeight)<4&&(b.current=!0)},t=()=>{e.scrollHeight-(e.scrollTop+e.clientHeight)<4&&(b.current=!0)},n=()=>{b.current&&(e.scrollTop=e.scrollHeight)};e.addEventListener("wheel",s,{passive:!0}),e.addEventListener("scroll",t);const i=new ResizeObserver(n),a=()=>[...e.children].forEach(e=>i.observe(e));a();const o=new MutationObserver(()=>{a(),n()});return o.observe(e,{childList:!0}),()=>{e.removeEventListener("wheel",s),e.removeEventListener("scroll",t),i.disconnect(),o.disconnect()}},[]),{messages:m,setMessages:g,batchMode:_,setBatchMode:h,selectedMsgIds:p,setSelectedMsgIds:f,chatContainerRef:v,followRef:b,isNearBottom:(e,s=120)=>{const{scrollTop:t,scrollHeight:n,clientHeight:i}=e;return n-(t+i)<s},scrollToBottom:y,request_scroll_bottom:N,apply_session:e=>{if(!e)return g([]),void N();let s=e.messages??[];e.live_messages?.length&&(s=[...s,...e.live_messages]),g(S(s)),N()},handleDelete:e=>{u({sub_title:l("cf_one"),confirm_fun:async()=>{const n=m.findIndex(s=>s.id===e);if(n<0)return;if(g(m.filter(s=>s.id!==e)),!o)return;const i=t(o);i?s("message_delete",{session_id:o,user_id:i,indices:[n]}).catch(console.error):c.jV.post("session/message/delete",{session_id:o,indices:[n]}).catch(console.error)}})},handleCopy:async e=>{(0,D.lW)(j(e)),(0,x.SK)("复制成功")},handleCopyAll:async()=>{const e=i();if(!e.length)return void(0,x.SK)("暂无聊天记录");const t=[];for(const n of e){const e=n.user_id?await s("get",{session_id:n.id,user_id:n.user_id}):await c.jV.post("session/get",{session_id:n.id});if(e.code!==d.m.Success||!e.data)continue;const i=e.data,a=S([...i.messages??[],...i.live_messages??[]]).map(j).filter(Boolean).join("\n\n\n");a&&t.push(a)}t.length?((0,D.lW)(t.join("\n\n\n")),(0,x.SK)("复制成功")):(0,x.SK)("暂无聊天记录")},handleBatchCopy:()=>{const e=m.filter(e=>p.has(e.id)).map(j).filter(Boolean).join("\n\n\n");e?((0,D.lW)(e),(0,x.SK)("复制成功")):(0,x.SK)("暂无内容")},toggleBatchMode:()=>{_&&f(new Set),h(e=>!e)},toggleMsgSelect:e=>{f(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},batchDeleteMessages:()=>{0!==p.size&&u({sub_title:l("cf_msgs"),confirm_fun:async()=>{const e=[];if(m.forEach((s,t)=>{p.has(s.id)&&e.push(t)}),g(m.filter(e=>!p.has(e.id))),f(new Set),h(!1),!o||0===e.length)return;const n=t(o);n?s("message_delete",{session_id:o,user_id:n,indices:e}).catch(console.error):c.jV.post("session/message/delete",{session_id:o,indices:e}).catch(console.error)}})}}}({admin_call:(e,s)=>c.jV.post("admin/session",{action:e,...s||{}}),owner_of_session:e=>we.current?ve.current.find(s=>s.id===e)?.user_id:void 0,get_sessions:()=>ve.current,activeSessionId:be.current,admin_mode_ref:we});ye.current=ke.apply_session;const Ce=function(e){const{on_session_loaded:s,set_session_panel_open:t,on_session_change:o,init_cwd:r,write_url_session:l,url_session_id:u,init_session_id:_}=e,{t:h}=(0,a.Bd)(),p=(0,$.y)(),[f,j]=(0,i.fp)(m.AG.ai_last_session_id),[v,b]=(0,n.useState)([]),[w,S]=(0,n.useState)(""),[y,N]=(0,n.useState)(""),[k,C]=(0,n.useState)(!1),[A,M]=(0,n.useState)(!1),[D,T]=(0,n.useState)(!1),V=(0,n.useRef)(!1),E=(0,n.useRef)([]);(0,n.useEffect)(()=>{V.current=k},[k]),(0,n.useEffect)(()=>{E.current=v},[v]);const H=(e,s={})=>c.jV.post("admin/session",{action:e,...s}),P=e=>{if(V.current)return E.current.find(s=>s.id===e)?.user_id},K=async(e,n=!1,i)=>{const a=i??E.current.find(s=>s.id===e)?.user_id,r=V.current&&a?await H("get",{session_id:e,user_id:a}):await c.jV.post("session/get",{session_id:e});if(r.code!==d.m.Success||!r.data)return!1;const m=r.data;return S(m.id),j(m.id),u!==m.id&&l(m.id),o?.(m.id),M(!!m.running),N(m.sys_prompt_id??""),n&&t(!0),s(m),!0},F=async e=>{const t=V.current?await H("list_all_sessions"):await c.jV.get("sessions");if(t.code!==d.m.Success)return!1;const n=t.data??[];b(n);const i=null===e?n[0]?.id??"":e||w||n[0]?.id||"";if(!i)return S(""),l(null),s(null),!1;if(e&&!n.some(s=>s.id===e))return!1;const a=n.find(e=>e.id===i)?.user_id;return await K(i,!1,a)},z=async e=>{if(!e)return null;const s=await c.jV.get("sessions");if(s.code!==d.m.Success)return null;const t=s.data??[],n=(0,I.ed)(e),i=t.find(e=>(0,I.ed)(e.file_cwd_path)===n);if(i)return i.id;const a=await c.jV.post("session",{file_cwd_path:e});return a.code!==d.m.Success?null:a.data.id};return{sessions:v,setSessions:b,sessions_ref:E,activeSessionId:w,setActiveSessionId:S,selectedSysPromptId:y,setSelectedSysPromptId:N,admin_all_mode:k,admin_mode_ref:V,readonly:D,activeSessionRunning:A,setActiveSessionRunning:M,admin_call:H,call:(e,s,t)=>V.current?H(e,s):t(),owner_of_session:P,refreshSessions:async()=>{const e=V.current?await H("list_all_sessions"):await c.jV.get("sessions");e.code===d.m.Success&&b(e.data??[])},markSessionRunning:(e,s)=>{b(t=>{const n=t.find(s=>s.id===e);return n&&!!n.running!==s?t.map(t=>t.id===e?{...t,running:s}:t):t})},loadSession:K,loadSessions:F,createSession:async e=>{const n=await c.jV.post("session",{sys_prompt_id:e||void 0,file_cwd_path:r||void 0});if(n.code!==d.m.Success)return;const i=n.data;S(i.id),N(i.sys_prompt_id??""),t(!0),s(null),await F(i.id),requestAnimationFrame(()=>{const e=document.querySelector(".chat-input");e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,200)+"px")})},locate_session_by_cwd:z,init_active_session:async()=>{if(r){const e=await z(r);e&&await F(e)||await F()}else _?await F(_)||await F():u?await F(u)||await F():f&&await F(f)||await F()},reorderSessions:(e,s)=>{if(V.current)return;const t=E.current.findIndex(s=>s.id===e),n=E.current.findIndex(e=>e.id===s);if(t<0||n<0||t===n)return;const i=(0,R.TI)(E.current,t,n);b(i),c.jV.post("sessions/update/sort",{session_ids:i.map(e=>e.id)}).catch(()=>{})},deleteSession:e=>{p({sub_title:"确认删除这个会话吗?",confirm_fun:async()=>{const s=P(e);s?await H("delete",{session_id:e,user_id:s}):await c.jV.post("session/delete",{session_id:e}),w===e?(S(""),await F(null)):await F(w)}})},renameSession:(e,s)=>{let t=s;p({confirm_fun:async()=>{const s=P(e);s?await H("rename",{session_id:e,user_id:s,title:t}):await c.jV.post("sessions/update/meta",{id:e,title:t}),await F(w)},context_div:(0,B.jsx)("div",{className:"card-content",children:(0,B.jsx)(g.Sm,{value:t,handleInputChange:e=>{t=e}})})})},toggleCmdAuto:async(e,s)=>{const t=P(e);t?await H("cmd_auto",{session_id:e,user_id:t,allow:s}):await c.jV.post("session/cmd_auto_allow",{session_id:e,allow:s}),(0,x.SK)(h(s?"命令检测已开启":"命令检测已关闭")),await F(w)},batchDeleteSessions:(e,s)=>{0!==e.size&&p({sub_title:h("cf_ses"),confirm_fun:async()=>{if(V.current)await H("batch_delete",{session_ids:Array.from(e)});else for(const s of e)await c.jV.post("session/delete",{session_id:s});s(),e.has(w)?(S(""),await F(null)):await F(w)}})},clearAllSessions:()=>{p({sub_title:h("cf_all"),confirm_fun:async()=>{await c.jV.post("sessions/clear",{}),S(""),s(null),await F(null)}})},toggleAllUsersMode:async()=>{const e=!k;C(e),V.current=e,T(e),S(""),s(null);const t=e?await H("list_all_sessions"):await c.jV.get("sessions"),n=t.code===d.m.Success?t.data??[]:[];b(n),n[0]?.id&&await K(n[0].id,!1,n[0].user_id)},changeSystemPrompt:(e,s)=>{const t=s||w;if(!t)return;b(s=>s.map(s=>s.id===t?{...s,sys_prompt_id:e||void 0}:s)),t===w&&N(e);const n=P(t);n?H("sys_prompt",{session_id:t,user_id:n,sys_prompt_id:e||void 0}).catch(console.error):c.jV.post("session/sys_prompt",{session_id:t,sys_prompt_id:e||void 0}).catch(console.error)}}}({on_session_loaded:e=>{if(e&&(e.running&&(p.ws.sendData(f.HK.ai_chat_subscribe,{session_id:e.id,subscribe:!0}),Se.current=e.id),ye.current(e),e.live_messages?.length)){const s=S([...e.messages??[],...e.live_messages]);Ne.current?.bind_live_bubbles(s,e.live_messages.length)}},set_session_panel_open:e=>K(!e),on_session_change:b,init_cwd:_,write_url_session:e=>{v&&k(s=>{const t=new URLSearchParams(s);return e?t.set("session",e):t.delete("session"),t},{replace:!0})},url_session_id:C,init_session_id:t});(0,n.useEffect)(()=>{be.current=Ce.activeSessionId,we.current=Ce.admin_all_mode,ve.current=Ce.sessions},[Ce.activeSessionId,Ce.admin_all_mode,Ce.sessions]);const Ae=T({active_session_id_ref:be,local_owner_ref:xe,subscribed_ref:Se,set_messages:ke.setMessages,scroll_to_bottom:()=>ke.scrollToBottom(!1),follow_ref:ke.followRef,mark_session_running:Ce.markSessionRunning,refresh_sessions:Ce.refreshSessions,reload_session:e=>Ce.loadSession(e),set_active_session_running:Ce.setActiveSessionRunning,on_chat_end:()=>je.current()});Ne.current=Ae;const Me=(0,n.useRef)((0,r.n)(e=>{ke.setMessages(e),ke.followRef.current&&ke.scrollToBottom(!1)},50)).current,Ie=function(e){const{getMessages:s,setMessages:t,setMessagesDebounced:i,setSending:a,getActiveSessionId:o,setActiveSessionId:c,refreshSessions:r,scrollToBottom:l,buildRequestMessages:d,getSelectedSysPromptId:u,setLocalOwner:m}=e,[g,_]=(0,n.useState)(!1),h=(0,n.useRef)([]),x=(0,n.useRef)(null),j=(e,n,c)=>{const g=s(),_=g.length+1,h={...n,id:_},j=[...g,h];t(j),a(e),m(e),x.current={abort:()=>{}};const v={id:-1,sender:"bot",text:"AI thinking ...",is_loading:!0};j.push(v),t([...j]);const b=new Map,w=()=>{o()===e&&i([...j])},y=()=>{const e=j.indexOf(v);-1!==e&&j.splice(e,1)},N=s=>{const t=s.context||{};if(t.session_id!==e)return;const n=t.text||"",i=t.tool_call_ends,a=t.chunk_index??0;if(t.notice)return v.id=-1,v.text=n,v.is_loading=!0,j.includes(v)||j.push(v),void w();if("[DONE]"===n)return;if(!n&&!i)return;y();let o=b.get(a);if(o||(o={id:_+1+a,sender:"bot",text:"",is_loading:!0},j.push(o),b.set(a,o)),n){o.text=o.text+n;const e=o.content_list?.[0];e&&(e.content=o.text),o.is_loading=!1}i&&(o.content_list=[{tool_call_ends:i,content:o.text,role:"assistant"}],o.is_loading=!1),w()},k=s=>{const n=s.context||{};n.session_id===e&&(A(),x.current=null,m(null),a(s=>s===e?null:s),o()===e&&t(e=>{const s=e.filter(M);let t=s;if(n.once_messages_list?.length){let e=-1;for(let t=s.length-1;t>=0;t--)if("user"===s[t].sender){e=t;break}const i=e>=0?e+1:s.length;t=[...s.slice(0,i),...S(n.once_messages_list)]}return t.map((e,s)=>({...e,id:s+1}))}),r(),l(!0),c())},C=s=>{const n=s.context||{};if(n.session_id!==e)return;A(),x.current=null,a(s=>s===e?null:s);const i="AI request error: "+(n.message||"未知错误");y();const r=[...j].reverse().find(e=>"bot"===e.sender);r?(r.text=r.text?`${r.text}\n\n${i}`:i,r.is_loading=!1):j.push({id:_+1,sender:"bot",text:i}),o()===e&&t([...j].map((e,s)=>({...e,id:s+1}))),c()},A=()=>{p.ws.off_message(`message_${f.HK.ai_chat_msg}`,N),p.ws.off_message(`message_${f.HK.ai_chat_end}`,k),p.ws.off_message(`message_${f.HK.ai_chat_error}`,C)};p.ws.addMsg(f.HK.ai_chat_msg,N),p.ws.addMsg(f.HK.ai_chat_end,k),p.ws.addMsg(f.HK.ai_chat_error,C),p.ws.sendData(f.HK.ai_chat_req,{messages:d(n),session_id:e,sys_prompt_id:u()})},v=()=>{const e=h.current;if(0===e.length)return;const s=e.shift();if(!s)return;t(e=>e.map(e=>"user"===e.sender&&e.text.includes("⏳(排队中...)")?{...e,text:e.text.replace(" ⏳(排队中...)","")}:e));const n={id:w(),sender:"user",text:s.text,attachments:s.attachments};j(o(),n,v)};return{startChatStream:j,processPendingQueue:v,enqueueMessage:(e,s)=>{h.current.push({text:e,attachments:s})},getQueueLength:()=>h.current.length,abort:()=>{const e=o();e&&(p.ws.sendData(f.HK.ai_chat_abort,{session_id:e}),x.current=null,_(!0))},pausing:g,setPausing:_}}({getMessages:()=>ke.messages,setMessages:ke.setMessages,setMessagesDebounced:Me,setSending:J,getActiveSessionId:()=>be.current,setActiveSessionId:Ce.setActiveSessionId,refreshSessions:Ce.refreshSessions,scrollToBottom:ke.scrollToBottom,buildRequestMessages:e=>{const s=(e.attachments??[]).filter(e=>"image"===e.kind);if(s.length>0){const t=[];e.text&&t.push({type:"text",text:e.text});for(const e of s)t.push({type:"image_url",image_url:{url:e.content}});return[{content:t,role:"user",attachments:e.attachments??[]}]}return[{content:e.text,role:"bot"===e.sender?"assistant":"user",attachments:e.attachments??[]}]},getSelectedSysPromptId:()=>Ce.selectedSysPromptId,setLocalOwner:e=>{xe.current=e}});je.current=()=>Ie.setPausing(!1);const Re=e=>{ae(e?.ai_config?.model??"")},$e=async()=>{try{const e=await c.jV.get("public_models");e.code===d.m.Success&&le(e.data?.groups??[])}catch{le([])}},Be=e=>{const s=Array.from(e??[]).filter(Boolean);s.length&&Q(e=>[...e,...s])},De=e=>Ce.owner_of_session(e),Te=()=>{ke.batchMode&&(ke.setSelectedMsgIds(new Set),Z(new Set)),ke.setBatchMode(e=>!e)};(0,n.useEffect)(()=>{(async()=>{const e=await c.XO.get("ai_agent_setting/env");e.code===d.m.Success&&(pe.current=e.data,Re(e.data)),await $e(),await Ce.init_active_session();const s=await c.jV.get("system_prompts");s.code===d.m.Success&&te(s.data??[])})(),requestAnimationFrame(()=>ke.scrollToBottom(!1)),he.current.onCountChange=ue,he.current.refresh?.();const e=e=>{const s=e?.context?.count;"number"==typeof s&&ue(s)};return p.ws.addMsg(f.HK.ai_bg_process_count_notify,e),()=>{p.ws.off_message(`message_${f.HK.ai_bg_process_count_notify}`,e)}},[]);const Ve=U===Ce.activeSessionId||Ce.activeSessionRunning;return(0,B.jsxs)(n.Fragment,{children:[(0,B.jsx)(X,{inline:s,currentModelName:ie,setCurrentModelName:ae,modelGroups:oe,onModelChanged:async()=>{await $e();const e=await c.XO.get("ai_agent_setting/env");e.code===d.m.Success&&(pe.current=e.data,Re(e.data))},batchMode:ke.batchMode,selectedMsgCount:ke.selectedMsgIds.size,sessionVisible:!P,onToggleSessionPanel:()=>K(e=>!e),onCreateSession:Ce.createSession,onBatchDeleteMessages:ke.batchDeleteMessages,onToggleBatchMode:Te,bgProcessVisible:F,bgProcessCount:de,onToggleBgProcess:()=>z(e=>!e)}),(0,B.jsxs)("div",{className:"chat-page"+(s?" chat-page--embedded":" chat-page-with-sessions"),style:{"--ai-chat-zoom":G},children:[!P&&(0,B.jsx)("div",{className:"chat-session-overlay",onClick:()=>K(!0)}),!P&&(0,B.jsx)(se,{sessions:Ce.sessions,activeSessionId:Ce.activeSessionId,onSelectSession:e=>Ce.loadSession(e,!1),onReorderSessions:Ce.reorderSessions,onRenameSession:Ce.renameSession,onDeleteSession:Ce.deleteSession,onToggleCmdAuto:Ce.toggleCmdAuto,onShowUsageStats:async e=>{q({open:!0,title:y("Token消耗统计"),context_div:(0,B.jsx)("div",{className:"usage-stats-loading",children:y("加载中...")}),cancel:()=>q({open:!1})});try{const s=De(e),t=s?await Ce.admin_call("usage_stats",{session_id:e,user_id:s}):await c.jV.post("session/usage_stats",{session_id:e});if(t.code===d.m.Success&&t.data){const e=t.data;q({open:!0,title:y("Token消耗统计"),context_div:(0,B.jsxs)("div",{className:"usage-stats-panel",children:[[{l:y("对话轮次"),v:(e.turns??0).toString()},{l:y("AI输入Token"),v:h(e.input_tokens)},{l:y("AI输出Token"),v:h(e.output_tokens)},{l:y("AI输入Token(最近一轮)"),v:h(e.recent_input_tokens)},{l:y("AI输出Token(最近一轮)"),v:h(e.recent_output_tokens)}].map((e,s)=>(0,B.jsxs)("div",{className:"usage-stats-row",children:[(0,B.jsx)("span",{className:"usage-stats-label",children:e.l}),(0,B.jsx)("span",{className:"usage-stats-value",children:e.v})]},s)),(0,B.jsxs)("div",{className:"usage-stats-row usage-stats-total",children:[(0,B.jsx)("span",{className:"usage-stats-label",children:y("AI Token总计消耗")}),(0,B.jsx)("span",{className:"usage-stats-value",children:h((e.input_tokens||0)+(e.output_tokens||0))})]})]}),cancel:()=>q({open:!1})})}else q({open:!0,title:y("Token消耗统计"),context_div:(0,B.jsx)("div",{className:"usage-stats-empty",children:y("暂无统计数据")}),cancel:()=>q({open:!1})})}catch{q({open:!0,title:y("Token消耗统计"),context_div:(0,B.jsx)("div",{className:"usage-stats-empty",children:y("暂无统计数据")}),cancel:()=>q({open:!1})})}},onShowSessionSetting:e=>{let s=Ce.sessions.find(s=>s.id===e)?.file_cwd_path??"";q({open:!0,title:y("会话设置"),context_div:(0,B.jsxs)("div",{className:"session-setting",children:[(0,B.jsx)("div",{className:"session-setting__label",children:y("服务器工作目录")}),(0,B.jsx)(g.Sm,{value:s,placeholder:y("服务器工作目录提示"),handleInputChange:e=>{s=e}})]}),confirm:async()=>{try{const t=De(e);(t?await Ce.admin_call("setting",{session_id:e,user_id:t,file_cwd_path:s.trim()}):await c.jV.post("session/setting",{session_id:e,file_cwd_path:s.trim()})).code===d.m.Success&&(0,x.SK)(y("保存成功"))}catch{}q({open:!1}),await Ce.loadSessions(Ce.activeSessionId)},cancel:()=>q({open:!1})})},batchMode:ke.batchMode,selectedSessionIds:Y,onToggleSessionSelect:e=>{Z(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onToggleBatchMode:Te,onBatchDeleteSessions:()=>Ce.batchDeleteSessions(Y,()=>{Z(new Set),ke.setBatchMode(!1)}),onClearAllSessions:Ce.admin_all_mode?void 0:Ce.clearAllSessions,allUsersMode:Ce.admin_all_mode,onToggleAllUsersMode:Ce.toggleAllUsersMode,showAllUsersEntry:H,sysPromptList:ee,onChangeSysPrompt:(e,s)=>Ce.changeSystemPrompt(s,e)}),(0,B.jsx)(re,{panelRef:he}),(0,B.jsxs)("section",{className:"chat-main",children:[0===ke.messages?.length&&(0,B.jsx)("div",{className:"chat-header",children:(0,B.jsx)("div",{children:y("ai_ask")})}),(0,B.jsx)(ne,{messages:ke.messages,batchMode:ke.batchMode,selectedMsgIds:ke.selectedMsgIds,sending:Ve,chatContainerRef:ke.chatContainerRef,messagesEndRef:_e,onToggleMsgSelect:ke.toggleMsgSelect,onDelete:ke.handleDelete,onCopy:ke.handleCopy,onCopyAll:ke.handleCopyAll,onToggleBatchMode:Te,onBatchCopy:ke.handleBatchCopy,onBatchDelete:ke.batchDeleteMessages,showBatchBar:ke.batchMode&&ke.selectedMsgIds.size>0&&0===Y.size,t:y}),(0,B.jsx)(ce,{ref:me,onSend:async()=>{if(Ce.admin_all_mode)return;const e=(me.current?.getValue()??"").trim();if(!e&&0===W.length)return;if(U===Ce.activeSessionId){const s=await A(W);Ie.enqueueMessage(e,s),me.current?.clear(),Q([]);const t={id:w(),sender:"user",text:e+(Ie.getQueueLength()>1?" ⏳(排队中...)":""),attachments:s};return void ke.setMessages(e=>[...e,t])}let s=Ce.activeSessionId;if(!s){const t=await c.jV.post("session",{title:(e||W[0]?.name).slice(0,28),sys_prompt_id:void 0,file_cwd_path:_||void 0});if(t.code!==d.m.Success)return;s=t.data.id,Ce.setActiveSessionId(s),b?.(s),await Ce.loadSessions(s)}const t=await A(W),n={id:w(),sender:"user",text:e,attachments:t};me.current?.clear(),Q([]);const i=pe.current?.ai_config?.request_type||"completions";if("completions"!==i){const t={id:ke.messages.length+2,sender:"bot",text:"处理中...",is_loading:!0},a={...n,id:ke.messages.length+1},o=[...ke.messages,a,t];ke.setMessages(o),J(s);return void(await O(i,e,s,async(e,s)=>{t.text=e,t.is_loading=!1,s?.images&&(t.images=s.images),s?.audio&&(t.audio=s.audio),s?.embeddings&&(t.embeddings=s.embeddings),ke.setMessages([...o]),J(null),Ce.refreshSessions(),ke.scrollToBottom(!0),Ie.processPendingQueue()})||(t.text=`请求类型 "${i}" 的专用处理器尚未实现,请使用 completions 类型。`,t.is_loading=!1,ke.setMessages([...o]),J(null),Ie.processPendingQueue()))}Ie.startChatStream(s,n,()=>Ie.processPendingQueue())},readonly:Ce.admin_all_mode,sending:Ve,pausing:Ie.pausing,onAbort:Ie.abort,pendingAttachments:W,onRemoveAttachment:e=>{Q(s=>s.filter((s,t)=>t!==e))},onOpenFilePicker:()=>{ge.current?.click()},onAddFiles:Be,onDrop:e=>{const s=e.dataTransfer?.files;s&&s.length>0&&(e.preventDefault(),Be(s))},onDragOver:e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},fileInputRef:ge})]})]})]})}},72693(e,s,t){t.d(s,{w:()=>g});var n=t(96540),i=t(22022),a=t(14944),o=t(92275),c=t(34843),r=t(82893),l=t(85997),d=t(14284),u=t(74848);function m(e){const{t:s}=(0,i.Bd)(),[t,a]=(0,n.useState)(!1),o=!!e.sessionId;return(0,u.jsxs)("div",{children:[(0,u.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}),o&&(0,u.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"0.5em",marginBottom:"0.75em",color:t?"var(--icon-blue)":"var(--textSecondary)"},children:[(0,u.jsx)(l.Ay,{checked:t,onChange:s=>{a(s),s&&e.onAutoAllow()},title:s("此会话不再询问")}),(0,u.jsx)("span",{children:s("此会话不再询问")})]}),(0,u.jsxs)("div",{style:{display:"flex",gap:"0.5em",justifyContent:"flex-end"},children:[(0,u.jsx)(l.$n,{text:s("拒绝"),color:"var(--red)",clickFun:e.onDeny}),(0,u.jsx)(l.$n,{text:s("允许"),clickFun:e.onAllow})]})]})}function g(){const[e,s]=(0,c.fp)(r.AG.prompt_card),{t}=(0,i.Bd)(),l=(0,n.useRef)([]),g=(0,n.useRef)(!1),_=(0,n.useRef)(null),h=(0,n.useRef)(void 0),p=(0,n.useRef)(()=>{}),f=(0,n.useCallback)(e=>{s({open:!1}),g.current=!1,_.current&&(a.ws.sendData(o.HK.ai_confirm_cmd,{askId:_.current,approved:e}),_.current=null),p.current()},[s]),x=(0,n.useCallback)(()=>{if(g.current)return;if(0===l.current.length)return g.current=!1,void s({open:!1});g.current=!0;const e=l.current.shift();e?(_.current=e.askId,h.current=e.session_id,s({open:!0,title:t("命令确认"),cancel:()=>f(!1),context_div:(0,u.jsx)(m,{cmd:e.cmd,sessionId:e.session_id,onDeny:()=>f(!1),onAllow:()=>f(!0),onAutoAllow:async()=>{if(h.current)try{await d.jV.post("session/cmd_auto_allow",{session_id:h.current,allow:!0})}catch(e){console.error("设置会话命令免确认失败",e)}f(!0)}})})):g.current=!1},[t,f,s]);p.current=x;const j=(0,n.useCallback)(e=>{l.current.push(e),x()},[x]);(0,n.useEffect)(()=>{const e=e=>{const t=e.context||{};if(t.dismiss&&t.askId)return l.current=l.current.filter(e=>e.askId!==t.askId),void(g.current&&_.current===t.askId&&(_.current=null,g.current=!1,s({open:!1}),x()));t.askId&&t.cmd&&j({askId:t.askId,cmd:t.cmd,session_id:t.session_id})};return a.ws.addMsg(o.HK.ai_confirm_cmd,e),()=>{a.ws.off_message(`message_${o.HK.ai_confirm_cmd}`,e)}},[j]),(0,n.useEffect)(()=>()=>{l.current=[],g.current=!1,_.current=null},[])}},84369(e,s,t){t.d(s,{y:()=>o});var n=t(96540),i=t(2543);function a(e){if(void 0!==e)return"function"==typeof e?e():e}function o(e){const{direction:s="vertical",target_ref:t,get_start_size:o,px_to_unit:c,min:r,max:l,throttle:d,on_change:u,on_drag_end:m}=e,[g,_]=(0,n.useState)(!1),h=(0,n.useRef)(null),p=(0,n.useRef)(u);p.current=u;const f=e=>"vertical"===s?e.clientY:e.clientX,x=(0,n.useRef)({direction:s,get_start_size:o,px_to_unit:c,min:r,max:l,get_pos:f});x.current={direction:s,get_start_size:o,px_to_unit:c,min:r,max:l,get_pos:f};const j=(0,n.useCallback)(e=>{const s=h.current;if(!s)return;const{px_to_unit:t,min:n,max:i,get_pos:o}=x.current,c=s.pos-o(e);let r=s.size+t(c);const l=a(n),d=a(i);void 0!==l&&(r=Math.max(l,r)),void 0!==d&&(r=Math.min(d,r)),p.current(r)},[]),v=n.useMemo(()=>void 0===d?j:i.throttle(e=>j(e),d),[d,j]),b=(0,n.useCallback)(()=>{h.current=null,_(!1);const e=v;"function"==typeof e.cancel&&e.cancel(),m?.()},[v,m]),w=(0,n.useCallback)(e=>{const{get_start_size:s,get_pos:t}=x.current;h.current={pos:t(e),size:s()},_(!0)},[]);return(0,n.useEffect)(()=>{if(!g)return;const e=t?.current??window;return e.addEventListener("pointermove",v),e.addEventListener("pointerup",b),()=>{e.removeEventListener("pointermove",v),e.removeEventListener("pointerup",b)}},[g,v,b,t]),(0,n.useEffect)(()=>{const e=v;return()=>{"function"==typeof e.cancel&&e.cancel()}},[v]),{dragging:g,on_pointer_down:w,on_pointer_up:b}}}}]);
|
package/build/dist/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><base href="/"><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>{{{web_site_title}}}</title><link rel="icon" href="{{{logo_favicon}}}"/><script defer="defer" src="main.
|
|
1
|
+
<!doctype html><html lang="en"><head><base href="/"><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>{{{web_site_title}}}</title><link rel="icon" href="{{{logo_favicon}}}"/><script defer="defer" src="main.b3a24ee626d321ee67fc.js"></script></head><body><div id="root"></div></body><script id="pre_code" type="text/template">return {{{Windows_FileCat}}};</script><script>window.EXCALIDRAW_ASSET_PATH = "/";window.FileCat;</script></html>
|