filecat 6.14.1 → 6.14.2

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.
Files changed (25) hide show
  1. package/build/dist/{1448.c54dfb4f0ace2c6f84cb.js → 1448.cb0b816ecce11857fbc4.js} +1 -1
  2. package/build/dist/{2542.d6a50122f60efba32a30.js → 2542.26cb302b60de23166227.js} +1 -1
  3. package/build/dist/{2674.4fc554b04a11a3a3151d.js → 2674.570467c7d8e3378316cc.js} +1 -1
  4. package/build/dist/{4488.8a2727ce013104c4cfb4.js → 4488.72cda485aa8175ce03bd.js} +1 -1
  5. package/build/dist/{5308.93a513c4d2025f65e546.js → 5308.cc7a2e88ea22f247ec76.js} +1 -1
  6. package/build/dist/{5516.679dadeb7510275a7616.js → 5516.f442aef7efd919af92cd.js} +1 -1
  7. package/build/dist/{5937.d865e6e197bc253c59c2.js → 5937.820d7e5fcf608c346964.js} +1 -1
  8. package/build/dist/{6247.1b04f0b4739846af26ce.js → 6247.8116d7df0a5040d144c2.js} +1 -1
  9. package/build/dist/{6413.1fd049f6d4f791f72e1e.js → 6413.38627ec984b26437de1e.js} +1 -1
  10. package/build/dist/{6505.c1a0b35e1c2a0c66e837.js → 6505.f730960378f6e4b7bc24.js} +1 -1
  11. package/build/dist/{6892.bc3f13ff4689ffab1237.js → 6892.fac5b622852f0aad613d.js} +1 -1
  12. package/build/dist/{7181.984cdb2ff1a58762c55b.js → 7181.9f22415130200367cfda.js} +1 -1
  13. package/build/dist/{7209.9672e5474b99d79ee570.js → 7209.de0fc874821ef1cb0684.js} +1 -1
  14. package/build/dist/{8302.3d668f33b2a6c22b50d6.js → 8302.19a72820071ef3c3e981.js} +1 -1
  15. package/build/dist/{8603.cb2ce741aa06a7b51f41.js → 8603.8b4a272c8bbe4d5fd4c4.js} +1 -1
  16. package/build/dist/{8714.fe6d795fe2147cf0a86a.js → 8714.0609ed38a42421e9eb02.js} +1 -1
  17. package/build/dist/{8765.9b2daf5a74be623229d3.js → 8765.e8c4f80fb9afd6730bd3.js} +1 -1
  18. package/build/dist/{9782.913585e0ff779ece45b5.js → 9782.1b7bf041c0f1673905df.js} +1 -1
  19. package/build/dist/index.html +1 -1
  20. package/build/dist/main.e8e3157be6063ea4da8a.js +2 -0
  21. package/build/dist/{main.27ca5409b10e4b78791e.js.LICENSE.txt → main.e8e3157be6063ea4da8a.js.LICENSE.txt} +1 -1
  22. package/build/main.js +1 -1
  23. package/build/threads.work.filecat.js +1 -1
  24. package/package.json +1 -1
  25. package/build/dist/main.27ca5409b10e4b78791e.js +0 -2
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[6010,8302],{83277(e,t,n){n.d(t,{$j:()=>a,Lv:()=>o,qq:()=>i});class s{options_agent_url_list;options_agent_key_list;options_agent_model_list}class o{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 n of t)if(n.value===e)return n.label;return e}static have_label_by_v(e,t){if(!e||!t?.length)return!1;for(const n of t)if(n.value===e)return!0;return!1}}class i extends s{tool_error_max=50;tool_call_max=300;allow_exec_cmd_directly=!1;proxy_url}const l=JSON.stringify({stream:!0,thinking:{type:"disabled"}});function a(e){return"string"==typeof e?e:Array.isArray(e)?e.map(e=>"text"===e.type?e.text:"[图片]").join("\n"):""}n.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',"cL",0,l])},77481(e,t,n){n.d(t,{S:()=>l,X:()=>i});var s=n(96540),o=n(74848);function i(e){const[t,n]=s.useState([]);return(0,s.useEffect)(()=>{e.children?n(Array.isArray(e.children)?e.children:[e.children]):n(e.rows)},[e.rows,e.children]),(0,o.jsxs)("table",{children:[(0,o.jsx)("thead",{children:(0,o.jsx)("tr",{children:e.headers?.map((e,t)=>(0,o.jsx)("th",{children:e},t))})}),(0,o.jsx)("tbody",{children:t.map((t,n)=>(0,o.jsx)("tr",{onContextMenu:()=>{e.handleContextMenu&&e.handleContextMenu(t)},children:t.map((n,s)=>(0,o.jsx)("td",{style:{width:e.width??"auto"},className:s===t.length-1?"small":"",children:n},s))},n))})]})}function l(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))})}},29591(e,t,n){n.r(t),n.d(t,{default:()=>K});var s=n(22022),o=n(96540),i=n(85997),l=n(57952),a=n(34843),r=n(82893),c=n(75725),d=n(77481),p=n(61443),u=n(70447),h=n(34299),_=n(74848);var m=n(14284),x=n(53459),j=n(62042),v=n(7523),g=n(78247),f=n(23430),w=n(52671),y=n(14944),C=n(92275),k=n(88815),b=n(45907),A=n(12721),S=n(24659),I=n(83277),$=n(96494);function K(){const{t:e}=(0,s.Bd)(),{initUserInfo:t}=(0,o.useContext)(v.F),n=[e("编号"),e("url"),e("model类型"),e("是否开启"),e("key"),"model",e("成为tool"),e("更多属性"),e("备注")],K=(0,$.r)(),N=[e("编号"),e("本地目录"),e("自动加载"),e("备注")],[P,M]=(0,o.useState)([]),[O,X]=(0,o.useState)([]),[V,L]=(0,o.useState)([]),[H,F]=(0,o.useState)(null),Y=(0,o.useRef)(),q=(0,o.useRef)(!1),G=(0,o.useRef)(!1),[z,B]=(0,o.useState)([]),[R,T]=(0,o.useState)(!1),[D,E]=(0,a.fp)(r.AG.prompt_card),[J,Z]=(0,a.fp)(r.AG.user_base_info),[U,W]=(0,o.useState)(!1),Q=V.filter(e=>"http"!==(e.transport??"stdio")),ee=V.filter(e=>"http"===e.transport),te=[e("编号"),e("名称"),e("是否开启"),"command","args","cwd",e("tools|env"),e("备注")],ne=[e("编号"),e("名称"),e("是否开启"),e("endpoint"),e("tools|headers"),e("备注")],se=[e("编号"),e("提示词"),e("备注")],[oe,ie]=(0,o.useState)([]),le=function(){const[e,t]=(0,a.fp)(r.AG.prompt_card);return e=>{t({open:!0,title:"信息",context_div:(0,_.jsx)("div",{children:(0,_.jsx)(h.default,{context:e})})})}}(),{check_user_auth:ae}=(0,g.MH)(),[re,ce]=(0,a.fp)(r.AG.editorSetting),de=(0,w.Zp)(),pe=(0,b.y)(),ue=(0,S.K)(),he=async()=>{const e=await m.jV.get("docs_on_get");e.code===x.m.Success&&W(e.data)};(0,o.useEffect)(()=>{(async()=>{const e=await m.XO.get("ai_agent_setting");e.code===x.m.Success&&M(e.data.models),await y.ws.addMsg(C.HK.ai_load_info,e=>{F(e.context)});const t=await y.ws.sendData(C.HK.ai_load_info,{});t?.context&&F(t.context);const n=await m.XO.get("ai_docs_setting");n.code===x.m.Success&&(Y.current=n.data.param,n.data.list?.length&&X(n.data.list));const s=await m.XO.get("ai_mcp_setting");s.code===x.m.Success&&L(s.data.list??[]),await ge(),he();const o=await m.XO.get("ai_system_prompts");o.code===x.m.Success&&ie(o.data??[])})()},[]);const _e=(e="stdio")=>{const t="http"===e?{name:"",open:!1,note:"",transport:"http",endpoint:"",headers:"",stream:!1,timeout_ms:1e4}:{name:"",open:!1,command:"",args:"",cwd:"",env:"",note:"",transport:"stdio",timeout_ms:1e4};L([...V,t]),q.current=!0},me=e=>{const t=V.indexOf(e);t<0||(V.splice(t,1),L([...V]),q.current=!0)},xe=e=>{L([...V,{...e,open:!1}]),q.current=!0},je=async e=>{for(let e=0;e<P.length;e++)P[e].index=e;(await m.XO.post("ai_agent_setting/save",{models:e??P})).code===x.m.Success&&(0,j.SK)("保存成功")},ve=async e=>{for(let e=0;e<V.length;e++)V[e].index=e;(await m.XO.post("ai_mcp_setting/save",{list:e??V})).code===x.m.Success&&((0,j.SK)("保存成功"),q.current=!1,await ge())},ge=async()=>{const e=await m.XO.get("ai_mcp_tools");return e.code===x.m.Success?(B(e.data??[]),e.data??[]):[]},fe=async e=>{T(!0);try{const t=await m.XO.post("ai_mcp_tools/reload",{index:e});if(t.code===x.m.Success)return await ge(),(0,j.SK)("MCP工具加载成功"),t.data??null}finally{T(!1)}return null},we=async(t,n,s,o)=>{const i=o??z.find(e=>e.index===n)??{index:n,key:`${n}`,name:t.name??"",note:t.note,transport:t.transport??"stdio",open:!!t.open,loaded:!1,tool_count:0,tools:[]},l=(i.tools??[]).map(t=>({id:t.runtime_name,title:t.tool_name,subtitle:t.description||e("无描述"),detail:t.display_name,meta:t.runtime_name}));E({open:!0,title:`${t.name||t.note||n} MCP工具`,context_div:(0,_.jsx)(A.O,{title:`${t.name||t.note||n} MCP工具`,subtitle:`${i.transport??"stdio"} | ${i.open?e("是"):e("否")} | ${i.loaded?"loaded":"idle"} | ${i.tool_count} tools`,pages:l,initialPageId:s,onRefresh:async()=>{const e=await fe(n);e&&await we(t,n,s,e)},renderPage:t=>{if(!t)return(0,_.jsx)("div",{className:"prompt-switch-page__empty",children:e("暂无工具")});const n=i.tools?.find(e=>e.runtime_name===t.id);return n?(0,_.jsxs)("div",{className:"prompt-switch-page__detail",children:[(0,_.jsx)("div",{className:"prompt-switch-page__detail-title",children:n.display_name}),(0,_.jsx)("div",{className:"prompt-switch-page__detail-desc",children:n.description||e("无描述")}),(0,_.jsxs)("div",{className:"prompt-switch-page__detail-row",children:[(0,_.jsx)("strong",{children:"runtime:"})," ",n.runtime_name]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("strong",{children:"schema:"}),(0,_.jsx)("pre",{className:"prompt-switch-page__schema",children:JSON.stringify(n.input_schema??{},null,2)})]})]}):(0,_.jsx)("div",{className:"prompt-switch-page__empty",children:e("暂无工具")})}}),cancel:()=>E({open:!1})})},ye=async e=>{for(let e=0;e<P.length;e++)P[e].index=e;let t={list:O,docs_update_tag:G.current};null!=e&&(t={param:e}),G.current=!1;(await m.XO.post("ai_docs_setting_save",t)).code===x.m.Success&&(0,j.SK)("保存成功")},Ce=async()=>{for(let e=0;e<oe.length;e++)oe[e].index=e;(await m.XO.post("ai_system_prompts/save",{list:oe})).code===x.m.Success&&(0,j.SK)("保存成功")};return(0,_.jsxs)("div",{children:[(0,_.jsx)(l.A,{children:ae(f.oV.ai_agent_setting)&&(0,_.jsx)(i.rA,{icon:"arrow_back",title:e("上一页"),onClick:()=>{de(-1)}})}),(0,_.jsx)(c.jW,{isFull:!0,more:!0,children:(0,_.jsx)(c.NN,{children:(0,_.jsxs)(c.xh,{children:[(0,_.jsx)(c.fI,{children:(0,_.jsx)(c.VP,{widthPer:100,children:(0,_.jsx)(u.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsx)("h2",{children:e("Model")+" "+e("设置")})," ",(0,_.jsx)(i.rA,{icon:"info",onClick:()=>{le('\n1. 只能使用符合openai风格的ai接口,接口不能只填域名,而是类似 https://ark.cn-beijing.volces.com/api/v3/chat/completions 这样的全路径链接聊天url\n2. 对话的历史越长,消耗的大模型token费用越贵,目前不具备长期记忆简化能力,可以在系统prompt中设置一下让AI回答的简洁一点,节省tokens\n3. model请求参数json编写,里面只能编写json,来用于编写openai风格ai支持的属性,比如 temperature thinking(豆包的深度思考开关)等\n4. 可以在model请求参数中开启 "stream":true 提高响应速度\n5. 深度思考现在会影响输出速度,建议设置`{\n "thinking" : { \n "type":"disabled"\n }\n}`关闭(豆包例子)\n6. 使用AI功能来查询服务器信息,那么AI就需要能够之一些命令,需要先在用户设置中,给用户设置命令权限,建议设置 `*` 允许全部命令,在设置禁止不能执行的危险命令。\n7. 成为tool 后,该模型将会作为一个工具被加载,可以实现不同模型作为不能角色的能力。\n8. model 类型是必须要设置的,因为不同类型的 model 接口格式不同。\n')},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"add",title:e("添加"),onClick:()=>{M([...P,{note:"",open:!1,path:"",dotenv:I.CP,json_params:I.cL}])}}),(0,_.jsx)(i.rA,{icon:"save",title:e("保存"),onClick:async()=>{await je()}})]}),children:(0,_.jsx)(d.X,{headers:n,rows:P.map((t,n)=>{const s=[(0,_.jsx)("div",{children:n}),(0,_.jsx)(p.Sm,{value:I.Lv.get_label_by_v(t.url,t.show_options?.options_agent_url_list),options:t.show_options?.options_agent_url_list,handleInputChange:e=>{t.url=e},no_border:!0}),(0,_.jsx)(p.l6,{value:t.request_type??"completions",onChange:e=>{t.request_type=e,M([...P])},options:K,no_border:!0}),(0,_.jsx)(p.l6,{value:t.open,onChange:e=>{((e,t,n)=>{const s=[];for(let e=0;e<P.length;e++)P[e].open=e===n&&t,s.push(P[e]);M(s)})(0,e,n)},options:ue,no_border:!0}),(0,_.jsx)(p.Sm,{type:I.Lv.have_label_by_v(t.token,t.show_options?.options_agent_key_list)?null:"password",value:I.Lv.get_label_by_v(t.token,t.show_options?.options_agent_key_list),options:t.show_options?.options_agent_key_list,handleInputChange:e=>{t.token=e},no_border:!0}),(0,_.jsx)(p.Sm,{value:I.Lv.get_label_by_v(t.model,t.show_options?.options_agent_model_list),options:t.show_options?.options_agent_model_list,handleInputChange:e=>{t.model=e},no_border:!0}),(0,_.jsx)(p.l6,{value:t.tool_mode,onChange:n=>{t.open&&!0===n?(0,j.zN)(e("开启状态不能成为tool")):(t.tool_mode=n,M([...P]))},options:ue,no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"short_text",title:"prompt",onClick:()=>{g.xK.set_value_temp(P[n].sys_prompt??""),ce({model:"ace/mode/text",open:!0,fileName:"",save:async e=>{P[n].sys_prompt=e,M(P),g.xK.set_value_temp(""),je(P)}})}}),(0,_.jsx)(i.rA,{icon:"edit_attributes",title:"model请求参数json编写",onClick:()=>{g.xK.set_value_temp(P[n].json_params),ce({model:"ace/mode/json",open:!0,fileName:"",save:async e=>{P[n].json_params=e,M(P),g.xK.set_value_temp(""),je(P)},can_format:!0})}}),(0,_.jsx)(i.rA,{icon:"settings",title:"额外参数设置",onClick:()=>{g.xK.set_value_temp(P[n].dotenv),ce({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{P[n].dotenv=e,M(P),g.xK.set_value_temp(""),je(P)}})}})]}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{P.splice(e,1),M([...P])})(n)}),(0,_.jsx)(i.rA,{icon:"copy_all",title:e("复制"),onClick:()=>(e=>{M([...P,{...P[e],open:!1}])})(n)})]})];return s}),width:"10rem"})})})}),(0,_.jsx)(c.fI,{children:(0,_.jsx)(c.VP,{widthPer:70,children:(0,_.jsx)(u.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsxs)("h2",{children:[e("MCP")+" "+e("设置")," - stdio"]})," ",(0,_.jsx)(i.rA,{icon:"info",onClick:()=>{le("\n1. 这里配置的是 MCP Client 启动参数,当前实现的是 stdio 模式,也就是通过 command + args 启动本地 MCP Server\n2. 例如可以填 npx / uvx / python 等命令,再配合对应的 MCP server 包参数\n3. 保存后会自动重新加载 MCP 工具,agent 聊天时会把这些工具一起带给模型\n4. 建议把 cwd 配到具体项目目录,避免 server 在错误目录里运行\n")},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"add",title:e("添加"),onClick:()=>_e("stdio")}),(0,_.jsx)(i.rA,{icon:"save",title:e("保存"),onClick:()=>{ve()}})]}),children:(0,_.jsx)(d.X,{headers:te,rows:Q.map((t,n)=>{const s=V.indexOf(t);return[(0,_.jsx)("div",{children:n}),(0,_.jsx)(p.Sm,{value:t.name,handleInputChange:e=>{t.name=e,q.current=!0},no_border:!0}),(0,_.jsx)(p.l6,{value:t.open,onChange:e=>{t.open=e,L([...V]),q.current=!0},options:ue,no_border:!0}),(0,_.jsx)(p.Sm,{value:t.command,handleInputChange:e=>{t.command=e,q.current=!0},no_border:!0}),(0,_.jsx)(p.Sm,{value:t.args,handleInputChange:e=>{t.args=e,q.current=!0},no_border:!0}),(0,_.jsx)(p.Sm,{value:t.cwd,handleInputChange:e=>{t.cwd=e,q.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"visibility",title:"查看工具",onClick:()=>{we(t,s)}}),(0,_.jsx)(i.rA,{icon:"settings",title:"env",onClick:()=>{g.xK.set_value_temp(t.env??""),ce({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{t.env=e,L([...V]),g.xK.set_value_temp(""),q.current=!0,ve()}})}})]}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e,q.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"delete",title:e("删除"),onClick:()=>me(t)}),(0,_.jsx)(i.rA,{icon:"copy_all",title:e("复制"),onClick:()=>xe(t)})]})]}),width:"10rem"})})})}),(0,_.jsx)(c.fI,{children:(0,_.jsxs)(c.VP,{widthPer:70,children:[(0,_.jsx)(u.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsxs)("h2",{children:[e("MCP")+" "+e("设置")," - HTTP"]})," "]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"add",title:e("添加"),onClick:()=>_e("http")}),(0,_.jsx)(i.rA,{icon:"save",title:e("保存"),onClick:()=>{ve()}})]}),children:(0,_.jsx)(d.X,{headers:ne,rows:ee.map((t,n)=>{const s=V.indexOf(t);return[(0,_.jsx)("div",{children:n}),(0,_.jsx)(p.Sm,{value:t.name,handleInputChange:e=>{t.name=e,q.current=!0},no_border:!0}),(0,_.jsx)(p.l6,{value:t.open,onChange:e=>{t.open=e,L([...V]),q.current=!0},options:ue,no_border:!0}),(0,_.jsx)(p.Sm,{value:t.endpoint,handleInputChange:e=>{t.endpoint=e,q.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"visibility",title:"查看工具",onClick:()=>{we(t,s)}}),(0,_.jsx)(i.rA,{icon:"settings",title:"headers",onClick:()=>{g.xK.set_value_temp(t.headers??""),ce({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{t.headers=e,L([...V]),g.xK.set_value_temp(""),q.current=!0,ve()}})}})]}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e,q.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"delete",title:e("删除"),onClick:()=>me(t)}),(0,_.jsx)(i.rA,{icon:"copy_all",title:e("复制"),onClick:()=>xe(t)})]})]}),width:"10rem"})}),(0,_.jsx)(u.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsx)("h2",{children:e("系统会话提示词")})," ",(0,_.jsx)(i.rA,{icon:"info",onClick:()=>{le('\n1. 系统会话提示词,在 AI 聊天页创建会话时可以选择,选中的提示词会自动填入聊天框作为第一条系统消息\n2. 适用于预先设定常用的会话场景模板,如"代码审查"、"翻译助手"、"运维诊断"等\n')},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"add",title:e("添加"),onClick:()=>{ie([...oe,{prompt:"",note:""}])}}),(0,_.jsx)(i.rA,{icon:"save",title:e("保存"),onClick:()=>{Ce()}})]}),children:(0,_.jsx)(d.X,{headers:se,rows:oe.map((t,n)=>{const s=[(0,_.jsx)("div",{children:n}),(0,_.jsx)("div",{children:(0,_.jsx)(i.rA,{icon:"short_text",title:e("提示词"),onClick:()=>{g.xK.set_value_temp(t.prompt??""),ce({model:"ace/mode/text",open:!0,fileName:"",save:async e=>{t.prompt=e,ie([...oe]),g.xK.set_value_temp(""),Ce()}})}})}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,_.jsx)("div",{children:(0,_.jsx)(i.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{oe.splice(e,1),ie([...oe])})(n)})})];return s}),width:"10rem"})})]})}),(0,_.jsxs)(c.fI,{children:[(0,_.jsx)(c.VP,{widthPer:50,children:(0,_.jsx)(u.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsx)("h2",{children:e("本地知识库")})," ",(0,_.jsx)(i.rA,{icon:"info",onClick:()=>{le("\n1. 本地知识库用于为AI增强理解能力,或者分析本地文件,原理读取本地的文件,对文件在内存中建立全文索引,为AI提供额外数据(需要有模型开启才能使用)\n2. 该功能只能用于小型知识库,作为本地小型或者公司内部资料使用还是没有问题的\n3. 每次保存都会重新加载知识库中的文件,不会全部重新加载,而是检测哪些文件有变更\n")},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(i.Ay,{checked:U,onChange:async e=>{await m.jV.post("docs_on_set",{status:e}),he(),t()},title:e("知识库开关")}),(0,_.jsx)(i.rA,{icon:"settings",title:"额外参数设置",onClick:()=>{g.xK.set_value_temp(Y.current),ce({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{Y.current=e,g.xK.set_value_temp(""),ye(Y.current)}})}}),(0,_.jsx)(i.rA,{icon:"add",title:e("添加"),onClick:()=>{X([...O,{note:"",auto_load:!1,dir:""}]),G.current=!0}}),(0,_.jsx)(i.rA,{icon:"save",title:e("保存"),onClick:()=>{ye()}})]}),children:(0,_.jsx)(d.X,{headers:N,rows:O.map((t,n)=>{const s=[(0,_.jsx)("div",{children:n}),(0,_.jsx)(p.Sm,{value:t.dir,handleInputChange:e=>{t.dir=e,G.current=!0},no_border:!0}),(0,_.jsx)(p.l6,{value:t.auto_load,onChange:e=>{t.auto_load=e,X([...O]),G.current=!0},options:ue,no_border:!0}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"delete",title:e("删除记录"),onClick:()=>(e=>{O.splice(e,1),X([...O]),G.current=!0})(n)}),(0,_.jsx)(i.rA,{icon:"restore",title:e("手动加载"),onClick:()=>{pe({sub_title:"手动加载",confirm_fun:()=>{m.jV.post("ai_load_one_file",{param_path:t.dir}),(0,j.SK)("ok")}})}}),(0,_.jsx)(i.rA,{icon:"delete_forever",title:e("从索引删除"),onClick:()=>{pe({sub_title:"从索引删除",confirm_fun:()=>{m.jV.post("ai_del",{param_path:t.dir}),(0,j.SK)("ok")}})}})]})];return s}),width:"10rem"})})}),H&&(0,_.jsx)(c.VP,{widthPer:50,children:(0,_.jsxs)(u.Zp,{title:e("知识库加载信息"),children:[(0,_.jsx)(c.Yh,{left:e("最近一次加载")+","+e("加载进度"),right:H?.progress}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总文件数量")}`,right:H?.num}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总文件字符数量")}`,right:H?.char_num}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总文件大小")}`,right:(0,k.v7)(H?.size)}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总耗时")}`,right:(0,k.a3)(H?.consume_time_ms_len)}),(0,_.jsx)(c.Yh,{left:`${e("总文件数量")}`,right:H?.total_num})]})})]})]})})})]})}},96494(e,t,n){n.d(t,{r:()=>o});var s=n(22022);function o(){const{t:e}=(0,s.Bd)();return[{value:"completions",label:e("文本对话")},{value:"images",label:e("图片生成")}]}},34299(e,t,n){n.r(t),n.d(t,{default:()=>m});n(96540);var s=n(73557),o=n(53995),i=n(18569),l=n(77979),a=n(8263),r=n(69428),c=n.n(r),d=(n(3775),n(21499)),p=n(99214),u=n(19878),h=(n(72411),n(74848));const _=new s.A({html:!0,highlight:function(e,t){if(t&&u.A.getLanguage(t))try{return`<pre class="hljs code-block-with-copy"><code class="hljs language-${t}">${u.A.highlight(e,{language:t}).value}</code></pre>`}catch(e){}try{return`<pre class="hljs code-block-with-copy"><code class="hljs">${u.A.highlightAuto(e).value}</code></pre>`}catch(e){}return`<pre class="hljs code-block-with-copy"><code>${_.utils.escapeHtml(e)}</code></pre>`}});function m(e){return(0,p.VD)(),(0,h.jsx)("div",{dangerouslySetInnerHTML:{__html:_.render(e.context)}})}_.use(o.A).use(i.A).use(l.A).use(a.A).use(c()).use(e=>{e.renderer.rules.fence;e.renderer.rules.fence=(t,n,s,o,i)=>{const l=t[n],a=l.content.trim(),r=l.info.trim();let c="";if(r&&u.A.getLanguage(r))try{c=u.A.highlight(a,{language:r}).value}catch(t){c=e.utils.escapeHtml(a)}else try{c=u.A.highlightAuto(a).value}catch(t){c=e.utils.escapeHtml(a)}return`\n <div class="code-block-with-copy">\n <div class="code-header">\n <span class="code-language">${r||"code"}</span>\n <button class="copy-btn" data-code="${e.utils.escapeHtml(a)}">复制</button>\n </div>\n <pre><code class="hljs ${r?`language-${r}`:""}">${c}</code></pre>\n </div>`}}).use(e=>{const t=e.renderer.rules.link_open||function(e,t,n,s,o){return o.renderToken(e,t,n)};e.renderer.rules.link_open=(e,n,s,o,i)=>{const l=e[n],a=l.attrIndex("href");if(a>=0){const e=l.attrs[a][1];l.attrs[a][1]=(0,d.bi)(window.location.href,e)}return t(e,n,s,o,i)}})},45907(e,t,n){n.d(t,{y:()=>i});var s=n(34843),o=n(82893);function i(){const[e,t]=(0,s.fp)(o.AG.confirm);return({sub_title:e,confirm_fun:n,title:s,context_div:o})=>{t({open:!0,sub_title:e,handle:()=>{n(),t({open:!1,handle:null})},title:s,context_div:o})}}},24659(e,t,n){var s=n(22022);n.d(t,["K",0,()=>{const{t:e}=(0,s.Bd)();return[{title:e("是"),value:!0,color:"#28a745"},{title:e("否"),value:!1,color:"#666666"}]}])},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>"}}]);
1
+ "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[6010,8302],{83277(e,t,n){n.d(t,{$j:()=>a,Lv:()=>o,qq:()=>i});class s{options_agent_url_list;options_agent_key_list;options_agent_model_list}class o{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 n of t)if(n.value===e)return n.label;return e}static have_label_by_v(e,t){if(!e||!t?.length)return!1;for(const n of t)if(n.value===e)return!0;return!1}}class i extends s{tool_error_max=50;tool_call_max=300;allow_exec_cmd_directly=!1;proxy_url}const l=JSON.stringify({stream:!0,thinking:{type:"disabled"}});function a(e){return"string"==typeof e?e:Array.isArray(e)?e.map(e=>"text"===e.type?e.text:"[图片]").join("\n"):""}n.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',"cL",0,l])},77481(e,t,n){n.d(t,{S:()=>l,X:()=>i});var s=n(96540),o=n(74848);function i(e){const[t,n]=s.useState([]);return(0,s.useEffect)(()=>{e.children?n(Array.isArray(e.children)?e.children:[e.children]):n(e.rows)},[e.rows,e.children]),(0,o.jsxs)("table",{children:[(0,o.jsx)("thead",{children:(0,o.jsx)("tr",{children:e.headers?.map((e,t)=>(0,o.jsx)("th",{children:e},t))})}),(0,o.jsx)("tbody",{children:t.map((t,n)=>(0,o.jsx)("tr",{onContextMenu:()=>{e.handleContextMenu&&e.handleContextMenu(t)},children:t.map((n,s)=>(0,o.jsx)("td",{style:{width:e.width??"auto"},className:s===t.length-1?"small":"",children:n},s))},n))})]})}function l(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))})}},29591(e,t,n){n.r(t),n.d(t,{default:()=>K});var s=n(22022),o=n(96540),i=n(85997),l=n(57952),a=n(34843),r=n(82893),c=n(75725),d=n(77481),p=n(61443),u=n(70447),h=n(34299),_=n(74848);var m=n(14284),x=n(53459),j=n(62042),v=n(7523),g=n(78247),f=n(23430),w=n(61973),y=n(14944),C=n(92275),k=n(88815),b=n(45907),A=n(12721),S=n(24659),I=n(83277),$=n(96494);function K(){const{t:e}=(0,s.Bd)(),{initUserInfo:t}=(0,o.useContext)(v.F),n=[e("编号"),e("url"),e("model类型"),e("是否开启"),e("key"),"model",e("成为tool"),e("更多属性"),e("备注")],K=(0,$.r)(),N=[e("编号"),e("本地目录"),e("自动加载"),e("备注")],[P,M]=(0,o.useState)([]),[O,X]=(0,o.useState)([]),[V,L]=(0,o.useState)([]),[H,F]=(0,o.useState)(null),Y=(0,o.useRef)(),q=(0,o.useRef)(!1),G=(0,o.useRef)(!1),[z,B]=(0,o.useState)([]),[R,T]=(0,o.useState)(!1),[D,E]=(0,a.fp)(r.AG.prompt_card),[J,Z]=(0,a.fp)(r.AG.user_base_info),[U,W]=(0,o.useState)(!1),Q=V.filter(e=>"http"!==(e.transport??"stdio")),ee=V.filter(e=>"http"===e.transport),te=[e("编号"),e("名称"),e("是否开启"),"command","args","cwd",e("tools|env"),e("备注")],ne=[e("编号"),e("名称"),e("是否开启"),e("endpoint"),e("tools|headers"),e("备注")],se=[e("编号"),e("提示词"),e("备注")],[oe,ie]=(0,o.useState)([]),le=function(){const[e,t]=(0,a.fp)(r.AG.prompt_card);return e=>{t({open:!0,title:"信息",context_div:(0,_.jsx)("div",{children:(0,_.jsx)(h.default,{context:e})})})}}(),{check_user_auth:ae}=(0,g.MH)(),[re,ce]=(0,a.fp)(r.AG.editorSetting),de=(0,w.Zp)(),pe=(0,b.y)(),ue=(0,S.K)(),he=async()=>{const e=await m.jV.get("docs_on_get");e.code===x.m.Success&&W(e.data)};(0,o.useEffect)(()=>{(async()=>{const e=await m.XO.get("ai_agent_setting");e.code===x.m.Success&&M(e.data.models),await y.ws.addMsg(C.HK.ai_load_info,e=>{F(e.context)});const t=await y.ws.sendData(C.HK.ai_load_info,{});t?.context&&F(t.context);const n=await m.XO.get("ai_docs_setting");n.code===x.m.Success&&(Y.current=n.data.param,n.data.list?.length&&X(n.data.list));const s=await m.XO.get("ai_mcp_setting");s.code===x.m.Success&&L(s.data.list??[]),await ge(),he();const o=await m.XO.get("ai_system_prompts");o.code===x.m.Success&&ie(o.data??[])})()},[]);const _e=(e="stdio")=>{const t="http"===e?{name:"",open:!1,note:"",transport:"http",endpoint:"",headers:"",stream:!1,timeout_ms:1e4}:{name:"",open:!1,command:"",args:"",cwd:"",env:"",note:"",transport:"stdio",timeout_ms:1e4};L([...V,t]),q.current=!0},me=e=>{const t=V.indexOf(e);t<0||(V.splice(t,1),L([...V]),q.current=!0)},xe=e=>{L([...V,{...e,open:!1}]),q.current=!0},je=async e=>{for(let e=0;e<P.length;e++)P[e].index=e;(await m.XO.post("ai_agent_setting/save",{models:e??P})).code===x.m.Success&&(0,j.SK)("保存成功")},ve=async e=>{for(let e=0;e<V.length;e++)V[e].index=e;(await m.XO.post("ai_mcp_setting/save",{list:e??V})).code===x.m.Success&&((0,j.SK)("保存成功"),q.current=!1,await ge())},ge=async()=>{const e=await m.XO.get("ai_mcp_tools");return e.code===x.m.Success?(B(e.data??[]),e.data??[]):[]},fe=async e=>{T(!0);try{const t=await m.XO.post("ai_mcp_tools/reload",{index:e});if(t.code===x.m.Success)return await ge(),(0,j.SK)("MCP工具加载成功"),t.data??null}finally{T(!1)}return null},we=async(t,n,s,o)=>{const i=o??z.find(e=>e.index===n)??{index:n,key:`${n}`,name:t.name??"",note:t.note,transport:t.transport??"stdio",open:!!t.open,loaded:!1,tool_count:0,tools:[]},l=(i.tools??[]).map(t=>({id:t.runtime_name,title:t.tool_name,subtitle:t.description||e("无描述"),detail:t.display_name,meta:t.runtime_name}));E({open:!0,title:`${t.name||t.note||n} MCP工具`,context_div:(0,_.jsx)(A.O,{title:`${t.name||t.note||n} MCP工具`,subtitle:`${i.transport??"stdio"} | ${i.open?e("是"):e("否")} | ${i.loaded?"loaded":"idle"} | ${i.tool_count} tools`,pages:l,initialPageId:s,onRefresh:async()=>{const e=await fe(n);e&&await we(t,n,s,e)},renderPage:t=>{if(!t)return(0,_.jsx)("div",{className:"prompt-switch-page__empty",children:e("暂无工具")});const n=i.tools?.find(e=>e.runtime_name===t.id);return n?(0,_.jsxs)("div",{className:"prompt-switch-page__detail",children:[(0,_.jsx)("div",{className:"prompt-switch-page__detail-title",children:n.display_name}),(0,_.jsx)("div",{className:"prompt-switch-page__detail-desc",children:n.description||e("无描述")}),(0,_.jsxs)("div",{className:"prompt-switch-page__detail-row",children:[(0,_.jsx)("strong",{children:"runtime:"})," ",n.runtime_name]}),(0,_.jsxs)("div",{children:[(0,_.jsx)("strong",{children:"schema:"}),(0,_.jsx)("pre",{className:"prompt-switch-page__schema",children:JSON.stringify(n.input_schema??{},null,2)})]})]}):(0,_.jsx)("div",{className:"prompt-switch-page__empty",children:e("暂无工具")})}}),cancel:()=>E({open:!1})})},ye=async e=>{for(let e=0;e<P.length;e++)P[e].index=e;let t={list:O,docs_update_tag:G.current};null!=e&&(t={param:e}),G.current=!1;(await m.XO.post("ai_docs_setting_save",t)).code===x.m.Success&&(0,j.SK)("保存成功")},Ce=async()=>{for(let e=0;e<oe.length;e++)oe[e].index=e;(await m.XO.post("ai_system_prompts/save",{list:oe})).code===x.m.Success&&(0,j.SK)("保存成功")};return(0,_.jsxs)("div",{children:[(0,_.jsx)(l.A,{children:ae(f.oV.ai_agent_setting)&&(0,_.jsx)(i.rA,{icon:"arrow_back",title:e("上一页"),onClick:()=>{de(-1)}})}),(0,_.jsx)(c.jW,{isFull:!0,more:!0,children:(0,_.jsx)(c.NN,{children:(0,_.jsxs)(c.xh,{children:[(0,_.jsx)(c.fI,{children:(0,_.jsx)(c.VP,{widthPer:100,children:(0,_.jsx)(u.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsx)("h2",{children:e("Model")+" "+e("设置")})," ",(0,_.jsx)(i.rA,{icon:"info",onClick:()=>{le('\n1. 只能使用符合openai风格的ai接口,接口不能只填域名,而是类似 https://ark.cn-beijing.volces.com/api/v3/chat/completions 这样的全路径链接聊天url\n2. 对话的历史越长,消耗的大模型token费用越贵,目前不具备长期记忆简化能力,可以在系统prompt中设置一下让AI回答的简洁一点,节省tokens\n3. model请求参数json编写,里面只能编写json,来用于编写openai风格ai支持的属性,比如 temperature thinking(豆包的深度思考开关)等\n4. 可以在model请求参数中开启 "stream":true 提高响应速度\n5. 深度思考现在会影响输出速度,建议设置`{\n "thinking" : { \n "type":"disabled"\n }\n}`关闭(豆包例子)\n6. 使用AI功能来查询服务器信息,那么AI就需要能够之一些命令,需要先在用户设置中,给用户设置命令权限,建议设置 `*` 允许全部命令,在设置禁止不能执行的危险命令。\n7. 成为tool 后,该模型将会作为一个工具被加载,可以实现不同模型作为不能角色的能力。\n8. model 类型是必须要设置的,因为不同类型的 model 接口格式不同。\n')},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"add",title:e("添加"),onClick:()=>{M([...P,{note:"",open:!1,path:"",dotenv:I.CP,json_params:I.cL}])}}),(0,_.jsx)(i.rA,{icon:"save",title:e("保存"),onClick:async()=>{await je()}})]}),children:(0,_.jsx)(d.X,{headers:n,rows:P.map((t,n)=>{const s=[(0,_.jsx)("div",{children:n}),(0,_.jsx)(p.Sm,{value:I.Lv.get_label_by_v(t.url,t.show_options?.options_agent_url_list),options:t.show_options?.options_agent_url_list,handleInputChange:e=>{t.url=e},no_border:!0}),(0,_.jsx)(p.l6,{value:t.request_type??"completions",onChange:e=>{t.request_type=e,M([...P])},options:K,no_border:!0}),(0,_.jsx)(p.l6,{value:t.open,onChange:e=>{((e,t,n)=>{const s=[];for(let e=0;e<P.length;e++)P[e].open=e===n&&t,s.push(P[e]);M(s)})(0,e,n)},options:ue,no_border:!0}),(0,_.jsx)(p.Sm,{type:I.Lv.have_label_by_v(t.token,t.show_options?.options_agent_key_list)?null:"password",value:I.Lv.get_label_by_v(t.token,t.show_options?.options_agent_key_list),options:t.show_options?.options_agent_key_list,handleInputChange:e=>{t.token=e},no_border:!0}),(0,_.jsx)(p.Sm,{value:I.Lv.get_label_by_v(t.model,t.show_options?.options_agent_model_list),options:t.show_options?.options_agent_model_list,handleInputChange:e=>{t.model=e},no_border:!0}),(0,_.jsx)(p.l6,{value:t.tool_mode,onChange:n=>{t.open&&!0===n?(0,j.zN)(e("开启状态不能成为tool")):(t.tool_mode=n,M([...P]))},options:ue,no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"short_text",title:"prompt",onClick:()=>{g.xK.set_value_temp(P[n].sys_prompt??""),ce({model:"ace/mode/text",open:!0,fileName:"",save:async e=>{P[n].sys_prompt=e,M(P),g.xK.set_value_temp(""),je(P)}})}}),(0,_.jsx)(i.rA,{icon:"edit_attributes",title:"model请求参数json编写",onClick:()=>{g.xK.set_value_temp(P[n].json_params),ce({model:"ace/mode/json",open:!0,fileName:"",save:async e=>{P[n].json_params=e,M(P),g.xK.set_value_temp(""),je(P)},can_format:!0})}}),(0,_.jsx)(i.rA,{icon:"settings",title:"额外参数设置",onClick:()=>{g.xK.set_value_temp(P[n].dotenv),ce({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{P[n].dotenv=e,M(P),g.xK.set_value_temp(""),je(P)}})}})]}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{P.splice(e,1),M([...P])})(n)}),(0,_.jsx)(i.rA,{icon:"copy_all",title:e("复制"),onClick:()=>(e=>{M([...P,{...P[e],open:!1}])})(n)})]})];return s}),width:"10rem"})})})}),(0,_.jsx)(c.fI,{children:(0,_.jsx)(c.VP,{widthPer:70,children:(0,_.jsx)(u.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsxs)("h2",{children:[e("MCP")+" "+e("设置")," - stdio"]})," ",(0,_.jsx)(i.rA,{icon:"info",onClick:()=>{le("\n1. 这里配置的是 MCP Client 启动参数,当前实现的是 stdio 模式,也就是通过 command + args 启动本地 MCP Server\n2. 例如可以填 npx / uvx / python 等命令,再配合对应的 MCP server 包参数\n3. 保存后会自动重新加载 MCP 工具,agent 聊天时会把这些工具一起带给模型\n4. 建议把 cwd 配到具体项目目录,避免 server 在错误目录里运行\n")},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"add",title:e("添加"),onClick:()=>_e("stdio")}),(0,_.jsx)(i.rA,{icon:"save",title:e("保存"),onClick:()=>{ve()}})]}),children:(0,_.jsx)(d.X,{headers:te,rows:Q.map((t,n)=>{const s=V.indexOf(t);return[(0,_.jsx)("div",{children:n}),(0,_.jsx)(p.Sm,{value:t.name,handleInputChange:e=>{t.name=e,q.current=!0},no_border:!0}),(0,_.jsx)(p.l6,{value:t.open,onChange:e=>{t.open=e,L([...V]),q.current=!0},options:ue,no_border:!0}),(0,_.jsx)(p.Sm,{value:t.command,handleInputChange:e=>{t.command=e,q.current=!0},no_border:!0}),(0,_.jsx)(p.Sm,{value:t.args,handleInputChange:e=>{t.args=e,q.current=!0},no_border:!0}),(0,_.jsx)(p.Sm,{value:t.cwd,handleInputChange:e=>{t.cwd=e,q.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"visibility",title:"查看工具",onClick:()=>{we(t,s)}}),(0,_.jsx)(i.rA,{icon:"settings",title:"env",onClick:()=>{g.xK.set_value_temp(t.env??""),ce({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{t.env=e,L([...V]),g.xK.set_value_temp(""),q.current=!0,ve()}})}})]}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e,q.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"delete",title:e("删除"),onClick:()=>me(t)}),(0,_.jsx)(i.rA,{icon:"copy_all",title:e("复制"),onClick:()=>xe(t)})]})]}),width:"10rem"})})})}),(0,_.jsx)(c.fI,{children:(0,_.jsxs)(c.VP,{widthPer:70,children:[(0,_.jsx)(u.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsxs)("h2",{children:[e("MCP")+" "+e("设置")," - HTTP"]})," "]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"add",title:e("添加"),onClick:()=>_e("http")}),(0,_.jsx)(i.rA,{icon:"save",title:e("保存"),onClick:()=>{ve()}})]}),children:(0,_.jsx)(d.X,{headers:ne,rows:ee.map((t,n)=>{const s=V.indexOf(t);return[(0,_.jsx)("div",{children:n}),(0,_.jsx)(p.Sm,{value:t.name,handleInputChange:e=>{t.name=e,q.current=!0},no_border:!0}),(0,_.jsx)(p.l6,{value:t.open,onChange:e=>{t.open=e,L([...V]),q.current=!0},options:ue,no_border:!0}),(0,_.jsx)(p.Sm,{value:t.endpoint,handleInputChange:e=>{t.endpoint=e,q.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"visibility",title:"查看工具",onClick:()=>{we(t,s)}}),(0,_.jsx)(i.rA,{icon:"settings",title:"headers",onClick:()=>{g.xK.set_value_temp(t.headers??""),ce({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{t.headers=e,L([...V]),g.xK.set_value_temp(""),q.current=!0,ve()}})}})]}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e,q.current=!0},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"delete",title:e("删除"),onClick:()=>me(t)}),(0,_.jsx)(i.rA,{icon:"copy_all",title:e("复制"),onClick:()=>xe(t)})]})]}),width:"10rem"})}),(0,_.jsx)(u.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsx)("h2",{children:e("系统会话提示词")})," ",(0,_.jsx)(i.rA,{icon:"info",onClick:()=>{le('\n1. 系统会话提示词,在 AI 聊天页创建会话时可以选择,选中的提示词会自动填入聊天框作为第一条系统消息\n2. 适用于预先设定常用的会话场景模板,如"代码审查"、"翻译助手"、"运维诊断"等\n')},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"add",title:e("添加"),onClick:()=>{ie([...oe,{prompt:"",note:""}])}}),(0,_.jsx)(i.rA,{icon:"save",title:e("保存"),onClick:()=>{Ce()}})]}),children:(0,_.jsx)(d.X,{headers:se,rows:oe.map((t,n)=>{const s=[(0,_.jsx)("div",{children:n}),(0,_.jsx)("div",{children:(0,_.jsx)(i.rA,{icon:"short_text",title:e("提示词"),onClick:()=>{g.xK.set_value_temp(t.prompt??""),ce({model:"ace/mode/text",open:!0,fileName:"",save:async e=>{t.prompt=e,ie([...oe]),g.xK.set_value_temp(""),Ce()}})}})}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,_.jsx)("div",{children:(0,_.jsx)(i.rA,{icon:"delete",title:e("删除"),onClick:()=>(e=>{oe.splice(e,1),ie([...oe])})(n)})})];return s}),width:"10rem"})})]})}),(0,_.jsxs)(c.fI,{children:[(0,_.jsx)(c.VP,{widthPer:50,children:(0,_.jsx)(u.uF,{self_title:(0,_.jsxs)("span",{className:" div-row ",children:[(0,_.jsx)("h2",{children:e("本地知识库")})," ",(0,_.jsx)(i.rA,{icon:"info",onClick:()=>{le("\n1. 本地知识库用于为AI增强理解能力,或者分析本地文件,原理读取本地的文件,对文件在内存中建立全文索引,为AI提供额外数据(需要有模型开启才能使用)\n2. 该功能只能用于小型知识库,作为本地小型或者公司内部资料使用还是没有问题的\n3. 每次保存都会重新加载知识库中的文件,不会全部重新加载,而是检测哪些文件有变更\n")},title:"信息"})]}),titleCom:(0,_.jsxs)("div",{children:[(0,_.jsx)(i.Ay,{checked:U,onChange:async e=>{await m.jV.post("docs_on_set",{status:e}),he(),t()},title:e("知识库开关")}),(0,_.jsx)(i.rA,{icon:"settings",title:"额外参数设置",onClick:()=>{g.xK.set_value_temp(Y.current),ce({model:"ace/mode/ini",open:!0,fileName:"",save:async e=>{Y.current=e,g.xK.set_value_temp(""),ye(Y.current)}})}}),(0,_.jsx)(i.rA,{icon:"add",title:e("添加"),onClick:()=>{X([...O,{note:"",auto_load:!1,dir:""}]),G.current=!0}}),(0,_.jsx)(i.rA,{icon:"save",title:e("保存"),onClick:()=>{ye()}})]}),children:(0,_.jsx)(d.X,{headers:N,rows:O.map((t,n)=>{const s=[(0,_.jsx)("div",{children:n}),(0,_.jsx)(p.Sm,{value:t.dir,handleInputChange:e=>{t.dir=e,G.current=!0},no_border:!0}),(0,_.jsx)(p.l6,{value:t.auto_load,onChange:e=>{t.auto_load=e,X([...O]),G.current=!0},options:ue,no_border:!0}),(0,_.jsx)(p.Sm,{value:t.note,handleInputChange:e=>{t.note=e},no_border:!0}),(0,_.jsxs)("div",{children:[(0,_.jsx)(i.rA,{icon:"delete",title:e("删除记录"),onClick:()=>(e=>{O.splice(e,1),X([...O]),G.current=!0})(n)}),(0,_.jsx)(i.rA,{icon:"restore",title:e("手动加载"),onClick:()=>{pe({sub_title:"手动加载",confirm_fun:()=>{m.jV.post("ai_load_one_file",{param_path:t.dir}),(0,j.SK)("ok")}})}}),(0,_.jsx)(i.rA,{icon:"delete_forever",title:e("从索引删除"),onClick:()=>{pe({sub_title:"从索引删除",confirm_fun:()=>{m.jV.post("ai_del",{param_path:t.dir}),(0,j.SK)("ok")}})}})]})];return s}),width:"10rem"})})}),H&&(0,_.jsx)(c.VP,{widthPer:50,children:(0,_.jsxs)(u.Zp,{title:e("知识库加载信息"),children:[(0,_.jsx)(c.Yh,{left:e("最近一次加载")+","+e("加载进度"),right:H?.progress}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总文件数量")}`,right:H?.num}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总文件字符数量")}`,right:H?.char_num}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总文件大小")}`,right:(0,k.v7)(H?.size)}),(0,_.jsx)(c.Yh,{left:`${e("最近一次加载")},${e("总耗时")}`,right:(0,k.a3)(H?.consume_time_ms_len)}),(0,_.jsx)(c.Yh,{left:`${e("总文件数量")}`,right:H?.total_num})]})})]})]})})})]})}},96494(e,t,n){n.d(t,{r:()=>o});var s=n(22022);function o(){const{t:e}=(0,s.Bd)();return[{value:"completions",label:e("文本对话")},{value:"images",label:e("图片生成")}]}},34299(e,t,n){n.r(t),n.d(t,{default:()=>m});n(96540);var s=n(73557),o=n(53995),i=n(18569),l=n(77979),a=n(8263),r=n(69428),c=n.n(r),d=(n(3775),n(21499)),p=n(99214),u=n(19878),h=(n(72411),n(74848));const _=new s.A({html:!0,highlight:function(e,t){if(t&&u.A.getLanguage(t))try{return`<pre class="hljs code-block-with-copy"><code class="hljs language-${t}">${u.A.highlight(e,{language:t}).value}</code></pre>`}catch(e){}try{return`<pre class="hljs code-block-with-copy"><code class="hljs">${u.A.highlightAuto(e).value}</code></pre>`}catch(e){}return`<pre class="hljs code-block-with-copy"><code>${_.utils.escapeHtml(e)}</code></pre>`}});function m(e){return(0,p.VD)(),(0,h.jsx)("div",{dangerouslySetInnerHTML:{__html:_.render(e.context)}})}_.use(o.A).use(i.A).use(l.A).use(a.A).use(c()).use(e=>{e.renderer.rules.fence;e.renderer.rules.fence=(t,n,s,o,i)=>{const l=t[n],a=l.content.trim(),r=l.info.trim();let c="";if(r&&u.A.getLanguage(r))try{c=u.A.highlight(a,{language:r}).value}catch(t){c=e.utils.escapeHtml(a)}else try{c=u.A.highlightAuto(a).value}catch(t){c=e.utils.escapeHtml(a)}return`\n <div class="code-block-with-copy">\n <div class="code-header">\n <span class="code-language">${r||"code"}</span>\n <button class="copy-btn" data-code="${e.utils.escapeHtml(a)}">复制</button>\n </div>\n <pre><code class="hljs ${r?`language-${r}`:""}">${c}</code></pre>\n </div>`}}).use(e=>{const t=e.renderer.rules.link_open||function(e,t,n,s,o){return o.renderToken(e,t,n)};e.renderer.rules.link_open=(e,n,s,o,i)=>{const l=e[n],a=l.attrIndex("href");if(a>=0){const e=l.attrs[a][1];l.attrs[a][1]=(0,d.bi)(window.location.href,e)}return t(e,n,s,o,i)}})},45907(e,t,n){n.d(t,{y:()=>i});var s=n(34843),o=n(82893);function i(){const[e,t]=(0,s.fp)(o.AG.confirm);return({sub_title:e,confirm_fun:n,title:s,context_div:o})=>{t({open:!0,sub_title:e,handle:()=>{n(),t({open:!1,handle:null})},title:s,context_div:o})}}},24659(e,t,n){var s=n(22022);n.d(t,["K",0,()=>{const{t:e}=(0,s.Bd)();return[{title:e("是"),value:!0,color:"#28a745"},{title:e("否"),value:!1,color:"#666666"}]}])},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>"}}]);
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[8603],{58603(e,t,i){i.r(t),i.d(t,{default:()=>$});var n=i(96540),s=i(75725),r=i(70447),a=i(34843),l=i(82893),o=i(60096),c=i(85997),d=i(34251),m=i(34289),h=i(87361),_=i(14284),u=i(53459),x=i(61443),f=i(22022),p=i(62042),j=(i(47022),i(57952)),k=i(99214),w=i(6960),g=i(88815),v=i(78247),z=i(40505),F=i(23430),b=i(64694),C=i(52671),N=i(74848);function $(){const[e,t]=(0,n.useState)(null),i=(0,n.useRef)(""),$=(0,n.useRef)(""),[y,S]=(0,a.fp)(l.AG.prompt_card),[A,M]=(0,a.fp)(l.AG.share_sort_type),{t:G}=(0,f.Bd)(),[I,U]=(0,a.fp)(l.AG.selectedFileList),[V,W]=(0,a.fp)(l.AG.clickFileList),{click_file:D}=(0,v.kZ)(),[L]=(0,C.ok)(),R=(0,k.oT)(),B=(0,k.xp)(),H=(0,k.Vs)(!0),T=(0,n.useMemo)(()=>{const t=[...e?.items??[]],i=e=>Number(e.mtime??0);return A===F.t8.time_minx_max?t.sort((e,t)=>i(e)-i(t)):A===F.t8.time_max_min&&t.sort((e,t)=>i(t)-i(e)),t},[e?.items,A]),E=async()=>{const e=await _.$M.post("share",{id:i.current,token:$.current});if(e.code===u.m.Success){const n={is_dir:e.data.is_dir};n.items=e.data.files??[];for(const e of n.items)e.origin_size=e.size,e.show_mtime=e.mtime?(0,w.s)(e.mtime):"",e.size=(0,g.v7)(e.size);if(!n.is_dir){const t=e.data.files[0];n.name=t.name,n.size=t.size,n.show_mtime=t.show_mtime}localStorage.setItem(`file_share_token_${i.current}`,$.current);const s=L.get("share_preview_file_name");if(s)try{const t=e.data.files.find(e=>e.name===s);D({file_path:t.path,file_url:_.$M.getDownloadUrlV2(t.path,"share_download",{share_id:i.current,share_token:$.current}),name:t.name,size:t.origin_size,opt_shell:!0,mtime:t.mtime,not_type_tip:G("未知类型,请下载查看"),close:()=>{R("share_preview_file_name",null)}})}catch(e){(0,p.zN)(e?.message||e)}else t(n)}else e.code===u.m.need_token_share&&(localStorage.removeItem(`file_share_token_${i.current}`),(0,p.zN)("需要正确的访问token"),S({open:!0,title:"share file",confirm:()=>{S({open:!1}),E()},context_div:(0,N.jsx)("div",{className:"card-content",children:(0,N.jsx)(x.Sm,{placeholderOut:G("请输入访问token"),value:"",handleInputChange:e=>{$.current=e}})})}))};if((0,n.useEffect)(()=>{const e=(0,m.oW)(`${(0,m.GG)(h.o.share,(0,m.vX)())}`);i.current=e,$.current=localStorage.getItem(`file_share_token_${e}`),E()},[L]),!e)return(0,N.jsx)(s.jW,{isFull:!0,children:(0,N.jsx)("div",{className:"common-box common-box-center",children:"Loading..."})});return(0,N.jsxs)(n.Fragment,{children:[(0,N.jsxs)(j.A,{left_children:(0,N.jsx)(N.Fragment,{children:(0,N.jsxs)("h2",{children:["Share ",e.is_dir?"Folder":"File"]})}),children:[I.length>0&&(0,N.jsx)(c.rA,{icon:"download",title:G("下载"),onClick:function(){const e=[];for(let t=0;t<I.length;t++){const i=T[I[t]];e.push(encodeURIComponent(i.path))}const t=_.$M.getDownloadUrlV2(e,"share_download",{share_id:i.current,share_token:$.current});window.open(t)}}),e.is_dir&&(0,N.jsx)(c.rA,{icon:"grid_view",title:G("切换样式"),onClick:H}),e.is_dir&&(0,N.jsx)(c.rA,{icon:"schedule",title:A===F.t8.time_minx_max?G("时间逆序"):G("时间顺序"),onClick:()=>{const e=(0,b.jH)([F.t8.time_max_min,F.t8.time_minx_max,F.t8.defualt],A);M(e),U([]),W([])}})]}),(0,N.jsx)(s.xh,{children:(0,N.jsx)(s.jW,{isFull:!0,children:(0,N.jsx)("div",{className:"common-box ",children:e.is_dir?(0,N.jsx)(o.QW,{share:{share_id:i.current,share_token:$.current},handleContextMenu:()=>{},file_list:T,clickBlank:e=>{e.target===e.currentTarget&&(U([]),W([]))}}):(0,N.jsx)(r.uF,{children:(0,N.jsxs)("div",{style:{height:"25rem"},className:"common-box common-box-center",children:[(0,N.jsx)("div",{className:"file-icons",children:(0,N.jsx)("div",{"data-type":(0,d.uL)(e.name),"data-dir":e.is_dir,"aria-label":e.name,children:(0,N.jsx)(c.In,{icon:"",style:{fontSize:"10rem",display:"inline-block",lineHeight:1},aria_label:e.name})})}),(0,N.jsx)("div",{className:"",children:e.name}),(0,N.jsx)("div",{className:"",children:e.size}),(0,N.jsx)("div",{className:"",children:e.show_mtime}),(0,N.jsx)(c.C3,{text:"download",clickFun:()=>{const e=T[0],t=_.$M.getDownloadUrlV2(e.path,"share_download",{share_id:i.current,share_token:$.current});window.open(t)}}),(0,N.jsx)(c.C3,{text:"copy url",clickFun:()=>{const e=T[0],t=_.$M.getDownloadUrlV2(e.path,"share_download",{share_id:i.current,share_token:$.current}),n=_.$M.get_full_url(t);(0,z.lW)(n),(0,p.SK)(n)}}),(0,N.jsx)(c.C3,{text:"preview",clickFun:()=>{const e=T[0];B(e.name)}})]})})})})})]})}}}]);
1
+ "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[8603],{58603(e,t,i){i.r(t),i.d(t,{default:()=>$});var n=i(96540),s=i(75725),r=i(70447),a=i(34843),l=i(82893),o=i(60096),c=i(85997),d=i(34251),m=i(34289),h=i(87361),_=i(14284),u=i(53459),x=i(61443),f=i(22022),p=i(62042),j=(i(47022),i(57952)),k=i(99214),w=i(6960),g=i(88815),v=i(78247),z=i(40505),F=i(23430),b=i(64694),C=i(61973),N=i(74848);function $(){const[e,t]=(0,n.useState)(null),i=(0,n.useRef)(""),$=(0,n.useRef)(""),[y,S]=(0,a.fp)(l.AG.prompt_card),[A,M]=(0,a.fp)(l.AG.share_sort_type),{t:G}=(0,f.Bd)(),[I,U]=(0,a.fp)(l.AG.selectedFileList),[V,W]=(0,a.fp)(l.AG.clickFileList),{click_file:D}=(0,v.kZ)(),[L]=(0,C.ok)(),R=(0,k.oT)(),B=(0,k.xp)(),H=(0,k.Vs)(!0),T=(0,n.useMemo)(()=>{const t=[...e?.items??[]],i=e=>Number(e.mtime??0);return A===F.t8.time_minx_max?t.sort((e,t)=>i(e)-i(t)):A===F.t8.time_max_min&&t.sort((e,t)=>i(t)-i(e)),t},[e?.items,A]),E=async()=>{const e=await _.$M.post("share",{id:i.current,token:$.current});if(e.code===u.m.Success){const n={is_dir:e.data.is_dir};n.items=e.data.files??[];for(const e of n.items)e.origin_size=e.size,e.show_mtime=e.mtime?(0,w.s)(e.mtime):"",e.size=(0,g.v7)(e.size);if(!n.is_dir){const t=e.data.files[0];n.name=t.name,n.size=t.size,n.show_mtime=t.show_mtime}localStorage.setItem(`file_share_token_${i.current}`,$.current);const s=L.get("share_preview_file_name");if(s)try{const t=e.data.files.find(e=>e.name===s);D({file_path:t.path,file_url:_.$M.getDownloadUrlV2(t.path,"share_download",{share_id:i.current,share_token:$.current}),name:t.name,size:t.origin_size,opt_shell:!0,mtime:t.mtime,not_type_tip:G("未知类型,请下载查看"),close:()=>{R("share_preview_file_name",null)}})}catch(e){(0,p.zN)(e?.message||e)}else t(n)}else e.code===u.m.need_token_share&&(localStorage.removeItem(`file_share_token_${i.current}`),(0,p.zN)("需要正确的访问token"),S({open:!0,title:"share file",confirm:()=>{S({open:!1}),E()},context_div:(0,N.jsx)("div",{className:"card-content",children:(0,N.jsx)(x.Sm,{placeholderOut:G("请输入访问token"),value:"",handleInputChange:e=>{$.current=e}})})}))};if((0,n.useEffect)(()=>{const e=(0,m.oW)(`${(0,m.GG)(h.o.share,(0,m.vX)())}`);i.current=e,$.current=localStorage.getItem(`file_share_token_${e}`),E()},[L]),!e)return(0,N.jsx)(s.jW,{isFull:!0,children:(0,N.jsx)("div",{className:"common-box common-box-center",children:"Loading..."})});return(0,N.jsxs)(n.Fragment,{children:[(0,N.jsxs)(j.A,{left_children:(0,N.jsx)(N.Fragment,{children:(0,N.jsxs)("h2",{children:["Share ",e.is_dir?"Folder":"File"]})}),children:[I.length>0&&(0,N.jsx)(c.rA,{icon:"download",title:G("下载"),onClick:function(){const e=[];for(let t=0;t<I.length;t++){const i=T[I[t]];e.push(encodeURIComponent(i.path))}const t=_.$M.getDownloadUrlV2(e,"share_download",{share_id:i.current,share_token:$.current});window.open(t)}}),e.is_dir&&(0,N.jsx)(c.rA,{icon:"grid_view",title:G("切换样式"),onClick:H}),e.is_dir&&(0,N.jsx)(c.rA,{icon:"schedule",title:A===F.t8.time_minx_max?G("时间逆序"):G("时间顺序"),onClick:()=>{const e=(0,b.jH)([F.t8.time_max_min,F.t8.time_minx_max,F.t8.defualt],A);M(e),U([]),W([])}})]}),(0,N.jsx)(s.xh,{children:(0,N.jsx)(s.jW,{isFull:!0,children:(0,N.jsx)("div",{className:"common-box ",children:e.is_dir?(0,N.jsx)(o.QW,{share:{share_id:i.current,share_token:$.current},handleContextMenu:()=>{},file_list:T,clickBlank:e=>{e.target===e.currentTarget&&(U([]),W([]))}}):(0,N.jsx)(r.uF,{children:(0,N.jsxs)("div",{style:{height:"25rem"},className:"common-box common-box-center",children:[(0,N.jsx)("div",{className:"file-icons",children:(0,N.jsx)("div",{"data-type":(0,d.uL)(e.name),"data-dir":e.is_dir,"aria-label":e.name,children:(0,N.jsx)(c.In,{icon:"",style:{fontSize:"10rem",display:"inline-block",lineHeight:1},aria_label:e.name})})}),(0,N.jsx)("div",{className:"",children:e.name}),(0,N.jsx)("div",{className:"",children:e.size}),(0,N.jsx)("div",{className:"",children:e.show_mtime}),(0,N.jsx)(c.C3,{text:"download",clickFun:()=>{const e=T[0],t=_.$M.getDownloadUrlV2(e.path,"share_download",{share_id:i.current,share_token:$.current});window.open(t)}}),(0,N.jsx)(c.C3,{text:"copy url",clickFun:()=>{const e=T[0],t=_.$M.getDownloadUrlV2(e.path,"share_download",{share_id:i.current,share_token:$.current}),n=_.$M.get_full_url(t);(0,z.lW)(n),(0,p.SK)(n)}}),(0,N.jsx)(c.C3,{text:"preview",clickFun:()=>{const e=T[0];B(e.name)}})]})})})})})]})}}}]);
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[8714],{47374(e,t,i){i.d(t,{e:()=>f});var o=i(96540),n=i(52671),s=i(64694),a=i(34289),r=i(61443),l=i(75725),c=i(22022),_=i(85997),d=i(74848);function f(e){let t=(0,n.zy)();const[i,f]=(0,o.useState)([]),[p,m]=(0,o.useState)("/"),[h,u]=(0,o.useState)(void 0),{t:w,i18n:v}=(0,c.Bd)();o.useEffect(()=>{let t="",i=(0,a.vX)().split("/");i=i.filter(e=>e);const o=i.indexOf(e.baseRoute),n=[];if(-1!=o){t=(0,s.IO)(i.slice(0,o),e.baseRoute);const a=i.slice(o+1);for(let e=0;e<a.length;e++){const i=a[e];n.push({value:i,href:0===e?`${t}${i}/`:(0,s.IO)(n[e-1].href,i)})}m(t),f(n)}},[t]);const y=t=>{t.stopPropagation(),e.clickFun(t)};return(0,d.jsx)("div",{className:"breadcrumbs",onClick:e=>{u(void 0!==h?void 0:"")},children:(0,d.jsx)(o.Fragment,{children:void 0===h?(0,d.jsxs)(o.Fragment,{children:[(0,d.jsx)("span",{className:"chevron",children:(0,d.jsx)(n.N_,{to:p,onClick:y,children:(0,d.jsx)(_.In,{icon:"home"})})}),i.map((e,t)=>(0,d.jsxs)("span",{className:"chevron",children:[(0,d.jsx)(_.In,{icon:"keyboard_arrow_right"}),(0,d.jsx)(n.N_,{to:e.href,onClick:y,children:decodeURIComponent(e.value)})]},t))]}):(0,d.jsx)(l.QM,{click:()=>{u(void 0)},children:(0,d.jsx)(r.Sm,{width:"100%",placeholder:w("输入跳转的目录"),handlerEnter:t=>{e.input_path_enter&&e.input_path_enter(t),u(void 0)}})})})})}},78714(e,t,i){i.r(t),i.d(t,{default:()=>N});var o=i(96540),n=i(47374),s=i(34843),a=i(82893),r=i(14284),l=i(52671),c=i(57952),_=i(27690),d=i(34289),f=i(53459),p=i(99214),m=i(61443),h=i(47022),u=i(62042),w=i(22022),v=i(7523),y=i(78247),g=i(88815),x=i(6960),k=i(47071),j=i(14944),G=i(92275),A=i(23430);var C=i(34251),b=i(60096),z=i(85997),P=i(23496),F=i(12730),M=i(75725),$=i(70447),S=i(87361),D=i(74848);let X={};function I(){const{t:e}=(0,w.Bd)();let t=(0,l.zy)();const i=(0,l.Zp)(),{check_user_auth:n}=(0,y.MH)(),[c,f]=(0,s.fp)(a.AG.nowFileList),[m,g]=(0,s.fp)(a.AG.uploadFiles),[x,k]=(0,s.fp)(a.AG.showPrompt),[b,P]=(0,s.fp)(a.AG.selectedFileList),[I,E]=(0,s.fp)(a.AG.copyedFileList),[K,Y]=(0,s.fp)(a.AG.cutedFileList),[L,R]=(0,s.fp)(a.AG.selectedFileList),[H,N]=(0,s.fp)(a.AG.clickFileList),[U,W]=(0,s.fp)(a.AG.fileShellShow),[B,O]=(0,s.fp)(a.AG.file_root_list),[Z,q]=(0,s.fp)(a.AG.file_root_index),[V,T]=(0,o.useState)(void 0),[J,Q]=(0,o.useState)(""),[ee,te]=(0,s.fp)(a.AG.workflow_show),[ie,oe]=(0,s.fp)(a.AG.workflow_realtime_show),[ne,se]=(0,s.fp)(a.AG.work_flow_show),{initUserInfo:ae}=(0,o.useContext)(v.F),[re,le]=(0,s.fp)(a.AG.user_base_info),{click_file:ce}=(0,y.kZ)(),[_e,de]=(0,s.fp)(a.AG.prompt_card),fe=(0,o.useMemo)(()=>c.files.reduce((e,t)=>e+(t.type!==h.Iw.folder?1:0),0),[c]),pe=(0,o.useMemo)(()=>c.files.reduce((e,t)=>e+(t.type===h.Iw.folder?1:0),0)+(c.folders?.length??0),[c]);function me(e){(0,u.SK)(e)}(0,o.useEffect)(()=>{X={}},[t]),(0,o.useEffect)(()=>()=>{W({show:!1,path:""})},[]);const he=(0,p.Vs)(),ue=t=>{de({open:!0,title:e("信息"),context_div:(0,D.jsxs)("div",{style:{maxWidth:"25rem"},children:[(0,D.jsx)(M.Yh,{left:e("挂载位置磁盘"),right:t?.total_size}),(0,D.jsx)(M.Yh,{left:`${e("磁盘剩余")}`,right:t?.left_size}),(0,D.jsx)(M.Yh,{left:`${e("文件系统")}`,right:t?.fs_type}),(0,D.jsx)(M.Yh,{left:`${e("文件夹数")}`,right:pe}),(0,D.jsx)(M.Yh,{left:`${e("文件数")}`,right:fe}),(0,D.jsx)(M.Yh,{left:`${e("当前位置")}`,right:(0,D.jsx)($.xP,{context:t?.now_absolute_path})})]}),cancel:()=>{j.ws.removeMsg(G.HK.file_info)}})};return(0,D.jsxs)(o.Fragment,{children:[b.length>0&&(0,D.jsx)(z.rA,{icon:"delete",title:e("删除"),onClick:()=>{k({show:!0,type:_.PromptEnum.FilesDelete,overlay:!0,data:{}})}}),b.length>0&&(0,D.jsx)(z.rA,{icon:"content_copy",title:e("复制"),onClick:function(){const e=(0,p.ib)(c,b);E(e.map(e=>(0,p.Ok)(e.name))),Y([]),me("已复制")}}),b.length>0&&(0,D.jsx)(z.rA,{icon:"content_cut",title:e("剪切"),onClick:function(){const e=(0,p.ib)(c,b);Y(e.map(e=>(0,p.Ok)(e.name))),E([]),me("已剪切")}}),(I.length>0||K.length>0)&&(0,D.jsx)(z.rA,{onClick:function(){k({show:!0,type:_.PromptEnum.Confirm,overlay:!0,data:{}})},icon:"content_paste",title:e("粘贴到此处"),tip:I.length+K.length}),b.length>0&&(0,D.jsx)(z.rA,{icon:"download",title:e("下载"),onClick:function(){const e=(0,p.ib)(c,b);for(let t=0;t<e.length;t++){const i=e[t];e[t]=encodeURIComponent((0,p.Ok)(i.name))}const t=r.$M.getDownloadUrl(e);window.open(t)}}),b.length>0&&(0,D.jsx)(z.rA,{icon:"compress",title:e("压缩"),onClick:function(){const e=(0,p.ib)(c,b);for(let t=0;t<e.length;t++){const i=e[t];e[t]=(0,p.Ok)(i.name)}e&&0!==e.length?k({show:!0,type:_.PromptEnum.Compress,overlay:!0,data:{files:e}}):(0,u.zN)("没有选中")}}),1===b.length&&(0,D.jsx)(z.rA,{icon:"edit_attributes",title:e("重命名"),onClick:function(){k({show:!0,type:_.PromptEnum.FileRename,overlay:!0,data:{}})}}),ne&&(0,D.jsx)(z.rA,{icon:"api",title:"workflow",onClick:()=>{te(!ee)}}),(0,D.jsx)(z.rA,{icon:"terminal",title:"shell",onClick:function(){U.show?W({show:!1,path:""}):W({show:!0,path:(0,d.GG)("file",(0,d.vX)())})}}),n(A.oV.share_file)&&(0,D.jsx)(z.rA,{icon:"share",title:e("文件分享"),onClick:()=>{i(`/${S.o.share_list_setting_page}`)}}),(0,D.jsx)(z.rA,{icon:"grid_view",title:e("切换样式"),onClick:he}),(0,D.jsx)(z.rA,{icon:"create_new_folder",title:e("创建文件夹"),onClick:function(){k({show:!0,type:_.PromptEnum.DirNew,overlay:!0,data:{dir:(0,d.GG)("file",(0,d.vX)())}})}}),(0,D.jsx)(z.rA,{icon:"note_add",title:e("创建文本文件"),onClick:function(){k({show:!0,type:_.PromptEnum.FileNew,overlay:!0,data:{dir:(0,d.GG)("file",(0,d.vX)())}})}}),(0,D.jsx)(z.rA,{icon:"upload_file",title:e("上传"),onClick:()=>{k({show:!0,type:_.PromptEnum.UploadFile,overlay:!0,data:{call:e=>{let t=e.currentTarget?.files;if(!t)return;let i=!!t[0].webkitRelativePath;const o=[],n=new Set;for(let e=0;e<t.length;e++){const s=t[e],a=i?s.webkitRelativePath:`${s.webkitRelativePath}${s.name}`;s.fullPath=a,i&&n.add((0,F.S)(a)),o.push(s)}const s=[];if(i)for(const e of n)s.push({isDir:!0,fullPath:e,name:e});s.push(...o),g(s),k({show:!0,type:_.PromptEnum.FilesUpload,overlay:!1,data:{}})}}})}}),(0,D.jsx)(z.rA,{icon:"info",title:e("信息"),onClick:async()=>{let e;if(!X.now_absolute_path){j.ws.addMsg(G.HK.file_info,t=>{const i=t.context;e&&(X={...X,...i},j.ws.removeMsg(G.HK.file_info),ue(X))});const t=await j.ws.sendData(G.HK.file_info,{type:h.Iw.folder,path:(0,d.GG)("file",(0,d.vX)())});e=t.context,X=e,ue(X)}ue(X)}}),(0,D.jsx)(z.rA,{icon:"more_vert",title:e("切换目录"),onClick:t=>{const o=new C.ik;o.x=t.clientX,o.y=t.clientY,o.type=h.Iw.directory,o.items=B,o.item_pre_value=Z,o.textClick=async t=>{if(-1===t)return i(`/${S.o.setting_private_env_setting}`),k({data:void 0,overlay:!1,type:"",show:!1}),void(0,u.N9)(e("请配置 文件夹路径"));(async e=>{q(e),await r.$M.post("base_switch",{root_index:e}),await ae(),i("/file/"),R([]),N([])})(t),k({data:void 0,overlay:!1,type:"",show:!1})},k({show:!0,type:_.PromptEnum.FileMenu,overlay:!1,data:o})}})]})}var E=i(2543),K=i(21499),Y=i(64694);const L=o.lazy(()=>Promise.all([i.e(7856),i.e(6349),i.e(3659)]).then(i.bind(i,63659))),R=o.lazy(()=>Promise.all([i.e(7856),i.e(1636)]).then(i.bind(i,81636)));let H;function N(){const[e,t]=(0,s.fp)(a.AG.editorSetting),[i,u]=(0,s.fp)(a.AG.file_preview),{t:F}=(0,w.Bd)();let M=(0,l.zy)();const $=(0,l.Zp)(),[X,N]=(0,s.fp)(a.AG.nowFileList),[U,W]=(0,s.fp)(a.AG.showPrompt),[B,O]=(0,s.fp)(a.AG.selectedFileList),[Z,q]=(0,s.fp)(a.AG.clickFileList),[V,T]=(0,s.fp)(a.AG.fileShellShow),[J,Q]=(0,o.useState)(""),[ee,te]=(0,s.fp)(a.AG.workflow_show),[ie,oe]=(0,s.fp)(a.AG.workflow_realtime_show),[ne,se]=(0,s.fp)(a.AG.work_flow_show),{initUserInfo:ae}=(0,o.useContext)(v.F),[re,le]=(0,s.fp)(a.AG.user_base_info),{click_file:ce}=(0,y.kZ)(),[_e,de]=(0,s.fp)(a.AG.to_running_files),[fe,pe]=(0,s.fp)(a.AG.file_page),[me]=(0,s.fp)(a.AG.blank_search_mode),[he,ue]=(0,s.fp)(a.AG.blank_search_mode_for_temp),we=function(){const[e,t]=(0,s.fp)(a.AG.user_base_info),{t:i}=(0,w.Bd)(),{check_user_auth:n}=(0,y.MH)(),[c,f]=(0,s.fp)(a.AG.router_jump),m=(0,l.Zp)(),{initUserInfo:u}=(0,o.useContext)(v.F),[g,x]=(0,s.fp)(a.AG.nowFileList),[k,b]=(0,s.fp)(a.AG.showPrompt),[z,F]=(0,s.fp)(a.AG.fileShellShow),[M,$]=(0,s.fp)(a.AG.blank_search_mode);return t=>{t.preventDefault(),t.stopPropagation();const o=new C.ik;o.x=t.clientX,o.y=t.clientY,o.type=h.Iw.directory;const s=[{r:(0,D.jsx)("span",{style:{color:e.user_data.dir_show_type===A.t8.time_minx_max?"green":void 0},children:i("时间逆序")}),v:A.t8.time_minx_max},{r:(0,D.jsx)("span",{style:{color:e.user_data.dir_show_type===A.t8.time_max_min?"green":void 0},children:i("时间顺序")}),v:A.t8.time_max_min}],a=[{r:(0,D.jsx)("span",{style:{color:e.user_data.dir_show_type===A.t8.size_min_max?"green":void 0},children:i("大小顺序")}),v:A.t8.size_min_max},{r:(0,D.jsx)("span",{style:{color:e.user_data.dir_show_type===A.t8.size_max_min?"green":void 0},children:i("大小逆序")}),v:A.t8.size_max_min}],l=[{r:(0,D.jsx)("span",{style:{color:e.user_data.file_list_pagination_mode&&e.user_data.file_list_pagination_mode!==A.yM.all?void 0:"green"},children:i("全部加载文件")}),v:A.yM.all},{r:(0,D.jsx)("span",{style:{color:e.user_data.file_list_pagination_mode===A.yM.pagination?"green":void 0},children:i("分页滚动加载文件")}),v:A.yM.pagination}],c=[{r:(0,D.jsx)("span",{style:{color:e.user_data.file_time_show_type&&e.user_data.file_time_show_type!==A.KD.current?void 0:"green"},children:i("最近时间")}),v:A.KD.current},{r:(0,D.jsx)("span",{style:{color:e.user_data.file_time_show_type===A.KD.time?"green":void 0},children:i("准确时间")}),v:A.KD.time}],w=[{r:i("文件列表展示"),items:[{r:i("文件排序"),v:"",items:[{r:(0,D.jsx)("span",{style:{color:e.user_data.dir_show_type?void 0:"green"},children:i("系统默认")}),v:A.t8.defualt},{r:(0,D.jsx)("span",{style:{color:e.user_data.dir_show_type===A.t8.name?"green":void 0},children:i("名字")}),v:A.t8.name},{r:(0,D.jsx)("span",{style:{color:e.user_data.dir_show_type===A.t8.time_minx_max||e.user_data.dir_show_type===A.t8.time_max_min?"green":void 0},children:i("修改时间")}),v:!1,items:s},{r:(0,D.jsx)("span",{style:{color:e.user_data.dir_show_type===A.t8.size_min_max||e.user_data.dir_show_type===A.t8.size_max_min?"green":void 0},children:i("文件大小")}),v:!1,items:a}]},{r:i("文件加载方式"),v:"",items:l},{r:i("时间展示"),v:"",items:c},{r:i("缩放调整"),v:"zoom_adjust"},{r:(0,D.jsx)("span",{style:{color:M?"green":void 0},children:i("以空白搜索模式打开目录")}),v:"blank_search_mode"}]},{r:i("以配置表方式打开目录"),v:"gcfg_dir_config"}];g?.folders?.find(e=>".git"===e.name)&&w.push({r:i("查看Git提交"),v:"git_page"}),n(A.oV.code_resource)&&w.push({r:i("添加http资源根目录"),v:"code_resource"}),n(A.oV.http_proxy)&&w.push({r:i("在此目录下载http资源"),v:"http_resource"}),e?.user_data?.quick_cmd&&(0,p.LL)([...e.user_data.quick_cmd],w),o.items=w,o.textClick=async e=>{if(console.log(e),!1===e)return;const t={};if("gcfg_dir_config"===e){const e=(0,d.GG)("file",(0,d.vX)());return b({data:void 0,overlay:!1,type:"",show:!1}),void m(`/${S.o.gcfg_page}/${encodeURIComponent(e)}`)}if("git_page"===e){const e=(0,d.GG)("file",(0,d.vX)());return b({data:void 0,overlay:!1,type:"",show:!1}),void m(`/${S.o.git_page}/${encodeURIComponent(e)}`)}if("code_resource"===e){const e=await j.ws.sendData(G.HK.file_info,{path:(0,d.GG)("file",(0,d.vX)())});return f({page_self_router_api_data:[`/api/${Date.now()}`,e.context.now_absolute_path]}),b({data:void 0,overlay:!1,type:"",show:!1}),void m("/setting/customer_router/")}if("http_resource"===e){const e=await j.ws.sendData(G.HK.file_info,{path:(0,d.GG)("file",(0,d.vX)())});return f({http_download_map_path:e.context.now_absolute_path}),b({data:void 0,overlay:!1,type:"",show:!1}),void m("/proxy/http/")}if("zoom_adjust"===e)return b({data:void 0,overlay:!1,type:"",show:!1}),void setTimeout(()=>{b({show:!0,type:_.PromptEnum.ZoomAdjust,overlay:!1,data:{}})},0);if("object"==typeof e&&"quick_cmd"===e.tag){let t=e.cmd;t&&(t.endsWith("\r")||(t+="\r",F({show:!0,path:(0,d.GG)("file",(0,d.vX)()),cmd:t})))}else{if("blank_search_mode"===e)return $(!M),void b({data:void 0,overlay:!1,type:"",show:!1});if(e===A.yM.all||e===A.yM.pagination)t.is_pagination_mode=!0;else if(e===A.KD.current||e===A.KD.time)t.is_file_show_type=!0;else{if(e!==A.t8.defualt&&e!==A.t8.name&&e!==A.t8.size_max_min&&e!==A.t8.size_min_max&&e!==A.t8.time_max_min&&e!==A.t8.time_minx_max)return;t.is_dir_list_type=!0}}await r.wm.post(P.s.user_save_private_attr,{type:e,...t}),await u(),b({data:void 0,overlay:!1,type:"",show:!1}),m((0,d.vX)())},b({show:!0,type:_.PromptEnum.FileMenu,overlay:!1,data:o})}}(),ve=async()=>{const e=new k.Nd;e.dir_path=`${(0,d.GG)("file",(0,d.vX)())}`,j.ws.addMsg(G.HK.workflow_realtime,e=>{const t=e.context;if(e.context){for(const e of t.sucess_file_list)(0,p.Ys)(e);for(const e of t.failed_file_list)(0,p.V$)(e);de(new Set(t.running_file_list))}}),await j.ws.sendData(G.HK.workflow_realtime,e)},ye=async e=>{let t=!1;for(const i of e.files??[])i.origin_size=i.size,i.size=(0,g.v7)(i.size),re.user_data.file_time_show_type===A.KD.time?i.show_mtime=i.mtime?(0,K.Yq)(i.mtime):"":i.show_mtime=i.mtime?(0,x.s)(i.mtime):"",t||!i.name.endsWith(".workflow.yml")&&!i.name.endsWith(".act")||(t=!0,Promise.resolve().then(()=>{ve()})),i.name===k.SB&&(t=!0);for(const i of e.folders??[])re.user_data.file_time_show_type===A.KD.time?i.show_mtime=i.mtime?(0,K.Yq)(i.mtime):"":i.show_mtime=i.mtime?(0,x.s)(i.mtime):"",i.name===k.SB&&(t=!0);se(t)};(0,o.useEffect)(()=>async()=>{de(new Set)},[]);const ge=()=>{(async()=>{const e=(0,d.GG)("file",(0,d.vX)());if(me||he)return;let t;if(re.user_data.file_list_pagination_mode===A.yM.pagination){if(fe.page_num<0)return;t=await r.$M.post("file_get_page",{param_path:e,page_num:fe.page_num,page_size:fe.page_size});const i=t.data;i.files?.length||pe({page_size:fe.page_size,page_num:-1}),i.files=(0,E.cloneDeep)([...X.files,...i.files])}else t=await r.$M.get(e);if(t.code!==f.m.Success)return;const i=t.data;(0,p.yC)(i,re.user_data.dir_show_type),ye(t.data),N(t.data),H=t.data})(),t({open:!1}),u({open:!1}),se(!1)};(0,o.useEffect)(()=>{ge()},[M,fe]);const xe=e=>{e.target===e.currentTarget&&(O([]),q([]))};return(0,D.jsxs)(o.Fragment,{children:[(0,D.jsxs)(c.A,{left_children:(0,D.jsx)(m.$Z,{handleEnterPress:async()=>{if(me||he){if(O([]),q([]),!J||!J.trim())return void N({files:[],folders:[]});const e=(0,d.GG)("file",(0,d.vX)()),t=await r.$M.post("file_get_page",{param_path:e,page_num:1,page_size:1e4,search:J.trim()});if(t.code!==f.m.Success)return;const i=t.data;return(0,p.yC)(i,re.user_data.dir_show_type),ye(i),N(i),void(H=i)}if(!H)return;O([]),q([]);const e=[],t=[];for(const t of H.files??[])t.name.includes(J)&&e.push(t);for(const e of H.folders??[])e.name.includes(J)&&t.push(e);N({files:e,folders:t})},placeholder:F("搜索当前目录"),icon:"search",value:"",handleInputChange:e=>{Q(e)},max_width:"25em"}),children:[(0,D.jsx)("div",{className:"mobile-context-btn",children:(0,D.jsx)(z.rA,{icon:"more_horiz",title:F("右键"),onClick:()=>{const e=B[B.length-1];if(void 0!==e){const t=[...X.folders??[],...X.files??[]][e];if(t){const i=document.querySelectorAll(".item")[e],o=i?i.getBoundingClientRect():{left:window.innerWidth/2,bottom:100},n={preventDefault:()=>{},stopPropagation:()=>{},clientX:o.left+10,clientY:o.bottom??100},s=new C.ik;s.path=(0,Y.IO)((0,d.vX)(),t.name),s.filename=t.name,s.x=n.clientX,s.y=n.clientY,s.type=t.type===h.Iw.folder?h.Iw.folder:(0,C.uL)(t.name),s.size=t.origin_size,W({show:!0,type:_.PromptEnum.FileMenu,overlay:!1,data:s})}}else{const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:window.innerWidth/2,clientY:window.innerHeight/2};we(e)}}})}),(0,D.jsx)(I,{})]}),(0,D.jsx)(n.e,{baseRoute:"file",clickFun:function(){O([]),q([])},input_path_enter:e=>{var t;!function(e){return"string"==typeof e&&(/^[a-zA-Z]:[\\\/]/.test(e)||/^\//.test(e))}(e)?$(function(e,t){let i=function(e){let t="\\";for(const i of e)if("/"===i||"\\"===i){t=i;break}return t}(e);if("."===t)return e;if(".."===t){if(e.length>1){let t=e[e.length-1]===i?1:0;for(let o=e.length-1-t;o>=0;o--)if(e[o]===i)return e.substring(0,o+1)}return e}return e.endsWith(i)&&t.startsWith(i)?e.slice(0,-1)+t:e.endsWith(i)||t.startsWith(i)?e+t:e+i+t}((0,d.vX)(),e)):(e=e.replace(0===(t=re.user_data).folder_item_now||void 0===t.folder_item_now?t.cwd:t.folder_items[t.folder_item_now-1].path,""),$(e)),O([]),q([]),N({files:[],folders:[]})}}),re.user_data.file_list_pagination_mode===A.yM.pagination?(0,D.jsx)(b.$J,{handleContextMenu:we,clickBlank:xe,list:X.files}):(0,D.jsx)(b.t$,{handleContextMenu:we,file_list:X.files,folder_list:X.folders,clickBlank:xe}),ee&&(0,D.jsx)(L,{}),ie.open&&(0,D.jsx)(R,{})]})}}}]);
1
+ "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[8714],{47374(e,t,i){i.d(t,{e:()=>f});var o=i(96540),n=i(61973),s=i(64694),a=i(34289),r=i(61443),l=i(75725),c=i(22022),_=i(85997),d=i(74848);function f(e){let t=(0,n.zy)();const[i,f]=(0,o.useState)([]),[p,m]=(0,o.useState)("/"),[h,u]=(0,o.useState)(void 0),{t:w,i18n:v}=(0,c.Bd)();o.useEffect(()=>{let t="",i=(0,a.vX)().split("/");i=i.filter(e=>e);const o=i.indexOf(e.baseRoute),n=[];if(-1!=o){t=(0,s.IO)(i.slice(0,o),e.baseRoute);const a=i.slice(o+1);for(let e=0;e<a.length;e++){const i=a[e];n.push({value:i,href:0===e?`${t}${i}/`:(0,s.IO)(n[e-1].href,i)})}m(t),f(n)}},[t]);const y=t=>{t.stopPropagation(),e.clickFun(t)};return(0,d.jsx)("div",{className:"breadcrumbs",onClick:e=>{u(void 0!==h?void 0:"")},children:(0,d.jsx)(o.Fragment,{children:void 0===h?(0,d.jsxs)(o.Fragment,{children:[(0,d.jsx)("span",{className:"chevron",children:(0,d.jsx)(n.N_,{to:p,onClick:y,children:(0,d.jsx)(_.In,{icon:"home"})})}),i.map((e,t)=>(0,d.jsxs)("span",{className:"chevron",children:[(0,d.jsx)(_.In,{icon:"keyboard_arrow_right"}),(0,d.jsx)(n.N_,{to:e.href,onClick:y,children:decodeURIComponent(e.value)})]},t))]}):(0,d.jsx)(l.QM,{click:()=>{u(void 0)},children:(0,d.jsx)(r.Sm,{width:"100%",placeholder:w("输入跳转的目录"),handlerEnter:t=>{e.input_path_enter&&e.input_path_enter(t),u(void 0)}})})})})}},78714(e,t,i){i.r(t),i.d(t,{default:()=>N});var o=i(96540),n=i(47374),s=i(34843),a=i(82893),r=i(14284),l=i(61973),c=i(57952),_=i(27690),d=i(34289),f=i(53459),p=i(99214),m=i(61443),h=i(47022),u=i(62042),w=i(22022),v=i(7523),y=i(78247),g=i(88815),x=i(6960),k=i(47071),j=i(14944),G=i(92275),A=i(23430);var C=i(34251),b=i(60096),z=i(85997),P=i(23496),F=i(12730),M=i(75725),$=i(70447),S=i(87361),D=i(74848);let X={};function I(){const{t:e}=(0,w.Bd)();let t=(0,l.zy)();const i=(0,l.Zp)(),{check_user_auth:n}=(0,y.MH)(),[c,f]=(0,s.fp)(a.AG.nowFileList),[m,g]=(0,s.fp)(a.AG.uploadFiles),[x,k]=(0,s.fp)(a.AG.showPrompt),[b,P]=(0,s.fp)(a.AG.selectedFileList),[I,E]=(0,s.fp)(a.AG.copyedFileList),[K,Y]=(0,s.fp)(a.AG.cutedFileList),[L,R]=(0,s.fp)(a.AG.selectedFileList),[H,N]=(0,s.fp)(a.AG.clickFileList),[U,W]=(0,s.fp)(a.AG.fileShellShow),[B,O]=(0,s.fp)(a.AG.file_root_list),[Z,q]=(0,s.fp)(a.AG.file_root_index),[V,T]=(0,o.useState)(void 0),[J,Q]=(0,o.useState)(""),[ee,te]=(0,s.fp)(a.AG.workflow_show),[ie,oe]=(0,s.fp)(a.AG.workflow_realtime_show),[ne,se]=(0,s.fp)(a.AG.work_flow_show),{initUserInfo:ae}=(0,o.useContext)(v.F),[re,le]=(0,s.fp)(a.AG.user_base_info),{click_file:ce}=(0,y.kZ)(),[_e,de]=(0,s.fp)(a.AG.prompt_card),fe=(0,o.useMemo)(()=>c.files.reduce((e,t)=>e+(t.type!==h.Iw.folder?1:0),0),[c]),pe=(0,o.useMemo)(()=>c.files.reduce((e,t)=>e+(t.type===h.Iw.folder?1:0),0)+(c.folders?.length??0),[c]);function me(e){(0,u.SK)(e)}(0,o.useEffect)(()=>{X={}},[t]),(0,o.useEffect)(()=>()=>{W({show:!1,path:""})},[]);const he=(0,p.Vs)(),ue=t=>{de({open:!0,title:e("信息"),context_div:(0,D.jsxs)("div",{style:{maxWidth:"25rem"},children:[(0,D.jsx)(M.Yh,{left:e("挂载位置磁盘"),right:t?.total_size}),(0,D.jsx)(M.Yh,{left:`${e("磁盘剩余")}`,right:t?.left_size}),(0,D.jsx)(M.Yh,{left:`${e("文件系统")}`,right:t?.fs_type}),(0,D.jsx)(M.Yh,{left:`${e("文件夹数")}`,right:pe}),(0,D.jsx)(M.Yh,{left:`${e("文件数")}`,right:fe}),(0,D.jsx)(M.Yh,{left:`${e("当前位置")}`,right:(0,D.jsx)($.xP,{context:t?.now_absolute_path})})]}),cancel:()=>{j.ws.removeMsg(G.HK.file_info)}})};return(0,D.jsxs)(o.Fragment,{children:[b.length>0&&(0,D.jsx)(z.rA,{icon:"delete",title:e("删除"),onClick:()=>{k({show:!0,type:_.PromptEnum.FilesDelete,overlay:!0,data:{}})}}),b.length>0&&(0,D.jsx)(z.rA,{icon:"content_copy",title:e("复制"),onClick:function(){const e=(0,p.ib)(c,b);E(e.map(e=>(0,p.Ok)(e.name))),Y([]),me("已复制")}}),b.length>0&&(0,D.jsx)(z.rA,{icon:"content_cut",title:e("剪切"),onClick:function(){const e=(0,p.ib)(c,b);Y(e.map(e=>(0,p.Ok)(e.name))),E([]),me("已剪切")}}),(I.length>0||K.length>0)&&(0,D.jsx)(z.rA,{onClick:function(){k({show:!0,type:_.PromptEnum.Confirm,overlay:!0,data:{}})},icon:"content_paste",title:e("粘贴到此处"),tip:I.length+K.length}),b.length>0&&(0,D.jsx)(z.rA,{icon:"download",title:e("下载"),onClick:function(){const e=(0,p.ib)(c,b);for(let t=0;t<e.length;t++){const i=e[t];e[t]=encodeURIComponent((0,p.Ok)(i.name))}const t=r.$M.getDownloadUrl(e);window.open(t)}}),b.length>0&&(0,D.jsx)(z.rA,{icon:"compress",title:e("压缩"),onClick:function(){const e=(0,p.ib)(c,b);for(let t=0;t<e.length;t++){const i=e[t];e[t]=(0,p.Ok)(i.name)}e&&0!==e.length?k({show:!0,type:_.PromptEnum.Compress,overlay:!0,data:{files:e}}):(0,u.zN)("没有选中")}}),1===b.length&&(0,D.jsx)(z.rA,{icon:"edit_attributes",title:e("重命名"),onClick:function(){k({show:!0,type:_.PromptEnum.FileRename,overlay:!0,data:{}})}}),ne&&(0,D.jsx)(z.rA,{icon:"api",title:"workflow",onClick:()=>{te(!ee)}}),(0,D.jsx)(z.rA,{icon:"terminal",title:"shell",onClick:function(){U.show?W({show:!1,path:""}):W({show:!0,path:(0,d.GG)("file",(0,d.vX)())})}}),n(A.oV.share_file)&&(0,D.jsx)(z.rA,{icon:"share",title:e("文件分享"),onClick:()=>{i(`/${S.o.share_list_setting_page}`)}}),(0,D.jsx)(z.rA,{icon:"grid_view",title:e("切换样式"),onClick:he}),(0,D.jsx)(z.rA,{icon:"create_new_folder",title:e("创建文件夹"),onClick:function(){k({show:!0,type:_.PromptEnum.DirNew,overlay:!0,data:{dir:(0,d.GG)("file",(0,d.vX)())}})}}),(0,D.jsx)(z.rA,{icon:"note_add",title:e("创建文本文件"),onClick:function(){k({show:!0,type:_.PromptEnum.FileNew,overlay:!0,data:{dir:(0,d.GG)("file",(0,d.vX)())}})}}),(0,D.jsx)(z.rA,{icon:"upload_file",title:e("上传"),onClick:()=>{k({show:!0,type:_.PromptEnum.UploadFile,overlay:!0,data:{call:e=>{let t=e.currentTarget?.files;if(!t)return;let i=!!t[0].webkitRelativePath;const o=[],n=new Set;for(let e=0;e<t.length;e++){const s=t[e],a=i?s.webkitRelativePath:`${s.webkitRelativePath}${s.name}`;s.fullPath=a,i&&n.add((0,F.S)(a)),o.push(s)}const s=[];if(i)for(const e of n)s.push({isDir:!0,fullPath:e,name:e});s.push(...o),g(s),k({show:!0,type:_.PromptEnum.FilesUpload,overlay:!1,data:{}})}}})}}),(0,D.jsx)(z.rA,{icon:"info",title:e("信息"),onClick:async()=>{let e;if(!X.now_absolute_path){j.ws.addMsg(G.HK.file_info,t=>{const i=t.context;e&&(X={...X,...i},j.ws.removeMsg(G.HK.file_info),ue(X))});const t=await j.ws.sendData(G.HK.file_info,{type:h.Iw.folder,path:(0,d.GG)("file",(0,d.vX)())});e=t.context,X=e,ue(X)}ue(X)}}),(0,D.jsx)(z.rA,{icon:"more_vert",title:e("切换目录"),onClick:t=>{const o=new C.ik;o.x=t.clientX,o.y=t.clientY,o.type=h.Iw.directory,o.items=B,o.item_pre_value=Z,o.textClick=async t=>{if(-1===t)return i(`/${S.o.setting_private_env_setting}`),k({data:void 0,overlay:!1,type:"",show:!1}),void(0,u.N9)(e("请配置 文件夹路径"));(async e=>{q(e),await r.$M.post("base_switch",{root_index:e}),await ae(),i("/file/"),R([]),N([])})(t),k({data:void 0,overlay:!1,type:"",show:!1})},k({show:!0,type:_.PromptEnum.FileMenu,overlay:!1,data:o})}})]})}var E=i(2543),K=i(21499),Y=i(64694);const L=o.lazy(()=>Promise.all([i.e(7856),i.e(6349),i.e(3659)]).then(i.bind(i,63659))),R=o.lazy(()=>Promise.all([i.e(7856),i.e(1636)]).then(i.bind(i,81636)));let H;function N(){const[e,t]=(0,s.fp)(a.AG.editorSetting),[i,u]=(0,s.fp)(a.AG.file_preview),{t:F}=(0,w.Bd)();let M=(0,l.zy)();const $=(0,l.Zp)(),[X,N]=(0,s.fp)(a.AG.nowFileList),[U,W]=(0,s.fp)(a.AG.showPrompt),[B,O]=(0,s.fp)(a.AG.selectedFileList),[Z,q]=(0,s.fp)(a.AG.clickFileList),[V,T]=(0,s.fp)(a.AG.fileShellShow),[J,Q]=(0,o.useState)(""),[ee,te]=(0,s.fp)(a.AG.workflow_show),[ie,oe]=(0,s.fp)(a.AG.workflow_realtime_show),[ne,se]=(0,s.fp)(a.AG.work_flow_show),{initUserInfo:ae}=(0,o.useContext)(v.F),[re,le]=(0,s.fp)(a.AG.user_base_info),{click_file:ce}=(0,y.kZ)(),[_e,de]=(0,s.fp)(a.AG.to_running_files),[fe,pe]=(0,s.fp)(a.AG.file_page),[me]=(0,s.fp)(a.AG.blank_search_mode),[he,ue]=(0,s.fp)(a.AG.blank_search_mode_for_temp),we=function(){const[e,t]=(0,s.fp)(a.AG.user_base_info),{t:i}=(0,w.Bd)(),{check_user_auth:n}=(0,y.MH)(),[c,f]=(0,s.fp)(a.AG.router_jump),m=(0,l.Zp)(),{initUserInfo:u}=(0,o.useContext)(v.F),[g,x]=(0,s.fp)(a.AG.nowFileList),[k,b]=(0,s.fp)(a.AG.showPrompt),[z,F]=(0,s.fp)(a.AG.fileShellShow),[M,$]=(0,s.fp)(a.AG.blank_search_mode);return t=>{t.preventDefault(),t.stopPropagation();const o=new C.ik;o.x=t.clientX,o.y=t.clientY,o.type=h.Iw.directory;const s=[{r:(0,D.jsx)("span",{style:{color:e.user_data.dir_show_type===A.t8.time_minx_max?"green":void 0},children:i("时间逆序")}),v:A.t8.time_minx_max},{r:(0,D.jsx)("span",{style:{color:e.user_data.dir_show_type===A.t8.time_max_min?"green":void 0},children:i("时间顺序")}),v:A.t8.time_max_min}],a=[{r:(0,D.jsx)("span",{style:{color:e.user_data.dir_show_type===A.t8.size_min_max?"green":void 0},children:i("大小顺序")}),v:A.t8.size_min_max},{r:(0,D.jsx)("span",{style:{color:e.user_data.dir_show_type===A.t8.size_max_min?"green":void 0},children:i("大小逆序")}),v:A.t8.size_max_min}],l=[{r:(0,D.jsx)("span",{style:{color:e.user_data.file_list_pagination_mode&&e.user_data.file_list_pagination_mode!==A.yM.all?void 0:"green"},children:i("全部加载文件")}),v:A.yM.all},{r:(0,D.jsx)("span",{style:{color:e.user_data.file_list_pagination_mode===A.yM.pagination?"green":void 0},children:i("分页滚动加载文件")}),v:A.yM.pagination}],c=[{r:(0,D.jsx)("span",{style:{color:e.user_data.file_time_show_type&&e.user_data.file_time_show_type!==A.KD.current?void 0:"green"},children:i("最近时间")}),v:A.KD.current},{r:(0,D.jsx)("span",{style:{color:e.user_data.file_time_show_type===A.KD.time?"green":void 0},children:i("准确时间")}),v:A.KD.time}],w=[{r:i("文件列表展示"),items:[{r:i("文件排序"),v:"",items:[{r:(0,D.jsx)("span",{style:{color:e.user_data.dir_show_type?void 0:"green"},children:i("系统默认")}),v:A.t8.defualt},{r:(0,D.jsx)("span",{style:{color:e.user_data.dir_show_type===A.t8.name?"green":void 0},children:i("名字")}),v:A.t8.name},{r:(0,D.jsx)("span",{style:{color:e.user_data.dir_show_type===A.t8.time_minx_max||e.user_data.dir_show_type===A.t8.time_max_min?"green":void 0},children:i("修改时间")}),v:!1,items:s},{r:(0,D.jsx)("span",{style:{color:e.user_data.dir_show_type===A.t8.size_min_max||e.user_data.dir_show_type===A.t8.size_max_min?"green":void 0},children:i("文件大小")}),v:!1,items:a}]},{r:i("文件加载方式"),v:"",items:l},{r:i("时间展示"),v:"",items:c},{r:i("缩放调整"),v:"zoom_adjust"},{r:(0,D.jsx)("span",{style:{color:M?"green":void 0},children:i("以空白搜索模式打开目录")}),v:"blank_search_mode"}]},{r:i("以配置表方式打开目录"),v:"gcfg_dir_config"}];g?.folders?.find(e=>".git"===e.name)&&w.push({r:i("查看Git提交"),v:"git_page"}),n(A.oV.code_resource)&&w.push({r:i("添加http资源根目录"),v:"code_resource"}),n(A.oV.http_proxy)&&w.push({r:i("在此目录下载http资源"),v:"http_resource"}),e?.user_data?.quick_cmd&&(0,p.LL)([...e.user_data.quick_cmd],w),o.items=w,o.textClick=async e=>{if(console.log(e),!1===e)return;const t={};if("gcfg_dir_config"===e){const e=(0,d.GG)("file",(0,d.vX)());return b({data:void 0,overlay:!1,type:"",show:!1}),void m(`/${S.o.gcfg_page}/${encodeURIComponent(e)}`)}if("git_page"===e){const e=(0,d.GG)("file",(0,d.vX)());return b({data:void 0,overlay:!1,type:"",show:!1}),void m(`/${S.o.git_page}/${encodeURIComponent(e)}`)}if("code_resource"===e){const e=await j.ws.sendData(G.HK.file_info,{path:(0,d.GG)("file",(0,d.vX)())});return f({page_self_router_api_data:[`/api/${Date.now()}`,e.context.now_absolute_path]}),b({data:void 0,overlay:!1,type:"",show:!1}),void m("/setting/customer_router/")}if("http_resource"===e){const e=await j.ws.sendData(G.HK.file_info,{path:(0,d.GG)("file",(0,d.vX)())});return f({http_download_map_path:e.context.now_absolute_path}),b({data:void 0,overlay:!1,type:"",show:!1}),void m("/proxy/http/")}if("zoom_adjust"===e)return b({data:void 0,overlay:!1,type:"",show:!1}),void setTimeout(()=>{b({show:!0,type:_.PromptEnum.ZoomAdjust,overlay:!1,data:{}})},0);if("object"==typeof e&&"quick_cmd"===e.tag){let t=e.cmd;t&&(t.endsWith("\r")||(t+="\r",F({show:!0,path:(0,d.GG)("file",(0,d.vX)()),cmd:t})))}else{if("blank_search_mode"===e)return $(!M),void b({data:void 0,overlay:!1,type:"",show:!1});if(e===A.yM.all||e===A.yM.pagination)t.is_pagination_mode=!0;else if(e===A.KD.current||e===A.KD.time)t.is_file_show_type=!0;else{if(e!==A.t8.defualt&&e!==A.t8.name&&e!==A.t8.size_max_min&&e!==A.t8.size_min_max&&e!==A.t8.time_max_min&&e!==A.t8.time_minx_max)return;t.is_dir_list_type=!0}}await r.wm.post(P.s.user_save_private_attr,{type:e,...t}),await u(),b({data:void 0,overlay:!1,type:"",show:!1}),m((0,d.vX)())},b({show:!0,type:_.PromptEnum.FileMenu,overlay:!1,data:o})}}(),ve=async()=>{const e=new k.Nd;e.dir_path=`${(0,d.GG)("file",(0,d.vX)())}`,j.ws.addMsg(G.HK.workflow_realtime,e=>{const t=e.context;if(e.context){for(const e of t.sucess_file_list)(0,p.Ys)(e);for(const e of t.failed_file_list)(0,p.V$)(e);de(new Set(t.running_file_list))}}),await j.ws.sendData(G.HK.workflow_realtime,e)},ye=async e=>{let t=!1;for(const i of e.files??[])i.origin_size=i.size,i.size=(0,g.v7)(i.size),re.user_data.file_time_show_type===A.KD.time?i.show_mtime=i.mtime?(0,K.Yq)(i.mtime):"":i.show_mtime=i.mtime?(0,x.s)(i.mtime):"",t||!i.name.endsWith(".workflow.yml")&&!i.name.endsWith(".act")||(t=!0,Promise.resolve().then(()=>{ve()})),i.name===k.SB&&(t=!0);for(const i of e.folders??[])re.user_data.file_time_show_type===A.KD.time?i.show_mtime=i.mtime?(0,K.Yq)(i.mtime):"":i.show_mtime=i.mtime?(0,x.s)(i.mtime):"",i.name===k.SB&&(t=!0);se(t)};(0,o.useEffect)(()=>async()=>{de(new Set)},[]);const ge=()=>{(async()=>{const e=(0,d.GG)("file",(0,d.vX)());if(me||he)return;let t;if(re.user_data.file_list_pagination_mode===A.yM.pagination){if(fe.page_num<0)return;t=await r.$M.post("file_get_page",{param_path:e,page_num:fe.page_num,page_size:fe.page_size});const i=t.data;i.files?.length||pe({page_size:fe.page_size,page_num:-1}),i.files=(0,E.cloneDeep)([...X.files,...i.files])}else t=await r.$M.get(e);if(t.code!==f.m.Success)return;const i=t.data;(0,p.yC)(i,re.user_data.dir_show_type),ye(t.data),N(t.data),H=t.data})(),t({open:!1}),u({open:!1}),se(!1)};(0,o.useEffect)(()=>{ge()},[M,fe]);const xe=e=>{e.target===e.currentTarget&&(O([]),q([]))};return(0,D.jsxs)(o.Fragment,{children:[(0,D.jsxs)(c.A,{left_children:(0,D.jsx)(m.$Z,{handleEnterPress:async()=>{if(me||he){if(O([]),q([]),!J||!J.trim())return void N({files:[],folders:[]});const e=(0,d.GG)("file",(0,d.vX)()),t=await r.$M.post("file_get_page",{param_path:e,page_num:1,page_size:1e4,search:J.trim()});if(t.code!==f.m.Success)return;const i=t.data;return(0,p.yC)(i,re.user_data.dir_show_type),ye(i),N(i),void(H=i)}if(!H)return;O([]),q([]);const e=[],t=[];for(const t of H.files??[])t.name.includes(J)&&e.push(t);for(const e of H.folders??[])e.name.includes(J)&&t.push(e);N({files:e,folders:t})},placeholder:F("搜索当前目录"),icon:"search",value:"",handleInputChange:e=>{Q(e)},max_width:"25em"}),children:[(0,D.jsx)("div",{className:"mobile-context-btn",children:(0,D.jsx)(z.rA,{icon:"more_horiz",title:F("右键"),onClick:()=>{const e=B[B.length-1];if(void 0!==e){const t=[...X.folders??[],...X.files??[]][e];if(t){const i=document.querySelectorAll(".item")[e],o=i?i.getBoundingClientRect():{left:window.innerWidth/2,bottom:100},n={preventDefault:()=>{},stopPropagation:()=>{},clientX:o.left+10,clientY:o.bottom??100},s=new C.ik;s.path=(0,Y.IO)((0,d.vX)(),t.name),s.filename=t.name,s.x=n.clientX,s.y=n.clientY,s.type=t.type===h.Iw.folder?h.Iw.folder:(0,C.uL)(t.name),s.size=t.origin_size,W({show:!0,type:_.PromptEnum.FileMenu,overlay:!1,data:s})}}else{const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:window.innerWidth/2,clientY:window.innerHeight/2};we(e)}}})}),(0,D.jsx)(I,{})]}),(0,D.jsx)(n.e,{baseRoute:"file",clickFun:function(){O([]),q([])},input_path_enter:e=>{var t;!function(e){return"string"==typeof e&&(/^[a-zA-Z]:[\\\/]/.test(e)||/^\//.test(e))}(e)?$(function(e,t){let i=function(e){let t="\\";for(const i of e)if("/"===i||"\\"===i){t=i;break}return t}(e);if("."===t)return e;if(".."===t){if(e.length>1){let t=e[e.length-1]===i?1:0;for(let o=e.length-1-t;o>=0;o--)if(e[o]===i)return e.substring(0,o+1)}return e}return e.endsWith(i)&&t.startsWith(i)?e.slice(0,-1)+t:e.endsWith(i)||t.startsWith(i)?e+t:e+i+t}((0,d.vX)(),e)):(e=e.replace(0===(t=re.user_data).folder_item_now||void 0===t.folder_item_now?t.cwd:t.folder_items[t.folder_item_now-1].path,""),$(e)),O([]),q([]),N({files:[],folders:[]})}}),re.user_data.file_list_pagination_mode===A.yM.pagination?(0,D.jsx)(b.$J,{handleContextMenu:we,clickBlank:xe,list:X.files}):(0,D.jsx)(b.t$,{handleContextMenu:we,file_list:X.files,folder_list:X.folders,clickBlank:xe}),ee&&(0,D.jsx)(L,{}),ie.open&&(0,D.jsx)(R,{})]})}}}]);
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[8765],{60096(e,i,t){t.d(i,{QW:()=>F,Ic:()=>z,t$:()=>$,$J:()=>b});var n=t(96540),s=t(47022),l=t(34843),o=t(82893),a=t(52671),r=t(64694),d=t(14284),f=t(34289),c=t(23430),m=t(62042),h=t(99214),p=t(85997),u=t(74848);function _(e){const[i,t]=(0,l.fp)(o.AG.selectedFileList),[n,a]=(0,l.fp)(o.AG.nowFileList),[f,m]=(0,l.fp)(o.AG.confirm),[h,_]=(0,l.fp)(o.AG.user_base_info);return(0,u.jsxs)("div",{...e.extraAttr,onClick:()=>{!async function(i){e.click&&e.click(i,e.name)}(e.index)},className:"item",role:"button","data-type":e.isLink?"invalid_link":e.type,"data-dir":!e.type||e.type===s.Iw.folder,"aria-selected":null!==(0,r.kW)(i,e.index),"aria-label":e.name,style:{"--filewidth":e.itemWidth??"33%"},onDragStart:n=>{return s=e.index,void(i.find(e=>e===s)||t([...i,s]));var s},onDrop:i=>((i,t)=>{const l=i.dataTransfer;let o,a=!1;for(let e=0;e<l.items.length;e++)if("file"===l.items[e].kind){a=!0;break}if(!a){if(h?.user_data?.file_list_pagination_mode===c.yM.pagination){if(o=n.files[t],n.files[t]?.type!==s.Iw.folder)return}else if(o=n.folders[t],n.folders.length<=t)return;m({open:!0,title:`确定将文件移动并覆盖到${o?.name}吗?`,handle:async()=>{await e.draggable_handle(o?.name)}})}})(i,e.index),draggable:void 0!==e.draggable_handle,children:[void 0===e.icon&&(0,u.jsx)("div",{children:e.type!==s.Iw.image||null==e.path||h?.user_data?.not_pre_show_image?(0,u.jsx)(p.In,{icon:""}):(0,u.jsx)("img",{loading:"lazy",src:d.$M.getDownloadUrl(e.path,{mtime:e.mtime,cache:1}),alt:e.name})}),void 0!==e.icon&&(0,u.jsx)("div",{className:"rotating-div",children:(0,u.jsx)("span",{className:"material-icons",children:e.icon})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"name",children:e.name}),e.size?(0,u.jsx)("p",{children:e.size}):(0,u.jsx)("p",{children:"—"}),(0,u.jsx)("p",{children:e.show_mtime})]}),e.children]})}var x=t(27690),g=t(34251),y=t(22022),w=t(78247);function k(e){const[i,t]=(0,l.fp)(o.AG.selectedFileList),[n,c]=(0,l.fp)(o.AG.clickFileList),[m,p]=(0,l.fp)(o.AG.nowFileList),[k,v]=(0,l.fp)(o.AG.confirm),[A,j]=(0,l.fp)(o.AG.file_page),[G,F]=(0,l.fp)(o.AG.enterKey),{click_file:z}=(0,w.kZ)(),{t:$}=(0,y.Bd)(),b=(0,a.Zp)();(0,a.zy)();const C=(0,h.A9)(),[W,M]=(0,l.fp)(o.AG.showPrompt);return(0,u.jsx)(_,{extraAttr:{onContextMenu:i=>{((e,i,t,n)=>{e.preventDefault(),e.stopPropagation();const l=new g.ik;l.path=(0,r.IO)((0,f.vX)(),i),l.filename=i,l.x=e.clientX,l.y=e.clientY,l.type=t?s.Iw.folder:(0,g.uL)(i),l.size=n,M({show:!0,type:x.PromptEnum.FileMenu,overlay:!1,data:l})})(i,e.name,e.type===s.Iw.folder,e.origin_size)}},draggable_handle:async e=>{const n=(0,h.ib)(m,i).map(e=>(0,h.Ok)(e.name));await d.$M.post("cut",{files:n,to:`${(0,f.GG)("file",(0,f.vX)())}/${e}`});t([]),v({open:!1,handle:null}),b((0,f.vX)())},name:e.name,index:e.index,mtime:e.mtime,size:e.size,type:e.type,isLink:e.isLink,path:e.path,icon:e.icon,show_mtime:e.show_mtime,click:async(l,o)=>{if(null!==(0,r.kW)(i,l))t((0,r.P1)(i,l));else if("ctrl"===G)t([...i,l]);else if("shift"===G){const{max:e,min:n}=(0,r.a7)(i),s=[];if(l>=e)for(let i=e;i<=l;i++)s.push(i);else for(let e=n;e>=l;e--)s.push(e);t(s)}else t([l]);if(c([...n,l]),setTimeout(()=>{c((0,r.P1)(n,l))},300),e.type===s.Iw.folder){if(void 0!==n.find(e=>e===l))return void C(o)}else{void 0!==n.find(e=>e===l)&&z({name:o,size:e.origin_size,opt_shell:!0,mtime:e.mtime})}},itemWidth:e.itemWidth})}t(38240);var v=t(64405),A=t(88815);function j(e){const[i,t]=(0,l.fp)(o.AG.selectedFileList),[n,c]=(0,l.fp)(o.AG.clickFileList),[p,x]=(0,l.fp)(o.AG.editorSetting),[g,k]=(0,l.fp)(o.AG.shellNowDir),[j,G]=(0,l.fp)(o.AG.sshInfo),[F,z]=(0,l.fp)(o.AG.nowFileList),[$,b]=(0,l.fp)(o.AG.enterKey),[C,W]=(0,l.fp)(o.AG.confirm),M=(0,a.Zp)(),{t:S}=(0,y.Bd)();return(0,u.jsx)(_,{draggable_handle:async n=>{const s=new v.x;Object.assign(s,j),s.target=(0,r.HS)(...g,n);const l=(0,h.ib)(F,i).map(e=>(0,r.HS)(...g,e.name));for(const e of l)if(s.source=e,!await d.Fg.post("move",s))return!1;t([]),W({open:!1,handle:null}),await e.fileHandler()},name:e.name,index:e.index,mtime:e.mtime,size:e.size,type:e.type,itemWidth:e.itemWidth,show_mtime:e.show_mtime,click:async(l,o)=>{if(null!==(0,r.kW)(i,l))t((0,r.P1)(i,l));else if("ctrl"===$)t([...i,l]);else if("shift"===$){const{max:e,min:n}=(0,r.a7)(i),s=[];if(l>=e)for(let i=e;i<=l;i++)s.push(i);else for(let e=n;e>=l;e--)s.push(e);t(s)}else t([l]);if(c([...n,l]),setTimeout(()=>{c((0,r.P1)(n,l))},300),e.type===s.Iw.folder){if(void 0!==n.find(e=>e===l)){const e=new v.x;return e.key=j.key,e.dir=`/${(0,f.GG)("remoteShell",(0,f.vX)())}${o}`,M((0,r.IO)((0,f.vX)(),o)),t([]),c([]),void z({files:[],folders:[]})}}else{if(void 0!==n.find(e=>e===l)){const i=async()=>{const i=new v.x;i.key=j.key,i.file=`/${(0,f.GG)("remoteShell",(0,f.vX)())}${o}`;const t=await d.Fg.post("get/file/text",i);let n;o.endsWith(s.Iw.workflow_act)?n="ace/mode/yaml":(o.endsWith(s.Iw.draw)||o.endsWith(s.Iw.excalidraw))&&(n="ace/mode/json"),x({model:n,open:!0,fileName:e.name,save:async e=>{i.context=e;0===(await d.Fg.post("update/file/text",i)).code&&(w.xK.set_value_temp(""),(0,m.SK)("success"))}}),w.xK.set_value_temp(t.data)};return"number"==typeof e.origin_size&&e.origin_size>A.o5?void W({open:!0,title:S("提示"),sub_title:"文件超过20MB了确定要打开吗?",handle:async()=>{W({open:!1,handle:null}),await i()}}):void await i()}}}})}function G(e){const[i,t]=(0,l.fp)(o.AG.selectedFileList),[n,a]=(0,l.fp)(o.AG.clickFileList),[f,c]=(0,l.fp)(o.AG.enterKey),{click_file:m}=(0,w.kZ)(),[p,k]=(0,l.fp)(o.AG.nowFileList),{t:v}=(0,y.Bd)(),[A,j]=(0,l.fp)(o.AG.showPrompt),G=((0,h.oT)(),(0,h.xp)());return(0,u.jsx)(_,{extraAttr:{onContextMenu:i=>{((i,t,n,l)=>{i.preventDefault(),i.stopPropagation();const o=new g.ik,a=e.item_list;for(const e of a)if(e.name===t){o.path=e.path;break}o.is_share=!0,o.filename=t,o.x=i.clientX,o.y=i.clientY,o.type=n?s.Iw.folder:(0,g.uL)(t),o.size=l,o.share_token=e.share.share_token,o.share_id=e.share.share_id,j({show:!0,type:x.PromptEnum.FileMenu,overlay:!1,data:o})})(i,e.name,e.type===s.Iw.folder,e.origin_size)}},name:e.name,index:e.index,mtime:e.mtime,size:e.size,type:e.type,itemWidth:e.itemWidth,show_mtime:e.show_mtime,click:async(l,o)=>{if(null!==(0,r.kW)(i,l))t((0,r.P1)(i,l));else if("ctrl"===f)t([...i,l]);else if("shift"===f){const{max:e,min:n}=(0,r.a7)(i),s=[];if(l>=e)for(let i=e;i<=l;i++)s.push(i);else for(let e=n;e>=l;e--)s.push(e);t(s)}else t([l]);if(a([...n,l]),setTimeout(()=>{a((0,r.P1)(n,l))},300),e.type!==s.Iw.folder){const i=n.find(e=>e===l);if(void 0!==i){if(G(o))return;m({file_path:e.item_list[i].path,file_url:d.$M.getDownloadUrlV2(e.item_list[i].path,"share_download",{share_id:e.share.share_id,share_token:e.share.share_token}),name:o,size:e.origin_size,opt_shell:!0,mtime:e.mtime,not_type_tip:v("未知类型,请下载查看")})}}}})}function F({handleContextMenu:e,file_list:i,clickBlank:t,share:s}){const[a,r]=(0,l.fp)(o.AG.user_base_info),d=(0,n.useRef)(null),{t:f}=(0,y.Bd)(),c=(0,h.OJ)(),{file_is_running:m}=(0,w.hg)();return(0,h.UK)(i,[],d),(0,u.jsx)("div",{onContextMenu:e,id:"listing",style:{paddingBottom:"10rem"},className:`mosaic file-icons ${a?.user_data?.file_list_show_type??""}`,ref:d,children:(0,u.jsx)("div",{onClick:t,children:i.map((e,t)=>(0,u.jsx)(n.Fragment,{children:(0,u.jsx)(G,{share:s,item_list:i,icon:m(e.name)?"refresh":void 0,itemWidth:c,index:t+0,...e})},t+0))})})}function z({handleContextMenu:e,file_list:i,folder_list:t,clickBlank:s,fileHandler:a}){const[r,d]=(0,l.fp)(o.AG.user_base_info),f=(0,n.useRef)(null),{t:c}=(0,y.Bd)(),m=(0,h.OJ)(),{file_is_running:p}=(0,w.hg)(),[_,g]=(0,l.fp)(o.AG.fileShellShow),k=(0,n.useMemo)(()=>t?.length??0,[t]);return(0,h.ei)(f,x.PromptEnum.SshUpload),(0,h.UK)(i,t,f),(0,n.useEffect)(()=>()=>{_.show&&g({show:!1,path:""})},[]),(0,u.jsxs)("div",{onContextMenu:e,id:"listing",style:{paddingBottom:"10rem"},className:`mosaic file-icons ${r?.user_data?.file_list_show_type??""}`,ref:f,children:[t&&t.length>0&&(0,u.jsx)("h2",{children:c("文件夹")}),t&&(0,u.jsx)("div",{onClick:s,children:t.map((e,i)=>(0,u.jsx)(n.Fragment,{children:(0,u.jsx)(j,{fileHandler:a,itemWidth:m,index:i,...e})},i))}),i&&i.length>0&&(0,u.jsx)("h2",{onClick:s,children:c("文件")}),i&&(0,u.jsx)("div",{onClick:s,children:i.map((e,i)=>(0,u.jsx)(n.Fragment,{children:(0,u.jsx)(j,{fileHandler:a,icon:p(e.name)?"refresh":void 0,itemWidth:m,index:i+k,...e})},i+k))})]})}function $({handleContextMenu:e,file_list:i,folder_list:t,clickBlank:s}){const[a,r]=(0,l.fp)(o.AG.user_base_info),d=(0,n.useRef)(null),{t:f}=(0,y.Bd)(),[c]=(0,l.fp)(o.AG.zoom_style_by_percent),m=(0,h.OJ)(),{file_is_running:p}=(0,w.hg)(),[_,g]=(0,l.fp)(o.AG.fileShellShow),v=(0,n.useMemo)(()=>t?.length??0,[t]),A=(0,h.pi)(c);return(0,h.ei)(d,x.PromptEnum.FilesUpload),(0,h.UK)(i,t,d),(0,n.useEffect)(()=>()=>{_.show&&g({show:!1,path:""})},[]),(0,u.jsxs)("div",{onContextMenu:e,id:"listing",style:{paddingBottom:"10rem",fontSize:A.fontSize},className:`mosaic file-icons ${a?.user_data?.file_list_show_type??""}`,ref:d,children:[t&&t.length>0&&(0,u.jsx)("h2",{children:f("文件夹")}),t&&(0,u.jsx)("div",{onClick:s,children:t.map((e,i)=>(0,u.jsx)(n.Fragment,{children:(0,u.jsx)(k,{itemWidth:m,index:i,...e})},i))}),i&&i.length>0&&(0,u.jsx)("h2",{onClick:s,children:f("文件")}),i&&(0,u.jsx)("div",{onClick:s,children:i.map((e,i)=>(0,u.jsx)(n.Fragment,{children:(0,u.jsx)(k,{icon:p(e.name)?"refresh":void 0,itemWidth:m,index:i+v,...e})},i+v))})]})}function b({handleContextMenu:e,list:i,clickBlank:t}){const[s,a]=(0,l.fp)(o.AG.user_base_info),r=(0,n.useRef)(null),{t:d}=(0,y.Bd)(),[f]=(0,l.fp)(o.AG.zoom_style_by_percent),c=(0,h.OJ)(),{file_is_running:m}=(0,w.hg)(),[p,_]=(0,l.fp)(o.AG.fileShellShow),[g,v]=(0,l.fp)(o.AG.enterKey),[A,j]=(0,l.fp)(o.AG.selectedFileList),[G,F]=(0,l.fp)(o.AG.file_page),z=(0,h.pi)(f);return(0,h.UK)(i,[],r),(0,h.ei)(r,x.PromptEnum.FilesUpload),(0,h.SQ)(r,()=>{F(e=>e.page_num<0?e:{page_size:e.page_size,page_num:e.page_num+1})},()=>{}),(0,n.useEffect)(()=>()=>{p.show&&_({show:!1,path:""})},[]),(0,u.jsx)("div",{onContextMenu:e,id:"listing",style:{paddingBottom:"10rem",fontSize:z.fontSize},className:`mosaic file-icons ${s?.user_data?.file_list_show_type??""}`,ref:r,children:i&&(0,u.jsx)("div",{onClick:t,children:i.map((e,i)=>(0,u.jsx)(n.Fragment,{children:(0,u.jsx)(k,{icon:m(e.name)?"refresh":void 0,itemWidth:c,index:i,...e})},i))})})}},6960(e,i,t){t.d(i,{s:()=>o});var n=t(72635);const s=1440,l=525600;function o(e){e=e>1e12?e:1e3*e;const i=Date.now(),t=Math.abs(i-e)/6e4;return t<1?n.Ay.t("小于一分钟"):t<60?`${t.toFixed(0)} ${n.Ay.t("分钟前")}`:t<s?`${(t/60).toFixed(0)} ${n.Ay.t("小时前")}`:t<43200?`${(t/s).toFixed(0)} ${n.Ay.t("天前")}`:t<l?`${(t/43200).toFixed(0)} ${n.Ay.t("月前")}`:`${(t/l).toFixed(0)} ${n.Ay.t("年前")}`}}}]);
1
+ "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[8765],{60096(e,i,t){t.d(i,{QW:()=>F,Ic:()=>z,t$:()=>$,$J:()=>b});var n=t(96540),s=t(47022),l=t(34843),o=t(82893),a=t(61973),r=t(64694),d=t(14284),f=t(34289),c=t(23430),m=t(62042),h=t(99214),p=t(85997),u=t(74848);function _(e){const[i,t]=(0,l.fp)(o.AG.selectedFileList),[n,a]=(0,l.fp)(o.AG.nowFileList),[f,m]=(0,l.fp)(o.AG.confirm),[h,_]=(0,l.fp)(o.AG.user_base_info);return(0,u.jsxs)("div",{...e.extraAttr,onClick:()=>{!async function(i){e.click&&e.click(i,e.name)}(e.index)},className:"item",role:"button","data-type":e.isLink?"invalid_link":e.type,"data-dir":!e.type||e.type===s.Iw.folder,"aria-selected":null!==(0,r.kW)(i,e.index),"aria-label":e.name,style:{"--filewidth":e.itemWidth??"33%"},onDragStart:n=>{return s=e.index,void(i.find(e=>e===s)||t([...i,s]));var s},onDrop:i=>((i,t)=>{const l=i.dataTransfer;let o,a=!1;for(let e=0;e<l.items.length;e++)if("file"===l.items[e].kind){a=!0;break}if(!a){if(h?.user_data?.file_list_pagination_mode===c.yM.pagination){if(o=n.files[t],n.files[t]?.type!==s.Iw.folder)return}else if(o=n.folders[t],n.folders.length<=t)return;m({open:!0,title:`确定将文件移动并覆盖到${o?.name}吗?`,handle:async()=>{await e.draggable_handle(o?.name)}})}})(i,e.index),draggable:void 0!==e.draggable_handle,children:[void 0===e.icon&&(0,u.jsx)("div",{children:e.type!==s.Iw.image||null==e.path||h?.user_data?.not_pre_show_image?(0,u.jsx)(p.In,{icon:""}):(0,u.jsx)("img",{loading:"lazy",src:d.$M.getDownloadUrl(e.path,{mtime:e.mtime,cache:1}),alt:e.name})}),void 0!==e.icon&&(0,u.jsx)("div",{className:"rotating-div",children:(0,u.jsx)("span",{className:"material-icons",children:e.icon})}),(0,u.jsxs)("div",{children:[(0,u.jsx)("p",{className:"name",children:e.name}),e.size?(0,u.jsx)("p",{children:e.size}):(0,u.jsx)("p",{children:"—"}),(0,u.jsx)("p",{children:e.show_mtime})]}),e.children]})}var x=t(27690),g=t(34251),y=t(22022),w=t(78247);function k(e){const[i,t]=(0,l.fp)(o.AG.selectedFileList),[n,c]=(0,l.fp)(o.AG.clickFileList),[m,p]=(0,l.fp)(o.AG.nowFileList),[k,v]=(0,l.fp)(o.AG.confirm),[A,j]=(0,l.fp)(o.AG.file_page),[G,F]=(0,l.fp)(o.AG.enterKey),{click_file:z}=(0,w.kZ)(),{t:$}=(0,y.Bd)(),b=(0,a.Zp)();(0,a.zy)();const C=(0,h.A9)(),[W,M]=(0,l.fp)(o.AG.showPrompt);return(0,u.jsx)(_,{extraAttr:{onContextMenu:i=>{((e,i,t,n)=>{e.preventDefault(),e.stopPropagation();const l=new g.ik;l.path=(0,r.IO)((0,f.vX)(),i),l.filename=i,l.x=e.clientX,l.y=e.clientY,l.type=t?s.Iw.folder:(0,g.uL)(i),l.size=n,M({show:!0,type:x.PromptEnum.FileMenu,overlay:!1,data:l})})(i,e.name,e.type===s.Iw.folder,e.origin_size)}},draggable_handle:async e=>{const n=(0,h.ib)(m,i).map(e=>(0,h.Ok)(e.name));await d.$M.post("cut",{files:n,to:`${(0,f.GG)("file",(0,f.vX)())}/${e}`});t([]),v({open:!1,handle:null}),b((0,f.vX)())},name:e.name,index:e.index,mtime:e.mtime,size:e.size,type:e.type,isLink:e.isLink,path:e.path,icon:e.icon,show_mtime:e.show_mtime,click:async(l,o)=>{if(null!==(0,r.kW)(i,l))t((0,r.P1)(i,l));else if("ctrl"===G)t([...i,l]);else if("shift"===G){const{max:e,min:n}=(0,r.a7)(i),s=[];if(l>=e)for(let i=e;i<=l;i++)s.push(i);else for(let e=n;e>=l;e--)s.push(e);t(s)}else t([l]);if(c([...n,l]),setTimeout(()=>{c((0,r.P1)(n,l))},300),e.type===s.Iw.folder){if(void 0!==n.find(e=>e===l))return void C(o)}else{void 0!==n.find(e=>e===l)&&z({name:o,size:e.origin_size,opt_shell:!0,mtime:e.mtime})}},itemWidth:e.itemWidth})}t(38240);var v=t(64405),A=t(88815);function j(e){const[i,t]=(0,l.fp)(o.AG.selectedFileList),[n,c]=(0,l.fp)(o.AG.clickFileList),[p,x]=(0,l.fp)(o.AG.editorSetting),[g,k]=(0,l.fp)(o.AG.shellNowDir),[j,G]=(0,l.fp)(o.AG.sshInfo),[F,z]=(0,l.fp)(o.AG.nowFileList),[$,b]=(0,l.fp)(o.AG.enterKey),[C,W]=(0,l.fp)(o.AG.confirm),M=(0,a.Zp)(),{t:S}=(0,y.Bd)();return(0,u.jsx)(_,{draggable_handle:async n=>{const s=new v.x;Object.assign(s,j),s.target=(0,r.HS)(...g,n);const l=(0,h.ib)(F,i).map(e=>(0,r.HS)(...g,e.name));for(const e of l)if(s.source=e,!await d.Fg.post("move",s))return!1;t([]),W({open:!1,handle:null}),await e.fileHandler()},name:e.name,index:e.index,mtime:e.mtime,size:e.size,type:e.type,itemWidth:e.itemWidth,show_mtime:e.show_mtime,click:async(l,o)=>{if(null!==(0,r.kW)(i,l))t((0,r.P1)(i,l));else if("ctrl"===$)t([...i,l]);else if("shift"===$){const{max:e,min:n}=(0,r.a7)(i),s=[];if(l>=e)for(let i=e;i<=l;i++)s.push(i);else for(let e=n;e>=l;e--)s.push(e);t(s)}else t([l]);if(c([...n,l]),setTimeout(()=>{c((0,r.P1)(n,l))},300),e.type===s.Iw.folder){if(void 0!==n.find(e=>e===l)){const e=new v.x;return e.key=j.key,e.dir=`/${(0,f.GG)("remoteShell",(0,f.vX)())}${o}`,M((0,r.IO)((0,f.vX)(),o)),t([]),c([]),void z({files:[],folders:[]})}}else{if(void 0!==n.find(e=>e===l)){const i=async()=>{const i=new v.x;i.key=j.key,i.file=`/${(0,f.GG)("remoteShell",(0,f.vX)())}${o}`;const t=await d.Fg.post("get/file/text",i);let n;o.endsWith(s.Iw.workflow_act)?n="ace/mode/yaml":(o.endsWith(s.Iw.draw)||o.endsWith(s.Iw.excalidraw))&&(n="ace/mode/json"),x({model:n,open:!0,fileName:e.name,save:async e=>{i.context=e;0===(await d.Fg.post("update/file/text",i)).code&&(w.xK.set_value_temp(""),(0,m.SK)("success"))}}),w.xK.set_value_temp(t.data)};return"number"==typeof e.origin_size&&e.origin_size>A.o5?void W({open:!0,title:S("提示"),sub_title:"文件超过20MB了确定要打开吗?",handle:async()=>{W({open:!1,handle:null}),await i()}}):void await i()}}}})}function G(e){const[i,t]=(0,l.fp)(o.AG.selectedFileList),[n,a]=(0,l.fp)(o.AG.clickFileList),[f,c]=(0,l.fp)(o.AG.enterKey),{click_file:m}=(0,w.kZ)(),[p,k]=(0,l.fp)(o.AG.nowFileList),{t:v}=(0,y.Bd)(),[A,j]=(0,l.fp)(o.AG.showPrompt),G=((0,h.oT)(),(0,h.xp)());return(0,u.jsx)(_,{extraAttr:{onContextMenu:i=>{((i,t,n,l)=>{i.preventDefault(),i.stopPropagation();const o=new g.ik,a=e.item_list;for(const e of a)if(e.name===t){o.path=e.path;break}o.is_share=!0,o.filename=t,o.x=i.clientX,o.y=i.clientY,o.type=n?s.Iw.folder:(0,g.uL)(t),o.size=l,o.share_token=e.share.share_token,o.share_id=e.share.share_id,j({show:!0,type:x.PromptEnum.FileMenu,overlay:!1,data:o})})(i,e.name,e.type===s.Iw.folder,e.origin_size)}},name:e.name,index:e.index,mtime:e.mtime,size:e.size,type:e.type,itemWidth:e.itemWidth,show_mtime:e.show_mtime,click:async(l,o)=>{if(null!==(0,r.kW)(i,l))t((0,r.P1)(i,l));else if("ctrl"===f)t([...i,l]);else if("shift"===f){const{max:e,min:n}=(0,r.a7)(i),s=[];if(l>=e)for(let i=e;i<=l;i++)s.push(i);else for(let e=n;e>=l;e--)s.push(e);t(s)}else t([l]);if(a([...n,l]),setTimeout(()=>{a((0,r.P1)(n,l))},300),e.type!==s.Iw.folder){const i=n.find(e=>e===l);if(void 0!==i){if(G(o))return;m({file_path:e.item_list[i].path,file_url:d.$M.getDownloadUrlV2(e.item_list[i].path,"share_download",{share_id:e.share.share_id,share_token:e.share.share_token}),name:o,size:e.origin_size,opt_shell:!0,mtime:e.mtime,not_type_tip:v("未知类型,请下载查看")})}}}})}function F({handleContextMenu:e,file_list:i,clickBlank:t,share:s}){const[a,r]=(0,l.fp)(o.AG.user_base_info),d=(0,n.useRef)(null),{t:f}=(0,y.Bd)(),c=(0,h.OJ)(),{file_is_running:m}=(0,w.hg)();return(0,h.UK)(i,[],d),(0,u.jsx)("div",{onContextMenu:e,id:"listing",style:{paddingBottom:"10rem"},className:`mosaic file-icons ${a?.user_data?.file_list_show_type??""}`,ref:d,children:(0,u.jsx)("div",{onClick:t,children:i.map((e,t)=>(0,u.jsx)(n.Fragment,{children:(0,u.jsx)(G,{share:s,item_list:i,icon:m(e.name)?"refresh":void 0,itemWidth:c,index:t+0,...e})},t+0))})})}function z({handleContextMenu:e,file_list:i,folder_list:t,clickBlank:s,fileHandler:a}){const[r,d]=(0,l.fp)(o.AG.user_base_info),f=(0,n.useRef)(null),{t:c}=(0,y.Bd)(),m=(0,h.OJ)(),{file_is_running:p}=(0,w.hg)(),[_,g]=(0,l.fp)(o.AG.fileShellShow),k=(0,n.useMemo)(()=>t?.length??0,[t]);return(0,h.ei)(f,x.PromptEnum.SshUpload),(0,h.UK)(i,t,f),(0,n.useEffect)(()=>()=>{_.show&&g({show:!1,path:""})},[]),(0,u.jsxs)("div",{onContextMenu:e,id:"listing",style:{paddingBottom:"10rem"},className:`mosaic file-icons ${r?.user_data?.file_list_show_type??""}`,ref:f,children:[t&&t.length>0&&(0,u.jsx)("h2",{children:c("文件夹")}),t&&(0,u.jsx)("div",{onClick:s,children:t.map((e,i)=>(0,u.jsx)(n.Fragment,{children:(0,u.jsx)(j,{fileHandler:a,itemWidth:m,index:i,...e})},i))}),i&&i.length>0&&(0,u.jsx)("h2",{onClick:s,children:c("文件")}),i&&(0,u.jsx)("div",{onClick:s,children:i.map((e,i)=>(0,u.jsx)(n.Fragment,{children:(0,u.jsx)(j,{fileHandler:a,icon:p(e.name)?"refresh":void 0,itemWidth:m,index:i+k,...e})},i+k))})]})}function $({handleContextMenu:e,file_list:i,folder_list:t,clickBlank:s}){const[a,r]=(0,l.fp)(o.AG.user_base_info),d=(0,n.useRef)(null),{t:f}=(0,y.Bd)(),[c]=(0,l.fp)(o.AG.zoom_style_by_percent),m=(0,h.OJ)(),{file_is_running:p}=(0,w.hg)(),[_,g]=(0,l.fp)(o.AG.fileShellShow),v=(0,n.useMemo)(()=>t?.length??0,[t]),A=(0,h.pi)(c);return(0,h.ei)(d,x.PromptEnum.FilesUpload),(0,h.UK)(i,t,d),(0,n.useEffect)(()=>()=>{_.show&&g({show:!1,path:""})},[]),(0,u.jsxs)("div",{onContextMenu:e,id:"listing",style:{paddingBottom:"10rem",fontSize:A.fontSize},className:`mosaic file-icons ${a?.user_data?.file_list_show_type??""}`,ref:d,children:[t&&t.length>0&&(0,u.jsx)("h2",{children:f("文件夹")}),t&&(0,u.jsx)("div",{onClick:s,children:t.map((e,i)=>(0,u.jsx)(n.Fragment,{children:(0,u.jsx)(k,{itemWidth:m,index:i,...e})},i))}),i&&i.length>0&&(0,u.jsx)("h2",{onClick:s,children:f("文件")}),i&&(0,u.jsx)("div",{onClick:s,children:i.map((e,i)=>(0,u.jsx)(n.Fragment,{children:(0,u.jsx)(k,{icon:p(e.name)?"refresh":void 0,itemWidth:m,index:i+v,...e})},i+v))})]})}function b({handleContextMenu:e,list:i,clickBlank:t}){const[s,a]=(0,l.fp)(o.AG.user_base_info),r=(0,n.useRef)(null),{t:d}=(0,y.Bd)(),[f]=(0,l.fp)(o.AG.zoom_style_by_percent),c=(0,h.OJ)(),{file_is_running:m}=(0,w.hg)(),[p,_]=(0,l.fp)(o.AG.fileShellShow),[g,v]=(0,l.fp)(o.AG.enterKey),[A,j]=(0,l.fp)(o.AG.selectedFileList),[G,F]=(0,l.fp)(o.AG.file_page),z=(0,h.pi)(f);return(0,h.UK)(i,[],r),(0,h.ei)(r,x.PromptEnum.FilesUpload),(0,h.SQ)(r,()=>{F(e=>e.page_num<0?e:{page_size:e.page_size,page_num:e.page_num+1})},()=>{}),(0,n.useEffect)(()=>()=>{p.show&&_({show:!1,path:""})},[]),(0,u.jsx)("div",{onContextMenu:e,id:"listing",style:{paddingBottom:"10rem",fontSize:z.fontSize},className:`mosaic file-icons ${s?.user_data?.file_list_show_type??""}`,ref:r,children:i&&(0,u.jsx)("div",{onClick:t,children:i.map((e,i)=>(0,u.jsx)(n.Fragment,{children:(0,u.jsx)(k,{icon:m(e.name)?"refresh":void 0,itemWidth:c,index:i,...e})},i))})})}},6960(e,i,t){t.d(i,{s:()=>o});var n=t(72635);const s=1440,l=525600;function o(e){e=e>1e12?e:1e3*e;const i=Date.now(),t=Math.abs(i-e)/6e4;return t<1?n.Ay.t("小于一分钟"):t<60?`${t.toFixed(0)} ${n.Ay.t("分钟前")}`:t<s?`${(t/60).toFixed(0)} ${n.Ay.t("小时前")}`:t<43200?`${(t/s).toFixed(0)} ${n.Ay.t("天前")}`:t<l?`${(t/43200).toFixed(0)} ${n.Ay.t("月前")}`:`${(t/l).toFixed(0)} ${n.Ay.t("年前")}`}}}]);
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[6010,9782],{83277(e,t,s){s.d(t,{$j:()=>c,Lv:()=>a,qq:()=>i});class n{options_agent_url_list;options_agent_key_list;options_agent_model_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}const o=JSON.stringify({stream:!0,thinking:{type:"disabled"}});function c(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',"cL",0,o])},86271(e,t,s){s.r(t),s.d(t,{default:()=>M});var n=s(96540),a=s(14284),i=s(7463),o=s(57952),c=s(85997),r=s(78247),l=s(23430),d=s(40505),u=s(62042),m=s(22022),h=s(45907),g=s(53459),p=s(87361),x=s(52671),_=s(34843),f=s(82893),j=s(27690),v=s(61443),y=s(72693),b=s(83277),w=s(74848);function S({sessions:e,activeSessionId:t,onSelectSession:s,onRenameSession:a,onDeleteSession:i,onShowUsageStats:o,batchMode:r,selectedSessionIds:l,onToggleSessionSelect:d}){const{t:u}=(0,m.Bd)(),[h,g]=(0,_.fp)(f.AG.ai_session_collapsed),[p,x]=(0,n.useState)(""),v=p.trim()?e.filter(e=>(e.title||"").toLowerCase().includes(p.toLowerCase())||(e.summary||"").toLowerCase().includes(p.toLowerCase())||(e.long_term_memory||"").toLowerCase().includes(p.toLowerCase())):e;return(0,w.jsxs)("aside",{className:`chat-session-list ${h?"active":""} ${h?"collapsed":""}`,children:[!h&&(0,w.jsx)("div",{className:"chat-session-search",children:(0,w.jsx)("input",{type:"text",className:"chat-session-search-input",placeholder:u("搜索会话"),value:p,onChange:e=>x(e.target.value)})}),v.map(e=>{return(0,w.jsx)("div",{children:(0,w.jsxs)("button",{className:`chat-session-item ${t===e.id?"active":""} ${r?"batch-mode":""}`,onClick:()=>{r&&d?d(e.id):s(e.id)},title:e.summary||e.long_term_memory||e.title,children:[r&&(0,w.jsx)("input",{type:"checkbox",className:"chat-session-checkbox",checked:l?.has(e.id)??!1,onChange:()=>d?.(e.id),onClick:e=>e.stopPropagation()}),(0,w.jsx)("span",{children:(n=e.title,n||"新会话")}),(0,w.jsx)("small",{children:e.message_count}),"web"!==e.source&&(0,w.jsx)("em",{className:"chat-session-source",children:e.source}),!r&&(0,w.jsx)(j.MenuSelect,{list:[{name:u("重命名"),click:()=>a(e.id,e.title)},{name:u("字符消耗统计"),click:()=>o(e.id)},{name:u("删除"),click:()=>i(e.id)}],children:(0,w.jsx)(c.In,{icon:"more_horiz"})})]})},e.id);var n})]})}function k({pendingAttachments:e,onRemove:t}){return 0===e.length?null:(0,w.jsx)("div",{className:"chat-attachment-strip",children:e.map((e,s)=>(0,w.jsxs)("div",{className:"chat-attachment-chip",children:[(0,w.jsx)(c.In,{icon:"attach_file"}),(0,w.jsx)("span",{title:e.name,children:e.name}),(0,w.jsx)("button",{type:"button",onClick:()=>t(s),children:(0,w.jsx)(c.In,{icon:"close"})})]},`${e.name}_${s}`))})}function N({inputValue:e,onInputChange:t,onKeyDown:s,onPaste:n,onSend:a,sending:i,pendingAttachments:o,onRemoveAttachment:r,onOpenFilePicker:l,onAddFiles:d,onDrop:u,onDragOver:h,fileInputRef:g}){const{t:p}=(0,m.Bd)();return(0,w.jsxs)("div",{className:"chat-input-area",onDrop:u,onDragOver:h,children:[(0,w.jsx)("input",{ref:g,type:"file",multiple:!0,style:{display:"none"},onChange:e=>{e.target.files?.length&&(d(e.target.files),e.currentTarget.value="")}}),(0,w.jsxs)("div",{className:"chat-input-shell",children:[(0,w.jsx)(k,{pendingAttachments:o,onRemove:r}),(0,w.jsx)("textarea",{value:e,onChange:t,onPaste:n,onKeyDown:s,placeholder:p("输入消息"),className:"chat-input"})]}),(0,w.jsx)(c.rA,{title:p("添加文件"),icon:"attach_file",onClick:l}),!1===i?(0,w.jsx)(c.Vi,{text:p("发送"),clickFun:a}):(0,w.jsx)("div",{className:"ai-thinking-indicator",children:(0,w.jsxs)("div",{className:"ai-thinking-dots",children:[(0,w.jsx)("div",{className:"ai-thinking-dot"}),(0,w.jsx)("div",{className:"ai-thinking-dot"}),(0,w.jsx)("div",{className:"ai-thinking-dot"})]})})]})}var A=s(96494);function C(){try{const e=localStorage.getItem("ai_images_extra_params");if(e)return JSON.parse(e)}catch{}return{size:"1024x1024",n:1}}function $({onClose:e}){const{t}=(0,m.Bd)(),[s,a]=(0,n.useState)(C),[i,o]=(0,n.useState)(s.size||"1024x1024"),[r,l]=(0,n.useState)(String(s.n??1)),[d,u]=(0,n.useState)(s.quality||""),[h,g]=(0,n.useState)(s.style||""),[p,x]=(0,n.useState)(s.extra_json||"");return(0,w.jsxs)("div",{className:"card images-params-card",children:[(0,w.jsx)("h3",{children:t("图片生成参数设置")}),(0,w.jsx)("p",{className:"images-params-hint",children:"不同模型支持的参数不同,请参考模型文档。常见 size 值: 1024x1024, 1792x1024, 1024x1792 (DALL-E 3)"}),(0,w.jsxs)("div",{className:"images-params-fields",children:[(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{children:"size (图片尺寸)"}),(0,w.jsx)(v.Sm,{value:i,handleInputChange:o,no_border:!1})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{children:"n (生成数量)"}),(0,w.jsx)(v.Sm,{value:r,handleInputChange:l,no_border:!1})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{children:'quality (画质, 如 "standard" / "hd")'}),(0,w.jsx)(v.Sm,{value:d,handleInputChange:u,no_border:!1})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{children:'style (风格, 如 "vivid" / "natural")'}),(0,w.jsx)(v.Sm,{value:h,handleInputChange:g,no_border:!1})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{children:"额外参数 (JSON,会合并到请求体中)"}),(0,w.jsx)(v.Sm,{value:p,handleInputChange:x,no_border:!1})]})]}),(0,w.jsxs)("div",{className:"images-params-actions",children:[(0,w.jsx)(c.rA,{icon:"close",title:t("取消"),onClick:e}),(0,w.jsx)(c.rA,{icon:"save",title:t("保存"),onClick:()=>{const t={size:i,n:parseInt(r)||1};d&&(t.quality=d),h&&(t.style=h),p&&(t.extra_json=p),function(e){localStorage.setItem("ai_images_extra_params",JSON.stringify(e))}(t),e()}})]})]})}function I(){const{t:e}=(0,m.Bd)(),[t,s]=(0,_.fp)(f.AG.ai_request_type),[a,i]=(0,n.useState)(!1),o=(0,A.r)(),c=o.find(e=>e.value===t)??o[0];return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(j.MenuSelect,{list:[...o.map(e=>({name:e.label,click:()=>s(e.value)})),..."images"===t?[{name:e("图片参数设置"),click:()=>i(!0)}]:[],..."audio_speech"===t?[{name:e("语音参数设置"),click:()=>{const t=localStorage.getItem("ai_audio_extra_params"),s=t?JSON.parse(t):{},n=s.voice||"alloy",a=s.speed||"1.0",i=prompt(e("输入 voice (如 alloy, echo, fable, onyx, nova, shimmer)"),n);if(null!==i){const t=prompt(e("输入 speed (0.25 ~ 4.0)"),a);null!==t&&localStorage.setItem("ai_audio_extra_params",JSON.stringify({voice:i,speed:parseFloat(t)||1}))}}}]:[]],children:(0,w.jsxs)("div",{className:"menu-select-trigger",children:[(0,w.jsx)("span",{children:c.label}),(0,w.jsx)("span",{className:"menu-select-arrow",children:"▾"})]})}),a&&(0,w.jsx)("div",{className:"modal-overlay",onClick:()=>i(!1),children:(0,w.jsx)("div",{onClick:e=>e.stopPropagation(),children:(0,w.jsx)($,{onClose:()=>i(!1)})})})]})}var O=s(34299);function D(e){const t=e.attachments&&e.attachments.length>0?(0,w.jsx)("div",{className:"chat-message-attachments",children:e.attachments.map((e,t)=>(0,w.jsxs)("div",{className:"chat-message-attachment",children:[(0,w.jsx)(c.In,{icon:"attach_file"}),(0,w.jsx)("span",{children:e.name}),(0,w.jsxs)("small",{children:[e.size," B"]})]},`${e.name}_${t}`))}):null,s=[];return e.images&&"bot"===e.sender&&s.push((0,w.jsx)(n.Fragment,{children:(0,w.jsx)(F,{images:e.images,text:e.text})},"images")),e.audio&&"bot"===e.sender&&s.push((0,w.jsx)(n.Fragment,{children:(0,w.jsx)(V,{audio:e.audio,text:e.text})},"audio")),e.embeddings&&"bot"===e.sender&&s.push((0,w.jsx)(n.Fragment,{children:(0,w.jsx)(z,{embeddings:e.embeddings,text:e.text})},"embeddings")),0===s.length?(0,w.jsxs)(w.Fragment,{children:[t,(0,w.jsx)(O.default,{context:e.text})]}):(0,w.jsxs)(w.Fragment,{children:[s,t,e.text&&(0,w.jsx)(O.default,{context:e.text})]})}function F({images:e,text:t}){let s=e||[];if(!s.length&&t)try{s=JSON.parse(t).data||[]}catch{}return s.length?(0,w.jsxs)("div",{className:"image-generation-result",children:[s.map((e,t)=>(0,w.jsxs)("div",{className:"image-generation-item",children:[e.url&&(0,w.jsx)("div",{className:"image-generation-image-wrapper",children:(0,w.jsx)("img",{src:e.url,alt:e.revised_prompt||`生成的图片 ${t+1}`,loading:"lazy"})}),e.b64_json&&(0,w.jsx)("div",{className:"image-generation-image-wrapper",children:(0,w.jsx)("img",{src:`data:image/png;base64,${e.b64_json}`,alt:`生成的图片 ${t+1}`})}),e.revised_prompt&&(0,w.jsx)("p",{className:"image-generation-prompt",children:(0,w.jsx)("small",{children:e.revised_prompt})})]},t)),t&&!e&&(0,w.jsx)(O.default,{context:t})]}):(0,w.jsx)(O.default,{context:t||""})}function V({audio:e,text:t}){if(e){if(e.url)return(0,w.jsx)("div",{className:"audio-result",children:(0,w.jsx)("audio",{controls:!0,src:e.url,children:"您的浏览器不支持音频播放"})});if(e.data){const t=e.mime_type||"audio/mpeg";return(0,w.jsx)("div",{className:"audio-result",children:(0,w.jsx)("audio",{controls:!0,src:`data:${t};base64,${e.data}`,children:"您的浏览器不支持音频播放"})})}}const s=t||"";if(s.startsWith("http://")||s.startsWith("https://"))return(0,w.jsx)("div",{className:"audio-result",children:(0,w.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,w.jsx)("div",{className:"audio-result",children:(0,w.jsx)("audio",{controls:!0,src:`data:audio/mpeg;base64,${t}`,children:"您的浏览器不支持音频播放"})})}}catch{}return(0,w.jsx)(O.default,{context:s})}function J({content:e,label:t}){const[s,a]=n.useState(!1);return(0,w.jsxs)("button",{className:"embeddings-copy-btn",onClick:()=>{(0,d.lW)(e),a(!0),setTimeout(()=>a(!1),1500)},children:[(0,w.jsx)(c.In,{icon:s?"check":"content_copy"}),s?"已复制":t||"复制"]})}function z({embeddings:e,text:t}){let s=e||null;if(!s&&t)try{s=JSON.parse(t)}catch{return(0,w.jsx)(O.default,{context:t})}if(!s)return(0,w.jsx)(O.default,{context:t||""});const n=s?.data||[],a=s?.usage,i=JSON.stringify(s,null,2);return(0,w.jsxs)("div",{className:"embeddings-result",children:[(0,w.jsxs)("div",{className:"embeddings-summary",children:[(0,w.jsx)("strong",{children:"向量嵌入结果"}),(0,w.jsxs)("span",{children:["维度: ",n[0]?.embedding?.length??"N/A"]}),(0,w.jsxs)("span",{children:["数量: ",n.length]}),a&&(0,w.jsxs)("span",{children:["使用 tokens: ",a.total_tokens??"N/A"]})]}),(0,w.jsxs)("div",{className:"embeddings-toolbar",children:[(0,w.jsx)(J,{content:i,label:"复制全部结果"}),n.length>0&&n[0]?.embedding&&(0,w.jsx)(J,{content:JSON.stringify(n[0].embedding,null,2),label:"复制第一条向量"}),n.length>0&&(0,w.jsx)(J,{content:JSON.stringify(n.map(e=>e.embedding),null,2),label:"复制所有向量数据"})]}),n.length>0&&n[0]?.embedding&&(0,w.jsx)("div",{className:"embeddings-preview",children:(0,w.jsxs)("span",{children:["向量预览: [",n[0].embedding.slice(0,5).join(", "),n[0].embedding.length>5?", ...":"","]"]})}),n.length>0&&(0,w.jsxs)("details",{children:[(0,w.jsx)("summary",{children:"查看详细数据"}),(0,w.jsx)("pre",{className:"embeddings-raw",children:i})]})]})}async function R(e,t){const s=function(){try{const e=localStorage.getItem("ai_images_extra_params");if(e)return JSON.parse(e)}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 i=await a.jV.post("images/generations",n);if(0!==i.code)throw new Error(i.message||"图片生成失败");const o=i.data||{},c=(o.data||[]).map(e=>({url:e.url,b64_json:e.b64_json,revised_prompt:e.revised_prompt})),r=c.map((e,t)=>`![生成图片${t+1}](${e.url||`data:image/png;base64,${e.b64_json}`})${e.revised_prompt?`\n> ${e.revised_prompt}`:""}`).join("\n\n");return{session_id:o.session_id||t,images:c,text:r||`生成了 ${c.length} 张图片`}}async function q(e,t,s,n){try{switch(e){case"images":{const e=await R(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,o=await a.arrayBuffer();return{session_id:i,audio:{data:btoa(String.fromCharCode(...Array.from(new Uint8Array(o)))),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 a.jV.post("embeddings",{input:e,session_id:t});if(0!==s.code)throw new Error(s.message||"Embeddings 请求失败");const n=s.data||{},i=n?.data??[],o=`向量维度: ${i[0]?.embedding?.length??0}, 数量: ${i.length}`;return{session_id:n.session_id||t,embeddings:n,text:`✅ Embeddings 结果 - ${o}\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}}function H(e){return e.type?.startsWith("image/")?"image":e.type?.startsWith("text/")||/\.(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.test(e.name)?"text":"binary"}function L(e){return e.text()}function E(e){return new Promise((t,s)=>{const n=new FileReader;n.onload=()=>t(n.result),n.onerror=s,n.readAsDataURL(e)})}function B(e){return e.map(e=>({role:"bot"===e.sender?"assistant":"user",content:e.text,attachments:e.attachments??[],images:e.images,audio:e.audio,embeddings:e.embeddings}))}function M(){const[e,t]=(0,n.useState)([]),[s,k]=(0,n.useState)([]),[C,$]=(0,n.useState)(""),[O,F]=(0,_.fp)(f.AG.ai_session_collapsed),[V,J]=(0,n.useState)([]),[z,R]=(0,_.fp)(f.AG.ai_request_type);(0,y.w)();const M=(0,A.r)(),{t:T}=(0,m.Bd)(),K=(0,n.useRef)(null),[P,G]=(0,_.fp)(f.AG.prompt_card),[W,U]=(0,n.useState)(!1),[X,Z]=(0,n.useState)(new Set),[Q,Y]=(0,n.useState)(new Set),ee=(0,n.useRef)((0,i.sg)(e=>{t(e),de.current&&xe(!1)},50)).current,[te,se]=(0,n.useState)(!1),{check_user_auth:ne}=(0,r.MH)(),[ae,ie]=(0,n.useState)(""),oe=(0,n.useRef)(null),ce=(0,n.useRef)(null),re=(0,h.y)(),le=(0,x.Zp)(),de=(0,n.useRef)(!0),ue=(0,n.useRef)(new b.qq),[me,he]=(0,n.useState)([]),[ge,pe]=(0,n.useState)(""),xe=(e=!1)=>{const t=ce.current;t&&t.scrollTo({top:t.scrollHeight,behavior:e?"smooth":"auto"})},_e=e=>{const t=Array.from(e??[]).filter(Boolean);t.length&&J(e=>[...e,...t])},fe=async e=>{const s=await a.jV.get("sessions");if(s.code!==g.m.Success)return;const n=s.data??[];k(n);const i=null===e?n[0]?.id??"":e||C||n[0]?.id||"";i?await ve(i):(t([]),$(""))},je=async()=>{const e=await a.jV.get("sessions");e.code===g.m.Success&&k(e.data??[])},ve=async(e,s=!1)=>{const n=await a.jV.post("session/get",{session_id:e});if(n.code!==g.m.Success||!n.data)return;const i=n.data;$(i.id),t(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:(0,b.$j)(e.content),attachments:e.attachments??[],images:e.images,audio:e.audio,embeddings:e.embeddings}))}(i.messages)),s&&F(!1),requestAnimationFrame(()=>xe(!1))},ye=async e=>{const s=await a.jV.post("session",{title:"新会话"});if(s.code!==g.m.Success)return;const n=s.data;$(n.id),e?(ie(e),t([])):t([]),F(!1),await fe(n.id),requestAnimationFrame(()=>{const e=document.querySelector(".chat-input");e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,200)+"px")})};(0,n.useEffect)(()=>{(async()=>{const e=await a.XO.get("ai_agent_setting/env");if(e.code===g.m.Success){ue.current=e.data;const t=e.data.current_model_note||"",s=(e.data.options_agent_model_list??[]).find(e=>e.label===t);pe(s?s.value:t)}await fe();const t=await a.jV.get("system_prompts");t.code===g.m.Success&&he(t.data??[])})(),requestAnimationFrame(()=>{xe(!1)})},[]),(0,n.useEffect)(()=>{const e=ce.current;if(!e)return;const t=()=>{de.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)(()=>{de.current&&xe(!1)},[e]);const be=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??[]}]},we=async()=>{const s=ae.trim();if(te||!s&&0===V.length)return;let n=C;if(!n){const e=await a.jV.post("session",{title:(s||V[0]?.name||"新会话").slice(0,28)});if(e.code!==g.m.Success)return;n=e.data.id,$(n),await fe(n)}const o=await(async e=>{const t=[];for(const s of e){const e=H(s);let n="";if("text"===e)try{const e=await L(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 E(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})(V),c={id:Date.now(),sender:"user",text:s,attachments:o},r=[...e,c];if(t(r),ie(""),J([]),se(!0),"completions"!==z){const e={id:c.id+1,sender:"bot",text:"处理中..."};r.push(e),t([...r]);return void(await q(z,s,n,async(s,n)=>{e.text=s,n?.images&&(e.images=n.images),n?.audio&&(e.audio=n.audio),n?.embeddings&&(e.embeddings=n.embeddings),t([...r]),se(!1),je(),xe(!0)})||(e.text=`请求类型 "${z}" 的专用处理器尚未实现,请使用 completions 类型。`,t([...r]),se(!1)))}const l={id:c.id+1,sender:"bot",text:"AI思考中..."};r.push(l),t([...r]);let d=!0;a.jV.sse_post("chat",{messages:be(c),session_id:n},{onMessage:e=>{d&&(l.text="",d=!1);try{const t=JSON.parse(e),s="string"==typeof t?t:t?.choices?.[0]?.delta?.content??t?.choices?.[0]?.message?.content;s&&(l.text+=s)}catch(t){try{l.text+=JSON.parse(e)}catch(t){l.text+=e}}ee([...r])},onDone:(0,i.nF)(async()=>{se(!1),await je(),xe(!0)},100)})},Se=e=>null==e||e<0?"0":e.toLocaleString();return(0,w.jsxs)(n.Fragment,{children:[(0,w.jsxs)(o.A,{children:[(0,w.jsx)(c.rA,{icon:"menu",title:T("会话"),onClick:()=>{window.innerWidth<=736?F(!0):F(e=>!e)}}),(0,w.jsx)(c.rA,{icon:"add",title:T("新会话"),onClick:()=>ye()}),me.length>0&&(0,w.jsx)(j.MenuSelect,{list:me.map((e,t)=>({name:e.note||`${T("提示词")} ${t+1}`,click:()=>{e.prompt&&ye(e.prompt)}})),children:(0,w.jsx)(c.rA,{icon:"add_comment",title:T("提示词模板创建会话")})}),(0,w.jsx)(I,{}),(ue.current?.options_agent_model_list?.length??0)>0&&(0,w.jsx)(v.l6,{value:ge,options:ue.current.options_agent_model_list?.map(e=>({title:e.label,value:e.value}))??[],onChange:e=>{pe(e),a.jV.post("set_active_model",{model_name:e}).then(()=>{(0,u.SK)("success"),a.XO.get("ai_agent_setting/env").then(e=>{e.code===g.m.Success&&(ue.current=e.data)})}).catch(console.error)},no_border:!0,width:"auto"}),(0,w.jsx)(c.rA,{icon:W?"check_circle":"checklist",title:T(W?"取消批量选择":"批量选择"),onClick:()=>{W&&(Z(new Set),Y(new Set)),U(e=>!e)}}),W&&X.size>0&&(0,w.jsx)(c.rA,{icon:"delete",title:T("删除选中消息"),onClick:()=>{0!==X.size&&re({sub_title:T("确认删除选中的聊天消息吗?"),confirm_fun:()=>{const s=e.filter(e=>!X.has(e.id));t(s),Z(new Set),U(!1),C&&s.length!==e.length&&a.jV.post("session/messages",{session_id:C,messages:B(s)}).catch(console.error)}})}}),W&&Q.size>0&&(0,w.jsx)(c.rA,{icon:"delete",title:T("删除选中会话"),onClick:()=>{0!==Q.size&&re({sub_title:T("确认删除选中的会话吗?"),confirm_fun:async()=>{for(const e of Q)await a.jV.post("session/delete",{session_id:e});Y(new Set),U(!1),Q.has(C)?($(""),await fe(null)):await fe(C)}})}}),(0,w.jsx)(c.rA,{icon:"delete_sweep",title:T("清空全部会话"),onClick:()=>{re({sub_title:T("确认删除全部聊天会话吗?"),confirm_fun:async()=>{await a.jV.post("sessions/clear",{}),$(""),t([]),await fe(null)}})}}),ne(l.oV.ai_agent_setting)&&(0,w.jsx)(c.rA,{icon:"smart_toy",title:"机器人配置",onClick:()=>{le(`/${p.o.ai_rebot_setting_page}`)}}),ne(l.oV.ai_agent_setting)&&(0,w.jsx)(c.rA,{icon:"settings",title:"ai setting",onClick:()=>{le(`/${p.o.ai_agent_setting_page}`)}})]}),(0,w.jsxs)("div",{className:"chat-page chat-page-with-sessions",children:[O&&(0,w.jsx)("div",{className:"chat-session-overlay",onClick:()=>F(!1)}),(0,w.jsx)(S,{sessions:s,activeSessionId:C,onSelectSession:e=>ve(e,!1),onRenameSession:(e,t)=>{let s=t;re({confirm_fun:async()=>{await a.jV.post("sessions/update/meta",{id:e,title:s}),await fe(C)},context_div:(0,w.jsx)("div",{className:"card-content",children:(0,w.jsx)(v.Sm,{value:s,handleInputChange:e=>s=e})})})},onDeleteSession:e=>{re({sub_title:"确认删除这个会话吗?",confirm_fun:async()=>{await a.jV.post("session/delete",{session_id:e}),C===e?($(""),await fe(null)):await fe(C)}})},onShowUsageStats:async e=>{G({open:!0,title:T("字符消耗统计"),context_div:(0,w.jsx)("div",{className:"usage-stats-loading",children:T("加载中...")}),cancel:()=>G({open:!1})});try{const t=await a.jV.post("session/usage_stats",{session_id:e});if(t.code===g.m.Success&&t.data){const e=t.data;G({open:!0,title:T("字符消耗统计"),context_div:(0,w.jsxs)("div",{className:"usage-stats-panel",children:[[{l:T("对话轮次"),v:(e.turns??0).toString()},{l:T("AI输入字符"),v:Se(e.input_chars)},{l:T("AI输出字符"),v:Se(e.output_chars)},{l:T("AI输入字符(最近一轮)"),v:Se(e.recent_input_chars)},{l:T("AI输出字符(最近一轮)"),v:Se(e.recent_output_chars)}].map((e,t)=>(0,w.jsxs)("div",{className:"usage-stats-row",children:[(0,w.jsx)("span",{className:"usage-stats-label",children:e.l}),(0,w.jsx)("span",{className:"usage-stats-value",children:e.v})]},t)),(0,w.jsxs)("div",{className:"usage-stats-row usage-stats-total",children:[(0,w.jsx)("span",{className:"usage-stats-label",children:T("AI字符总计消耗")}),(0,w.jsx)("span",{className:"usage-stats-value",children:Se((e.input_chars||0)+(e.output_chars||0))})]})]}),cancel:()=>G({open:!1})})}else G({open:!0,title:T("字符消耗统计"),context_div:(0,w.jsx)("div",{className:"usage-stats-empty",children:T("暂无统计数据")}),cancel:()=>G({open:!1})})}catch{G({open:!0,title:T("字符消耗统计"),context_div:(0,w.jsx)("div",{className:"usage-stats-empty",children:T("暂无统计数据")}),cancel:()=>G({open:!1})})}},batchMode:W,selectedSessionIds:Q,onToggleSessionSelect:e=>{Y(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})}}),(0,w.jsxs)("section",{className:"chat-main",children:[0===e?.length&&(0,w.jsx)("div",{className:"chat-header",children:(0,w.jsx)("div",{children:"completions"===z?T("询问服务器的一切"):M.find(e=>e.value===z)?.label??z})}),(0,w.jsxs)("div",{className:"chat-messages",ref:ce,children:[e.map(s=>(0,w.jsxs)("div",{className:`chat-message ${s.sender} ${W?"batch-mode":""}`,children:[W&&(0,w.jsx)("input",{type:"checkbox",className:"chat-message-checkbox",checked:X.has(s.id),onChange:()=>{return e=s.id,void Z(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s});var e}}),D(s),!W&&(0,w.jsxs)("div",{className:"message-actions",children:[(0,w.jsx)("button",{onClick:()=>{return n=s.id,void re({sub_title:T("确认删除这条消息吗?"),confirm_fun:()=>{const s=e.filter(e=>e.id!==n);t(s),C&&a.jV.post("session/messages",{session_id:C,messages:B(s)}).catch(console.error)}});var n},children:T("删除")}),(0,w.jsx)("button",{onClick:()=>(async e=>{(0,d.lW)(e),(0,u.SK)("复制成功")})(s.text),children:T("复制")})]})]},s.id)),(0,w.jsx)("div",{ref:oe})]}),(0,w.jsx)(N,{inputValue:ae,onInputChange:e=>{const t=e.target;t.style.height="auto",t.style.height=Math.min(t.scrollHeight,200)+"px",ie(t.value)},onKeyDown:e=>{"Process"===e.key||e.nativeEvent.isComposing||e.shiftKey||e.ctrlKey||"Enter"===e.key&&(e.preventDefault(),we())},onPaste:e=>{const t=e.clipboardData?.files;t&&t.length>0&&(e.preventDefault(),_e(t))},onSend:we,sending:te,pendingAttachments:V,onRemoveAttachment:e=>{J(t=>t.filter((t,s)=>s!==e))},onOpenFilePicker:()=>{K.current?.click()},onAddFiles:_e,onDrop:e=>{const t=e.dataTransfer?.files;t&&t.length>0&&(e.preventDefault(),_e(t))},onDragOver:e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},fileInputRef:K})]})]})]})}},96494(e,t,s){s.d(t,{r:()=>a});var n=s(22022);function a(){const{t:e}=(0,n.Bd)();return[{value:"completions",label:e("文本对话")},{value:"images",label:e("图片生成")}]}},72693(e,t,s){s.d(t,{w:()=>u});var n=s(96540),a=s(22022),i=s(14944),o=s(92275),c=s(34843),r=s(82893),l=s(85997),d=s(74848);function u(){const[e,t]=(0,c.fp)(r.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(o.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)(l.$n,{text:s("拒绝"),color:"var(--red)",clickFun:()=>{i.ws.sendData(o.HK.ai_confirm_cmd,{askId:e.askId,approved:!1}),t({open:!1}),m.current=!1,h()}}),(0,d.jsx)(l.$n,{text:s("允许"),clickFun:()=>{i.ws.sendData(o.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(o.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(o.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),o=s(77979),c=s(8263),r=s(69428),l=s.n(r),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(o.A).use(c.A).use(l()).use(e=>{e.renderer.rules.fence;e.renderer.rules.fence=(t,s,n,a,i)=>{const o=t[s],c=o.content.trim(),r=o.info.trim();let l="";if(r&&m.A.getLanguage(r))try{l=m.A.highlight(c,{language:r}).value}catch(t){l=e.utils.escapeHtml(c)}else try{l=m.A.highlightAuto(c).value}catch(t){l=e.utils.escapeHtml(c)}return`\n <div class="code-block-with-copy">\n <div class="code-header">\n <span class="code-language">${r||"code"}</span>\n <button class="copy-btn" data-code="${e.utils.escapeHtml(c)}">复制</button>\n </div>\n <pre><code class="hljs ${r?`language-${r}`:""}">${l}</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 o=e[s],c=o.attrIndex("href");if(c>=0){const e=o.attrs[c][1];o.attrs[c][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>"}}]);
1
+ "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[6010,9782],{83277(e,t,s){s.d(t,{$j:()=>c,Lv:()=>a,qq:()=>i});class n{options_agent_url_list;options_agent_key_list;options_agent_model_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}const o=JSON.stringify({stream:!0,thinking:{type:"disabled"}});function c(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',"cL",0,o])},86271(e,t,s){s.r(t),s.d(t,{default:()=>M});var n=s(96540),a=s(14284),i=s(7463),o=s(57952),c=s(85997),r=s(78247),l=s(23430),d=s(40505),u=s(62042),m=s(22022),h=s(45907),g=s(53459),p=s(87361),x=s(61973),_=s(34843),f=s(82893),j=s(27690),v=s(61443),y=s(72693),b=s(83277),w=s(74848);function S({sessions:e,activeSessionId:t,onSelectSession:s,onRenameSession:a,onDeleteSession:i,onShowUsageStats:o,batchMode:r,selectedSessionIds:l,onToggleSessionSelect:d}){const{t:u}=(0,m.Bd)(),[h,g]=(0,_.fp)(f.AG.ai_session_collapsed),[p,x]=(0,n.useState)(""),v=p.trim()?e.filter(e=>(e.title||"").toLowerCase().includes(p.toLowerCase())||(e.summary||"").toLowerCase().includes(p.toLowerCase())||(e.long_term_memory||"").toLowerCase().includes(p.toLowerCase())):e;return(0,w.jsxs)("aside",{className:`chat-session-list ${h?"active":""} ${h?"collapsed":""}`,children:[!h&&(0,w.jsx)("div",{className:"chat-session-search",children:(0,w.jsx)("input",{type:"text",className:"chat-session-search-input",placeholder:u("搜索会话"),value:p,onChange:e=>x(e.target.value)})}),v.map(e=>{return(0,w.jsx)("div",{children:(0,w.jsxs)("button",{className:`chat-session-item ${t===e.id?"active":""} ${r?"batch-mode":""}`,onClick:()=>{r&&d?d(e.id):s(e.id)},title:e.summary||e.long_term_memory||e.title,children:[r&&(0,w.jsx)("input",{type:"checkbox",className:"chat-session-checkbox",checked:l?.has(e.id)??!1,onChange:()=>d?.(e.id),onClick:e=>e.stopPropagation()}),(0,w.jsx)("span",{children:(n=e.title,n||"新会话")}),(0,w.jsx)("small",{children:e.message_count}),"web"!==e.source&&(0,w.jsx)("em",{className:"chat-session-source",children:e.source}),!r&&(0,w.jsx)(j.MenuSelect,{list:[{name:u("重命名"),click:()=>a(e.id,e.title)},{name:u("字符消耗统计"),click:()=>o(e.id)},{name:u("删除"),click:()=>i(e.id)}],children:(0,w.jsx)(c.In,{icon:"more_horiz"})})]})},e.id);var n})]})}function k({pendingAttachments:e,onRemove:t}){return 0===e.length?null:(0,w.jsx)("div",{className:"chat-attachment-strip",children:e.map((e,s)=>(0,w.jsxs)("div",{className:"chat-attachment-chip",children:[(0,w.jsx)(c.In,{icon:"attach_file"}),(0,w.jsx)("span",{title:e.name,children:e.name}),(0,w.jsx)("button",{type:"button",onClick:()=>t(s),children:(0,w.jsx)(c.In,{icon:"close"})})]},`${e.name}_${s}`))})}function N({inputValue:e,onInputChange:t,onKeyDown:s,onPaste:n,onSend:a,sending:i,pendingAttachments:o,onRemoveAttachment:r,onOpenFilePicker:l,onAddFiles:d,onDrop:u,onDragOver:h,fileInputRef:g}){const{t:p}=(0,m.Bd)();return(0,w.jsxs)("div",{className:"chat-input-area",onDrop:u,onDragOver:h,children:[(0,w.jsx)("input",{ref:g,type:"file",multiple:!0,style:{display:"none"},onChange:e=>{e.target.files?.length&&(d(e.target.files),e.currentTarget.value="")}}),(0,w.jsxs)("div",{className:"chat-input-shell",children:[(0,w.jsx)(k,{pendingAttachments:o,onRemove:r}),(0,w.jsx)("textarea",{value:e,onChange:t,onPaste:n,onKeyDown:s,placeholder:p("输入消息"),className:"chat-input"})]}),(0,w.jsx)(c.rA,{title:p("添加文件"),icon:"attach_file",onClick:l}),!1===i?(0,w.jsx)(c.Vi,{text:p("发送"),clickFun:a}):(0,w.jsx)("div",{className:"ai-thinking-indicator",children:(0,w.jsxs)("div",{className:"ai-thinking-dots",children:[(0,w.jsx)("div",{className:"ai-thinking-dot"}),(0,w.jsx)("div",{className:"ai-thinking-dot"}),(0,w.jsx)("div",{className:"ai-thinking-dot"})]})})]})}var A=s(96494);function C(){try{const e=localStorage.getItem("ai_images_extra_params");if(e)return JSON.parse(e)}catch{}return{size:"1024x1024",n:1}}function $({onClose:e}){const{t}=(0,m.Bd)(),[s,a]=(0,n.useState)(C),[i,o]=(0,n.useState)(s.size||"1024x1024"),[r,l]=(0,n.useState)(String(s.n??1)),[d,u]=(0,n.useState)(s.quality||""),[h,g]=(0,n.useState)(s.style||""),[p,x]=(0,n.useState)(s.extra_json||"");return(0,w.jsxs)("div",{className:"card images-params-card",children:[(0,w.jsx)("h3",{children:t("图片生成参数设置")}),(0,w.jsx)("p",{className:"images-params-hint",children:"不同模型支持的参数不同,请参考模型文档。常见 size 值: 1024x1024, 1792x1024, 1024x1792 (DALL-E 3)"}),(0,w.jsxs)("div",{className:"images-params-fields",children:[(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{children:"size (图片尺寸)"}),(0,w.jsx)(v.Sm,{value:i,handleInputChange:o,no_border:!1})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{children:"n (生成数量)"}),(0,w.jsx)(v.Sm,{value:r,handleInputChange:l,no_border:!1})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{children:'quality (画质, 如 "standard" / "hd")'}),(0,w.jsx)(v.Sm,{value:d,handleInputChange:u,no_border:!1})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{children:'style (风格, 如 "vivid" / "natural")'}),(0,w.jsx)(v.Sm,{value:h,handleInputChange:g,no_border:!1})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{children:"额外参数 (JSON,会合并到请求体中)"}),(0,w.jsx)(v.Sm,{value:p,handleInputChange:x,no_border:!1})]})]}),(0,w.jsxs)("div",{className:"images-params-actions",children:[(0,w.jsx)(c.rA,{icon:"close",title:t("取消"),onClick:e}),(0,w.jsx)(c.rA,{icon:"save",title:t("保存"),onClick:()=>{const t={size:i,n:parseInt(r)||1};d&&(t.quality=d),h&&(t.style=h),p&&(t.extra_json=p),function(e){localStorage.setItem("ai_images_extra_params",JSON.stringify(e))}(t),e()}})]})]})}function I(){const{t:e}=(0,m.Bd)(),[t,s]=(0,_.fp)(f.AG.ai_request_type),[a,i]=(0,n.useState)(!1),o=(0,A.r)(),c=o.find(e=>e.value===t)??o[0];return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(j.MenuSelect,{list:[...o.map(e=>({name:e.label,click:()=>s(e.value)})),..."images"===t?[{name:e("图片参数设置"),click:()=>i(!0)}]:[],..."audio_speech"===t?[{name:e("语音参数设置"),click:()=>{const t=localStorage.getItem("ai_audio_extra_params"),s=t?JSON.parse(t):{},n=s.voice||"alloy",a=s.speed||"1.0",i=prompt(e("输入 voice (如 alloy, echo, fable, onyx, nova, shimmer)"),n);if(null!==i){const t=prompt(e("输入 speed (0.25 ~ 4.0)"),a);null!==t&&localStorage.setItem("ai_audio_extra_params",JSON.stringify({voice:i,speed:parseFloat(t)||1}))}}}]:[]],children:(0,w.jsxs)("div",{className:"menu-select-trigger",children:[(0,w.jsx)("span",{children:c.label}),(0,w.jsx)("span",{className:"menu-select-arrow",children:"▾"})]})}),a&&(0,w.jsx)("div",{className:"modal-overlay",onClick:()=>i(!1),children:(0,w.jsx)("div",{onClick:e=>e.stopPropagation(),children:(0,w.jsx)($,{onClose:()=>i(!1)})})})]})}var O=s(34299);function D(e){const t=e.attachments&&e.attachments.length>0?(0,w.jsx)("div",{className:"chat-message-attachments",children:e.attachments.map((e,t)=>(0,w.jsxs)("div",{className:"chat-message-attachment",children:[(0,w.jsx)(c.In,{icon:"attach_file"}),(0,w.jsx)("span",{children:e.name}),(0,w.jsxs)("small",{children:[e.size," B"]})]},`${e.name}_${t}`))}):null,s=[];return e.images&&"bot"===e.sender&&s.push((0,w.jsx)(n.Fragment,{children:(0,w.jsx)(F,{images:e.images,text:e.text})},"images")),e.audio&&"bot"===e.sender&&s.push((0,w.jsx)(n.Fragment,{children:(0,w.jsx)(V,{audio:e.audio,text:e.text})},"audio")),e.embeddings&&"bot"===e.sender&&s.push((0,w.jsx)(n.Fragment,{children:(0,w.jsx)(z,{embeddings:e.embeddings,text:e.text})},"embeddings")),0===s.length?(0,w.jsxs)(w.Fragment,{children:[t,(0,w.jsx)(O.default,{context:e.text})]}):(0,w.jsxs)(w.Fragment,{children:[s,t,e.text&&(0,w.jsx)(O.default,{context:e.text})]})}function F({images:e,text:t}){let s=e||[];if(!s.length&&t)try{s=JSON.parse(t).data||[]}catch{}return s.length?(0,w.jsxs)("div",{className:"image-generation-result",children:[s.map((e,t)=>(0,w.jsxs)("div",{className:"image-generation-item",children:[e.url&&(0,w.jsx)("div",{className:"image-generation-image-wrapper",children:(0,w.jsx)("img",{src:e.url,alt:e.revised_prompt||`生成的图片 ${t+1}`,loading:"lazy"})}),e.b64_json&&(0,w.jsx)("div",{className:"image-generation-image-wrapper",children:(0,w.jsx)("img",{src:`data:image/png;base64,${e.b64_json}`,alt:`生成的图片 ${t+1}`})}),e.revised_prompt&&(0,w.jsx)("p",{className:"image-generation-prompt",children:(0,w.jsx)("small",{children:e.revised_prompt})})]},t)),t&&!e&&(0,w.jsx)(O.default,{context:t})]}):(0,w.jsx)(O.default,{context:t||""})}function V({audio:e,text:t}){if(e){if(e.url)return(0,w.jsx)("div",{className:"audio-result",children:(0,w.jsx)("audio",{controls:!0,src:e.url,children:"您的浏览器不支持音频播放"})});if(e.data){const t=e.mime_type||"audio/mpeg";return(0,w.jsx)("div",{className:"audio-result",children:(0,w.jsx)("audio",{controls:!0,src:`data:${t};base64,${e.data}`,children:"您的浏览器不支持音频播放"})})}}const s=t||"";if(s.startsWith("http://")||s.startsWith("https://"))return(0,w.jsx)("div",{className:"audio-result",children:(0,w.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,w.jsx)("div",{className:"audio-result",children:(0,w.jsx)("audio",{controls:!0,src:`data:audio/mpeg;base64,${t}`,children:"您的浏览器不支持音频播放"})})}}catch{}return(0,w.jsx)(O.default,{context:s})}function J({content:e,label:t}){const[s,a]=n.useState(!1);return(0,w.jsxs)("button",{className:"embeddings-copy-btn",onClick:()=>{(0,d.lW)(e),a(!0),setTimeout(()=>a(!1),1500)},children:[(0,w.jsx)(c.In,{icon:s?"check":"content_copy"}),s?"已复制":t||"复制"]})}function z({embeddings:e,text:t}){let s=e||null;if(!s&&t)try{s=JSON.parse(t)}catch{return(0,w.jsx)(O.default,{context:t})}if(!s)return(0,w.jsx)(O.default,{context:t||""});const n=s?.data||[],a=s?.usage,i=JSON.stringify(s,null,2);return(0,w.jsxs)("div",{className:"embeddings-result",children:[(0,w.jsxs)("div",{className:"embeddings-summary",children:[(0,w.jsx)("strong",{children:"向量嵌入结果"}),(0,w.jsxs)("span",{children:["维度: ",n[0]?.embedding?.length??"N/A"]}),(0,w.jsxs)("span",{children:["数量: ",n.length]}),a&&(0,w.jsxs)("span",{children:["使用 tokens: ",a.total_tokens??"N/A"]})]}),(0,w.jsxs)("div",{className:"embeddings-toolbar",children:[(0,w.jsx)(J,{content:i,label:"复制全部结果"}),n.length>0&&n[0]?.embedding&&(0,w.jsx)(J,{content:JSON.stringify(n[0].embedding,null,2),label:"复制第一条向量"}),n.length>0&&(0,w.jsx)(J,{content:JSON.stringify(n.map(e=>e.embedding),null,2),label:"复制所有向量数据"})]}),n.length>0&&n[0]?.embedding&&(0,w.jsx)("div",{className:"embeddings-preview",children:(0,w.jsxs)("span",{children:["向量预览: [",n[0].embedding.slice(0,5).join(", "),n[0].embedding.length>5?", ...":"","]"]})}),n.length>0&&(0,w.jsxs)("details",{children:[(0,w.jsx)("summary",{children:"查看详细数据"}),(0,w.jsx)("pre",{className:"embeddings-raw",children:i})]})]})}async function R(e,t){const s=function(){try{const e=localStorage.getItem("ai_images_extra_params");if(e)return JSON.parse(e)}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 i=await a.jV.post("images/generations",n);if(0!==i.code)throw new Error(i.message||"图片生成失败");const o=i.data||{},c=(o.data||[]).map(e=>({url:e.url,b64_json:e.b64_json,revised_prompt:e.revised_prompt})),r=c.map((e,t)=>`![生成图片${t+1}](${e.url||`data:image/png;base64,${e.b64_json}`})${e.revised_prompt?`\n> ${e.revised_prompt}`:""}`).join("\n\n");return{session_id:o.session_id||t,images:c,text:r||`生成了 ${c.length} 张图片`}}async function q(e,t,s,n){try{switch(e){case"images":{const e=await R(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,o=await a.arrayBuffer();return{session_id:i,audio:{data:btoa(String.fromCharCode(...Array.from(new Uint8Array(o)))),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 a.jV.post("embeddings",{input:e,session_id:t});if(0!==s.code)throw new Error(s.message||"Embeddings 请求失败");const n=s.data||{},i=n?.data??[],o=`向量维度: ${i[0]?.embedding?.length??0}, 数量: ${i.length}`;return{session_id:n.session_id||t,embeddings:n,text:`✅ Embeddings 结果 - ${o}\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}}function H(e){return e.type?.startsWith("image/")?"image":e.type?.startsWith("text/")||/\.(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.test(e.name)?"text":"binary"}function L(e){return e.text()}function E(e){return new Promise((t,s)=>{const n=new FileReader;n.onload=()=>t(n.result),n.onerror=s,n.readAsDataURL(e)})}function B(e){return e.map(e=>({role:"bot"===e.sender?"assistant":"user",content:e.text,attachments:e.attachments??[],images:e.images,audio:e.audio,embeddings:e.embeddings}))}function M(){const[e,t]=(0,n.useState)([]),[s,k]=(0,n.useState)([]),[C,$]=(0,n.useState)(""),[O,F]=(0,_.fp)(f.AG.ai_session_collapsed),[V,J]=(0,n.useState)([]),[z,R]=(0,_.fp)(f.AG.ai_request_type);(0,y.w)();const M=(0,A.r)(),{t:T}=(0,m.Bd)(),K=(0,n.useRef)(null),[P,G]=(0,_.fp)(f.AG.prompt_card),[W,U]=(0,n.useState)(!1),[X,Z]=(0,n.useState)(new Set),[Q,Y]=(0,n.useState)(new Set),ee=(0,n.useRef)((0,i.sg)(e=>{t(e),de.current&&xe(!1)},50)).current,[te,se]=(0,n.useState)(!1),{check_user_auth:ne}=(0,r.MH)(),[ae,ie]=(0,n.useState)(""),oe=(0,n.useRef)(null),ce=(0,n.useRef)(null),re=(0,h.y)(),le=(0,x.Zp)(),de=(0,n.useRef)(!0),ue=(0,n.useRef)(new b.qq),[me,he]=(0,n.useState)([]),[ge,pe]=(0,n.useState)(""),xe=(e=!1)=>{const t=ce.current;t&&t.scrollTo({top:t.scrollHeight,behavior:e?"smooth":"auto"})},_e=e=>{const t=Array.from(e??[]).filter(Boolean);t.length&&J(e=>[...e,...t])},fe=async e=>{const s=await a.jV.get("sessions");if(s.code!==g.m.Success)return;const n=s.data??[];k(n);const i=null===e?n[0]?.id??"":e||C||n[0]?.id||"";i?await ve(i):(t([]),$(""))},je=async()=>{const e=await a.jV.get("sessions");e.code===g.m.Success&&k(e.data??[])},ve=async(e,s=!1)=>{const n=await a.jV.post("session/get",{session_id:e});if(n.code!==g.m.Success||!n.data)return;const i=n.data;$(i.id),t(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:(0,b.$j)(e.content),attachments:e.attachments??[],images:e.images,audio:e.audio,embeddings:e.embeddings}))}(i.messages)),s&&F(!1),requestAnimationFrame(()=>xe(!1))},ye=async e=>{const s=await a.jV.post("session",{title:"新会话"});if(s.code!==g.m.Success)return;const n=s.data;$(n.id),e?(ie(e),t([])):t([]),F(!1),await fe(n.id),requestAnimationFrame(()=>{const e=document.querySelector(".chat-input");e&&(e.style.height="auto",e.style.height=Math.min(e.scrollHeight,200)+"px")})};(0,n.useEffect)(()=>{(async()=>{const e=await a.XO.get("ai_agent_setting/env");if(e.code===g.m.Success){ue.current=e.data;const t=e.data.current_model_note||"",s=(e.data.options_agent_model_list??[]).find(e=>e.label===t);pe(s?s.value:t)}await fe();const t=await a.jV.get("system_prompts");t.code===g.m.Success&&he(t.data??[])})(),requestAnimationFrame(()=>{xe(!1)})},[]),(0,n.useEffect)(()=>{const e=ce.current;if(!e)return;const t=()=>{de.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)(()=>{de.current&&xe(!1)},[e]);const be=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??[]}]},we=async()=>{const s=ae.trim();if(te||!s&&0===V.length)return;let n=C;if(!n){const e=await a.jV.post("session",{title:(s||V[0]?.name||"新会话").slice(0,28)});if(e.code!==g.m.Success)return;n=e.data.id,$(n),await fe(n)}const o=await(async e=>{const t=[];for(const s of e){const e=H(s);let n="";if("text"===e)try{const e=await L(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 E(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})(V),c={id:Date.now(),sender:"user",text:s,attachments:o},r=[...e,c];if(t(r),ie(""),J([]),se(!0),"completions"!==z){const e={id:c.id+1,sender:"bot",text:"处理中..."};r.push(e),t([...r]);return void(await q(z,s,n,async(s,n)=>{e.text=s,n?.images&&(e.images=n.images),n?.audio&&(e.audio=n.audio),n?.embeddings&&(e.embeddings=n.embeddings),t([...r]),se(!1),je(),xe(!0)})||(e.text=`请求类型 "${z}" 的专用处理器尚未实现,请使用 completions 类型。`,t([...r]),se(!1)))}const l={id:c.id+1,sender:"bot",text:"AI思考中..."};r.push(l),t([...r]);let d=!0;a.jV.sse_post("chat",{messages:be(c),session_id:n},{onMessage:e=>{d&&(l.text="",d=!1);try{const t=JSON.parse(e),s="string"==typeof t?t:t?.choices?.[0]?.delta?.content??t?.choices?.[0]?.message?.content;s&&(l.text+=s)}catch(t){try{l.text+=JSON.parse(e)}catch(t){l.text+=e}}ee([...r])},onDone:(0,i.nF)(async()=>{se(!1),await je(),xe(!0)},100)})},Se=e=>null==e||e<0?"0":e.toLocaleString();return(0,w.jsxs)(n.Fragment,{children:[(0,w.jsxs)(o.A,{children:[(0,w.jsx)(c.rA,{icon:"menu",title:T("会话"),onClick:()=>{window.innerWidth<=736?F(!0):F(e=>!e)}}),(0,w.jsx)(c.rA,{icon:"add",title:T("新会话"),onClick:()=>ye()}),me.length>0&&(0,w.jsx)(j.MenuSelect,{list:me.map((e,t)=>({name:e.note||`${T("提示词")} ${t+1}`,click:()=>{e.prompt&&ye(e.prompt)}})),children:(0,w.jsx)(c.rA,{icon:"add_comment",title:T("提示词模板创建会话")})}),(0,w.jsx)(I,{}),(ue.current?.options_agent_model_list?.length??0)>0&&(0,w.jsx)(v.l6,{value:ge,options:ue.current.options_agent_model_list?.map(e=>({title:e.label,value:e.value}))??[],onChange:e=>{pe(e),a.jV.post("set_active_model",{model_name:e}).then(()=>{(0,u.SK)("success"),a.XO.get("ai_agent_setting/env").then(e=>{e.code===g.m.Success&&(ue.current=e.data)})}).catch(console.error)},no_border:!0,width:"auto"}),(0,w.jsx)(c.rA,{icon:W?"check_circle":"checklist",title:T(W?"取消批量选择":"批量选择"),onClick:()=>{W&&(Z(new Set),Y(new Set)),U(e=>!e)}}),W&&X.size>0&&(0,w.jsx)(c.rA,{icon:"delete",title:T("删除选中消息"),onClick:()=>{0!==X.size&&re({sub_title:T("确认删除选中的聊天消息吗?"),confirm_fun:()=>{const s=e.filter(e=>!X.has(e.id));t(s),Z(new Set),U(!1),C&&s.length!==e.length&&a.jV.post("session/messages",{session_id:C,messages:B(s)}).catch(console.error)}})}}),W&&Q.size>0&&(0,w.jsx)(c.rA,{icon:"delete",title:T("删除选中会话"),onClick:()=>{0!==Q.size&&re({sub_title:T("确认删除选中的会话吗?"),confirm_fun:async()=>{for(const e of Q)await a.jV.post("session/delete",{session_id:e});Y(new Set),U(!1),Q.has(C)?($(""),await fe(null)):await fe(C)}})}}),(0,w.jsx)(c.rA,{icon:"delete_sweep",title:T("清空全部会话"),onClick:()=>{re({sub_title:T("确认删除全部聊天会话吗?"),confirm_fun:async()=>{await a.jV.post("sessions/clear",{}),$(""),t([]),await fe(null)}})}}),ne(l.oV.ai_agent_setting)&&(0,w.jsx)(c.rA,{icon:"smart_toy",title:"机器人配置",onClick:()=>{le(`/${p.o.ai_rebot_setting_page}`)}}),ne(l.oV.ai_agent_setting)&&(0,w.jsx)(c.rA,{icon:"settings",title:"ai setting",onClick:()=>{le(`/${p.o.ai_agent_setting_page}`)}})]}),(0,w.jsxs)("div",{className:"chat-page chat-page-with-sessions",children:[O&&(0,w.jsx)("div",{className:"chat-session-overlay",onClick:()=>F(!1)}),(0,w.jsx)(S,{sessions:s,activeSessionId:C,onSelectSession:e=>ve(e,!1),onRenameSession:(e,t)=>{let s=t;re({confirm_fun:async()=>{await a.jV.post("sessions/update/meta",{id:e,title:s}),await fe(C)},context_div:(0,w.jsx)("div",{className:"card-content",children:(0,w.jsx)(v.Sm,{value:s,handleInputChange:e=>s=e})})})},onDeleteSession:e=>{re({sub_title:"确认删除这个会话吗?",confirm_fun:async()=>{await a.jV.post("session/delete",{session_id:e}),C===e?($(""),await fe(null)):await fe(C)}})},onShowUsageStats:async e=>{G({open:!0,title:T("字符消耗统计"),context_div:(0,w.jsx)("div",{className:"usage-stats-loading",children:T("加载中...")}),cancel:()=>G({open:!1})});try{const t=await a.jV.post("session/usage_stats",{session_id:e});if(t.code===g.m.Success&&t.data){const e=t.data;G({open:!0,title:T("字符消耗统计"),context_div:(0,w.jsxs)("div",{className:"usage-stats-panel",children:[[{l:T("对话轮次"),v:(e.turns??0).toString()},{l:T("AI输入字符"),v:Se(e.input_chars)},{l:T("AI输出字符"),v:Se(e.output_chars)},{l:T("AI输入字符(最近一轮)"),v:Se(e.recent_input_chars)},{l:T("AI输出字符(最近一轮)"),v:Se(e.recent_output_chars)}].map((e,t)=>(0,w.jsxs)("div",{className:"usage-stats-row",children:[(0,w.jsx)("span",{className:"usage-stats-label",children:e.l}),(0,w.jsx)("span",{className:"usage-stats-value",children:e.v})]},t)),(0,w.jsxs)("div",{className:"usage-stats-row usage-stats-total",children:[(0,w.jsx)("span",{className:"usage-stats-label",children:T("AI字符总计消耗")}),(0,w.jsx)("span",{className:"usage-stats-value",children:Se((e.input_chars||0)+(e.output_chars||0))})]})]}),cancel:()=>G({open:!1})})}else G({open:!0,title:T("字符消耗统计"),context_div:(0,w.jsx)("div",{className:"usage-stats-empty",children:T("暂无统计数据")}),cancel:()=>G({open:!1})})}catch{G({open:!0,title:T("字符消耗统计"),context_div:(0,w.jsx)("div",{className:"usage-stats-empty",children:T("暂无统计数据")}),cancel:()=>G({open:!1})})}},batchMode:W,selectedSessionIds:Q,onToggleSessionSelect:e=>{Y(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s})}}),(0,w.jsxs)("section",{className:"chat-main",children:[0===e?.length&&(0,w.jsx)("div",{className:"chat-header",children:(0,w.jsx)("div",{children:"completions"===z?T("询问服务器的一切"):M.find(e=>e.value===z)?.label??z})}),(0,w.jsxs)("div",{className:"chat-messages",ref:ce,children:[e.map(s=>(0,w.jsxs)("div",{className:`chat-message ${s.sender} ${W?"batch-mode":""}`,children:[W&&(0,w.jsx)("input",{type:"checkbox",className:"chat-message-checkbox",checked:X.has(s.id),onChange:()=>{return e=s.id,void Z(t=>{const s=new Set(t);return s.has(e)?s.delete(e):s.add(e),s});var e}}),D(s),!W&&(0,w.jsxs)("div",{className:"message-actions",children:[(0,w.jsx)("button",{onClick:()=>{return n=s.id,void re({sub_title:T("确认删除这条消息吗?"),confirm_fun:()=>{const s=e.filter(e=>e.id!==n);t(s),C&&a.jV.post("session/messages",{session_id:C,messages:B(s)}).catch(console.error)}});var n},children:T("删除")}),(0,w.jsx)("button",{onClick:()=>(async e=>{(0,d.lW)(e),(0,u.SK)("复制成功")})(s.text),children:T("复制")})]})]},s.id)),(0,w.jsx)("div",{ref:oe})]}),(0,w.jsx)(N,{inputValue:ae,onInputChange:e=>{const t=e.target;t.style.height="auto",t.style.height=Math.min(t.scrollHeight,200)+"px",ie(t.value)},onKeyDown:e=>{"Process"===e.key||e.nativeEvent.isComposing||e.shiftKey||e.ctrlKey||"Enter"===e.key&&(e.preventDefault(),we())},onPaste:e=>{const t=e.clipboardData?.files;t&&t.length>0&&(e.preventDefault(),_e(t))},onSend:we,sending:te,pendingAttachments:V,onRemoveAttachment:e=>{J(t=>t.filter((t,s)=>s!==e))},onOpenFilePicker:()=>{K.current?.click()},onAddFiles:_e,onDrop:e=>{const t=e.dataTransfer?.files;t&&t.length>0&&(e.preventDefault(),_e(t))},onDragOver:e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},fileInputRef:K})]})]})]})}},96494(e,t,s){s.d(t,{r:()=>a});var n=s(22022);function a(){const{t:e}=(0,n.Bd)();return[{value:"completions",label:e("文本对话")},{value:"images",label:e("图片生成")}]}},72693(e,t,s){s.d(t,{w:()=>u});var n=s(96540),a=s(22022),i=s(14944),o=s(92275),c=s(34843),r=s(82893),l=s(85997),d=s(74848);function u(){const[e,t]=(0,c.fp)(r.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(o.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)(l.$n,{text:s("拒绝"),color:"var(--red)",clickFun:()=>{i.ws.sendData(o.HK.ai_confirm_cmd,{askId:e.askId,approved:!1}),t({open:!1}),m.current=!1,h()}}),(0,d.jsx)(l.$n,{text:s("允许"),clickFun:()=>{i.ws.sendData(o.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(o.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(o.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),o=s(77979),c=s(8263),r=s(69428),l=s.n(r),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(o.A).use(c.A).use(l()).use(e=>{e.renderer.rules.fence;e.renderer.rules.fence=(t,s,n,a,i)=>{const o=t[s],c=o.content.trim(),r=o.info.trim();let l="";if(r&&m.A.getLanguage(r))try{l=m.A.highlight(c,{language:r}).value}catch(t){l=e.utils.escapeHtml(c)}else try{l=m.A.highlightAuto(c).value}catch(t){l=e.utils.escapeHtml(c)}return`\n <div class="code-block-with-copy">\n <div class="code-header">\n <span class="code-language">${r||"code"}</span>\n <button class="copy-btn" data-code="${e.utils.escapeHtml(c)}">复制</button>\n </div>\n <pre><code class="hljs ${r?`language-${r}`:""}">${l}</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 o=e[s],c=o.attrIndex("href");if(c>=0){const e=o.attrs[c][1];o.attrs[c][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>"}}]);
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>{{{web_site_title}}}</title><link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png"/><link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png"/><script defer="defer" src="main.27ca5409b10e4b78791e.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>
1
+ <!doctype html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>{{{web_site_title}}}</title><link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png"/><link rel="icon" type="image/png" sizes="16x16" href="favicon-16x16.png"/><script defer="defer" src="main.e8e3157be6063ea4da8a.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>