filecat 6.43.6 → 6.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dist/{1448.c9f76a52d88a488d6da2.js → 1448.9d36cf216585774aa090.js} +1 -1
- package/build/dist/{1472.1a9c627133a364ceeb61.js → 1472.1d82f53e309eceea3e9a.js} +1 -1
- package/build/dist/{1595.5f5ec6122acae3a9cd0b.js → 1595.2c366cdfe302dc5a5050.js} +1 -1
- package/build/dist/{1636.64b2c5dd5956d512a0fc.js → 1636.723781f88d68ed3657cb.js} +1 -1
- package/build/dist/{1832.a01933ba5df99576ecc2.js → 1832.99a4c37ffea35d9b9cb3.js} +1 -1
- package/build/dist/{2502.754728f7e85723b16fc3.js → 2502.cd914e22b13cdaaf78bc.js} +1 -1
- package/build/dist/{2542.26cb302b60de23166227.js → 2542.58c52e3d0bd7af6d9a62.js} +1 -1
- package/build/dist/2674.c58839496f66c6512ae5.js +1 -0
- package/build/dist/{2851.b4b84820b81113718235.js → 2851.a7ecf5bca38c79677f03.js} +1 -1
- package/build/dist/{3402.5d4caccb2e21dbeb3398.js → 3402.62335cc49fe962eaf134.js} +1 -1
- package/build/dist/{3659.f32a94d104cc1353e384.js → 3659.55a733505528331021e0.js} +1 -1
- package/build/dist/{4273.2f3c957012fa1d0c4747.js → 4273.19b11dd57545851ebc50.js} +1 -1
- package/build/dist/{4903.69328b798fc5c52d6069.js → 4903.f8714937dbb91b37c119.js} +1 -1
- package/build/dist/{5516.f442aef7efd919af92cd.js → 5516.e3b6d2b2c1439d8e4cf6.js} +1 -1
- package/build/dist/{5761.0afce3c97ce69979e9ee.js → 5761.2631a6de5c30fbfb66da.js} +1 -1
- package/build/dist/{5937.820d7e5fcf608c346964.js → 5937.9e77a5b78996adbdbe1b.js} +1 -1
- package/build/dist/{6247.cbbbe80520d738798cca.js → 6247.077a555b26c06aa2e96b.js} +1 -1
- package/build/dist/6505.bacc9c5cdd2094604a00.js +1 -0
- package/build/dist/678.f0aed27a613d4dd41080.js +1 -0
- package/build/dist/{6892.fac5b622852f0aad613d.js → 6892.4db4a81a58e94e4356cc.js} +1 -1
- package/build/dist/{7133.cf2a4a51286b78a653af.js → 7133.ae2c0ab24c0d2a3a5a1c.js} +1 -1
- package/build/dist/{7180.e79b454cc9ea523bfebc.js → 7180.32c831dec9865cde8006.js} +1 -1
- package/build/dist/{7181.9f22415130200367cfda.js → 7181.4a60db9c9a2603feeff8.js} +1 -1
- package/build/dist/{7209.de0fc874821ef1cb0684.js → 7209.f4ad503eb484aa601281.js} +1 -1
- package/build/dist/{7759.8041fbbd5fcb8366c098.js → 7759.b58c5676b606e60d7aac.js} +1 -1
- package/build/dist/8090.90cb45de35e21b9cfcb0.js +2 -0
- package/build/dist/{8603.8b4a272c8bbe4d5fd4c4.js → 8603.557bbe67c1b08a3627d6.js} +1 -1
- package/build/dist/{8714.a9a6d15b8cc47c1ae191.js → 8714.3360add5f45201f4c8da.js} +1 -1
- package/build/dist/{8765.32baeac654f4d839c1d0.js → 8765.35d24edc172c477ba795.js} +1 -1
- package/build/dist/8947.f2b4fad4c25fb147ea42.js +2 -0
- package/build/dist/index.html +1 -1
- package/build/dist/{main.427adb2d4ce72b3d6bc1.js → main.151df5e8840564caf370.js} +2 -2
- package/build/main.js +1 -1
- package/build/main.js.LICENSE.txt +1 -1
- package/build/threads.work.filecat.js +1 -1
- package/package.json +2 -2
- package/shell/config/base.webpack.config.js +1 -1
- package/shell/config/webpack.npm.config.js +2 -1
- package/build/dist/2674.570467c7d8e3378316cc.js +0 -1
- package/build/dist/6505.f730960378f6e4b7bc24.js +0 -1
- package/build/dist/678.3cd977536dffed60a0e4.js +0 -1
- package/build/dist/8090.c4e60cb0780036d49258.js +0 -2
- package/build/dist/9572.304acc81bcceeb2ade2a.js +0 -2
- /package/build/dist/{8090.c4e60cb0780036d49258.js.LICENSE.txt → 8090.90cb45de35e21b9cfcb0.js.LICENSE.txt} +0 -0
- /package/build/dist/{9572.304acc81bcceeb2ade2a.js.LICENSE.txt → 8947.f2b4fad4c25fb147ea42.js.LICENSE.txt} +0 -0
- /package/build/dist/{main.427adb2d4ce72b3d6bc1.js.LICENSE.txt → main.151df5e8840564caf370.js.LICENSE.txt} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "filecat",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.45.0",
|
|
4
4
|
"description": "FileCat File Browser Server Manager",
|
|
5
5
|
"author": "xiaobaidadada",
|
|
6
6
|
"repository": {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"ace-builds": "^1.32.9",
|
|
64
64
|
"archiver": "^7.0.1",
|
|
65
65
|
"awesomplete": "^1.1.7",
|
|
66
|
-
"axios": "1.
|
|
66
|
+
"axios": "1.18.1",
|
|
67
67
|
"babel-loader": "^10.1.1",
|
|
68
68
|
"chart.js": "^4.4.2",
|
|
69
69
|
"chokidar": "^4.0.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[2674],{92674(e,t,n){n.r(t),n.d(t,{default:()=>j});var a=n(96540),o=n(82893),i=n(34843),s=n(85997),l=n(57952),r=n(47022),c=n(34251),d=n(74848);function p(e){{const[t,n]=(0,a.useState)(!1),[o,i]=(0,a.useState)([]),l=e=>{i(e)},h=async()=>{"folder"===e.type?(t||!e.click||o||await e.click(e,l,e.pre_path),n(!t)):e.click&&await e.click(e,l,e.pre_path)},m=async(t=!1)=>{"folder"!==e.type||t?e.fatherNowToggleExpansion&&e.fatherNowToggleExpansion():await e.click(e,l,e.pre_path)};return(0,a.useEffect)(()=>{i(e.children)},[e.children]),(0,d.jsxs)("div",{className:"studio-item",children:[(0,d.jsxs)("div",{onClick:h,onContextMenu:t=>{t.stopPropagation(),t.nativeEvent.stopImmediatePropagation(),e.handleContextMenu&&e.handleContextMenu(t,e.name,e.pre_path,e.type===r.Iw.folder,m)},className:"studio-item-title",children:[(0,d.jsx)("i",{className:"material-icons studio-item-title-tag","data-icon":t?"arrow_drop_down":"arrow_right",children:"file"==e.type?"":t?"arrow_drop_down":"arrow_right"}),(0,d.jsx)("span",{className:"file-icons",children:(0,d.jsx)("span",{"data-type":(0,c.uL)(e.name),"data-dir":"folder"===e.type,"aria-label":e.name,children:(0,d.jsx)(s.In,{icon:"",aria_label:e.name})})}),(0,d.jsx)("span",{className:"studio-item-name",children:e.name})]}),t&&o&&(0,d.jsx)("div",{style:{marginLeft:20},children:o.map((t,n)=>(0,d.jsx)(a.Fragment,{children:(0,d.jsx)(p,{type:t.type,size:t.size,click:e.click,name:t.name,children:t.children,pre_path:`${e.pre_path}${t.name}${t.type===r.Iw.folder?"/":""}`,handleContextMenu:e.handleContextMenu,fatherNowToggleExpansion:m},n)},n))})]})}}n(61443);function h(e){return(0,d.jsx)("div",{children:e.list.map((t,n)=>(0,d.jsx)(p,{pre_path:`${e.pre_path}${t.name}${t.type===r.Iw.folder?"/":""}`,name:t.name,type:t.type,handleContextMenu:e.handleContextMenu,fatherNowToggleExpansion:e.fatherNowToggleExpansion,children:t.children,click:e.click,size:t.size},n))})}var m=n(14284),u=n(34289),f=n(53459),x=n(78247),w=(n(62042),n(2543)),y=n(27690),v=n(22022),_=n(88815),k=n(61973);const g=a.lazy(()=>Promise.all([n.e(9988),n.e(4091)]).then(n.bind(n,84091)));function j(e){const[t,n]=(0,a.useState)([]),[p,j]=(0,a.useState)(""),[C,E]=(0,a.useState)(""),[N,S]=(0,a.useState)(!1),[M,P]=(0,a.useState)({path:"",name:""}),[$,b]=(0,a.useState)(""),[G,I]=(0,i.fp)(o.AG.confirm),[z,A]=(0,a.useState)(!1),[F,D]=(0,i.fp)(o.AG.fileShellShow),[L,R]=(0,i.fp)(o.AG.file_shell_hidden),T=(0,a.useRef)(null),K=(0,a.useRef)(null),[U,B]=(0,a.useState)(!1),[W,X]=(0,a.useState)(16),[Y,Z]=(0,i.fp)(o.AG.showPrompt),{t:q}=(0,v.Bd)(),H=(0,k.Zp)();let J=(0,k.zy)().pathname.split("/").filter(Boolean).pop();J=decodeURIComponent(J);const O=async()=>{const e=(0,u.GG)("file",J);j(e);const t=await m.$M.post("studio/get/item",{path:e});if(t.code===f.m.Success){const e=[],a=[];for(const n of t.data.list)"folder"===n.type?e.push(n):"file"===n.type&&a.push(n);n([...e,...a])}};(0,a.useEffect)(()=>{E(""),P({}),A(!1),O()},[]);const Q=async(e,t)=>{const n=await m.$M.get(`${encodeURIComponent(t)}`);E(n.data),x.xK.set_value_temp(n.data),P({path:t,name:e}),b(t)},V=(e,t)=>{e.size>_.o5?I({open:!0,handle:()=>{Q(e.name,t),I({open:!1,handle:null}),A(!1)},title:"超过20MB了还要打开吗?"}):Q(e.name,t)};async function ee(){if(!z)return;const e={context:x.xK.get_editor_value()};0===(await m.$M.post(`save/${encodeURIComponent($)}`,e)).code&&A(!1)}const te=e=>{e.ctrlKey&&"s"===e.key&&(e.preventDefault(),z&&ee())};(0,a.useEffect)(()=>(document.addEventListener("keydown",te),()=>{document.removeEventListener("keydown",te)}),[z]);const ne=(0,a.useCallback)(w.throttle(e=>{const t=parseFloat(getComputedStyle(K.current).fontSize),n=window.innerWidth/t-4,a=e.clientX/t,o=2.25+T.current.offsetWidth/t;a<=n&&a>=o&&X(parseFloat(a.toFixed(2)))},32),[]),ae=()=>{B(!1),K.current.removeEventListener("pointermove",ne)},oe=[{r:q("创建文件"),v:"创建文件"},{r:q("创建目录"),v:"创建目录"},{r:q("重命名"),v:"重命名"},{r:q("删除"),v:"删除"}],ie=[{r:q("重命名"),v:"重命名"},{r:q("删除"),v:"删除"}],se=(e,t,n,a,o)=>{e.preventDefault();const i=new c.ik;i.path=n,i.filename=t,i.x=e.clientX,i.y=e.clientY,i.items=a?oe:ie,o===O&&(i.items=i.items.slice(0,2)),i.type=a?r.Iw.studio_folder:r.Iw.studio_file;const s=e=>{o(e)};i.textClick=e=>{switch(e){case"创建文件":Z({show:!0,type:y.PromptEnum.FileNew,overlay:!0,data:{dir:n,call:s}});break;case"创建目录":Z({show:!0,type:y.PromptEnum.DirNew,overlay:!0,data:{dir:n,call:s}});break;case"删除":if(z&&(M.path===n||M.path.includes(n))){const e=()=>{s(a),A(!1),P({}),E(""),x.xK.set_value_temp("")};Z({show:!0,type:y.PromptEnum.FilesDelete,overlay:!0,data:{path:n,call:e,filename:t}});break}Z({show:!0,type:y.PromptEnum.FilesDelete,overlay:!0,data:{path:n,filename:t,call:a?()=>{s(!0)}:s}});break;case"重命名":Z({show:!0,type:y.PromptEnum.FileRename,overlay:!0,data:{path:n,dir:(0,u.Yp)(n),call:()=>{s(!0)},filename:t}})}},Z({show:!0,type:y.PromptEnum.FileMenu,overlay:!1,data:i})};return(0,d.jsxs)("div",{className:"studio",children:[(0,d.jsxs)(l.A,{ignore_tags:!0,left_children:[(0,d.jsx)(s.rA,{title:"取消",icon:"close",onClick:()=>{D({show:!1,path:""}),R(void 0),H(-1)}},1),(0,d.jsx)("title",{children:M.name},2)],children:[(0,c.zr)(M.name)&&(0,d.jsx)(s.rA,{title:"格式化",icon:"data_object",onClick:function(){x.xK.get_editor()?.formatCode()}}),(0,d.jsx)(s.rA,{icon:"terminal",title:"shell",onClick:function(){void 0===L?F.show?D({show:!1,path:""}):(D({show:!0,path:(0,u.GG)("file",J)}),R(!1)):R(!L)}}),z&&(0,d.jsx)(s.rA,{title:"保存",icon:"save",onClick:ee})]}),(0,d.jsxs)("div",{className:"studio-body",ref:K,children:[(0,d.jsx)("div",{className:"studio-nav",style:{width:W-1+"em"},onContextMenu:e=>{se(e,M.name,(0,u.GG)("file",J),!0,O)},children:(0,d.jsx)(h,{pre_path:p,list:t,click:async(e,t,n)=>{if("folder"===e.type){const e=await m.$M.post("studio/get/item",{path:`${n}`});if(e.code===f.m.Success){const n=[],a=[];for(const t of e.data.list)"folder"===t.type?n.push(t):"file"===t.type&&a.push(t);t([...n,...a])}}else{if(z)return void I({open:!0,handle:()=>{I({open:!1,handle:null}),A(!1),V(e,n)},title:"确定不保存就切换吗?"});V(e,n)}},handleContextMenu:se,fatherNowToggleExpansion:O})}),(0,d.jsx)("div",{className:"studio__divider",ref:T,onPointerDown:()=>{B(!0),K.current.addEventListener("pointermove",ne)},onPointerUp:ae}),U&&(0,d.jsx)("div",{className:"shell__overlay",onPointerUp:ae}),(0,d.jsx)("div",{className:"studio-editor",children:M.name&&(0,d.jsx)(g,{name:M.name,on_change:()=>{z||A(!0)}})},M.path)]})]})}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[6505],{26505(e,t,s){s.r(t),s.d(t,{default:()=>k});var a=s(96540),r=(s(82893),s(14284)),n=s(62042),o=s(22022),i=s(85997),l=s(57952),d=s(61973),c=s(34289),p=s(87361),h=s(2543),x=s(74848);const u="var(--surfacePrimary, #ffffff)",f="var(--surfaceSecondary, #f1f3f4)",g="var(--divider, rgba(0,0,0,0.08))",y="var(--textPrimary, #202124)",b="var(--textSecondary, #5f6368)",m="var(--primary, #1a73e8)",j="var(--primary-light, #d2e3fc)",v="var(--secondary, #34a853)",S="var(--accent, #ea4335)",z="#f9ab00";function k(){const{t:e}=(0,o.Bd)(),t=(0,d.Zp)();let s=decodeURIComponent((0,c.GG)(p.o.git_page,(0,c.vX)()));s=s.replace(/\/+$/,"");const[k,C]=(0,a.useState)([]),[N,U]=(0,a.useState)([]),[$,R]=(0,a.useState)({current:"",branches:[]}),[T,W]=(0,a.useState)(""),[B,K]=(0,a.useState)(new Set),[_,P]=(0,a.useState)("status"),[A,D]=(0,a.useState)(!1),[I,F]=(0,a.useState)(16),[L,E]=(0,a.useState)(!1),G=(0,a.useRef)(null),X=(0,a.useRef)(null);(0,a.useEffect)(()=>{s&&(H(),M(),Z())},[s]);const H=async()=>{try{D(!0);const e=await r.TU.post("status",{path:s});0===e.code&&C(e.data||[])}catch(e){}finally{D(!1)}},M=async()=>{try{const e=await r.TU.post("log",{path:s,maxCount:50});0===e.code&&U(e.data||[])}catch(e){}},Z=async()=>{try{const e=await r.TU.post("branches",{path:s});0===e.code&&R(e.data||{current:"",branches:[]})}catch(e){}},q=()=>{B.size===k.length?K(new Set):K(new Set(k.map(e=>e.path)))},J=async(t=!1)=>{try{D(!0);const a=await r.TU.post("push",{path:s,force:t});0===a.code?(0,n.SK)(e("推送成功")):(0,n.zN)(a.message)}catch(e){(0,n.zN)(e?.message)}finally{D(!1)}},O=e=>{switch(e){case"modified":return z;case"added":return v;case"deleted":case"conflict":return S;case"untracked":default:return b;case"renamed":return m}},Q=e=>{switch(e){case"modified":return"M";case"added":return"A";case"deleted":return"D";case"untracked":return"?";case"renamed":return"R";case"conflict":return"!";default:return e}},V=(0,a.useCallback)(h.throttle(e=>{const t=parseFloat(getComputedStyle(X.current).fontSize),s=window.innerWidth/t-4,a=e.clientX/t,r=2.25+G.current.offsetWidth/t;a<=s&&a>=r&&F(parseFloat(a.toFixed(2)))},32),[]),Y=()=>{E(!1),X.current.removeEventListener("pointermove",V)},ee=s.split("/").filter(Boolean).pop()||s;return(0,x.jsxs)("div",{className:"studio",children:[(0,x.jsx)(l.A,{ignore_tags:!0,left_children:[(0,x.jsx)(i.rA,{title:e("取消"),icon:"close",onClick:()=>{t(-1)}},1),(0,x.jsx)("span",{children:decodeURIComponent(ee)})],children:(0,x.jsx)(i.rA,{icon:"refresh",title:e("刷新"),onClick:()=>{H(),M(),Z()}})}),(0,x.jsxs)("div",{className:"studio-body",ref:X,children:[(0,x.jsxs)("div",{className:"studio-nav",style:{width:I-1+"em"},children:[(0,x.jsxs)("div",{style:{display:"flex",borderBottom:`1px solid ${g}`},children:[(0,x.jsxs)("button",{onClick:()=>P("status"),style:{flex:1,padding:"10px 8px",border:"none",background:"status"===_?j:"transparent",color:"status"===_?m:b,cursor:"pointer",fontSize:13,fontWeight:"status"===_?600:400,borderBottom:"status"===_?`2px solid ${m}`:"2px solid transparent"},children:["📝 ",e("变更")," (",k.length,")"]}),(0,x.jsxs)("button",{onClick:()=>P("log"),style:{flex:1,padding:"10px 8px",border:"none",background:"log"===_?j:"transparent",color:"log"===_?m:b,cursor:"pointer",fontSize:13,fontWeight:"log"===_?600:400,borderBottom:"log"===_?`2px solid ${m}`:"2px solid transparent"},children:["📜 ",e("提交记录")," (",N.length,")"]})]}),"status"===_&&(0,x.jsxs)("div",{style:{flex:1,overflow:"auto"},children:[k.length>0&&(0,x.jsxs)("div",{style:{padding:"6px 12px",borderBottom:`1px solid ${g}`,display:"flex",alignItems:"center",gap:8,fontSize:12,color:b,cursor:"pointer"},onClick:q,children:[(0,x.jsx)("input",{type:"checkbox",checked:B.size===k.length&&k.length>0,onChange:q,style:{cursor:"pointer"}}),(0,x.jsxs)("span",{children:[e("全选")," (",B.size,"/",k.length,")"]})]}),k.map(e=>(0,x.jsxs)("div",{onClick:()=>(e=>{const t=new Set(B);t.has(e)?t.delete(e):t.add(e),K(t)})(e.path),style:{padding:"8px 12px",cursor:"pointer",borderBottom:`1px solid ${g}`,display:"flex",alignItems:"center",gap:8,background:B.has(e.path)?j:"transparent",transition:"background 0.2s"},children:[(0,x.jsx)("input",{type:"checkbox",checked:B.has(e.path),onChange:()=>{},style:{cursor:"pointer"}}),(0,x.jsx)("span",{style:{fontSize:11,fontWeight:600,width:20,height:20,borderRadius:4,display:"inline-flex",alignItems:"center",justifyContent:"center",color:"#fff",background:O(e.status),flexShrink:0},children:Q(e.status)}),(0,x.jsxs)("span",{style:{fontSize:13,color:y,wordBreak:"break-all"},children:[e.path,e.oldPath&&(0,x.jsxs)("span",{style:{color:b,fontSize:11},children:[" (← ",e.oldPath,")"]})]})]},e.path)),0===k.length&&(0,x.jsx)("p",{style:{color:b,textAlign:"center",padding:20,fontSize:12},children:e("没有变更")})]}),"log"===_&&(0,x.jsxs)("div",{style:{flex:1,overflow:"auto"},children:[N.map((e,t)=>(0,x.jsxs)("div",{style:{padding:"10px 12px",borderBottom:`1px solid ${g}`,display:"flex",flexDirection:"column",gap:4},children:[(0,x.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(0,x.jsx)("span",{style:{fontSize:11,fontFamily:"monospace",color:m,background:j,padding:"2px 6px",borderRadius:4},children:e.hash}),(0,x.jsx)("span",{style:{fontSize:13,color:y,flex:1},children:e.message})]}),(0,x.jsxs)("div",{style:{fontSize:11,color:b,paddingLeft:4},children:[e.author," · ",e.date]})]},t)),0===N.length&&(0,x.jsx)("p",{style:{color:b,textAlign:"center",padding:20,fontSize:12},children:e("暂无提交记录")})]})]}),(0,x.jsx)("div",{className:"studio__divider",ref:G,onPointerDown:()=>{E(!0),X.current.addEventListener("pointermove",V)},onPointerUp:Y}),L&&(0,x.jsx)("div",{className:"shell__overlay",onPointerUp:Y}),(0,x.jsx)("div",{className:"studio-editor",children:(0,x.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%",padding:"16px",gap:12,overflow:"auto"},children:[(0,x.jsxs)("div",{style:{padding:"12px",borderRadius:8,border:`1px solid ${g}`,background:u},children:[(0,x.jsxs)("div",{style:{fontSize:13,fontWeight:600,color:y,marginBottom:8},children:["🌿 ",e("分支"),": ",(0,x.jsx)("span",{style:{color:v},children:$.current})]}),(0,x.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:$.branches.map(t=>(0,x.jsx)("button",{onClick:()=>(async t=>{try{D(!0);const a=await r.TU.post("checkout",{path:s,branch:t});0===a.code?((0,n.SK)(e("切换分支成功")),H(),M(),Z()):(0,n.zN)(a.message)}catch(e){(0,n.zN)(e?.message)}finally{D(!1)}})(t),disabled:t===$.current||t.startsWith("*"),style:{padding:"4px 10px",borderRadius:12,fontSize:11,border:t===$.current?`1px solid ${v}`:`1px solid ${g}`,background:t===$.current?j:"transparent",color:t===$.current?v:b,cursor:t===$.current?"default":"pointer",opacity:t===$.current?1:.8},children:t.replace("remotes/origin/","")},t))})]}),(0,x.jsxs)("div",{style:{padding:"12px",borderRadius:8,border:`1px solid ${g}`,background:u,display:"flex",flexDirection:"column",gap:8},children:[(0,x.jsx)("textarea",{placeholder:e("输入提交信息..."),value:T,onChange:e=>W(e.target.value),rows:2,style:{width:"100%",padding:"8px 12px",borderRadius:8,border:`1px solid ${g}`,background:u,color:y,fontSize:13,boxSizing:"border-box",resize:"vertical"}}),(0,x.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[(0,x.jsxs)("button",{onClick:async()=>{if(T.trim())try{D(!0);const t=await r.TU.post("commit",{path:s,message:T.trim(),allChanged:!0});0===t.code?((0,n.SK)(e("提交成功")),W(""),H(),M()):(0,n.zN)(t.message)}catch(e){(0,n.zN)(e?.message)}finally{D(!1)}else(0,n.zN)(e("请输入提交信息"))},disabled:A||!T.trim(),style:w(v),children:["✅ ",e("提交")]}),(0,x.jsxs)("button",{onClick:async()=>{try{const t=await r.TU.post("add_all",{path:s});0===t.code?((0,n.SK)(e("已暂存全部")),H()):(0,n.zN)(t.message)}catch(e){(0,n.zN)(e?.message)}},style:w(m),children:["➕ ",e("暂存全部")]}),(0,x.jsxs)("button",{onClick:async()=>{if(0!==B.size)try{const t=await r.TU.post("add",{path:s,files:[...B]});0===t.code?((0,n.SK)(e("已暂存")),K(new Set),H()):(0,n.zN)(t.message)}catch(e){(0,n.zN)(e?.message)}else(0,n.zN)(e("请先选择文件"))},style:w(m),children:["📥 ",e("暂存选中")]}),(0,x.jsxs)("button",{onClick:async()=>{if(0!==B.size)try{const t=await r.TU.post("reset",{path:s,files:[...B]});0===t.code?((0,n.SK)(e("已取消暂存")),K(new Set),H()):(0,n.zN)(t.message)}catch(e){(0,n.zN)(e?.message)}else(0,n.zN)(e("请先选择文件"))},style:w(z),children:["↩ ",e("取消暂存")]})]})]}),(0,x.jsxs)("div",{style:{padding:"12px",borderRadius:8,border:`1px solid ${g}`,background:u,display:"flex",flexDirection:"column",gap:8},children:[(0,x.jsxs)("div",{style:{fontSize:13,fontWeight:600,color:y},children:["☁️ ",e("远程操作")]}),(0,x.jsxs)("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[(0,x.jsxs)("button",{onClick:async()=>{try{D(!0);const t=await r.TU.post("pull",{path:s});0===t.code?((0,n.SK)(e("拉取成功")),H(),M()):(0,n.zN)(t.message)}catch(e){(0,n.zN)(e?.message)}finally{D(!1)}},disabled:A,style:w(m),children:["⬇ ",e("拉取")]}),(0,x.jsxs)("button",{onClick:()=>J(!1),disabled:A,style:w(m),children:["⬆ ",e("推送")]}),(0,x.jsxs)("button",{onClick:()=>J(!0),disabled:A,style:w(S),children:["⚠ ",e("强制推送")]})]}),(0,x.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,x.jsxs)("button",{onClick:async()=>{try{const t=await r.TU.post("stash",{path:s});0===t.code?((0,n.SK)(e("暂存工作区成功")),H()):(0,n.zN)(t.message)}catch(e){(0,n.zN)(e?.message)}},style:w(b),children:["📦 ",e("暂存工作区")]}),(0,x.jsxs)("button",{onClick:async()=>{try{const t=await r.TU.post("stash_pop",{path:s});0===t.code?((0,n.SK)(e("恢复工作区成功")),H()):(0,n.zN)(t.message)}catch(e){(0,n.zN)(e?.message)}},style:w(b),children:["📤 ",e("恢复工作区")]})]})]}),(0,x.jsxs)("div",{style:{padding:"12px",borderRadius:8,border:`1px solid ${g}`,background:f,fontSize:11,color:b,lineHeight:1.6},children:["💡 ",e("提示:"),(0,x.jsxs)("ul",{style:{margin:"4px 0",paddingLeft:16},children:[(0,x.jsx)("li",{children:e("左侧勾选文件后,使用「暂存选中」将其加入暂存区")}),(0,x.jsx)("li",{children:e("输入提交信息后点击「提交」")}),(0,x.jsx)("li",{children:e("如有冲突,请自行在shell中解决冲突后再提交")}),(0,x.jsx)("li",{children:e("「强制推送」会覆盖远程分支,请谨慎使用")})]})]})]})})]})]})}function w(e){return{padding:"6px 12px",borderRadius:6,border:`1px solid ${e}`,background:"transparent",color:e,cursor:"pointer",fontSize:12}}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[678,6010],{83277(e,t,s){s.d(t,{$j:()=>o,Lv:()=>a,qq:()=>i});class n{options_agent_url_list;options_agent_key_list;options_agent_model_list;options_local_file_path_prompt_list}class a{token;open=!1;note;index;url;model;request_type;json_params;sys_prompt;dotenv="";tool_mode=!1;show_options;static get_label_by_v(e,t){if(!e||!t?.length)return e;for(const s of t)if(s.value===e)return s.label;return e}static have_label_by_v(e,t){if(!e||!t?.length)return!1;for(const s of t)if(s.value===e)return!0;return!1}}class i extends n{tool_error_max=50;tool_call_max=300;allow_exec_cmd_directly=!1;proxy_url;open_pick_model;max_recent_messages=12;compress_message_count=16;max_tool_content_chars=200}const c=JSON.stringify({stream:!0,thinking:{type:"disabled"}});function o(e){return"string"==typeof e?e:Array.isArray(e)?e.map(e=>"text"===e.type?e.text:"[图片]").join("\n"):""}s.d(t,["CP",0,'\n\n# 工具报错最大尝试次数\ntool_error_max=50\n# 聊天循环最大次数\ntool_call_max=300\n# 是否允许AI直接执行命令而不需要用户确认,默认为false,需要用户手动确认,如果使用 workflow 这里等价于为 true\nallow_exec_cmd_directly=false\n\n# 可选的代理 url,如果指定了所有访问大模型的请求将会走代理\n#proxy_url=\n\n# 可选的多个url 以数组分割\n# options_agent_url_list=[{"value":"http://..","label":"openai"}]\n\n# 可选的多个 key\n# options_agent_key_list=[{"value":"sh-aaa","label":"option1"}]\n\n# 可选的多个 model\n# options_agent_model_list=[{"value":"gpt-5.5","label":"gpt"}]\n\n# 存放本地的 prompt 文件 用于每次聊天的时候自动读取并加载\n# options_local_file_path_prompt_list=["/prompt/a.txt"]\n\n# 开启切换模型 ,开启以后,你可以自己写 prompt 提供多个模型让 ai 自己根据每次聊天切换下一步调用其他模型的次数\n# open_pick_model=false\n\n# 压缩后仍然完整保留的最近消息数\nmax_recent_messages=12\n# 当单个会话累计消息条数超过该值时,触发历史消息裁剪\ncompress_message_count=16\n# 历史消息中 tool 输出的最大字符数,只保留调用形式让 AI 知道调用了就行\nmax_tool_content_chars=200\n',"cL",0,c])},93583(e,t,s){s.r(t),s.d(t,{default:()=>Y});var n=s(96540),a=s(34843),i=s(22022),c=s(61973),o=s(92275),l=s(14284),r=s(7463),d=s(78247),u=s(40505),m=s(62042),h=s(45907),g=s(53459),p=s(72693),x=s(82893),_=s(61443),f=s(83277);function j(e){return null==e||e<0?"0":e.toLocaleString()}function v(e){const t=(0,f.$j)(e.content);if(t)return t;const s=e.content_list??[];return s.length?s.map(e=>(0,f.$j)(e.content)).filter(Boolean).join("\n\n"):""}const b=/\.(md|txt|json|js|jsx|ts|tsx|css|html?|xml|ya?ml|py|java|go|rs|c|cpp|h|hpp|sh|bat|cmd|ini|toml|csv|log|sql|env|gitignore|dockerfile)$/i;function y(e){return e.type?.startsWith("image/")?"image":e.type?.startsWith("text/")||b.test(e.name)?"text":"binary"}function S(e){return e.text()}function w(e){return new Promise((t,s)=>{const n=new FileReader;n.onload=()=>t(n.result),n.onerror=s,n.readAsDataURL(e)})}async function N(e){const t=[];for(const s of e){const e=y(s);let n="";if("text"===e)try{const e=await S(s),t=12e4;n=e.length>t?`${e.slice(0,t)}\n\n[内容已截断,原始长度 ${e.length} 字符]`:e}catch{n="[文本读取失败]"}else if("image"===e)try{n=await w(s)}catch{n=`[图片文件: ${s.name}]`}else n=`[二进制文件: ${s.name}]`;t.push({name:s.name,mime_type:s.type,size:s.size,kind:e,content:n})}return t}var k=s(14944);var C=s(52035),A=s(85997),I=s(34299),$=s(74848);function M(e){const t=e.attachments&&e.attachments.length>0?(0,$.jsx)("div",{className:"chat-message-attachments",children:e.attachments.map((e,t)=>(0,$.jsxs)("div",{className:"chat-message-attachment",children:[(0,$.jsx)(A.In,{icon:"attach_file"}),(0,$.jsx)("span",{children:e.name}),(0,$.jsxs)("small",{children:[e.size," B"]})]},`${e.name}_${t}`))}):null,s=[];e.images&&"bot"===e.sender&&s.push((0,$.jsx)(n.Fragment,{children:(0,$.jsx)(D,{images:e.images,text:e.text})},"images")),e.audio&&"bot"===e.sender&&s.push((0,$.jsx)(n.Fragment,{children:(0,$.jsx)(R,{audio:e.audio,text:e.text})},"audio")),e.embeddings&&"bot"===e.sender&&s.push((0,$.jsx)(n.Fragment,{children:(0,$.jsx)(P,{embeddings:e.embeddings,text:e.text})},"embeddings"));const a=function(e){if("bot"!==e.sender||!e.content_list?.length)return e.text?(0,$.jsx)(I.default,{context:e.text}):null;return(0,$.jsxs)($.Fragment,{children:[e.content_list.map((e,t)=>{const s=[],a=(0,f.$j)(e.content);return a&&s.push((0,$.jsx)(n.Fragment,{children:(0,$.jsx)(I.default,{context:a})},`content-${t}`)),e.tool_call_ends?.length&&s.push((0,$.jsx)(n.Fragment,{children:(0,$.jsx)(T,{callList:e.tool_call_ends})},`tool-${t}`)),(0,$.jsx)(n.Fragment,{children:s},`part-${t}`)}),!e.content_list.some(e=>e.content)&&e.text?(0,$.jsx)(I.default,{context:e.text}):null]})}(e);return 0===s.length?(0,$.jsxs)($.Fragment,{children:[t,a]}):(0,$.jsxs)($.Fragment,{children:[s,t,a]})}function T({callList:e}){const[t,s]=n.useState(!1);if(!e?.length)return null;e.filter(e=>e.success).length;const a=e.filter(e=>!e.success).length;return(0,$.jsxs)("div",{className:"chat-message-call-list",children:[(0,$.jsxs)("div",{className:"call-list-header",onClick:()=>s(!t),children:[(0,$.jsx)(A.In,{icon:t?"expand_less":"expand_more"}),(0,$.jsxs)("span",{className:"call-list-summary",children:["工具调用 (",e.length,")",a>0&&(0,$.jsx)("span",{className:"call-list-fail",children:" 失败 "})]})]}),t&&(0,$.jsx)("div",{className:"call-list-body",children:e.map((e,t)=>(0,$.jsxs)("div",{className:"call-list-item "+(e.success?"call-success":"call-fail"),children:[(0,$.jsxs)("div",{className:"call-list-item-header",children:[(0,$.jsx)(A.In,{icon:e.success?"check_circle":"error"}),(0,$.jsx)("span",{className:"call-list-tool-name",children:e.tool_display_name||e.tool_name}),(0,$.jsxs)("span",{className:"call-list-duration",children:[e.duration_ms,"ms"]})]}),e.tool_args&&(0,$.jsxs)("details",{className:"call-list-details",children:[(0,$.jsx)("summary",{children:"参数"}),(0,$.jsx)("pre",{className:"call-list-pre",children:JSON.stringify(e.tool_args,null,2)})]}),!e.success&&e.error&&(0,$.jsxs)("details",{className:"call-list-details",children:[(0,$.jsx)("summary",{children:"错误"}),(0,$.jsx)("pre",{className:"call-list-pre call-list-error-text",children:e.error})]}),e.success&&e.tool_result&&(0,$.jsxs)("details",{className:"call-list-details",children:[(0,$.jsx)("summary",{children:"结果"}),(0,$.jsx)("pre",{className:"call-list-pre",children:e.tool_result.length>500?e.tool_result.slice(0,500)+"...":e.tool_result})]})]},t))})]})}function D({images:e,text:t}){let s=e||[];if(!s.length&&t)try{s=JSON.parse(t).data||[]}catch{}return s.length?(0,$.jsxs)("div",{className:"image-generation-result",children:[s.map((e,t)=>(0,$.jsxs)("div",{className:"image-generation-item",children:[e.url&&(0,$.jsx)("div",{className:"image-generation-image-wrapper",children:(0,$.jsx)("img",{src:e.url,alt:e.revised_prompt||`生成的图片 ${t+1}`,loading:"lazy"})}),e.b64_json&&(0,$.jsx)("div",{className:"image-generation-image-wrapper",children:(0,$.jsx)("img",{src:`data:image/png;base64,${e.b64_json}`,alt:`生成的图片 ${t+1}`})}),e.revised_prompt&&(0,$.jsx)("p",{className:"image-generation-prompt",children:(0,$.jsx)("small",{children:e.revised_prompt})})]},t)),t&&!e&&(0,$.jsx)(I.default,{context:t})]}):(0,$.jsx)(I.default,{context:t||""})}function R({audio:e,text:t}){if(e){if(e.url)return(0,$.jsx)("div",{className:"audio-result",children:(0,$.jsx)("audio",{controls:!0,src:e.url,children:"您的浏览器不支持音频播放"})});if(e.data){const t=e.mime_type||"audio/mpeg";return(0,$.jsx)("div",{className:"audio-result",children:(0,$.jsx)("audio",{controls:!0,src:`data:${t};base64,${e.data}`,children:"您的浏览器不支持音频播放"})})}}const s=t||"";if(s.startsWith("http://")||s.startsWith("https://"))return(0,$.jsx)("div",{className:"audio-result",children:(0,$.jsx)("audio",{controls:!0,src:s,children:"您的浏览器不支持音频播放"})});try{const e=JSON.parse(s);if(e?.data||e?.audio_data){const t=e.data||e.audio_data;return(0,$.jsx)("div",{className:"audio-result",children:(0,$.jsx)("audio",{controls:!0,src:`data:audio/mpeg;base64,${t}`,children:"您的浏览器不支持音频播放"})})}}catch{}return(0,$.jsx)(I.default,{context:s})}function H({content:e,label:t}){const[s,a]=n.useState(!1);return(0,$.jsxs)("button",{className:"embeddings-copy-btn",onClick:()=>{(0,u.lW)(e),a(!0),setTimeout(()=>a(!1),1500)},children:[(0,$.jsx)(A.In,{icon:s?"check":"content_copy"}),s?"已复制":t||"复制"]})}function P({embeddings:e,text:t}){let s=e||null;if(!s&&t)try{s=JSON.parse(t)}catch{return(0,$.jsx)(I.default,{context:t})}if(!s)return(0,$.jsx)(I.default,{context:t||""});const n=s?.data||[],a=s?.usage,i=JSON.stringify(s,null,2);return(0,$.jsxs)("div",{className:"embeddings-result",children:[(0,$.jsxs)("div",{className:"embeddings-summary",children:[(0,$.jsx)("strong",{children:"向量嵌入结果"}),(0,$.jsxs)("span",{children:["维度: ",n[0]?.embedding?.length??"N/A"]}),(0,$.jsxs)("span",{children:["数量: ",n.length]}),a&&(0,$.jsxs)("span",{children:["使用 tokens: ",a.total_tokens??"N/A"]})]}),(0,$.jsxs)("div",{className:"embeddings-toolbar",children:[(0,$.jsx)(H,{content:i,label:"复制全部结果"}),n.length>0&&n[0]?.embedding&&(0,$.jsx)(H,{content:JSON.stringify(n[0].embedding,null,2),label:"复制第一条向量"}),n.length>0&&(0,$.jsx)(H,{content:JSON.stringify(n.map(e=>e.embedding),null,2),label:"复制所有向量数据"})]}),n.length>0&&n[0]?.embedding&&(0,$.jsx)("div",{className:"embeddings-preview",children:(0,$.jsxs)("span",{children:["向量预览: [",n[0].embedding.slice(0,5).join(", "),n[0].embedding.length>5?", ...":"","]"]})}),n.length>0&&(0,$.jsxs)("details",{children:[(0,$.jsx)("summary",{children:"查看详细数据"}),(0,$.jsx)("pre",{className:"embeddings-raw",children:i})]})]})}async function F(e,t){const s=function(){try{return(0,C.zp)().get(x.AG.ai_images_extra_params)||{}}catch{return{}}}(),n={prompt:e,n:s.n??1,size:s.size??"1024x1024",session_id:t};if(s.quality&&(n.quality=s.quality),s.style&&(n.style=s.style),s.extra_json)try{const e=JSON.parse(s.extra_json);Object.assign(n,e)}catch(e){console.warn("图片额外参数 JSON 解析失败:",e)}const a=await l.jV.post("images/generations",n);if(0!==a.code)throw new Error(a.message||"图片生成失败");const i=a.data||{},c=(i.data||[]).map(e=>({url:e.url,b64_json:e.b64_json,revised_prompt:e.revised_prompt})),o=c.map((e,t)=>`${e.revised_prompt?`\n> ${e.revised_prompt}`:""}`).join("\n\n");return{session_id:i.session_id||t,images:c,text:o||`生成了 ${c.length} 张图片`}}async function O(e,t,s,n){try{switch(e){case"images":{const e=await F(t,s);return e&&n(e.text,{images:e.images}),!0}case"audio_speech":{const e=await async function(e,t){const s={input:e,session_id:t};try{const e=localStorage.getItem("ai_audio_extra_params");if(e){const t=JSON.parse(e);t.voice&&(s.voice=t.voice),t.speed&&(s.speed=parseFloat(t.speed))}}catch{}const n=localStorage.getItem("token")||"",a=await fetch("/api/ai_agent/audio/speech",{method:"POST",headers:{"Content-Type":"application/json",Authorization:n},body:JSON.stringify(s)});if(!a.ok)throw new Error(`语音合成失败: ${a.statusText}`);const i=a.headers.get("X-Session-Id")||t,c=await a.arrayBuffer();return{session_id:i,audio:{data:btoa(String.fromCharCode(...Array.from(new Uint8Array(c)))),mime_type:a.headers.get("content-type")||"audio/mpeg"},text:`[音频文件: ${e.slice(0,50)}...]`}}(t,s);return e&&n(e.text,{audio:e.audio}),!0}case"embeddings":{const e=await async function(e,t){const s=await l.jV.post("embeddings",{input:e,session_id:t});if(0!==s.code)throw new Error(s.message||"Embeddings 请求失败");const n=s.data||{},a=n?.data??[],i=`向量维度: ${a[0]?.embedding?.length??0}, 数量: ${a.length}`;return{session_id:n.session_id||t,embeddings:n,text:`✅ Embeddings 结果 - ${i}\n\`\`\`json\n${JSON.stringify(n,null,2).slice(0,2e3)}\n\`\`\``}}(t,s);return e&&n(e.text,{embeddings:e.embeddings}),!0}default:return!1}}catch(e){return n(`请求失败: ${e?.message||JSON.stringify(e)}`),!0}}var V=s(57952),q=s(23430),B=s(87361);const E=({currentModelName:e,setCurrentModelName:t,envConfigRef:s,sysPromptList:n,batchMode:o,selectedMsgCount:r,onToggleSessionPanel:u,onCreateSession:h,onToggleBatchMode:p,onBatchDeleteMessages:f,bgProcessVisible:j,bgProcessCount:v,onToggleBgProcess:b,selectedSysPromptId:y,setSelectedSysPromptId:S})=>{const{t:w}=(0,i.Bd)(),N=(0,c.Zp)(),{check_user_auth:k}=(0,d.MH)(),[,C]=(0,a.fp)(x.AG.ai_session_collapsed);return(0,$.jsxs)(V.A,{children:[(0,$.jsx)(A.rA,{icon:"menu",title:w("会话"),onClick:u}),(0,$.jsx)(A.rA,{icon:"add",title:w("新会话"),onClick:()=>h()}),n.length>0&&(0,$.jsx)(_.l6,{value:y,options:[{title:w("选择系统提示词"),value:""},...n.map(e=>({title:e.note||e.prompt.slice(0,30),value:String(e.index)}))],onChange:e=>{S(e)},no_border:!0,width:"10rem"}),(s.current?.ai_config_env?.options_agent_model_list?.length??0)>0&&(0,$.jsx)(_.l6,{value:e,options:s.current.ai_config_env.options_agent_model_list?.map(e=>({title:e.label,value:e.value}))??[],onChange:e=>{t(e),l.jV.post("set_active_model",{model_name:e}).then(()=>{(0,m.SK)("success"),l.XO.get("ai_agent_setting/env").then(e=>{e.code===g.m.Success&&(s.current=e.data)})}).catch(console.error)},no_border:!0,width:"auto"}),o&&r>0&&(0,$.jsx)(A.rA,{icon:"delete",title:w("删除选中消息"),onClick:f}),(0,$.jsx)(A.rA,{icon:"terminal",title:w("后台进程"),onClick:b,selected:j,tip:v||null}),k(q.oV.ai_agent_setting)&&(0,$.jsx)(A.rA,{icon:"smart_toy",title:"机器人配置",onClick:()=>{N(`/${B.o.ai_rebot_setting_page}`)}}),k(q.oV.ai_agent_setting)&&(0,$.jsx)(A.rA,{icon:"settings",title:"ai setting",onClick:()=>{N(`/${B.o.ai_agent_setting_page}`)}})]})};var K=s(27690);function L({sessions:e,activeSessionId:t,onSelectSession:s,onRenameSession:c,onDeleteSession:o,onShowUsageStats:l,batchMode:r,selectedSessionIds:d,onToggleSessionSelect:u,onToggleBatchMode:m,onBatchDeleteSessions:h,onClearAllSessions:g}){const{t:p}=(0,i.Bd)(),[_,f]=(0,a.fp)(x.AG.ai_session_collapsed),[j,v]=(0,n.useState)(""),b=j.trim()?e.filter(e=>(e.title||"").toLowerCase().includes(j.toLowerCase())||(e.summary||"").toLowerCase().includes(j.toLowerCase())||(e.long_term_memory||"").toLowerCase().includes(j.toLowerCase())):e;return(0,$.jsxs)("aside",{className:`chat-session-list ${_?"active":""} ${_?"collapsed":""}`,children:[(0,$.jsx)("div",{className:"chat-session-search",children:(0,$.jsx)("input",{type:"text",className:"chat-session-search-input",placeholder:p("搜索会话"),value:j,onChange:e=>v(e.target.value)})}),(0,$.jsx)("div",{className:"chat-session-items-wrap",children:b.map(e=>{return(0,$.jsx)("div",{children:(0,$.jsxs)("button",{className:`chat-session-item ${t===e.id?"active":""} ${r?"batch-mode":""}`,onClick:()=>{r&&u?u(e.id):s(e.id)},title:e.summary||e.long_term_memory||e.title,children:[r&&(0,$.jsx)("input",{type:"checkbox",className:"chat-session-checkbox",checked:d?.has(e.id)??!1,onChange:()=>u?.(e.id),onClick:e=>e.stopPropagation()}),(0,$.jsx)("span",{children:(n=e.title,n||"新会话")}),(0,$.jsx)("small",{children:e.message_count}),"web"!==e.source&&(0,$.jsx)("em",{className:"chat-session-source",children:e.source}),!r&&(0,$.jsx)(K.MenuSelect,{list:[{name:p("重命名"),click:()=>c(e.id,e.title)},{name:p("字符消耗统计"),click:()=>l(e.id)},{name:p("删除"),click:()=>o(e.id)}],children:(0,$.jsx)(A.In,{icon:"more_horiz"})})]})},e.id);var n})}),(0,$.jsxs)("div",{className:"chat-session-actions",children:[(0,$.jsx)(A.rA,{icon:r?"check_circle":"checklist",title:p(r?"取消批量选择":"批量选择"),onClick:m}),r&&(d?.size??0)>0&&(0,$.jsx)(A.rA,{icon:"delete",title:p("删除选中会话"),onClick:h}),!r&&(0,$.jsx)(A.rA,{icon:"delete_sweep",title:p("删除全部会话"),onClick:g})]})]})}const z=({messages:e,batchMode:t,selectedMsgIds:s,sending:n,chatContainerRef:a,messagesEndRef:i,onToggleMsgSelect:c,onDelete:o,onCopy:l,onToggleBatchMode:r,t:d})=>(0,$.jsxs)("div",{className:"chat-messages",ref:a,"data-sending":n?"true":"false",children:[e.map(e=>(0,$.jsxs)("div",{className:`chat-message ${e.sender} ${t?"batch-mode":""} ${e.is_loading?"is-loading":""}`,children:[t&&(0,$.jsx)("input",{type:"checkbox",className:"chat-message-checkbox",checked:s.has(e.id),onChange:()=>c(e.id)}),e.is_loading?(0,$.jsxs)("div",{className:"ai-loading-bubble",children:[(0,$.jsxs)("div",{className:"ai-loading-dots",children:[(0,$.jsx)("span",{className:"ai-loading-dot"}),(0,$.jsx)("span",{className:"ai-loading-dot"}),(0,$.jsx)("span",{className:"ai-loading-dot"})]}),(0,$.jsx)("span",{className:"ai-loading-text",children:e.text})]}):(0,$.jsxs)($.Fragment,{children:[M(e),(0,$.jsx)("div",{className:"message-actions",children:t?(0,$.jsx)("button",{onClick:()=>c(e.id),children:s.has(e.id)?d("取消选择"):d("选择")}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)("button",{onClick:()=>o(e.id),children:d("删除")}),(0,$.jsx)("button",{onClick:()=>l(e.text),children:d("复制")}),(0,$.jsx)("button",{onClick:r,children:d("多选")})]})})]})]},e.id)),(0,$.jsx)("div",{ref:i})]});function J({onClose:e}){const{t}=(0,i.Bd)(),[s,c]=(0,a.fp)(x.AG.ai_images_extra_params),[o,l]=(0,n.useState)(s.size||"1024x1024"),[r,d]=(0,n.useState)(String(s.n??1)),[u,m]=(0,n.useState)(s.quality||""),[h,g]=(0,n.useState)(s.style||""),[p,f]=(0,n.useState)(s.extra_json||"");return(0,$.jsxs)("div",{className:"card floating",children:[(0,$.jsx)("div",{className:"card-title",children:(0,$.jsx)("h2",{children:t("图片生成参数设置")})}),(0,$.jsxs)("div",{className:"card-content",children:[(0,$.jsx)(_.Sm,{placeholderOut:t("图片尺寸 (size)"),value:o,handleInputChange:l,placeholder:"1024x1024"}),(0,$.jsx)(_.Sm,{placeholderOut:t("生成数量 (n)"),value:r,handleInputChange:d,type:"number"}),(0,$.jsx)(_.Sm,{placeholderOut:t("画质 (quality)"),value:u,handleInputChange:m,placeholder:"standard / hd"}),(0,$.jsx)(_.Sm,{placeholderOut:t("风格 (style)"),value:h,handleInputChange:g,placeholder:"vivid / natural"}),(0,$.jsx)(_.Sm,{placeholderOut:t("额外参数 JSON"),value:p,handleInputChange:f,placeholder:'{"key":"value"}'})]}),(0,$.jsxs)("div",{className:"card-action",children:[(0,$.jsx)("button",{className:"button button--flat button--grey",onClick:e,children:t("取消")}),(0,$.jsx)("button",{className:"button button--flat",onClick:()=>{const t={size:o,n:parseInt(r)||1};u&&(t.quality=u),h&&(t.style=h),p&&(t.extra_json=p),c(t),e()},children:t("确定")})]})]})}function G({requestType:e}){const{t}=(0,i.Bd)(),[s,a]=(0,n.useState)(!1);return"completions"===e?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(A.rA,{icon:"tune",title:t("模型参数设置"),onClick:()=>a(!0)}),s&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)("div",{className:"overlay",onClick:()=>a(!1)}),"images"===e&&(0,$.jsx)(J,{onClose:()=>a(!1)})]})]})}const W=(0,n.forwardRef)(function({placeholder:e="",disabled:t=!1,className:s,style:a,onEnter:i,onPaste:c,onChange:o},l){const r=(0,n.useRef)(null),[d,u]=(0,n.useState)(!0),[m,h]=(0,n.useState)(!1),g=(0,n.useCallback)(()=>{const e=r.current;return e?(e.textContent??"").replace(/\u00A0/g," ").trimEnd():""},[]);(0,n.useImperativeHandle)(l,()=>({getValue:()=>g(),setValue:e=>{const t=r.current;if(!t)return;t.textContent=e,u(!e);const s=document.createRange();s.selectNodeContents(t),s.collapse(!1);const n=window.getSelection();n?.removeAllRanges(),n?.addRange(s)},clear:()=>{const e=r.current;e&&(e.textContent="",u(!0))},focus:()=>r.current?.focus()})),(0,n.useEffect)(()=>{const e=r.current;if(!e)return;const t=()=>u(!e.textContent);return e.addEventListener("input",t),()=>e.removeEventListener("input",t)},[]);return(0,$.jsx)("div",{ref:r,contentEditable:!t,suppressContentEditableWarning:!0,className:"rich-textarea"+(s?" "+s:""),style:a,onKeyDown:e=>{m||"Enter"!==e.key||e.shiftKey||e.ctrlKey||e.metaKey||e.altKey||(e.preventDefault(),i?.())},onPaste:c,onInput:()=>o?.(g()),onCompositionStart:()=>h(!0),onCompositionEnd:()=>h(!1),"data-placeholder":d?e:void 0})});function Q({pendingAttachments:e,onRemove:t}){return 0===e.length?null:(0,$.jsx)("div",{className:"chat-attachment-strip",children:e.map((e,s)=>(0,$.jsxs)("div",{className:"chat-attachment-chip",children:[(0,$.jsx)(A.In,{icon:"attach_file"}),(0,$.jsx)("span",{title:e.name,children:e.name}),(0,$.jsx)("button",{type:"button",onClick:()=>t(s),children:(0,$.jsx)(A.In,{icon:"close"})})]},`${e.name}_${s}`))})}const U=(0,n.forwardRef)(({onSend:e,sending:t,onAbort:s,pendingAttachments:a,onRemoveAttachment:c,onOpenFilePicker:o,onAddFiles:l,onDrop:r,onDragOver:d,fileInputRef:u,requestType:m},h)=>{const{t:g}=(0,i.Bd)(),p=(0,n.useRef)(null);return(0,n.useImperativeHandle)(h,()=>({getValue:()=>p.current?.getValue()??"",setValue:e=>p.current?.setValue(e),clear:()=>p.current?.clear()})),(0,$.jsxs)("div",{className:"chat-input-area",onDrop:r,onDragOver:d,children:[(0,$.jsx)("input",{ref:u,type:"file",multiple:!0,style:{display:"none"},onChange:e=>{e.target.files?.length&&(l(e.target.files),e.currentTarget.value="")}}),(0,$.jsxs)("div",{className:"chat-input-shell",children:[(0,$.jsx)(Q,{pendingAttachments:a,onRemove:c}),(0,$.jsx)(W,{ref:p,placeholder:g("输入消息"),onEnter:()=>e(),onPaste:e=>{const t=e.clipboardData?.files;t&&t.length>0&&(e.preventDefault(),l(t))},className:"chat-input"})]}),(0,$.jsx)(A.rA,{title:g("添加文件"),icon:"attach_file",onClick:o}),(0,$.jsx)(G,{requestType:m}),t?(0,$.jsx)(A.Vi,{color:"var( --icon-red)",text:g("暂停"),clickFun:s}):(0,$.jsx)(A.Vi,{text:g("发送"),clickFun:e})]})}),X={},Z=function(){const{t:e}=(0,i.Bd)(),[t,s]=(0,n.useState)([]),[c,l]=(0,n.useState)(!1),[r,d]=(0,n.useState)(null),[u,h]=(0,n.useState)(null),[g,p]=(0,n.useState)(!1),[_,f]=(0,a.fp)(x.AG.ai_bg_expanded),[,j]=(0,a.fp)(x.AG.ai_session_collapsed),v=()=>{f(!1)},b=(0,n.useCallback)(async()=>{l(!0);try{const e=new o.hf(o.HK.ai_bg_process_list_req);e.context={};const t=await k.ws.send(e);t?.context?.processes&&(s(t.context.processes),X.onCountChange?.(t.context.processes.length))}catch(e){console.error("获取后台进程列表失败",e)}finally{l(!1)}},[]);X.refresh=b;const y=(0,n.useCallback)(async e=>{p(!0),d(e);try{const t=new o.hf(o.HK.ai_bg_process_output_req);t.context={pid:e};const s=await k.ws.send(t);h(s.context)}catch(e){console.error("获取进程输出失败",e),(0,m.zN)("获取进程输出失败")}finally{p(!1)}},[]),S=(0,n.useCallback)(async e=>{try{const t=new o.hf(o.HK.ai_bg_process_kill_req);t.context={pid:e};const s=await k.ws.send(t);s?.context?.success?((0,m.SK)("进程已终止"),b(),r===e&&(d(null),h(null))):(0,m.zN)(s?.context?.message||"终止失败")}catch(e){console.error("终止进程失败",e),(0,m.zN)("终止进程失败")}},[b,r]);(0,n.useEffect)(()=>{b();const e=setInterval(b,5e3);return()=>clearInterval(e)},[b]);const w=t.filter(e=>e.running),N=t.filter(e=>!e.running);return(0,$.jsxs)($.Fragment,{children:[_&&(0,$.jsx)("div",{className:"chat-session-overlay",onClick:v}),(0,$.jsxs)("aside",{className:"chat-bg-process-panel "+(_?"expanded":""),children:[(0,$.jsxs)("div",{className:"chat-bg-process-header",children:[(0,$.jsx)("span",{className:"chat-bg-process-title",children:e("后台进程")}),(0,$.jsx)(A.rA,{icon:"close",title:e("关闭"),onClick:v})]}),(0,$.jsxs)("div",{className:"chat-bg-process-toolbar",children:[(0,$.jsx)(A.rA,{icon:"refresh",title:e("刷新"),onClick:b}),(0,$.jsxs)("span",{className:"chat-bg-process-count",children:[w.length," ",e("个运行中"),N.length>0&&` / ${N.length} ${e("个已退出")}`]})]}),(0,$.jsxs)("div",{className:"chat-bg-process-list",children:[c&&0===t.length&&(0,$.jsx)("div",{className:"chat-bg-process-empty",children:e("加载中...")}),!c&&0===t.length&&(0,$.jsx)("div",{className:"chat-bg-process-empty",children:e("暂无后台进程")}),w.map(t=>(0,$.jsxs)("div",{className:`chat-bg-process-item ${r===t.pid?"active":""} running`,children:[(0,$.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(t.pid),children:[(0,$.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",t.pid]}),(0,$.jsx)("span",{className:"chat-bg-process-cmd",title:t.cmd,children:t.cmd.length>40?t.cmd.slice(0,40)+"...":t.cmd}),(0,$.jsx)("span",{className:"chat-bg-process-time",children:new Date(t.start_time).toLocaleTimeString()}),(0,$.jsx)("span",{className:"chat-bg-process-status running-dot",title:e("运行中"),children:"●"})]}),(0,$.jsxs)("div",{className:"chat-bg-process-item-actions",children:[(0,$.jsx)(A.rA,{icon:"terminal",title:e("查看输出"),onClick:()=>y(t.pid)}),(0,$.jsx)(A.rA,{icon:"stop",title:e("终止进程"),onClick:()=>S(t.pid)})]})]},t.pid)),N.map(e=>(0,$.jsx)("div",{className:`chat-bg-process-item ${r===e.pid?"active":""} finished`,children:(0,$.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(e.pid),children:[(0,$.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,$.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>30?e.cmd.slice(0,30)+"...":e.cmd}),(0,$.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,$.jsxs)("span",{className:"chat-bg-process-exit-code",children:["exit: ",e.exit_code]})]})},e.pid))]}),null!==r&&(0,$.jsxs)("div",{className:"chat-bg-process-output",children:[(0,$.jsxs)("div",{className:"chat-bg-process-output-header",children:[(0,$.jsxs)("span",{children:["PID: ",r," ",e("输出")]}),(0,$.jsx)(A.rA,{icon:"close",title:e("关闭"),onClick:()=>{d(null),h(null)}})]}),(0,$.jsx)("div",{className:"chat-bg-process-output-content",children:g?(0,$.jsx)("div",{className:"chat-bg-process-empty",children:e("加载中...")}):u?(0,$.jsx)("pre",{className:"chat-bg-process-output-pre",children:u.output||e("(无输出)")}):null})]})]})]})};function Y(){const{t:e}=(0,i.Bd)(),t=((0,c.Zp)(),(0,h.y)()),{check_user_auth:s}=(0,d.MH)();(0,p.w)();const[b,y]=(0,n.useState)([]),[S,w]=(0,n.useState)([]),[C,A]=(0,n.useState)(""),[I,M]=(0,n.useState)(!1),T=(0,n.useRef)(null),[D,R]=(0,n.useState)([]),[H,P]=(0,a.fp)(x.AG.ai_session_collapsed),[F,V]=(0,a.fp)(x.AG.ai_bg_expanded),[q,B]=(0,a.fp)(x.AG.prompt_card),[K,J]=(0,n.useState)(!1),[G,W]=(0,n.useState)(new Set),[Q,Y]=(0,n.useState)(new Set),[ee,te]=(0,n.useState)(""),se=(0,n.useRef)(null),ne=(0,n.useRef)(null),ae=(0,n.useRef)(null),ie=(0,n.useRef)(!0),ce=(0,n.useRef)(new f.qq),[oe,le]=(0,n.useState)([]),[re,de]=(0,n.useState)(""),[ue,me]=(0,n.useState)(0),he=()=>ce?.current?.ai_config?.request_type||"completions",ge=(0,n.useRef)((0,r.sg)(e=>{y(e),ie.current&&pe(!1)},50)).current,pe=(e=!1)=>{const t=ae.current;t&&t.scrollTo({top:t.scrollHeight,behavior:e?"smooth":"auto"})},xe=async()=>{const e=await l.jV.get("sessions");e.code===g.m.Success&&w(e.data??[])},_e=function(e){const{getMessages:t,setMessages:s,setMessagesDebounced:a,setSending:i,getActiveSessionId:c,setActiveSessionId:l,refreshSessions:r,scrollToBottom:d,buildRequestMessages:u,getSelectedSysPromptId:m}=e,h=(0,n.useRef)([]),g=(0,n.useRef)(null),p=(e,n,c)=>{const l=[...t(),n];s(l),i(!0),g.current={abort:()=>{}};const h={id:n.id+1,sender:"bot",text:"AI思考中...",is_loading:!0};l.push(h),s([...l]);const p=new Map;let x=!0,_=h;const f=e=>{const t=e.context||{},s=t.text||"",n=t.tool_call_ends,i=t.chunk_index??0;if("[DONE]"!==s)if(x)x=!1,_.text=s,n&&(_.content_list=[{tool_call_ends:n,content:_.text,role:"assistant"}]),_.is_loading=!1,_.chunk_index=i,p.set(i,_),a([...l]);else{const e=p.get(i);if(e)e.text+=s,n&&(e.content_list=[{tool_call_ends:n,content:e.text,role:"assistant"}]),a([...l]);else{const e={id:Date.now()+Math.random(),sender:"bot",text:s,chunk_index:i};n&&(e.content_list=[{tool_call_ends:n,content:e.text,role:"assistant"}]),l.push(e),p.set(i,e),a([...l])}}},j=e=>{b(),g.current=null,i(!1),_.is_loading=!1,r(),d(!0),c()},v=e=>{b(),g.current=null,i(!1);const t=e.context||{};_.text="AI请求出错: "+(t.message||"未知错误"),_.is_loading=!1,s([...l]),c()},b=()=>{k.ws.off_message(`message_${o.HK.ai_chat_msg}`,f),k.ws.off_message(`message_${o.HK.ai_chat_end}`,j),k.ws.off_message(`message_${o.HK.ai_chat_error}`,v)};k.ws.addMsg(o.HK.ai_chat_msg,f),k.ws.addMsg(o.HK.ai_chat_end,j),k.ws.addMsg(o.HK.ai_chat_error,v),k.ws.sendData(o.HK.ai_chat_req,{messages:u(n),session_id:e,sys_prompt_id:m()})},x=()=>{const e=h.current;if(0===e.length)return;const t=e.shift();if(!t)return;s(e=>e.map(e=>"user"===e.sender&&e.text.includes("⏳(排队中...)")?{...e,text:e.text.replace(" ⏳(排队中...)","")}:e));const n={id:Date.now(),sender:"user",text:t.text,attachments:t.attachments};p(c(),n,x)};return{startChatStream:p,processPendingQueue:x,enqueueMessage:(e,t)=>{h.current.push({text:e,attachments:t})},getQueueLength:()=>h.current.length,abort:()=>{g.current&&(k.ws.sendData(o.HK.ai_chat_abort,{session_id:c()}),g.current=null,i(!1))}}}({getMessages:()=>b,setMessages:y,setMessagesDebounced:ge,setSending:M,getActiveSessionId:()=>C,setActiveSessionId:A,refreshSessions:xe,scrollToBottom:pe,buildRequestMessages:e=>{const t=(e.attachments??[]).filter(e=>"image"===e.kind);if(t.length>0){const s=[];e.text&&s.push({type:"text",text:e.text});for(const e of t)s.push({type:"image_url",image_url:{url:e.content}});return[{content:s,role:"user",attachments:e.attachments??[]}]}return[{content:e.text,role:"bot"===e.sender?"assistant":"user",attachments:e.attachments??[]}]},getSelectedSysPromptId:()=>ee}),fe=async e=>{const t=await l.jV.get("sessions");if(t.code!==g.m.Success)return;const s=t.data??[];w(s);const n=null===e?s[0]?.id??"":e||C||s[0]?.id||"";n?await je(n):(y([]),A(""))},je=async(e,t=!1)=>{const s=await l.jV.post("session/get",{session_id:e});if(s.code!==g.m.Success||!s.data)return;const n=s.data;A(n.id),y(function(e=[]){return e.filter(e=>"user"===e.role||"assistant"===e.role).map((e,t)=>({id:Date.now()+t,sender:"assistant"===e.role?"bot":"user",text:v(e),attachments:e.attachments??[],content_list:e.content_list,images:e.images,audio:e.audio,embeddings:e.embeddings}))}(n.messages)),t&&P(!1),X.refresh?.(),requestAnimationFrame(()=>pe(!1))},ve=e=>{const t=Array.from(e??[]).filter(Boolean);t.length&&R(e=>[...e,...t])},be=()=>{K&&(W(new Set),Y(new Set)),J(e=>!e)};(0,n.useEffect)(()=>((async()=>{const e=await l.XO.get("ai_agent_setting/env");if(e.code===g.m.Success){ce.current=e.data;const t=e.data.ai_config?.model||"",s=(e.data.ai_config_env?.options_agent_model_list??[]).find(e=>e.label===t);de(s?s.value:t)}await fe();const t=await l.jV.get("system_prompts");t.code===g.m.Success&&le(t.data??[])})(),requestAnimationFrame(()=>pe(!1)),X.onCountChange=me,X.refresh?.(),k.ws.addMsg(o.HK.ai_bg_process_count_notify,e=>{const t=e?.context?.count;"number"==typeof t&&me(t)}),()=>{k.ws.removeMsg(o.HK.ai_bg_process_count_notify)}),[]),(0,n.useEffect)(()=>{const e=ae.current;if(!e)return;const t=()=>{ie.current=((e,t=120)=>{const{scrollTop:s,scrollHeight:n,clientHeight:a}=e;return n-(s+a)<t})(e)};return e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)},[]),(0,n.useLayoutEffect)(()=>{ie.current&&pe(!1)},[b]);return(0,$.jsxs)(n.Fragment,{children:[(0,$.jsx)(E,{currentModelName:re,setCurrentModelName:de,envConfigRef:ce,sysPromptList:oe,batchMode:K,selectedMsgCount:G.size,onToggleSessionPanel:()=>{P(e=>!e)},onCreateSession:async e=>{const t=await l.jV.post("session",{title:"新会话"});if(t.code!==g.m.Success)return;const s=t.data;A(s.id),y([]),P(!1),await fe(s.id),requestAnimationFrame(()=>{const e=document.querySelector(".chat-input");e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,200)+"px")})},onBatchDeleteMessages:()=>{0!==G.size&&t({sub_title:e("确认删除选中的聊天消息吗?"),confirm_fun:async()=>{const e=[];b.forEach((t,s)=>{G.has(t.id)&&e.push(s)}),y(b.filter(e=>!G.has(e.id))),W(new Set),J(!1),C&&e.length>0&&l.jV.post("session/message/delete",{session_id:C,indices:e}).catch(console.error)}})},bgProcessVisible:F,bgProcessCount:ue,onToggleBgProcess:()=>V(e=>!e),selectedSysPromptId:ee,setSelectedSysPromptId:te}),(0,$.jsxs)("div",{className:"chat-page chat-page-with-sessions",children:[H&&(0,$.jsx)("div",{className:"chat-session-overlay",onClick:()=>P(!1)}),(0,$.jsx)(L,{sessions:S,activeSessionId:C,onSelectSession:e=>je(e,!1),onRenameSession:(e,s)=>{let n=s;t({confirm_fun:async()=>{await l.jV.post("sessions/update/meta",{id:e,title:n}),await fe(C)},context_div:(0,$.jsx)("div",{className:"card-content",children:(0,$.jsx)(_.Sm,{value:n,handleInputChange:e=>{n=e}})})})},onDeleteSession:e=>{t({sub_title:"确认删除这个会话吗?",confirm_fun:async()=>{await l.jV.post("session/delete",{session_id:e}),C===e?(A(""),await fe(null)):await fe(C)}})},onShowUsageStats:async t=>{B({open:!0,title:e("Token消耗统计"),context_div:(0,$.jsx)("div",{className:"usage-stats-loading",children:e("加载中...")}),cancel:()=>B({open:!1})});try{const s=await l.jV.post("session/usage_stats",{session_id:t});if(s.code===g.m.Success&&s.data){const t=s.data;B({open:!0,title:e("Token消耗统计"),context_div:(0,$.jsxs)("div",{className:"usage-stats-panel",children:[[{l:e("对话轮次"),v:(t.turns??0).toString()},{l:e("AI输入Token"),v:j(t.input_tokens)},{l:e("AI输出Token"),v:j(t.output_tokens)},{l:e("AI输入Token(最近一轮)"),v:j(t.recent_input_tokens)},{l:e("AI输出Token(最近一轮)"),v:j(t.recent_output_tokens)}].map((e,t)=>(0,$.jsxs)("div",{className:"usage-stats-row",children:[(0,$.jsx)("span",{className:"usage-stats-label",children:e.l}),(0,$.jsx)("span",{className:"usage-stats-value",children:e.v})]},t)),(0,$.jsxs)("div",{className:"usage-stats-row usage-stats-total",children:[(0,$.jsx)("span",{className:"usage-stats-label",children:e("AI Token总计消耗")}),(0,$.jsx)("span",{className:"usage-stats-value",children:j((t.input_tokens||0)+(t.output_tokens||0))})]})]}),cancel:()=>B({open:!1})})}else B({open:!0,title:e("Token消耗统计"),context_div:(0,$.jsx)("div",{className:"usage-stats-empty",children:e("暂无统计数据")}),cancel:()=>B({open:!1})})}catch{B({open:!0,title:e("Token消耗统计"),context_div:(0,$.jsx)("div",{className:"usage-stats-empty",children:e("暂无统计数据")}),cancel:()=>B({open:!1})})}},batchMode:K,selectedSessionIds:Q,onToggleSessionSelect:e=>{Y(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},onToggleBatchMode:be,onBatchDeleteSessions:()=>{0!==Q.size&&t({sub_title:e("确认删除选中的会话吗?"),confirm_fun:async()=>{for(const e of Q)await l.jV.post("session/delete",{session_id:e});Y(new Set),J(!1),Q.has(C)?(A(""),await fe(null)):await fe(C)}})},onClearAllSessions:()=>{t({sub_title:e("确认删除全部聊天会话吗?"),confirm_fun:async()=>{await l.jV.post("sessions/clear",{}),A(""),y([]),await fe(null)}})}}),(0,$.jsx)(Z,{}),(0,$.jsxs)("section",{className:"chat-main",children:[0===b?.length&&(0,$.jsx)("div",{className:"chat-header",children:(0,$.jsx)("div",{children:e("询问服务器的一切")})}),(0,$.jsx)(z,{messages:b,batchMode:K,selectedMsgIds:G,sending:I,chatContainerRef:ae,messagesEndRef:ne,onToggleMsgSelect:e=>{W(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})},onDelete:s=>{t({sub_title:e("确认删除这条消息吗?"),confirm_fun:async()=>{const e=b.findIndex(e=>e.id===s);if(e<0)return;const t=b.filter(e=>e.id!==s);y(t),C&&l.jV.post("session/message/delete",{session_id:C,indices:[e]}).catch(console.error)}})},onCopy:async e=>{(0,u.lW)(e),(0,m.SK)("复制成功")},onToggleBatchMode:be,t:e}),(0,$.jsx)(U,{ref:T,onSend:async()=>{const e=(T.current?.getValue()??"").trim();if(!e&&0===D.length)return;if(I){const t=await N(D);_e.enqueueMessage(e,t),T.current?.clear(),R([]);const s={id:Date.now(),sender:"user",text:e+(_e.getQueueLength()>1?" ⏳(排队中...)":""),attachments:t};return void y(e=>[...e,s])}let t=C;if(!t){const s=await l.jV.post("session",{title:(e||D[0]?.name||"新会话").slice(0,28)});if(s.code!==g.m.Success)return;t=s.data.id,A(t),await fe(t)}const s=await N(D),n={id:Date.now(),sender:"user",text:e,attachments:s};T.current?.clear(),R([]);const a=he();if("completions"!==a){const s={id:n.id+1,sender:"bot",text:"处理中...",is_loading:!0},i=[...b,n,s];y(i),M(!0);return void(await O(a,e,t,async(e,t)=>{s.text=e,s.is_loading=!1,t?.images&&(s.images=t.images),t?.audio&&(s.audio=t.audio),t?.embeddings&&(s.embeddings=t.embeddings),y([...i]),M(!1),xe(),pe(!0),_e.processPendingQueue()})||(s.text=`请求类型 "${a}" 的专用处理器尚未实现,请使用 completions 类型。`,s.is_loading=!1,y([...i]),M(!1),_e.processPendingQueue()))}_e.startChatStream(t,n,()=>_e.processPendingQueue())},sending:I,onAbort:_e.abort,pendingAttachments:D,onRemoveAttachment:e=>{R(t=>t.filter((t,s)=>s!==e))},onOpenFilePicker:()=>{se.current?.click()},onAddFiles:ve,onDrop:e=>{const t=e.dataTransfer?.files;t&&t.length>0&&(e.preventDefault(),ve(t))},onDragOver:e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},fileInputRef:se,requestType:he()})]})]})]})}},72693(e,t,s){s.d(t,{w:()=>u});var n=s(96540),a=s(22022),i=s(14944),c=s(92275),o=s(34843),l=s(82893),r=s(85997),d=s(74848);function u(){const[e,t]=(0,o.fp)(l.AG.prompt_card),{t:s}=(0,a.Bd)(),u=(0,n.useRef)([]),m=(0,n.useRef)(!1),h=(0,n.useCallback)(()=>{if(m.current)return;if(0===u.current.length)return m.current=!1,void t({open:!1});m.current=!0;const e=u.current.shift();e?t({open:!0,title:s("命令确认"),cancel:()=>{i.ws.sendData(c.HK.ai_confirm_cmd,{askId:e.askId,approved:!1}),t({open:!1}),m.current=!1,h()},context_div:(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{style:{maxHeight:"60vh",overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-all",background:"var(--surfaceSecondary)",padding:"0.75em",borderRadius:"0.5em",marginBottom:"0.75em",fontFamily:"monospace",fontSize:"0.9em",lineHeight:"1.5"},children:e.cmd}),(0,d.jsxs)("div",{style:{display:"flex",gap:"0.5em",justifyContent:"flex-end"},children:[(0,d.jsx)(r.$n,{text:s("拒绝"),color:"var(--red)",clickFun:()=>{i.ws.sendData(c.HK.ai_confirm_cmd,{askId:e.askId,approved:!1}),t({open:!1}),m.current=!1,h()}}),(0,d.jsx)(r.$n,{text:s("允许"),clickFun:()=>{i.ws.sendData(c.HK.ai_confirm_cmd,{askId:e.askId,approved:!0}),t({open:!1}),m.current=!1,h()}})]})]})}):m.current=!1},[s]),g=(0,n.useCallback)(e=>{u.current.push(e),h()},[h]);(0,n.useEffect)(()=>(i.ws.addMsg(c.HK.ai_confirm_cmd,e=>{const s=e.context||{};if(s.dismiss&&s.askId)return u.current=u.current.filter(e=>e.askId!==s.askId),void(m.current&&(m.current=!1,t({open:!1}),h()));s.askId&&s.cmd&&g({askId:s.askId,cmd:s.cmd})}),()=>{i.ws.removeMsg(c.HK.ai_confirm_cmd)}),[g]),(0,n.useEffect)(()=>()=>{u.current=[],m.current=!1},[])}},34299(e,t,s){s.r(t),s.d(t,{default:()=>p});s(96540);var n=s(73557),a=s(53995),i=s(18569),c=s(77979),o=s(8263),l=s(69428),r=s.n(l),d=(s(3775),s(21499)),u=s(99214),m=s(19878),h=(s(72411),s(74848));const g=new n.A({html:!0,highlight:function(e,t){if(t&&m.A.getLanguage(t))try{return`<pre class="hljs code-block-with-copy"><code class="hljs language-${t}">${m.A.highlight(e,{language:t}).value}</code></pre>`}catch(e){}try{return`<pre class="hljs code-block-with-copy"><code class="hljs">${m.A.highlightAuto(e).value}</code></pre>`}catch(e){}return`<pre class="hljs code-block-with-copy"><code>${g.utils.escapeHtml(e)}</code></pre>`}});function p(e){return(0,u.VD)(),(0,h.jsx)("div",{dangerouslySetInnerHTML:{__html:g.render(e.context)}})}g.use(a.A).use(i.A).use(c.A).use(o.A).use(r()).use(e=>{e.renderer.rules.fence;e.renderer.rules.fence=(t,s,n,a,i)=>{const c=t[s],o=c.content.trim(),l=c.info.trim();let r="";if(l&&m.A.getLanguage(l))try{r=m.A.highlight(o,{language:l}).value}catch(t){r=e.utils.escapeHtml(o)}else try{r=m.A.highlightAuto(o).value}catch(t){r=e.utils.escapeHtml(o)}return`\n <div class="code-block-with-copy">\n <div class="code-header">\n <span class="code-language">${l||"code"}</span>\n <button class="copy-btn" data-code="${e.utils.escapeHtml(o)}">复制</button>\n </div>\n <pre><code class="hljs ${l?`language-${l}`:""}">${r}</code></pre>\n </div>`}}).use(e=>{const t=e.renderer.rules.link_open||function(e,t,s,n,a){return a.renderToken(e,t,s)};e.renderer.rules.link_open=(e,s,n,a,i)=>{const c=e[s],o=c.attrIndex("href");if(o>=0){const e=c.attrs[o][1];c.attrs[o][1]=(0,d.bi)(window.location.href,e)}return t(e,s,n,a,i)}})},45907(e,t,s){s.d(t,{y:()=>i});var n=s(34843),a=s(82893);function i(){const[e,t]=(0,n.fp)(a.AG.confirm);return({sub_title:e,confirm_fun:s,title:n,context_div:a})=>{t({open:!0,sub_title:e,handle:()=>{s(),t({open:!1,handle:null})},title:n,context_div:a})}}},60840(e){e.exports="data:image/svg+xml,<svg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 16 16%27 version=%271.1%27 aria-hidden=%27true%27><path fill-rule=%27evenodd%27 d=%27M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z%27></path></svg>"}}]);
|