filecat 6.50.0 → 6.51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dist/{1472.606c9e1ffa1bd8a6a7e3.js → 1472.16c1857f1b20e40064fe.js} +1 -1
- package/build/dist/1595.dd1679681930c0894b85.js +1 -0
- package/build/dist/165.e102ca8665bd0983f320.js +2 -0
- package/build/dist/678.be7b63312ca9e0300634.js +1 -0
- package/build/dist/{7180.3b02cb00bd281cfa9fbb.js → 7180.b79748c5109bf8427c64.js} +1 -1
- package/build/dist/8772.279446de10fefaf37eaa.js +2 -0
- package/build/dist/index.html +1 -1
- package/build/dist/{main.778f3ba58ef23dbb62d9.js → main.3876a819e780b321c1f1.js} +2 -2
- package/build/main.js +1 -1
- package/package.json +1 -1
- package/build/dist/1595.2c366cdfe302dc5a5050.js +0 -1
- package/build/dist/165.b77feb0226570120fb9d.js +0 -2
- package/build/dist/678.a0201b5e9046c8ee7101.js +0 -1
- package/build/dist/8772.2c35012c25ac9eb5f74d.js +0 -2
- /package/build/dist/{165.b77feb0226570120fb9d.js.LICENSE.txt → 165.e102ca8665bd0983f320.js.LICENSE.txt} +0 -0
- /package/build/dist/{8772.2c35012c25ac9eb5f74d.js.LICENSE.txt → 8772.279446de10fefaf37eaa.js.LICENSE.txt} +0 -0
- /package/build/dist/{main.778f3ba58ef23dbb62d9.js.LICENSE.txt → main.3876a819e780b321c1f1.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[678,6010],{83277(e,s,t){t.d(s,{$j:()=>o,Lv:()=>a,qq:()=>i});class n{options_agent_url_list;options_agent_key_list;options_agent_model_list;options_local_file_path_prompt_list}class a{token;open=!1;note;index;url;model;request_type;json_params;sys_prompt;dotenv="";tool_mode=!1;show_options;static get_label_by_v(e,s){if(!e||!s?.length)return e;for(const t of s)if(t.value===e)return t.label;return e}static have_label_by_v(e,s){if(!e||!s?.length)return!1;for(const t of s)if(t.value===e)return!0;return!1}}class i extends n{tool_error_max=50;tool_call_max=300;allow_exec_cmd_directly=!1;proxy_url;open_pick_model;max_recent_messages=12;compress_message_count=16;max_tool_content_chars=200}const c=JSON.stringify({stream:!0,thinking:{type:"disabled"}});function o(e){return"string"==typeof e?e:Array.isArray(e)?e.map(e=>"text"===e.type?e.text:"[图片]").join("\n"):""}t.d(s,["CP",0,'\n\n# 工具报错最大尝试次数\ntool_error_max=50\n# 聊天循环最大次数\ntool_call_max=300\n# 是否允许AI直接执行命令而不需要用户确认,默认为false,需要用户手动确认,如果使用 workflow 这里等价于为 true\nallow_exec_cmd_directly=false\n\n# 可选的代理 url,如果指定了所有访问大模型的请求将会走代理\n#proxy_url=\n\n# 可选的多个url 以数组分割\n# options_agent_url_list=[{"value":"http://..","label":"openai"}]\n\n# 可选的多个 key\n# options_agent_key_list=[{"value":"sh-aaa","label":"option1"}]\n\n# 可选的多个 model\n# options_agent_model_list=[{"value":"gpt-5.5","label":"gpt"}]\n\n# 存放本地的 prompt 文件 用于每次聊天的时候自动读取并加载\n# options_local_file_path_prompt_list=["/prompt/a.txt"]\n\n# 开启切换模型 ,开启以后,你可以自己写 prompt 提供多个模型让 ai 自己根据每次聊天切换下一步调用其他模型的次数\n# open_pick_model=false\n\n# 压缩后仍然完整保留的最近消息数\nmax_recent_messages=12\n# 当单个会话累计消息条数超过该值时,触发历史消息裁剪\ncompress_message_count=16\n# 历史消息中 tool 输出的最大字符数,只保留调用形式让 AI 知道调用了就行\nmax_tool_content_chars=200\n',"cL",0,c])},93583(e,s,t){t.r(s),t.d(s,{default:()=>ee});var n=t(96540),a=t(34843),i=t(34899),c=t(76213),o=t(92275),l=t(14284),r=t(7463),d=t(78247),u=t(40505),m=t(62042),h=t(45907),g=t(53459),p=t(72693),x=t(82893),_=t(61443),f=t(83277);function j(e){return null==e||e<0?"0":e.toLocaleString()}function v(e){const s=(0,f.$j)(e.content);if(s)return s;const t=e.content_list??[];return t.length?t.map(e=>(0,f.$j)(e.content)).filter(Boolean).join("\n\n"):""}const b=/\.(md|txt|json|js|jsx|ts|tsx|css|html?|xml|ya?ml|py|java|go|rs|c|cpp|h|hpp|sh|bat|cmd|ini|toml|csv|log|sql|env|gitignore|dockerfile)$/i;function y(e){return e.type?.startsWith("image/")?"image":e.type?.startsWith("text/")||b.test(e.name)?"text":"binary"}function w(e){return e.text()}function S(e){return new Promise((s,t)=>{const n=new FileReader;n.onload=()=>s(n.result),n.onerror=t,n.readAsDataURL(e)})}async function N(e){const s=[];for(const t of e){const e=y(t);let n="";if("text"===e)try{const e=await w(t),s=12e4;n=e.length>s?`${e.slice(0,s)}\n\n[内容已截断,原始长度 ${e.length} 字符]`:e}catch{n="[文本读取失败]"}else if("image"===e)try{n=await S(t)}catch{n=`[图片文件: ${t.name}]`}else n=`[二进制文件: ${t.name}]`;s.push({name:t.name,mime_type:t.type,size:t.size,kind:e,content:n})}return s}var k=t(14944);var C=t(52035),A=t(85997),I=t(34299),$=t(74848);function M(e){const s=e.attachments&&e.attachments.length>0?(0,$.jsx)("div",{className:"chat-message-attachments",children:e.attachments.map((e,s)=>(0,$.jsxs)("div",{className:"chat-message-attachment",children:[(0,$.jsx)(A.In,{icon:"attach_file"}),(0,$.jsx)("span",{children:e.name}),(0,$.jsxs)("small",{children:[e.size," B"]})]},`${e.name}_${s}`))}):null,t=[];e.images&&"bot"===e.sender&&t.push((0,$.jsx)(n.Fragment,{children:(0,$.jsx)(T,{images:e.images,text:e.text})},"images")),e.audio&&"bot"===e.sender&&t.push((0,$.jsx)(n.Fragment,{children:(0,$.jsx)(R,{audio:e.audio,text:e.text})},"audio")),e.embeddings&&"bot"===e.sender&&t.push((0,$.jsx)(n.Fragment,{children:(0,$.jsx)(P,{embeddings:e.embeddings,text:e.text})},"embeddings"));const a=function(e){if("bot"!==e.sender||!e.content_list?.length)return e.text?(0,$.jsx)(I.default,{context:e.text}):null;return(0,$.jsxs)($.Fragment,{children:[e.content_list.map((e,s)=>{const t=[],a=(0,f.$j)(e.content);return a&&t.push((0,$.jsx)(n.Fragment,{children:(0,$.jsx)(I.default,{context:a})},`content-${s}`)),e.tool_call_ends?.length&&t.push((0,$.jsx)(n.Fragment,{children:(0,$.jsx)(D,{callList:e.tool_call_ends})},`tool-${s}`)),(0,$.jsx)(n.Fragment,{children:t},`part-${s}`)}),!e.content_list.some(e=>e.content)&&e.text?(0,$.jsx)(I.default,{context:e.text}):null]})}(e);return 0===t.length?(0,$.jsxs)($.Fragment,{children:[s,a]}):(0,$.jsxs)($.Fragment,{children:[t,s,a]})}function D({callList:e}){const[s,t]=n.useState(!1);if(!e?.length)return null;e.filter(e=>e.success).length;const a=e.filter(e=>!e.success).length;return(0,$.jsxs)("div",{className:"chat-message-call-list",children:[(0,$.jsxs)("div",{className:"call-list-header",onClick:()=>t(!s),children:[(0,$.jsx)(A.In,{icon:s?"expand_less":"expand_more"}),(0,$.jsxs)("span",{className:"call-list-summary",children:["工具调用 (",e.length,")",a>0&&(0,$.jsx)("span",{className:"call-list-fail",children:" 失败 "})]})]}),s&&(0,$.jsx)("div",{className:"call-list-body",children:e.map((e,s)=>(0,$.jsxs)("div",{className:"call-list-item "+(e.success?"call-success":"call-fail"),children:[(0,$.jsxs)("div",{className:"call-list-item-header",children:[(0,$.jsx)(A.In,{icon:e.success?"check_circle":"error"}),(0,$.jsx)("span",{className:"call-list-tool-name",children:e.tool_display_name||e.tool_name}),(0,$.jsxs)("span",{className:"call-list-duration",children:[e.duration_ms,"ms"]})]}),e.tool_args&&(0,$.jsxs)("details",{className:"call-list-details",children:[(0,$.jsx)("summary",{children:"参数"}),(0,$.jsx)("pre",{className:"call-list-pre",children:JSON.stringify(e.tool_args,null,2)})]}),!e.success&&e.error&&(0,$.jsxs)("details",{className:"call-list-details",children:[(0,$.jsx)("summary",{children:"错误"}),(0,$.jsx)("pre",{className:"call-list-pre call-list-error-text",children:e.error})]}),e.success&&e.tool_result&&(0,$.jsxs)("details",{className:"call-list-details",children:[(0,$.jsx)("summary",{children:"结果"}),(0,$.jsx)("pre",{className:"call-list-pre",children:e.tool_result.length>500?e.tool_result.slice(0,500)+"...":e.tool_result})]})]},s))})]})}function T({images:e,text:s}){let t=e||[];if(!t.length&&s)try{t=JSON.parse(s).data||[]}catch{}return t.length?(0,$.jsxs)("div",{className:"image-generation-result",children:[t.map((e,s)=>(0,$.jsxs)("div",{className:"image-generation-item",children:[e.url&&(0,$.jsx)("div",{className:"image-generation-image-wrapper",children:(0,$.jsx)("img",{src:e.url,alt:e.revised_prompt||`生成的图片 ${s+1}`,loading:"lazy"})}),e.b64_json&&(0,$.jsx)("div",{className:"image-generation-image-wrapper",children:(0,$.jsx)("img",{src:`data:image/png;base64,${e.b64_json}`,alt:`生成的图片 ${s+1}`})}),e.revised_prompt&&(0,$.jsx)("p",{className:"image-generation-prompt",children:(0,$.jsx)("small",{children:e.revised_prompt})})]},s)),s&&!e&&(0,$.jsx)(I.default,{context:s})]}):(0,$.jsx)(I.default,{context:s||""})}function R({audio:e,text:s}){if(e){if(e.url)return(0,$.jsx)("div",{className:"audio-result",children:(0,$.jsx)("audio",{controls:!0,src:e.url,children:"您的浏览器不支持音频播放"})});if(e.data){const s=e.mime_type||"audio/mpeg";return(0,$.jsx)("div",{className:"audio-result",children:(0,$.jsx)("audio",{controls:!0,src:`data:${s};base64,${e.data}`,children:"您的浏览器不支持音频播放"})})}}const t=s||"";if(t.startsWith("http://")||t.startsWith("https://"))return(0,$.jsx)("div",{className:"audio-result",children:(0,$.jsx)("audio",{controls:!0,src:t,children:"您的浏览器不支持音频播放"})});try{const e=JSON.parse(t);if(e?.data||e?.audio_data){const s=e.data||e.audio_data;return(0,$.jsx)("div",{className:"audio-result",children:(0,$.jsx)("audio",{controls:!0,src:`data:audio/mpeg;base64,${s}`,children:"您的浏览器不支持音频播放"})})}}catch{}return(0,$.jsx)(I.default,{context:t})}function H({content:e,label:s}){const[t,a]=n.useState(!1);return(0,$.jsxs)("button",{className:"embeddings-copy-btn",onClick:()=>{(0,u.lW)(e),a(!0),setTimeout(()=>a(!1),1500)},children:[(0,$.jsx)(A.In,{icon:t?"check":"content_copy"}),t?"已复制":s||"复制"]})}function P({embeddings:e,text:s}){let t=e||null;if(!t&&s)try{t=JSON.parse(s)}catch{return(0,$.jsx)(I.default,{context:s})}if(!t)return(0,$.jsx)(I.default,{context:s||""});const n=t?.data||[],a=t?.usage,i=JSON.stringify(t,null,2);return(0,$.jsxs)("div",{className:"embeddings-result",children:[(0,$.jsxs)("div",{className:"embeddings-summary",children:[(0,$.jsx)("strong",{children:"向量嵌入结果"}),(0,$.jsxs)("span",{children:["维度: ",n[0]?.embedding?.length??"N/A"]}),(0,$.jsxs)("span",{children:["数量: ",n.length]}),a&&(0,$.jsxs)("span",{children:["使用 tokens: ",a.total_tokens??"N/A"]})]}),(0,$.jsxs)("div",{className:"embeddings-toolbar",children:[(0,$.jsx)(H,{content:i,label:"复制全部结果"}),n.length>0&&n[0]?.embedding&&(0,$.jsx)(H,{content:JSON.stringify(n[0].embedding,null,2),label:"复制第一条向量"}),n.length>0&&(0,$.jsx)(H,{content:JSON.stringify(n.map(e=>e.embedding),null,2),label:"复制所有向量数据"})]}),n.length>0&&n[0]?.embedding&&(0,$.jsx)("div",{className:"embeddings-preview",children:(0,$.jsxs)("span",{children:["向量预览: [",n[0].embedding.slice(0,5).join(", "),n[0].embedding.length>5?", ...":"","]"]})}),n.length>0&&(0,$.jsxs)("details",{children:[(0,$.jsx)("summary",{children:"查看详细数据"}),(0,$.jsx)("pre",{className:"embeddings-raw",children:i})]})]})}async function E(e,s){const t=function(){try{return(0,C.zp)().get(x.AG.ai_images_extra_params)||{}}catch{return{}}}(),n={prompt:e,n:t.n??1,size:t.size??"1024x1024",session_id:s};if(t.quality&&(n.quality=t.quality),t.style&&(n.style=t.style),t.extra_json)try{const e=JSON.parse(t.extra_json);Object.assign(n,e)}catch(e){console.warn("图片额外参数 JSON 解析失败:",e)}const a=await l.jV.post("images/generations",n);if(0!==a.code)throw new Error(a.message||"图片生成失败");const i=a.data||{},c=(i.data||[]).map(e=>({url:e.url,b64_json:e.b64_json,revised_prompt:e.revised_prompt})),o=c.map((e,s)=>`${e.revised_prompt?`\n> ${e.revised_prompt}`:""}`).join("\n\n");return{session_id:i.session_id||s,images:c,text:o||`生成了 ${c.length} 张图片`}}async function V(e,s,t,n){try{switch(e){case"images":{const e=await E(s,t);return e&&n(e.text,{images:e.images}),!0}case"audio_speech":{const e=await async function(e,s){const t={input:e,session_id:s};try{const e=localStorage.getItem("ai_audio_extra_params");if(e){const s=JSON.parse(e);s.voice&&(t.voice=s.voice),s.speed&&(t.speed=parseFloat(s.speed))}}catch{}const n=localStorage.getItem("token")||"",a=await fetch("/api/ai_agent/audio/speech",{method:"POST",headers:{"Content-Type":"application/json",Authorization:n},body:JSON.stringify(t)});if(!a.ok)throw new Error(`语音合成失败: ${a.statusText}`);const i=a.headers.get("X-Session-Id")||s,c=await a.arrayBuffer();return{session_id:i,audio:{data:btoa(String.fromCharCode(...Array.from(new Uint8Array(c)))),mime_type:a.headers.get("content-type")||"audio/mpeg"},text:`[音频文件: ${e.slice(0,50)}...]`}}(s,t);return e&&n(e.text,{audio:e.audio}),!0}case"embeddings":{const e=await async function(e,s){const t=await l.jV.post("embeddings",{input:e,session_id:s});if(0!==t.code)throw new Error(t.message||"Embeddings 请求失败");const n=t.data||{},a=n?.data??[],i=`向量维度: ${a[0]?.embedding?.length??0}, 数量: ${a.length}`;return{session_id:n.session_id||s,embeddings:n,text:`✅ Embeddings 结果 - ${i}\n\`\`\`json\n${JSON.stringify(n,null,2).slice(0,2e3)}\n\`\`\``}}(s,t);return e&&n(e.text,{embeddings:e.embeddings}),!0}default:return!1}}catch(e){return n(`请求失败: ${e?.message||JSON.stringify(e)}`),!0}}var B=t(57952),F=t(23430),L=t(87361);const O=({currentModelName:e,setCurrentModelName:s,envConfigRef:t,sysPromptList:n,batchMode:o,selectedMsgCount:r,onToggleSessionPanel:u,onCreateSession:h,onToggleBatchMode:p,onBatchDeleteMessages:f,bgProcessVisible:j,bgProcessCount:v,onToggleBgProcess:b,selectedSysPromptId:y,setSelectedSysPromptId:w})=>{const{t:S}=(0,i.Bd)(),N=(0,c.Zp)(),{check_user_auth:k}=(0,d.MH)(),[,C]=(0,a.fp)(x.AG.ai_session_collapsed);return(0,$.jsxs)(B.A,{children:[(0,$.jsx)(A.rA,{icon:"menu",title:S("会话"),onClick:u}),(0,$.jsx)(A.rA,{icon:"add",title:S("新会话"),onClick:()=>h()}),n.length>0&&(0,$.jsx)(_.l6,{value:y,options:[{title:S("选择系统提示词"),value:""},...n.map(e=>({title:e.note||e.prompt.slice(0,30),value:String(e.index)}))],onChange:e=>{w(e)},no_border:!0,width:"10rem"}),(t.current?.ai_config_env?.options_agent_model_list?.length??0)>0&&(0,$.jsx)(_.l6,{value:e,options:t.current.ai_config_env.options_agent_model_list?.map(e=>({title:e.label,value:e.value}))??[],onChange:e=>{s(e),l.jV.post("set_active_model",{model_name:e}).then(()=>{(0,m.SK)("success"),l.XO.get("ai_agent_setting/env").then(e=>{e.code===g.m.Success&&(t.current=e.data)})}).catch(console.error)},no_border:!0,width:"auto"}),o&&r>0&&(0,$.jsx)(A.rA,{icon:"delete",title:S("删除选中消息"),onClick:f}),(0,$.jsx)(A.rA,{icon:"terminal",title:S("后台进程"),onClick:b,selected:j,tip:v||null}),k(F.oV.ai_agent_setting)&&(0,$.jsx)(A.rA,{icon:"smart_toy",title:"机器人配置",onClick:()=>{N(`/${L.o.ai_rebot_setting_page}`)}}),k(F.oV.ai_agent_setting)&&(0,$.jsx)(A.rA,{icon:"settings",title:"ai setting",onClick:()=>{N(`/${L.o.ai_agent_setting_page}`)}})]})};var q=t(27690);function K({sessions:e,activeSessionId:s,onSelectSession:t,onRenameSession:c,onDeleteSession:o,onShowUsageStats:l,batchMode:r,selectedSessionIds:d,onToggleSessionSelect:u,onToggleBatchMode:m,onBatchDeleteSessions:h,onClearAllSessions:g}){const{t:p}=(0,i.Bd)(),[_,f]=(0,a.fp)(x.AG.ai_session_collapsed),[j,v]=(0,n.useState)(""),b=j.trim()?e.filter(e=>(e.title||"").toLowerCase().includes(j.toLowerCase())||(e.summary||"").toLowerCase().includes(j.toLowerCase())||(e.long_term_memory||"").toLowerCase().includes(j.toLowerCase())):e;return(0,$.jsxs)("aside",{className:`chat-session-list ${_?"active":""} ${_?"collapsed":""}`,children:[(0,$.jsx)("div",{className:"chat-session-search",children:(0,$.jsx)("input",{type:"text",className:"chat-session-search-input",placeholder:p("搜索会话"),value:j,onChange:e=>v(e.target.value)})}),(0,$.jsx)("div",{className:"chat-session-items-wrap",children:b.map(e=>{return(0,$.jsx)("div",{children:(0,$.jsxs)("button",{className:`chat-session-item ${s===e.id?"active":""} ${r?"batch-mode":""}`,onClick:()=>{r&&u?u(e.id):t(e.id)},title:e.summary||e.long_term_memory||e.title,children:[r&&(0,$.jsx)("input",{type:"checkbox",className:"chat-session-checkbox",checked:d?.has(e.id)??!1,onChange:()=>u?.(e.id),onClick:e=>e.stopPropagation()}),(0,$.jsx)("span",{children:(n=e.title,n||"新会话")}),(0,$.jsx)("small",{children:e.message_count}),"web"!==e.source&&(0,$.jsx)("em",{className:"chat-session-source",children:e.source}),!r&&(0,$.jsx)(q.MenuSelect,{list:[{name:p("重命名"),click:()=>c(e.id,e.title)},{name:p("字符消耗统计"),click:()=>l(e.id)},{name:p("删除"),click:()=>o(e.id)}],children:(0,$.jsx)(A.In,{icon:"more_horiz"})})]})},e.id);var n})}),(0,$.jsxs)("div",{className:"chat-session-actions",children:[(0,$.jsx)(A.rA,{icon:r?"check_circle":"checklist",title:p(r?"取消批量选择":"批量选择"),onClick:m}),r&&(d?.size??0)>0&&(0,$.jsx)(A.rA,{icon:"delete",title:p("删除选中会话"),onClick:h}),!r&&(0,$.jsx)(A.rA,{icon:"delete_sweep",title:p("删除全部会话"),onClick:g})]})]})}function z(e){const s=(e.text||"").split("\n").map(e=>e.trim()).find(Boolean)||"";return s.length>80?s.slice(0,80)+"…":s}const J=({messages:e,batchMode:s,selectedMsgIds:t,sending:a,chatContainerRef:i,messagesEndRef:c,onToggleMsgSelect:o,onDelete:l,onCopy:r,onToggleBatchMode:d,t:u})=>{const[m,h]=(0,n.useState)(new Set),g=(0,n.useMemo)(()=>e.filter(e=>!e.is_loading).map(e=>e.id),[e]),p=e=>{h(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},x=()=>{h(e=>e.size>0&&g.every(s=>e.has(s))?new Set:new Set(g))};return(0,$.jsxs)("div",{className:"chat-messages",ref:i,"data-sending":a?"true":"false",children:[e.map(e=>{const n=m.has(e.id);return(0,$.jsxs)("div",{className:`chat-message ${e.sender} ${s?"batch-mode":""} ${e.is_loading?"is-loading":""} ${n?"collapsed":""}`,children:[s&&(0,$.jsx)("input",{type:"checkbox",className:"chat-message-checkbox",checked:t.has(e.id),onChange:()=>o(e.id)}),e.is_loading?(0,$.jsxs)("div",{className:"ai-loading-bubble",children:[(0,$.jsxs)("div",{className:"ai-loading-dots",children:[(0,$.jsx)("span",{className:"ai-loading-dot"}),(0,$.jsx)("span",{className:"ai-loading-dot"}),(0,$.jsx)("span",{className:"ai-loading-dot"})]}),(0,$.jsx)("span",{className:"ai-loading-text",children:e.text})]}):(0,$.jsxs)($.Fragment,{children:[n?(0,$.jsxs)("div",{className:"chat-message-summary",title:e.text,onClick:()=>p(e.id),children:[(0,$.jsx)("span",{className:"chat-message-summary-icon",children:"▸"}),(0,$.jsx)("span",{className:"chat-message-summary-text",children:z(e)||u("(无内容)")})]}):(0,$.jsx)("div",{className:"chat-message-body",children:M(e)}),(0,$.jsxs)("div",{className:"message-collapse-bar",children:[(0,$.jsx)("button",{onClick:()=>p(e.id),children:u(n?"展开":"折叠")}),(0,$.jsx)("button",{onClick:x,children:u("全部折叠")})]}),(0,$.jsx)("div",{className:"message-actions",children:s?(0,$.jsx)("button",{onClick:()=>o(e.id),children:t.has(e.id)?u("取消选择"):u("选择")}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)("button",{onClick:()=>l(e.id),children:u("删除")}),(0,$.jsx)("button",{onClick:()=>r(e.text),children:u("复制")}),(0,$.jsx)("button",{onClick:d,children:u("多选")})]})})]})]},e.id)}),(0,$.jsx)("div",{ref:c})]})};function G({onClose:e}){const{t:s}=(0,i.Bd)(),[t,c]=(0,a.fp)(x.AG.ai_images_extra_params),[o,l]=(0,n.useState)(t.size||"1024x1024"),[r,d]=(0,n.useState)(String(t.n??1)),[u,m]=(0,n.useState)(t.quality||""),[h,g]=(0,n.useState)(t.style||""),[p,f]=(0,n.useState)(t.extra_json||"");return(0,$.jsxs)("div",{className:"card floating",children:[(0,$.jsx)("div",{className:"card-title",children:(0,$.jsx)("h2",{children:s("图片生成参数设置")})}),(0,$.jsxs)("div",{className:"card-content",children:[(0,$.jsx)(_.Sm,{placeholderOut:s("图片尺寸 (size)"),value:o,handleInputChange:l,placeholder:"1024x1024"}),(0,$.jsx)(_.Sm,{placeholderOut:s("生成数量 (n)"),value:r,handleInputChange:d,type:"number"}),(0,$.jsx)(_.Sm,{placeholderOut:s("画质 (quality)"),value:u,handleInputChange:m,placeholder:"standard / hd"}),(0,$.jsx)(_.Sm,{placeholderOut:s("风格 (style)"),value:h,handleInputChange:g,placeholder:"vivid / natural"}),(0,$.jsx)(_.Sm,{placeholderOut:s("额外参数 JSON"),value:p,handleInputChange:f,placeholder:'{"key":"value"}'})]}),(0,$.jsxs)("div",{className:"card-action",children:[(0,$.jsx)("button",{className:"button button--flat button--grey",onClick:e,children:s("取消")}),(0,$.jsx)("button",{className:"button button--flat",onClick:()=>{const s={size:o,n:parseInt(r)||1};u&&(s.quality=u),h&&(s.style=h),p&&(s.extra_json=p),c(s),e()},children:s("确定")})]})]})}function W({requestType:e}){const{t:s}=(0,i.Bd)(),[t,a]=(0,n.useState)(!1);return"completions"===e?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(A.rA,{icon:"tune",title:s("模型参数设置"),onClick:()=>a(!0)}),t&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)("div",{className:"overlay",onClick:()=>a(!1)}),"images"===e&&(0,$.jsx)(G,{onClose:()=>a(!1)})]})]})}const Q=(0,n.forwardRef)(function({placeholder:e="",disabled:s=!1,className:t,style:a,onEnter:i,onPaste:c,onChange:o},l){const r=(0,n.useRef)(null),[d,u]=(0,n.useState)(!0),[m,h]=(0,n.useState)(!1),g=(0,n.useCallback)(()=>{const e=r.current;return e?(e.textContent??"").replace(/\u00A0/g," ").trimEnd():""},[]);(0,n.useImperativeHandle)(l,()=>({getValue:()=>g(),setValue:e=>{const s=r.current;if(!s)return;s.textContent=e,u(!e);const t=document.createRange();t.selectNodeContents(s),t.collapse(!1);const n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)},clear:()=>{const e=r.current;e&&(e.textContent="",u(!0))},focus:()=>r.current?.focus()})),(0,n.useEffect)(()=>{const e=r.current;if(!e)return;const s=()=>u(!e.textContent);return e.addEventListener("input",s),()=>e.removeEventListener("input",s)},[]);return(0,$.jsx)("div",{ref:r,contentEditable:!s,suppressContentEditableWarning:!0,className:"rich-textarea"+(t?" "+t:""),style:a,onKeyDown:e=>{m||"Enter"!==e.key||e.shiftKey||e.ctrlKey||e.metaKey||e.altKey||(e.preventDefault(),i?.())},onPaste:c,onInput:()=>o?.(g()),onCompositionStart:()=>h(!0),onCompositionEnd:()=>h(!1),"data-placeholder":d?e:void 0})});function U({pendingAttachments:e,onRemove:s}){return 0===e.length?null:(0,$.jsx)("div",{className:"chat-attachment-strip",children:e.map((e,t)=>(0,$.jsxs)("div",{className:"chat-attachment-chip",children:[(0,$.jsx)(A.In,{icon:"attach_file"}),(0,$.jsx)("span",{title:e.name,children:e.name}),(0,$.jsx)("button",{type:"button",onClick:()=>s(t),children:(0,$.jsx)(A.In,{icon:"close"})})]},`${e.name}_${t}`))})}const X=(0,n.forwardRef)(({onSend:e,sending:s,onAbort:t,pendingAttachments:c,onRemoveAttachment:o,onOpenFilePicker:l,onAddFiles:r,onDrop:d,onDragOver:u,fileInputRef:m,requestType:h},g)=>{const{t:p}=(0,i.Bd)(),_=(0,n.useRef)(null),[f,j]=(0,n.useState)(!1),v=(0,n.useRef)(null),[b,y]=(0,a.fp)(x.AG.ai_chat_input_height);(0,n.useImperativeHandle)(g,()=>({getValue:()=>_.current?.getValue()??"",setValue:e=>_.current?.setValue(e),clear:()=>_.current?.clear()}));const w=(0,n.useCallback)(e=>{const s=v.current;if(!s)return;const t=s.getBoundingClientRect().bottom-e.clientY;let n=Math.round(t/21.375);n=Math.max(2,Math.min(20,n)),y(n)},[y]),S=(0,n.useCallback)(()=>j(!0),[]),N=(0,n.useCallback)(()=>j(!1),[]);(0,n.useEffect)(()=>{if(!f)return;const e=w;return window.addEventListener("pointermove",e),window.addEventListener("pointerup",N),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",N)}},[f,w,N]);const k={minHeight:`${b}em`,maxHeight:`${b}em`};return(0,$.jsxs)("div",{ref:v,className:"chat-input-area",onDrop:d,onDragOver:u,children:[(0,$.jsx)("div",{className:"chat-input-resize-handle"+(f?" dragging":""),onPointerDown:S}),(0,$.jsx)("input",{ref:m,type:"file",multiple:!0,style:{display:"none"},onChange:e=>{e.target.files?.length&&(r(e.target.files),e.currentTarget.value="")}}),(0,$.jsxs)("div",{className:"chat-input-shell",style:k,children:[(0,$.jsx)(U,{pendingAttachments:c,onRemove:o}),(0,$.jsx)(Q,{ref:_,placeholder:p("输入消息"),onEnter:()=>e(),onPaste:e=>{const s=e.clipboardData?.files;s&&s.length>0&&(e.preventDefault(),r(s))},className:"chat-input",style:k})]}),(0,$.jsx)(A.rA,{title:p("添加文件"),icon:"attach_file",onClick:l}),(0,$.jsx)(W,{requestType:h}),s?(0,$.jsx)(A.Vi,{color:"var( --icon-red)",text:p("暂停"),clickFun:t}):(0,$.jsx)(A.Vi,{text:p("发送"),clickFun:e}),f&&(0,$.jsx)("div",{className:"chat-input-overlay",onPointerUp:N})]})}),Z={},Y=function(){const{t:e}=(0,i.Bd)(),[s,t]=(0,n.useState)([]),[c,l]=(0,n.useState)(!1),[r,d]=(0,n.useState)(null),[u,h]=(0,n.useState)(null),[g,p]=(0,n.useState)(!1),[_,f]=(0,a.fp)(x.AG.ai_bg_expanded),[,j]=(0,a.fp)(x.AG.ai_session_collapsed),v=()=>{f(!1)},b=(0,n.useCallback)(async()=>{l(!0);try{const e=new o.hf(o.HK.ai_bg_process_list_req);e.context={};const s=await k.ws.send(e);s?.context?.processes&&(t(s.context.processes),Z.onCountChange?.(s.context.processes.length))}catch(e){console.error("获取后台进程列表失败",e)}finally{l(!1)}},[]);Z.refresh=b;const y=(0,n.useCallback)(async e=>{p(!0),d(e);try{const s=new o.hf(o.HK.ai_bg_process_output_req);s.context={pid:e};const t=await k.ws.send(s);h(t.context)}catch(e){console.error("获取进程输出失败",e),(0,m.zN)("获取进程输出失败")}finally{p(!1)}},[]),w=(0,n.useCallback)(async e=>{try{const s=new o.hf(o.HK.ai_bg_process_kill_req);s.context={pid:e};const t=await k.ws.send(s);t?.context?.success?((0,m.SK)("进程已终止"),b(),r===e&&(d(null),h(null))):(0,m.zN)(t?.context?.message||"终止失败")}catch(e){console.error("终止进程失败",e),(0,m.zN)("终止进程失败")}},[b,r]);(0,n.useEffect)(()=>{b();const e=setInterval(b,5e3);return()=>clearInterval(e)},[b]);const S=s.filter(e=>e.running),N=s.filter(e=>!e.running);return(0,$.jsxs)($.Fragment,{children:[_&&(0,$.jsx)("div",{className:"chat-session-overlay",onClick:v}),(0,$.jsxs)("aside",{className:"chat-bg-process-panel "+(_?"expanded":""),children:[(0,$.jsxs)("div",{className:"chat-bg-process-header",children:[(0,$.jsx)("span",{className:"chat-bg-process-title",children:e("后台进程")}),(0,$.jsx)(A.rA,{icon:"close",title:e("关闭"),onClick:v})]}),(0,$.jsxs)("div",{className:"chat-bg-process-toolbar",children:[(0,$.jsx)(A.rA,{icon:"refresh",title:e("刷新"),onClick:b}),(0,$.jsxs)("span",{className:"chat-bg-process-count",children:[S.length," ",e("个运行中"),N.length>0&&` / ${N.length} ${e("个已退出")}`]})]}),(0,$.jsxs)("div",{className:"chat-bg-process-list",children:[c&&0===s.length&&(0,$.jsx)("div",{className:"chat-bg-process-empty",children:e("加载中...")}),!c&&0===s.length&&(0,$.jsx)("div",{className:"chat-bg-process-empty",children:e("暂无后台进程")}),S.map(s=>(0,$.jsxs)("div",{className:`chat-bg-process-item ${r===s.pid?"active":""} running`,children:[(0,$.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(s.pid),children:[(0,$.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",s.pid]}),(0,$.jsx)("span",{className:"chat-bg-process-cmd",title:s.cmd,children:s.cmd.length>40?s.cmd.slice(0,40)+"...":s.cmd}),(0,$.jsx)("span",{className:"chat-bg-process-time",children:new Date(s.start_time).toLocaleTimeString()}),(0,$.jsx)("span",{className:"chat-bg-process-status running-dot",title:e("运行中"),children:"●"})]}),(0,$.jsxs)("div",{className:"chat-bg-process-item-actions",children:[(0,$.jsx)(A.rA,{icon:"terminal",title:e("查看输出"),onClick:()=>y(s.pid)}),(0,$.jsx)(A.rA,{icon:"stop",title:e("终止进程"),onClick:()=>w(s.pid)})]})]},s.pid)),N.map(e=>(0,$.jsx)("div",{className:`chat-bg-process-item ${r===e.pid?"active":""} finished`,children:(0,$.jsxs)("div",{className:"chat-bg-process-item-main",onClick:()=>y(e.pid),children:[(0,$.jsxs)("span",{className:"chat-bg-process-pid",children:["PID: ",e.pid]}),(0,$.jsx)("span",{className:"chat-bg-process-cmd",title:e.cmd,children:e.cmd.length>30?e.cmd.slice(0,30)+"...":e.cmd}),(0,$.jsx)("span",{className:"chat-bg-process-time",children:new Date(e.start_time).toLocaleTimeString()}),(0,$.jsxs)("span",{className:"chat-bg-process-exit-code",children:["exit: ",e.exit_code]})]})},e.pid))]}),null!==r&&(0,$.jsxs)("div",{className:"chat-bg-process-output",children:[(0,$.jsxs)("div",{className:"chat-bg-process-output-header",children:[(0,$.jsxs)("span",{children:["PID: ",r," ",e("输出")]}),(0,$.jsx)(A.rA,{icon:"close",title:e("关闭"),onClick:()=>{d(null),h(null)}})]}),(0,$.jsx)("div",{className:"chat-bg-process-output-content",children:g?(0,$.jsx)("div",{className:"chat-bg-process-empty",children:e("加载中...")}):u?(0,$.jsx)("pre",{className:"chat-bg-process-output-pre",children:u.output||e("(无输出)")}):null})]})]})]})};function ee(){const{t:e}=(0,i.Bd)(),s=((0,c.Zp)(),(0,h.y)()),{check_user_auth:t}=(0,d.MH)();(0,p.w)();const[b,y]=(0,n.useState)([]),[w,S]=(0,n.useState)([]),[C,A]=(0,n.useState)(""),[I,M]=(0,n.useState)(!1),D=(0,n.useRef)(null),[T,R]=(0,n.useState)([]),[H,P]=(0,a.fp)(x.AG.ai_session_collapsed),[E,B]=(0,a.fp)(x.AG.ai_bg_expanded),[F,L]=(0,a.fp)(x.AG.prompt_card),[q,z]=(0,n.useState)(!1),[G,W]=(0,n.useState)(new Set),[Q,U]=(0,n.useState)(new Set),[ee,se]=(0,n.useState)(""),te=(0,n.useRef)(null),ne=(0,n.useRef)(null),ae=(0,n.useRef)(null),ie=(0,n.useRef)(!0),ce=(0,n.useRef)(new f.qq),[oe,le]=(0,n.useState)([]),[re,de]=(0,n.useState)(""),[ue,me]=(0,n.useState)(0),he=()=>ce?.current?.ai_config?.request_type||"completions",ge=(0,n.useRef)((0,r.sg)(e=>{y(e),ie.current&&pe(!1)},50)).current,pe=(e=!1)=>{const s=ae.current;s&&s.scrollTo({top:s.scrollHeight,behavior:e?"smooth":"auto"})},xe=async()=>{const e=await l.jV.get("sessions");e.code===g.m.Success&&S(e.data??[])},_e=function(e){const{getMessages:s,setMessages:t,setMessagesDebounced:a,setSending:i,getActiveSessionId:c,setActiveSessionId:l,refreshSessions:r,scrollToBottom:d,buildRequestMessages:u,getSelectedSysPromptId:m}=e,h=(0,n.useRef)([]),g=(0,n.useRef)(null),p=(e,n,c)=>{const l=[...s(),n];t(l),i(!0),g.current={abort:()=>{}};const h={id:n.id+1,sender:"bot",text:"AI思考中...",is_loading:!0};l.push(h),t([...l]);const p=new Map;let x=!0,_=h;const f=e=>{const s=e.context||{},t=s.text||"",n=s.tool_call_ends,i=s.chunk_index??0;if("[DONE]"!==t)if(x)x=!1,_.text=t,n&&(_.content_list=[{tool_call_ends:n,content:_.text,role:"assistant"}]),_.is_loading=!1,_.chunk_index=i,p.set(i,_),a([...l]);else{const e=p.get(i);if(e)e.text+=t,n&&(e.content_list=[{tool_call_ends:n,content:e.text,role:"assistant"}]),a([...l]);else{const e={id:Date.now()+Math.random(),sender:"bot",text:t,chunk_index:i};n&&(e.content_list=[{tool_call_ends:n,content:e.text,role:"assistant"}]),l.push(e),p.set(i,e),a([...l])}}},j=e=>{b(),g.current=null,i(!1),_.is_loading=!1,r(),d(!0),c()},v=e=>{b(),g.current=null,i(!1);const s=e.context||{};_.text="AI请求出错: "+(s.message||"未知错误"),_.is_loading=!1,t([...l]),c()},b=()=>{k.ws.off_message(`message_${o.HK.ai_chat_msg}`,f),k.ws.off_message(`message_${o.HK.ai_chat_end}`,j),k.ws.off_message(`message_${o.HK.ai_chat_error}`,v)};k.ws.addMsg(o.HK.ai_chat_msg,f),k.ws.addMsg(o.HK.ai_chat_end,j),k.ws.addMsg(o.HK.ai_chat_error,v),k.ws.sendData(o.HK.ai_chat_req,{messages:u(n),session_id:e,sys_prompt_id:m()})},x=()=>{const e=h.current;if(0===e.length)return;const s=e.shift();if(!s)return;t(e=>e.map(e=>"user"===e.sender&&e.text.includes("⏳(排队中...)")?{...e,text:e.text.replace(" ⏳(排队中...)","")}:e));const n={id:Date.now(),sender:"user",text:s.text,attachments:s.attachments};p(c(),n,x)};return{startChatStream:p,processPendingQueue:x,enqueueMessage:(e,s)=>{h.current.push({text:e,attachments:s})},getQueueLength:()=>h.current.length,abort:()=>{g.current&&(k.ws.sendData(o.HK.ai_chat_abort,{session_id:c()}),g.current=null,i(!1))}}}({getMessages:()=>b,setMessages:y,setMessagesDebounced:ge,setSending:M,getActiveSessionId:()=>C,setActiveSessionId:A,refreshSessions:xe,scrollToBottom:pe,buildRequestMessages:e=>{const s=(e.attachments??[]).filter(e=>"image"===e.kind);if(s.length>0){const t=[];e.text&&t.push({type:"text",text:e.text});for(const e of s)t.push({type:"image_url",image_url:{url:e.content}});return[{content:t,role:"user",attachments:e.attachments??[]}]}return[{content:e.text,role:"bot"===e.sender?"assistant":"user",attachments:e.attachments??[]}]},getSelectedSysPromptId:()=>ee}),fe=async e=>{const s=await l.jV.get("sessions");if(s.code!==g.m.Success)return;const t=s.data??[];S(t);const n=null===e?t[0]?.id??"":e||C||t[0]?.id||"";n?await je(n):(y([]),A(""))},je=async(e,s=!1)=>{const t=await l.jV.post("session/get",{session_id:e});if(t.code!==g.m.Success||!t.data)return;const n=t.data;A(n.id),y(function(e=[]){return e.filter(e=>"user"===e.role||"assistant"===e.role).map((e,s)=>({id:Date.now()+s,sender:"assistant"===e.role?"bot":"user",text:v(e),attachments:e.attachments??[],content_list:e.content_list,images:e.images,audio:e.audio,embeddings:e.embeddings}))}(n.messages)),se(n.sys_prompt_id??""),s&&P(!1),Z.refresh?.(),requestAnimationFrame(()=>pe(!1))},ve=e=>{const s=Array.from(e??[]).filter(Boolean);s.length&&R(e=>[...e,...s])},be=()=>{q&&(W(new Set),U(new Set)),z(e=>!e)};(0,n.useEffect)(()=>((async()=>{const e=await l.XO.get("ai_agent_setting/env");if(e.code===g.m.Success){ce.current=e.data;const s=e.data.ai_config?.model||"",t=(e.data.ai_config_env?.options_agent_model_list??[]).find(e=>e.label===s);de(t?t.value:s)}await fe();const s=await l.jV.get("system_prompts");s.code===g.m.Success&&le(s.data??[])})(),requestAnimationFrame(()=>pe(!1)),Z.onCountChange=me,Z.refresh?.(),k.ws.addMsg(o.HK.ai_bg_process_count_notify,e=>{const s=e?.context?.count;"number"==typeof s&&me(s)}),()=>{k.ws.removeMsg(o.HK.ai_bg_process_count_notify)}),[]),(0,n.useEffect)(()=>{const e=ae.current;if(!e)return;const s=()=>{ie.current=((e,s=120)=>{const{scrollTop:t,scrollHeight:n,clientHeight:a}=e;return n-(t+a)<s})(e)};return e.addEventListener("scroll",s),()=>e.removeEventListener("scroll",s)},[]),(0,n.useLayoutEffect)(()=>{ie.current&&pe(!1)},[b]);return(0,$.jsxs)(n.Fragment,{children:[(0,$.jsx)(O,{currentModelName:re,setCurrentModelName:de,envConfigRef:ce,sysPromptList:oe,batchMode:q,selectedMsgCount:G.size,onToggleSessionPanel:()=>{P(e=>!e)},onCreateSession:async e=>{const s=void 0!==e?e:ee,t=await l.jV.post("session",{title:"新会话",sys_prompt_id:s||void 0});if(t.code!==g.m.Success)return;const n=t.data;A(n.id),y([]),se(n.sys_prompt_id??""),P(!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")})},onBatchDeleteMessages:()=>{0!==G.size&&s({sub_title:e("确认删除选中的聊天消息吗?"),confirm_fun:async()=>{const e=[];b.forEach((s,t)=>{G.has(s.id)&&e.push(t)}),y(b.filter(e=>!G.has(e.id))),W(new Set),z(!1),C&&e.length>0&&l.jV.post("session/message/delete",{session_id:C,indices:e}).catch(console.error)}})},bgProcessVisible:E,bgProcessCount:ue,onToggleBgProcess:()=>B(e=>!e),selectedSysPromptId:ee,setSelectedSysPromptId:e=>{se(e),C&&l.jV.post("session/sys_prompt",{session_id:C,sys_prompt_id:e||void 0}).catch(console.error)}}),(0,$.jsxs)("div",{className:"chat-page chat-page-with-sessions",children:[H&&(0,$.jsx)("div",{className:"chat-session-overlay",onClick:()=>P(!1)}),(0,$.jsx)(K,{sessions:w,activeSessionId:C,onSelectSession:e=>je(e,!1),onRenameSession:(e,t)=>{let n=t;s({confirm_fun:async()=>{await l.jV.post("sessions/update/meta",{id:e,title:n}),await fe(C)},context_div:(0,$.jsx)("div",{className:"card-content",children:(0,$.jsx)(_.Sm,{value:n,handleInputChange:e=>{n=e}})})})},onDeleteSession:e=>{s({sub_title:"确认删除这个会话吗?",confirm_fun:async()=>{await l.jV.post("session/delete",{session_id:e}),C===e?(A(""),await fe(null)):await fe(C)}})},onShowUsageStats:async s=>{L({open:!0,title:e("Token消耗统计"),context_div:(0,$.jsx)("div",{className:"usage-stats-loading",children:e("加载中...")}),cancel:()=>L({open:!1})});try{const t=await l.jV.post("session/usage_stats",{session_id:s});if(t.code===g.m.Success&&t.data){const s=t.data;L({open:!0,title:e("Token消耗统计"),context_div:(0,$.jsxs)("div",{className:"usage-stats-panel",children:[[{l:e("对话轮次"),v:(s.turns??0).toString()},{l:e("AI输入Token"),v:j(s.input_tokens)},{l:e("AI输出Token"),v:j(s.output_tokens)},{l:e("AI输入Token(最近一轮)"),v:j(s.recent_input_tokens)},{l:e("AI输出Token(最近一轮)"),v:j(s.recent_output_tokens)}].map((e,s)=>(0,$.jsxs)("div",{className:"usage-stats-row",children:[(0,$.jsx)("span",{className:"usage-stats-label",children:e.l}),(0,$.jsx)("span",{className:"usage-stats-value",children:e.v})]},s)),(0,$.jsxs)("div",{className:"usage-stats-row usage-stats-total",children:[(0,$.jsx)("span",{className:"usage-stats-label",children:e("AI Token总计消耗")}),(0,$.jsx)("span",{className:"usage-stats-value",children:j((s.input_tokens||0)+(s.output_tokens||0))})]})]}),cancel:()=>L({open:!1})})}else L({open:!0,title:e("Token消耗统计"),context_div:(0,$.jsx)("div",{className:"usage-stats-empty",children:e("暂无统计数据")}),cancel:()=>L({open:!1})})}catch{L({open:!0,title:e("Token消耗统计"),context_div:(0,$.jsx)("div",{className:"usage-stats-empty",children:e("暂无统计数据")}),cancel:()=>L({open:!1})})}},batchMode:q,selectedSessionIds:Q,onToggleSessionSelect:e=>{U(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onToggleBatchMode:be,onBatchDeleteSessions:()=>{0!==Q.size&&s({sub_title:e("确认删除选中的会话吗?"),confirm_fun:async()=>{for(const e of Q)await l.jV.post("session/delete",{session_id:e});U(new Set),z(!1),Q.has(C)?(A(""),await fe(null)):await fe(C)}})},onClearAllSessions:()=>{s({sub_title:e("确认删除全部聊天会话吗?"),confirm_fun:async()=>{await l.jV.post("sessions/clear",{}),A(""),y([]),await fe(null)}})}}),(0,$.jsx)(Y,{}),(0,$.jsxs)("section",{className:"chat-main",children:[0===b?.length&&(0,$.jsx)("div",{className:"chat-header",children:(0,$.jsx)("div",{children:e("询问服务器的一切")})}),(0,$.jsx)(J,{messages:b,batchMode:q,selectedMsgIds:G,sending:I,chatContainerRef:ae,messagesEndRef:ne,onToggleMsgSelect:e=>{W(s=>{const t=new Set(s);return t.has(e)?t.delete(e):t.add(e),t})},onDelete:t=>{s({sub_title:e("确认删除这条消息吗?"),confirm_fun:async()=>{const e=b.findIndex(e=>e.id===t);if(e<0)return;const s=b.filter(e=>e.id!==t);y(s),C&&l.jV.post("session/message/delete",{session_id:C,indices:[e]}).catch(console.error)}})},onCopy:async e=>{(0,u.lW)(e),(0,m.SK)("复制成功")},onToggleBatchMode:be,t:e}),(0,$.jsx)(X,{ref:D,onSend:async()=>{const e=(D.current?.getValue()??"").trim();if(!e&&0===T.length)return;if(I){const s=await N(T);_e.enqueueMessage(e,s),D.current?.clear(),R([]);const t={id:Date.now(),sender:"user",text:e+(_e.getQueueLength()>1?" ⏳(排队中...)":""),attachments:s};return void y(e=>[...e,t])}let s=C;if(!s){const t=await l.jV.post("session",{title:(e||T[0]?.name||"新会话").slice(0,28),sys_prompt_id:ee||void 0});if(t.code!==g.m.Success)return;s=t.data.id,A(s),await fe(s)}const t=await N(T),n={id:Date.now(),sender:"user",text:e,attachments:t};D.current?.clear(),R([]);const a=he();if("completions"!==a){const t={id:n.id+1,sender:"bot",text:"处理中...",is_loading:!0},i=[...b,n,t];y(i),M(!0);return void(await V(a,e,s,async(e,s)=>{t.text=e,t.is_loading=!1,s?.images&&(t.images=s.images),s?.audio&&(t.audio=s.audio),s?.embeddings&&(t.embeddings=s.embeddings),y([...i]),M(!1),xe(),pe(!0),_e.processPendingQueue()})||(t.text=`请求类型 "${a}" 的专用处理器尚未实现,请使用 completions 类型。`,t.is_loading=!1,y([...i]),M(!1),_e.processPendingQueue()))}_e.startChatStream(s,n,()=>_e.processPendingQueue())},sending:I,onAbort:_e.abort,pendingAttachments:T,onRemoveAttachment:e=>{R(s=>s.filter((s,t)=>t!==e))},onOpenFilePicker:()=>{te.current?.click()},onAddFiles:ve,onDrop:e=>{const s=e.dataTransfer?.files;s&&s.length>0&&(e.preventDefault(),ve(s))},onDragOver:e=>{e.dataTransfer?.types?.includes("Files")&&e.preventDefault()},fileInputRef:te,requestType:he()})]})]})]})}},72693(e,s,t){t.d(s,{w:()=>u});var n=t(96540),a=t(34899),i=t(14944),c=t(92275),o=t(34843),l=t(82893),r=t(85997),d=t(74848);function u(){const[e,s]=(0,o.fp)(l.AG.prompt_card),{t}=(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 s({open:!1});m.current=!0;const e=u.current.shift();e?s({open:!0,title:t("命令确认"),cancel:()=>{i.ws.sendData(c.HK.ai_confirm_cmd,{askId:e.askId,approved:!1}),s({open:!1}),m.current=!1,h()},context_div:(0,d.jsxs)("div",{children:[(0,d.jsx)("div",{style:{maxHeight:"60vh",overflow:"auto",whiteSpace:"pre-wrap",wordBreak:"break-all",background:"var(--surfaceSecondary)",padding:"0.75em",borderRadius:"0.5em",marginBottom:"0.75em",fontFamily:"monospace",fontSize:"0.9em",lineHeight:"1.5"},children:e.cmd}),(0,d.jsxs)("div",{style:{display:"flex",gap:"0.5em",justifyContent:"flex-end"},children:[(0,d.jsx)(r.$n,{text:t("拒绝"),color:"var(--red)",clickFun:()=>{i.ws.sendData(c.HK.ai_confirm_cmd,{askId:e.askId,approved:!1}),s({open:!1}),m.current=!1,h()}}),(0,d.jsx)(r.$n,{text:t("允许"),clickFun:()=>{i.ws.sendData(c.HK.ai_confirm_cmd,{askId:e.askId,approved:!0}),s({open:!1}),m.current=!1,h()}})]})]})}):m.current=!1},[t]),g=(0,n.useCallback)(e=>{u.current.push(e),h()},[h]);(0,n.useEffect)(()=>(i.ws.addMsg(c.HK.ai_confirm_cmd,e=>{const t=e.context||{};if(t.dismiss&&t.askId)return u.current=u.current.filter(e=>e.askId!==t.askId),void(m.current&&(m.current=!1,s({open:!1}),h()));t.askId&&t.cmd&&g({askId:t.askId,cmd:t.cmd})}),()=>{i.ws.removeMsg(c.HK.ai_confirm_cmd)}),[g]),(0,n.useEffect)(()=>()=>{u.current=[],m.current=!1},[])}},34299(e,s,t){t.r(s),t.d(s,{default:()=>p});t(96540);var n=t(73557),a=t(53995),i=t(18569),c=t(77979),o=t(8263),l=t(69428),r=t.n(l),d=(t(3775),t(21499)),u=t(99214),m=t(19878),h=(t(72411),t(74848));const g=new n.A({html:!0,highlight:function(e,s){if(s&&m.A.getLanguage(s))try{return`<pre class="hljs code-block-with-copy"><code class="hljs language-${s}">${m.A.highlight(e,{language:s}).value}</code></pre>`}catch(e){}try{return`<pre class="hljs code-block-with-copy"><code class="hljs">${m.A.highlightAuto(e).value}</code></pre>`}catch(e){}return`<pre class="hljs code-block-with-copy"><code>${g.utils.escapeHtml(e)}</code></pre>`}});function p(e){return(0,u.VD)(),(0,h.jsx)("div",{dangerouslySetInnerHTML:{__html:g.render(e.context)}})}g.use(a.A).use(i.A).use(c.A).use(o.A).use(r()).use(e=>{e.renderer.rules.fence;e.renderer.rules.fence=(s,t,n,a,i)=>{const c=s[t],o=c.content.trim(),l=c.info.trim();let r="";if(l&&m.A.getLanguage(l))try{r=m.A.highlight(o,{language:l}).value}catch(s){r=e.utils.escapeHtml(o)}else try{r=m.A.highlightAuto(o).value}catch(s){r=e.utils.escapeHtml(o)}return`\n <div class="code-block-with-copy">\n <div class="code-header">\n <span class="code-language">${l||"code"}</span>\n <button class="copy-btn" data-code="${e.utils.escapeHtml(o)}">复制</button>\n </div>\n <pre><code class="hljs ${l?`language-${l}`:""}">${r}</code></pre>\n </div>`}}).use(e=>{const s=e.renderer.rules.link_open||function(e,s,t,n,a){return a.renderToken(e,s,t)};e.renderer.rules.link_open=(e,t,n,a,i)=>{const c=e[t],o=c.attrIndex("href");if(o>=0){const e=c.attrs[o][1];c.attrs[o][1]=(0,d.bi)(window.location.href,e)}return s(e,t,n,a,i)}})},45907(e,s,t){t.d(s,{y:()=>i});var n=t(34843),a=t(82893);function i(){const[e,s]=(0,n.fp)(a.AG.confirm);return({sub_title:e,confirm_fun:t,title:n,context_div:a})=>{s({open:!0,sub_title:e,handle:()=>{t(),s({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
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[7180],{75007(e,t,s){s.d(t,{h:()=>o});s(96540);var n=s(85997),c=s(74848);function o(e){return(0,c.jsxs)("h2",{className:"message",children:[(0,c.jsx)(n.In,{icon:"sentiment_dissatisfied"}),(0,c.jsx)("span",{children:e.context})]})}},22081(e,t,s){var n=s(96540),c=s(16349),o=s(74848);const i=({percentage:e})=>{const t=(0,n.useRef)(null),[s,i]=(0,n.useState)(null);return(0,n.useEffect)(()=>{const s=t.current.getContext("2d"),n=new c.Ay(s,{type:"doughnut",data:{labels:["use","left"],datasets:[{data:[e,100-e],backgroundColor:["#007bff","#f0f0f0"],borderWidth:0}]},options:{plugins:{legend:{display:!1},tooltip:{enabled:!1}},elements:{arc:{borderWidth:0}}}});return i(n),()=>{n.destroy()}},[]),(0,n.useEffect)(()=>{s&&(s.data.datasets[0].data=[e,100-e],s.update())},[e]),(0,o.jsx)("div",{style:{width:"8rem",overflow:"hidden"},children:(0,o.jsx)("canvas",{ref:t})})};s.d(t,["A",0,i])},77481(e,t,s){s.d(t,{S:()=>i,X:()=>o});var n=s(96540),c=s(74848);function o(e){const[t,s]=n.useState([]);return(0,n.useEffect)(()=>{e.children?s(Array.isArray(e.children)?e.children:[e.children]):s(e.rows)},[e.rows,e.children]),(0,c.jsxs)("table",{children:[(0,c.jsx)("thead",{children:(0,c.jsx)("tr",{children:e.headers?.map((e,t)=>(0,c.jsx)("th",{children:e},t))})}),(0,c.jsx)("tbody",{children:t.map((t,s)=>(0,c.jsx)("tr",{onContextMenu:()=>{e.handleContextMenu&&e.handleContextMenu(t)},children:t.map((s,n)=>(0,c.jsx)("td",{style:{width:e.width??"auto"},className:n===t.length-1?"small":"",children:s},n))},s))})]})}function i(e){return(0,c.jsx)("div",{style:{display:e.isFlex?"flex":"block"},children:e.columns.map((e,t)=>(0,c.jsx)("div",{children:e},t))})}},88062(e,t,s){s(96540),s(47022);var n=s(74848);function c(e){return(0,n.jsx)("div",{className:"black-tip",onClick:()=>{e.click&&e.click(e)},onContextMenu:t=>{t.stopPropagation(),t.nativeEvent.stopImmediatePropagation(),e.onContextMenu&&e.onContextMenu(t,e)},children:e.name})}const o=e=>(0,n.jsxs)("li",{children:[e.click?(0,n.jsx)(c,{...e.node,name:e.render?e.render(e.node):e.node.name,click:e.click,onContextMenu:e.onContextMenu}):(0,n.jsx)("div",{children:e.render?e.render(e.node):e.node.name}),e.node.children&&e.node.children.length>0&&(0,n.jsx)("ul",{children:e.node.children.map((t,s)=>(0,n.jsx)(o,{node:t,click:e.click,onContextMenu:e.onContextMenu,render:e.render},s))})]}),i=e=>(0,n.jsx)("div",{className:"card-tree-view",children:(0,n.jsx)("ul",{children:e.list&&e.list.map((t,s)=>(0,n.jsx)(o,{node:t,click:e.click,onContextMenu:e.onContextMenu,render:e.render},s))})});s.d(t,["A",0,i])},57180(e,t,s){s.r(t),s.d(t,{default:()=>Q});var n=s(96540),c=s(75725),o=s(70447),i=s(22081),r=s(92275),l=s(14944),a=s(14284),d=s(57952),h=s(85997),x=s(77481),u=s(53459),p=s(34899),j=s(34843),f=s(82893),m=s(74777),_=s(62042),w=s(61443),g=s(74848);function y(e){const{t}=(0,p.Bd)(),[s,i]=(0,j.fp)(f.AG.disk),[r,l]=(0,n.useState)({}),[m,_]=(0,n.useState)([]),w=[t("名字"),t("当前值"),t("历史最低"),t("临界值")];return(0,n.useEffect)(()=>{(async()=>{const s=await a.Yu.post("sys/disk/info",{name:e.name});if(s.code===u.m.Success){const e=[];for(const n of s.data.ata_smart_attributes??[]){let s;n[1]>=n[2]?s="var(--icon-green)":n[1]<=n[3]&&(s="var(--icon-red)"),n[0]=(0,g.jsx)("span",{style:{color:s},children:t(n[0])}),e.push(n)}_(s.data.ata_smart_attributes),l(s.data)}})()},[]),(0,g.jsxs)("div",{children:[(0,g.jsx)(d.A,{children:(0,g.jsx)(h.rA,{icon:"close",title:t("关闭"),onClick:()=>{i({})}})}),(0,g.jsx)(c.jW,{isFull:!0,more:!0,children:(0,g.jsx)(c.NN,{children:(0,g.jsxs)(c.fI,{children:[(0,g.jsxs)(c.VP,{widthPer:30,children:[(0,g.jsx)(c.xh,{children:(0,g.jsxs)(o.Zp,{title:t("基本信息"),children:[(0,g.jsx)(c.Yh,{left:t("名字"),right:e.name}),(0,g.jsx)(c.Yh,{left:t("厂商名称"),right:e.typeName}),(0,g.jsx)(c.Yh,{left:t("类型"),right:e.type}),(0,g.jsx)(c.Yh,{left:t("容量"),right:e.total})]})}),(0,g.jsx)(c.xh,{children:(0,g.jsxs)(o.Zp,{title:t("物理信息"),children:[(0,g.jsx)(c.Yh,{left:t("是否健康"),right:!0===r.smart_status?"是":"否"}),(0,g.jsx)(c.Yh,{left:t("设备型号"),right:r.model_name}),(0,g.jsx)(c.Yh,{left:t("序列号"),right:r.serial_number}),(0,g.jsx)(c.Yh,{left:t("固件版本"),right:r.firmware_version}),(0,g.jsx)(c.Yh,{left:t("转速(每分钟)"),right:r.rotation_rate}),(0,g.jsx)(c.Yh,{left:t("通电时长(小时)"),right:r.power_on_time_hours}),(0,g.jsx)(c.Yh,{left:t("通电次数"),right:r.power_cycle_count}),(0,g.jsx)(c.Yh,{left:t("温度(°C)"),right:r.temperature}),(0,g.jsx)(c.Yh,{left:t("通信协议"),right:r.device_protocol})]})})]}),(0,g.jsx)(c.VP,{widthPer:50,children:(0,g.jsxs)(c.xh,{children:[m?.length?(0,g.jsx)(o.uF,{title:t("ATA/SATA详细信息"),children:(0,g.jsx)(x.X,{headers:w,rows:m,width:"10rem"})}):(0,g.jsx)(g.Fragment,{}),r.nvme_smart?(0,g.jsxs)(o.Zp,{title:t("NVME详细信息"),children:[(0,g.jsx)(c.Yh,{left:t("NVMe 可用备用块(%)"),right:r.nvme_smart.available_spare}),(0,g.jsx)(c.Yh,{left:t("NVMe 已使用寿命(%)"),right:r.nvme_smart.percentage_used}),(0,g.jsx)(c.Yh,{left:t("NVMe 读取量"),right:r.nvme_smart.data_units_read}),(0,g.jsx)(c.Yh,{left:t("NVMe 写入量"),right:r.nvme_smart.data_units_written}),(0,g.jsx)(c.Yh,{left:t("NVMe 通电次数"),right:r.nvme_smart.power_cycles}),(0,g.jsx)(c.Yh,{left:t("NVMe 通电时长(小时)"),right:r.nvme_smart.power_on_hours}),(0,g.jsx)(c.Yh,{left:t("NVMe 非正常关机"),right:r.nvme_smart.unsafe_shutdowns}),(0,g.jsx)(c.Yh,{left:t("NVMe 媒体错误"),right:r.nvme_smart.media_errors}),(0,g.jsx)(c.Yh,{left:t("NVMe 错误日志数"),right:r.nvme_smart.num_err_log_entries})]}):(0,g.jsx)(g.Fragment,{})]})})]})})})]})}let k=function(e){return e[e.mount=0]="mount",e}({});var v=s(88062),S=s(78247),A=s(23430);const C=e=>(0,g.jsxs)("div",{style:{border:"2px solid black",padding:"10px",width:"300px",height:"300px",position:"relative"},children:[e.name,e.lvms.map((e,t)=>(0,g.jsx)("div",{style:{margin:"5px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid "},children:e.name},t))]});function b(){return(0,g.jsx)("div",{style:{position:"relative",height:"300px",margin:"10px",width:"30px",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,g.jsx)("div",{style:{width:0,height:0,borderTop:"10px solid transparent",borderBottom:"10px solid transparent",borderLeft:"10px solid black"}})})}function P(){const{t:e}=(0,p.Bd)(),[t,s]=(0,j.fp)(f.AG.disk),[i,r]=(0,n.useState)({}),[l,m]=(0,n.useState)([]),[w,y]=(0,n.useState)([]),[P,V]=(0,j.fp)(f.AG.showPrompt),{check_user_auth:Y}=(0,S.MH)(),[F,M]=(0,n.useState)([]),{click_file:$}=(0,S.kZ)(),[I,K]=(0,j.fp)(f.AG.prompt_card),E=[e("挂载点"),"uuid",e("类型"),e("文件系统类型"),e("文件系统容量"),e("卷容量"),e("设备路径"),e("分区表类型")],N=async()=>{const e=await a.Yu.get("disk/blk");return e.code===u.m.Success&&m(e.data),e.code};(0,n.useEffect)(()=>{(async()=>{N()})()},[]);const H=[(0,g.jsx)(h.rA,{icon:"info",title:e("提示"),onClick:async()=>{K({open:!0,title:"信息",context_div:(0,g.jsx)("div",{children:(0,g.jsxs)("ul",{children:[(0,g.jsxs)("li",{children:["通用格式:","<文件系统> <挂载点> <类型> <挂载选项> <dump> <fsck> "]}),(0,g.jsxs)("li",{children:["文件系统,有多种格式",(0,g.jsxs)("ul",{children:[(0,g.jsx)("li",{children:"1(usb口默认名称)./dev/sda1"}),(0,g.jsx)("li",{children:"2(唯一Id).UUID=123e4567-e89b-12d3-a456-426614174000"}),(0,g.jsx)("li",{children:"3.LABEL=DATA"})]})]}),(0,g.jsx)("li",{children:"挂载点,就是文件路径,例如 /mnt/data ,这个目录要提前创建,且为空"}),(0,g.jsx)("li",{children:"类型,就是文件系统类型,对于系统不支持的类型,例如ntfs需要额外前提安装ntfs-3g(linux 5.15内核以后自带 ntfs)"}),(0,g.jsxs)("li",{children:['挂载选项的值只能是以下这些,可以用 "," 同时使用多个选项',(0,g.jsxs)("ul",{children:[(0,g.jsx)("li",{children:"defaults:使用默认挂载选项"}),(0,g.jsx)("li",{children:"noatime:不更新访问时间,提高性能"}),(0,g.jsx)("li",{children:"auto:系统启动时自动挂载"}),(0,g.jsx)("li",{children:"rw:以读写方式挂载"}),(0,g.jsx)("li",{children:"nofail:防止启动阻塞,挂载失败系统继续执行"}),(0,g.jsx)("li",{children:"...等"})]})]}),(0,g.jsx)("li",{children:"dump 0是需要备份 1是不需要备份"}),(0,g.jsx)("li",{children:"Fsck 整数值0是不检查,文件系统检查顺序越小越先检查"}),(0,g.jsx)("li",{children:"提示:只有含有文件系统的逻辑卷,或者分区才可以进行挂载。"})]})})})}}),(0,g.jsx)(h.rA,{icon:"update",title:e("更新挂载"),onClick:async()=>{(await a.Yu.post("cmd/exe",{type:k.mount})).code===u.m.Success&&(0,_.SK)("挂载文件已生效")}},1)],G=async()=>(await a.Yu.get("get_fstab")).data,Z=async e=>{await a.Yu.post("save_fstab",{content:e})};return(0,g.jsxs)("div",{children:[(0,g.jsx)(d.A,{children:(0,g.jsx)(h.rA,{icon:"close",title:e("关闭"),onClick:()=>{s({})}})}),(0,g.jsx)(c.jW,{isFull:!0,more:!0,children:(0,g.jsx)(c.NN,{children:(0,g.jsxs)(c.fI,{children:[(0,g.jsx)(c.VP,{widthPer:40,children:(0,g.jsxs)(o.Zp,{title:e("物理块(硬盘)设备、逻辑卷、物理卷"),titleCom:(0,g.jsxs)("div",{children:[Y(A.oV.sys_disk_mount)&&(0,g.jsx)(h.rA,{icon:"file_open",title:e("打开挂载文件"),onClick:async()=>{$({name:"fstab(谨慎修改,内容错误会导致系统无法启动)",model:"text",get_file_fun:G,save_file_fun:Z,menu_list:H})}}),(0,g.jsx)(h.rA,{icon:"update",title:e("刷新"),onClick:async()=>{await N()===u.m.Success&&(0,_.SK)("刷新成功")}})]}),children:[(0,g.jsx)(x.X,{headers:E,rows:w,width:"10rem"}),(0,g.jsx)(v.A,{list:l,render:e=>{let t=e.name;return e.label&&(t+=`(${e.label})`),e.mountpoint?(0,g.jsxs)("span",{children:[t,(0,g.jsx)("span",{style:{color:"green"},children:"(已挂载)"})]}):t},onContextMenu:(e,t)=>{e.preventDefault()},click:t=>{let s="";if(t.mountpoint)for(let e=0;e<t.mountpoints.length;e++)s+=t.mountpoints[e]+";";y([[(0,g.jsx)(o.xP,{children:s}),(0,g.jsx)(o.xP,{children:t.uuid}),e(t.type),e(t.fstype),t.fssize,t.size,(0,g.jsx)(o.xP,{children:t.path}),t.pttype]])}})]})}),(0,g.jsx)(c.VP,{widthPer:60,children:F.map((t,s)=>{const n=[];for(const e of t.pv_list)n.push({name:`${e.name}---(${e.size})---(${e.free_size})`});const i=[];for(const e of t.lv_list)i.push({name:`${e.name}---(${e.size})`});return(0,g.jsx)(o.Zp,{children:(0,g.jsxs)(c.n5,{children:[(0,g.jsx)(C,{name:e("物理卷"),lvms:n}),(0,g.jsx)(b,{}),(0,g.jsx)(C,{name:`${e("逻辑卷")}---(${t.name})---size(${t.size})`,lvms:[]}),(0,g.jsx)(b,{}),(0,g.jsx)(C,{name:e("逻辑卷"),lvms:i})]})},s)})})]})})})]})}var V=s(88815);let Y=!0;function F(e){const{t}=(0,p.Bd)(),s=[t("名字"),t("厂商名称"),t("类型"),t("容量")],w=[t("名字"),t("物理硬盘"),t("文件系统类型"),t("挂载位置"),t("总容量"),t("剩余容量")],[k,v]=(0,j.fp)(f.AG.user_base_info),[S,C]=(0,n.useState)(0),[b,F]=(0,n.useState)(0),[M,$]=(0,n.useState)(0),[I,K]=(0,n.useState)(0),[E,N]=(0,n.useState)(0),[H,G]=(0,n.useState)({}),[Z,B]=(0,n.useState)(!1),[W,z]=(0,n.useState)(!1),[X,L]=(0,n.useState)(!1),[T,q]=(0,n.useState)(Y),[D,U]=(0,n.useState)(null),[O,J]=(0,n.useState)([]),[R,Q]=(0,n.useState)([]),[ee,te]=(0,j.fp)(f.AG.user_base_info),[se,ne]=(0,j.fp)(f.AG.disk),ce=async()=>{if(!Y)return;const e=new r.hf(r.HK.sys_get);await l.ws.send(e),l.ws.addMsg(r.HK.sys_getting,e=>{K(e.context?.cpu_currentLoad);const t=e.context?.memLeft,s=e.context?.memTotal;F(t),$(s),C((s-t)/s*100),U(e.context?.node_memory_usage),N(e.context?.node_cpu_usage)})};return(0,n.useEffect)(()=>((async()=>{await ce()})(),()=>{l.ws.sendData(r.HK.sys_cancel,{})}),[]),(0,g.jsxs)("div",{children:[(0,g.jsxs)(d.A,{children:[k.sys===A.XM.linux&&(0,g.jsx)(h.rA,{icon:"sd_card",title:"硬盘挂载",onClick:()=>{ne({type:"mount"})}}),(0,g.jsx)(h.Z$,{defaultStatus:!1,text:t("基本信息"),clickFun:e=>{B(e),e&&(async()=>{const e=await a.Yu.get("base");if(e.code===u.m.Success){const t=e.data;G(t)}})()}}),(0,g.jsx)(h.Z$,{defaultStatus:!1,text:t("物理硬盘"),clickFun:e=>{z(e),e&&(async()=>{const e=await a.Yu.get("disk");if(e.code===u.m.Success){const s=e.data,n=[];let c=!0;ee.sysSoftWare&&ee.sysSoftWare[m.jk.smartmontools]&&ee.sysSoftWare[m.jk.smartmontools].installed||(c=!1);for(const e of s??[])n.push([(0,g.jsx)(o.xP,{context:e.name}),e.typeName,e.type,e.total,(0,g.jsx)(h.rA,{icon:"health_and_safety",title:t("查看健康信息"),onClick:()=>{c?ne({type:"check",data:e}):(0,_.zN)("没有安装smartmontools")}})]);J(n)}})()}}),(0,g.jsx)(h.Z$,{defaultStatus:!1,text:t("文件硬盘"),clickFun:e=>{L(e),e&&(async()=>{const e=await a.Yu.get("filedisk");if(e.code===u.m.Success){const t=e.data,s=[];for(const e of t??[])s.push([(0,g.jsx)(o.xP,{context:e.name}),(0,g.jsx)(o.xP,{context:e.device_name}),e.fsType,(0,g.jsx)(o.xP,{context:e.mount}),e.total,e.available]);Q(s)}})()}}),(0,g.jsx)(h.Z$,{defaultStatus:T,text:t("实时信息"),clickFun:e=>{q(e),Y=e,ce()}})]}),(0,g.jsxs)(c.xh,{children:[T&&(0,g.jsxs)(c.fI,{children:[(0,g.jsx)(c.VP,{widthPer:33,maxWidth:"30rem",children:(0,g.jsx)(o.Zp,{title:"Sys "+t("内存"),children:(0,g.jsxs)(c.fI,{children:[(0,g.jsx)(c.VP,{children:(0,g.jsx)(i.A,{percentage:S})}),(0,g.jsx)(c.VP,{children:(0,g.jsxs)(c.fI,{children:[(0,g.jsx)(c.VP,{widthPer:100,children:(0,g.jsx)("div",{children:(0,g.jsx)(c.Yh,{left:t("总容量"),center:`${M}G`})})}),(0,g.jsx)(c.VP,{widthPer:100,children:(0,g.jsx)(c.Yh,{left:t("剩余"),center:`${b}G`})})]})})]})})}),(0,g.jsx)(c.VP,{widthPer:33,maxWidth:"30rem",children:(0,g.jsx)(o.Zp,{title:"Sys cpu",children:(0,g.jsxs)(c.fI,{children:[(0,g.jsx)(c.VP,{children:(0,g.jsx)(i.A,{percentage:I})}),(0,g.jsx)(c.VP,{children:(0,g.jsx)(c.fI,{children:(0,g.jsx)(c.Yh,{left:t("使用率"),center:I})})})]})})}),(0,g.jsx)(c.VP,{widthPer:33,maxWidth:"30rem",children:(0,g.jsx)(o.Zp,{title:"FileCat",children:(0,g.jsxs)(c.fI,{children:[(0,g.jsxs)(c.VP,{children:[(0,g.jsx)(c.qV,{content:t("内存")}),(0,g.jsx)(c.qV,{content:"total: "+(0,V.v7)(D?.rss)}),(0,g.jsx)(c.qV,{content:"object: "+(0,V.v7)(D?.heapTotal)}),(0,g.jsx)(c.qV,{content:"obj-use: "+(0,V.v7)(D?.heapUsed)}),(0,g.jsx)(c.qV,{content:"external: "+(0,V.v7)(D?.external)}),(0,g.jsx)(c.qV,{content:"buffer: "+(0,V.v7)(D?.arrayBuffers)})]}),(0,g.jsx)(c.VP,{children:(0,g.jsx)(c.qV,{content:"cpu growth rate: "+E})})]})})})]}),(0,g.jsxs)(c.fI,{children:[Z&&(0,g.jsx)(c.VP,{children:(0,g.jsxs)(o.Zp,{title:t("基本信息"),children:[(0,g.jsx)(c.Yh,{left:t("总内存"),right:H.mem_total}),(0,g.jsx)(c.Yh,{left:`cpu ${t("制造商")}`,right:H.cpu_manufacturer}),(0,g.jsx)(c.Yh,{left:`cpu ${t("品牌")}`,right:H.cpu_brand}),(0,g.jsx)(c.Yh,{left:`cpu ${t("逻辑核心")}`,right:H.cpu_core_num}),(0,g.jsx)(c.Yh,{left:`cpu ${t("物理核心")}`,right:H.cpu_phy_core_num}),(0,g.jsx)(c.Yh,{left:`cpu ${t("最大")}hz`,right:H.cpu_speed_hz}),(0,g.jsx)(c.Yh,{left:`${t("当前系统")}:pid;ppid`,right:H.pid_ppid}),(0,g.jsx)(c.Yh,{left:t("运行用户"),right:H.user})]})}),W&&(0,g.jsx)(c.VP,{children:(0,g.jsx)(o.uF,{title:t("物理硬盘"),children:(0,g.jsx)(x.X,{headers:s,rows:O,width:"10rem"})})}),X&&(0,g.jsx)(c.VP,{children:(0,g.jsx)(o.uF,{title:t("文件硬盘"),children:(0,g.jsx)(x.X,{headers:w,rows:R,width:"10rem"})})})]})]}),se&&"check"===se.type&&(0,g.jsx)(y,{...se.data}),se&&"mount"===se.type&&(0,g.jsx)(P,{})]})}var M=s(75007),$=s(97856),I=s(64405);const K=n.lazy(()=>Promise.all([s.e(2543),s.e(5614)]).then(s.bind(s,85614)));function E(e){const[t,s]=(0,n.useState)(null),[c,o]=(0,j.fp)(f.AG.dockerShellShow),[i,a]=(0,j.fp)(f.AG.user_base_info),d=i.user_data.theme?.includes("dark")?"#FFFFFF":"#000000",h=()=>{(async()=>{t&&(t.writeln("[38;2;29;153;243mclose![0m "),t.dispose(),s(null))})()};(0,n.useEffect)(()=>{c.show?(async()=>{const e=new $.Terminal({fontFamily:"Monaco, Menlo, Consolas, 'Courier New', monospace",theme:{background:"#FFFFFF",foreground:d,cursor:d,selectionBackground:"#a6d2ff"},cursorBlink:!0,cursorStyle:"bar",scrollback:1e3,scrollSensitivity:1,tabStopWidth:4,convertEol:!0});let t;l.ws.subscribeUnconnect(h);const n=t=>{e.write(t)};t=s=>{e.clear(),e.write(s),t=n},l.ws.addMsg("logs"===c.type?r.HK.docker_shell_logs_getting:r.HK.docker_shell_exec_getting,e=>{"error"===e.context&&h(),t(e.context)}),"exec"===c.type&&e.onData(async e=>{const t=new r.hf(r.HK.docker_shell_exec);t.context=e,await l.ws.send(t)}),s(e)})():h()},[c]),(0,n.useEffect)(()=>()=>{h()},[]);return(0,g.jsx)(K,{show:c.show,terminal:t,init:(e,s)=>{t.writeln("[38;2;29;153;243mconnect...[0m ");const n=new I.n;let o;n.rows=e,n.cols=s,n.dockerId=c.dockerId,o="logs"===c.type?new r.hf(r.HK.docker_shell_logs):new r.hf(r.HK.docker_shell_exec_open),o.context=n,l.ws.send(o)}})}var N=s(27690);let H="",G=[],Z=!1;function B(e){const{t}=(0,p.Bd)(),[s,i]=(0,n.useState)({}),[m,y]=(0,n.useState)([]),[k,v]=(0,n.useState)([]),{check_user_auth:C}=(0,S.MH)(),[b,P]=(0,j.fp)(f.AG.dockerShellShow),[V,Y]=(0,j.fp)(f.AG.showPrompt),[F,$]=(0,j.fp)(f.AG.confirm),[I,K]=(0,n.useState)(H),[B,W]=(0,n.useState)(["id",t("名字"),t("镜像"),t("命令"),t("状态"),t("内存"),"cpu%",t("选择")]),[z,X]=(0,n.useState)([]),[L,T]=(0,n.useState)(void 0),[q,D]=(0,n.useState)(!1),U=["id",t("name"),t("create时间"),t("大小"),(0,g.jsxs)("span",{children:["选中",(0,g.jsx)(h.rA,{icon:"check_box",title:"全选",onClick:()=>{Z=!Z;const e={};for(let t=0;t<k.length&&Z;t++)e[k[t][0].props.context]=1;i(e)}})]})],O=async()=>{y([]),X([]);const e=new r.hf(r.HK.docker_get);await l.ws.send(e),l.ws.addMsg(r.HK.docker_getting,e=>{const t=[];if(H){for(const s of e.context)for(const e of s)if(`${e}`.includes(H)){t.push(s);break}}else t.push(...e.context);y(t.map(e=>{const t=e.map(e=>(0,g.jsx)(o.xP,{context:e}));return t.push((0,g.jsx)(h.rA,{icon:"place",title:"选中",onClick:()=>{X(t)}})),t}))})};(0,n.useEffect)(()=>(K(H),O(),()=>{(async()=>{P({show:!1,type:"",dockerId:""})})()}),[]),(0,n.useEffect)(()=>{H=I},[I]);const J=()=>{const e=new r.hf("logs"===b.type?r.HK.docker_shell_logs_cancel:r.HK.docker_shell_exec_cancel);e.context="",l.ws.send(e)},R=e=>{const t=new r.hf(r.HK.docker_switch);t.context={type:e,dockerId:z[0].props.context},X([]),l.ws.send(t)},Q=async()=>{const e=await a.Yu.get("docker/images");if(e.code===u.m.Success){const t=e.data??[],s=[];for(let e=0;e<t.length;e++){const n=t[e],c=[(0,g.jsx)(o.xP,{context:n[0]}),(0,g.jsx)(o.xP,{context:n[1]}),n[2],n[3],""];s.push(c)}G=s,v(s)}};return(0,g.jsxs)("div",{children:[(0,g.jsxs)(d.A,{left_children:(0,g.jsx)(h.Z$,{defaultStatus:!1,text:t("docker镜像"),clickFun:e=>{D(e),e?(Q(),X([])):(O(),v([]),i({}))}}),children:[Object.keys(s).length>0&&(0,g.jsx)(h.rA,{icon:"delete",title:t("删除镜像"),onClick:async()=>{$({open:!0,title:t("确定删除选中的镜像吗"),handle:async()=>{const e=Object.keys(s),t=await a.Yu.post("docker/check/delete",{ids:e});if(t.code===u.m.Success)if(0===t.data.length){(await a.Yu.post("docker/delete",{ids:e})).code===u.m.Success&&((0,_.SK)("删除完成"),Q(),$({open:!1,handle:null}))}else(0,_.N9)(`有镜像正在运行${JSON.stringify(t.data)}`)}})}}),z.length>0&&(0,g.jsx)("div",{children:z[1].props.context}),z.length>0&&(0,g.jsxs)("div",{children:[C(A.oV.docker_container_update)&&(0,g.jsx)(h.rA,{icon:"delete",title:t("删除容器"),onClick:()=>{Y({show:!0,overlay:!0,type:N.PromptEnum.DockerDel,data:{dockerId:z[0].props.context,name:z[1].props.context}})}}),(0,g.jsx)(h.rA,{icon:"print",title:t("打印日志"),onClick:()=>{b.show?(P({show:!1,type:"",dockerId:""}),J()):P({show:!0,dockerId:z[0].props.context,type:"logs"})}}),C(A.oV.docker_container_update)&&(0,g.jsx)(h.rA,{icon:"personal_video",title:t("执行命令"),onClick:()=>{b.show?(P({show:!1,type:"",dockerId:""}),J()):P({show:!0,dockerId:z[0].props.context,type:"exec"})}}),C(A.oV.docker_container_update)&&z[4].props.context.includes("Up")&&(0,g.jsx)(h.rA,{icon:"stop",title:t("停止"),onClick:()=>R("stop")}),C(A.oV.docker_container_update)&&!z[4].props.context.includes("Up")&&(0,g.jsx)(h.rA,{icon:"play_arrow",title:t("开启"),onClick:()=>{R("start")}})]}),(0!==m.length||I)&&!q&&(0,g.jsx)(h.rA,{icon:"refresh",title:t("列表更新"),onClick:async()=>{const e=new r.hf(r.HK.docker_get);await l.ws.send(e)}})]}),(0,g.jsxs)(c.xh,{children:[q&&(0,g.jsx)(c.fI,{children:(0,g.jsx)(c.VP,{widthPer:80,children:(0,g.jsx)(o.uF,{title:`${t("镜像")} (${k.length})`,titleCom:(0,g.jsx)(w.Sm,{placeholder:t("过滤镜像"),value:L,handleInputChange:e=>{T(e)},handlerEnter:()=>{const e=[];if(L){for(const t of k)(t[0].props.context.includes(L)||t[1].props.context.includes(L))&&e.push(t);v(e)}else v(G)}}),children:(0,g.jsx)(x.X,{headers:U,rows:k.map((e,n)=>(e[4]=(0,g.jsx)(w.GL,{context:t(""),selected:s[e[0].props.context],onchange:()=>{(e=>{const t={};Object.assign(t,s),t[e]?delete t[e]:t[e]=1,i(t)})(e[0].props.context)}}),e)),width:"10rem"})})})}),0===m.length&&!I&&!q&&(0,g.jsx)(M.h,{context:t("检测不到docker,主机可能没有安装docker or 容器为空")}),(0!==m.length||I)&&!q&&(0,g.jsx)(c.fI,{children:(0,g.jsx)(c.VP,{widthPer:80,children:(0,g.jsx)(o.uF,{title:`${t("容器")} (${m.length})`,titleCom:(0,g.jsx)(w.Sm,{placeholder:t("过滤"),value:I,handleInputChange:e=>{K(e)}}),children:(0,g.jsx)(x.X,{headers:B,rows:m,width:"10rem"})})})})]}),(0,g.jsx)(E,{})]})}var W=s(64694);let z="",X=!1,L=!1;function T(e){const{t}=(0,p.Bd)(),[s,i]=(0,n.useState)([]),[a,u]=(0,n.useState)([]),[j,f]=(0,n.useState)(0),[m,_]=(0,n.useState)(""),[y,k]=(0,n.useState)(["pid",t("名字"),t("创建用户"),(0,g.jsxs)("span",{children:[t("内存"),(0,g.jsx)(h.rA,{icon:"sort",title:t("升序"),onClick:()=>{X=!X}})]}),(0,g.jsxs)("span",{children:["cpu%",(0,g.jsx)(h.rA,{icon:"sort",title:t("升序"),onClick:()=>{L=!L}})]}),t("选择")]),{check_user_auth:v}=(0,S.MH)();(0,n.useEffect)(()=>{_(z),(async()=>{i([]),f(0),u([]);const e=new r.hf(r.HK.process_get);await l.ws.send(e),l.ws.addMsg(r.HK.process_getting,e=>{const s=[];if(z){for(const t of e.context)for(const e of t)if(`${e}`.includes(z)){s.push(t);break}}else s.push(...e.context);X&&(0,W.di)(s,e=>e[3],!1),L&&(0,W.di)(s,e=>e[4],!1);const n=s.map(e=>{const s=e.map((e,t)=>(0,g.jsx)(o.xP,{context:3===t?(0,V.v7)(e):e}));return s.push((0,g.jsx)(h.rA,{icon:"place",title:t("选中"),onClick:()=>{u(s)}})),s});f(s.length),i(n)})})()},[]),(0,n.useEffect)(()=>{z=m},[m]);return(0,g.jsxs)("div",{children:[(0,g.jsxs)(d.A,{children:[a.length>0&&(0,g.jsx)("div",{children:a[1].props.context}),a.length>0&&v(A.oV.sys_process_close)&&(0,g.jsx)("div",{children:(0,g.jsx)(h.rA,{icon:"stop",title:t("停止"),onClick:()=>{const e=new r.hf(r.HK.process_close);e.context={pid:a[0].props.context},u([]),l.ws.send(e)}})})]}),(0,g.jsx)(c.xh,{children:0!==s.length||z?(0,g.jsx)(c.fI,{children:(0,g.jsx)(c.VP,{widthPer:80,children:(0,g.jsx)(o.uF,{title:`${t("进程")} (${j})`,titleCom:(0,g.jsx)(w.Sm,{placeholder:t("过滤"),value:m,handleInputChange:e=>{_(e)}}),children:(0,g.jsx)(x.X,{headers:y,rows:s,width:"10rem"})})})}):(0,g.jsx)(M.h,{context:t("加载中请等待...")})})]})}const q=n.lazy(()=>Promise.all([s.e(2543),s.e(5614)]).then(s.bind(s,85614)));function D(e){const[t,s]=(0,n.useState)(null),[c,o]=(0,j.fp)(f.AG.systemd_shell_show),[i,a]=(0,j.fp)(f.AG.user_base_info),d=i.user_data.theme?.includes("dark")?"#FFFFFF":"#000000",h=()=>{(async()=>{t&&(t.writeln("[38;2;29;153;243mclose![0m "),t.dispose(),s(null))})()};(0,n.useEffect)(()=>{if(!c.show)return void h();(async()=>{const e=new $.Terminal({fontFamily:"Monaco, Menlo, Consolas, 'Courier New', monospace",theme:{background:"#FFFFFF",foreground:d,cursor:d,selectionBackground:"#a6d2ff"},cursorBlink:!0,cursorStyle:"bar",scrollback:1e3,scrollSensitivity:1,tabStopWidth:4,convertEol:!0});l.ws.subscribeUnconnect(h),l.ws.addMsg(r.HK.systemd_logs_getting,t=>{"error"===t.context&&h(),e.write(t.context)}),s(e)})();const e=e=>{};return document.addEventListener("cancel_systemd_logs",e),()=>{document.removeEventListener("cancel_systemd_logs",e)}},[c]),(0,n.useEffect)(()=>()=>{h()},[]);return(0,g.jsx)(q,{show:c.show,terminal:t,init:(e,s)=>{t.writeln("[38;2;29;153;243mconnect...[0m ");const n={unit_name:c.unit_name},o=new r.hf(r.HK.systemd_logs_get);o.context=n,l.ws.send(o)}})}let U,O="";function J(e){const{t}=(0,p.Bd)(),{check_user_auth:s}=(0,S.MH)(),[i,m]=(0,j.fp)(f.AG.systemd_shell_show),[y,k]=(0,j.fp)(f.AG.confirm),[v,C]=(0,n.useState)(["pid","name","process",t("创建用户"),t("内存"),t("cpu%"),t("active状态"),t("选择")]),[b,P]=(0,n.useState)(["单元名字","加载状态",t("active(sub)状态"),t("描述"),t("选择")]),[Y,F]=(0,n.useState)([]),[$,I]=(0,n.useState)([]),[K,E]=(0,n.useState)([]),[N,H]=(0,n.useState)(!1),[G,Z]=(0,n.useState)([]),[B,W]=(0,n.useState)(""),[z,X]=(0,n.useState)(""),[L,T]=(0,n.useState)(new Set),[q,J]=(0,j.fp)(f.AG.editorSetting);(0,n.useEffect)(()=>{X(O),(async()=>{F([]),E([]);const e=new r.hf(r.HK.systemd_inside_get);await l.ws.send(e),l.ws.addMsg(r.HK.systemd_inside_getting,e=>{const t=[];if(O){for(const s of e.context)for(const e of s)if(`${e}`.includes(O)){t.push(s);break}}else t.push(...e.context);F(t.map(e=>{const t=e.map((e,t)=>(0,g.jsx)(o.xP,{context:4===t?(0,V.v7)(e):e}));return t.push((0,g.jsx)(h.rA,{icon:"place",title:"选中",onClick:()=>{E(t)}})),t}))})})()},[]),(0,n.useEffect)(()=>{O=z},[z]);const R=e=>{if(i.show){m({show:!1,unit_name:""});const e=new CustomEvent("cancel_systemd_logs",{detail:{}});document.dispatchEvent(e)}else m({show:!0,unit_name:e})};return(0,g.jsxs)("div",{children:[(0,g.jsxs)(d.A,{left_children:(0,g.jsx)(h.Z$,{defaultStatus:!1,text:t("系统systemd单元"),clickFun:e=>{H(e),e?((async()=>{I([]),Z([]);const e=await a.Yu.get("systemd/inside/all");if(e.code!==u.m.Success)return;T(new Set(e.data));const t=await a.Yu.get("systemd/allget");if(t.code===u.m.Success){const e=t.data,s=[];for(const t of e??[]){const e=[(0,g.jsx)(o.xP,{context:t.unit}),t.load,`${t.active}(${t.sub})`,(0,g.jsx)(o.xP,{context:t.description})];s.push([...e,(0,g.jsx)(h.rA,{icon:"place",title:"添加",onClick:()=>{Z([...e])}})])}U=s,I(s)}})(),E([])):Z([])}}),children:[K.length>0&&(0,g.jsx)("div",{children:K[1].props.context}),G.length>0&&(0,g.jsx)("div",{children:G[0].props.context}),K.length>0&&(0,g.jsxs)("div",{children:[s(A.oV.systemd_update)&&(0,g.jsx)(h.rA,{icon:"delete",title:"从实时监控删除",onClick:()=>{(async e=>{k({open:!0,handle:async()=>{(await a.Yu.post("systemd/delete",{unit_name:e})).code===u.m.Success&&((0,_.SK)("删除成功"),k({open:!1,handle:null}))}})})(K[1].props.context)}}),(0,g.jsx)(h.rA,{icon:"print",title:"打印日志",onClick:()=>{R(K[1].props.context)}})]}),G.length>0&&(0,g.jsxs)("div",{children:[s(A.oV.systemd_update)&&(0,g.jsx)(h.rA,{icon:"delete",title:"删除系统上的sytemd",onClick:()=>{(async e=>{k({open:!0,handle:async()=>{(await a.Yu.post("systemd/sys/delete",{unit_name:e})).code===u.m.Success&&((0,_.SK)("删除成功"),k({open:!1,handle:null}))}})})(G[0].props.context)}}),(0,g.jsx)(h.rA,{icon:"print",title:"打印日志",onClick:()=>{R(G[0].props.context)}}),s(A.oV.systemd_update)&&(0,g.jsx)(h.rA,{icon:"text_fields",title:"sytemd文件内容",onClick:()=>{(async t=>{const s=await a.Yu.post("systemd/get/context",{unit_name:t});s.code===u.m.Success&&(J({model:"text",open:!0,fileName:e.name,save:async e=>{const t={context:e};"/"===s.data.path[0]&&(s.data.path=s.data.path.slice(1)),(await a.$M.post(`save/${s.data.path}`,t)).code===u.m.Success&&(S.xK.set_value_temp(""),J({open:!1,model:"",fileName:"",save:null}))}}),S.xK.set_value_temp(s.data.context))})(G[0].props.context)}}),s(A.oV.systemd_update)&&!L.has(G[0].props.context)&&(0,g.jsx)(h.rA,{icon:"plus_one",title:"添加到管理",onClick:()=>(async e=>{const t=await a.Yu.post("systemd/add",{unit_name:e});t.code===u.m.Success&&(T(new Set(t.data)),(0,_.SK)("添加成功"))})(G[0].props.context)})]})]}),(0,g.jsxs)(c.xh,{children:[N&&(0,g.jsx)(c.fI,{children:(0,g.jsx)(c.VP,{widthPer:80,children:(0,g.jsx)(o.uF,{title:`systemd系统单元(${$.length})`,titleCom:(0,g.jsx)(w.Sm,{placeholder:"过滤单元",value:B,handleInputChange:e=>{W(e)},handlerEnter:()=>{const e=[];if(B){for(const t of U)(t[0].props.context.includes(B)||t[3].props.context.includes(B))&&e.push(t);I(e)}else I(U)}}),children:(0,g.jsx)(x.X,{headers:b,rows:$,width:"10rem"})})})}),0===Y.length&&!N&&(0,g.jsx)(M.h,{context:"没有管理的单元 or 加载中请等待..."}),0!==Y.length&&!N&&(0,g.jsx)(c.fI,{children:(0,g.jsx)(c.VP,{widthPer:80,children:(0,g.jsx)(o.uF,{title:`filecat监控单元(${Y.length})`,titleCom:(0,g.jsx)(w.Sm,{placeholder:"过滤单元",value:z,handleInputChange:e=>{X(e)}}),children:(0,g.jsx)(x.X,{headers:v,rows:Y,width:"10rem"})})})})]}),(0,g.jsx)(D,{})]})}var R=s(87361);function Q(e){const{t}=(0,p.Bd)(),[s,n]=(0,j.fp)(f.AG.user_base_info),o=[{index:1,name:t("系统性能"),rto:"sys/",component:(0,g.jsx)(F,{})},{index:2,name:t("系统进程"),rto:"process/",component:(0,g.jsx)(T,{})},{index:3,name:t("docker容器"),rto:"docker/",component:(0,g.jsx)(B,{})}];return s.sys===A.XM.linux&&o.push({index:4,name:t("systemd"),rto:"systemd/",component:(0,g.jsx)(J,{})}),(0,g.jsx)(c.W1,{optionList:o,father_route:R.o.info})}}}]);
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[7180],{75007(e,t,s){s.d(t,{h:()=>o});s(96540);var n=s(85997),c=s(74848);function o(e){return(0,c.jsxs)("h2",{className:"message",children:[(0,c.jsx)(n.In,{icon:"sentiment_dissatisfied"}),(0,c.jsx)("span",{children:e.context})]})}},22081(e,t,s){var n=s(96540),c=s(16349),o=s(74848);const i=({percentage:e})=>{const t=(0,n.useRef)(null),[s,i]=(0,n.useState)(null);return(0,n.useEffect)(()=>{const s=t.current.getContext("2d"),n=new c.Ay(s,{type:"doughnut",data:{labels:["use","left"],datasets:[{data:[e,100-e],backgroundColor:["#007bff","#f0f0f0"],borderWidth:0}]},options:{plugins:{legend:{display:!1},tooltip:{enabled:!1}},elements:{arc:{borderWidth:0}}}});return i(n),()=>{n.destroy()}},[]),(0,n.useEffect)(()=>{s&&(s.data.datasets[0].data=[e,100-e],s.update())},[e]),(0,o.jsx)("div",{style:{width:"8rem",overflow:"hidden"},children:(0,o.jsx)("canvas",{ref:t})})};s.d(t,["A",0,i])},77481(e,t,s){s.d(t,{S:()=>i,X:()=>o});var n=s(96540),c=s(74848);function o(e){const[t,s]=n.useState([]);return(0,n.useEffect)(()=>{e.children?s(Array.isArray(e.children)?e.children:[e.children]):s(e.rows)},[e.rows,e.children]),(0,c.jsxs)("table",{children:[(0,c.jsx)("thead",{children:(0,c.jsx)("tr",{children:e.headers?.map((e,t)=>(0,c.jsx)("th",{children:e},t))})}),(0,c.jsx)("tbody",{children:t.map((t,s)=>(0,c.jsx)("tr",{onContextMenu:()=>{e.handleContextMenu&&e.handleContextMenu(t)},children:t.map((s,n)=>(0,c.jsx)("td",{style:{width:e.width??"auto"},className:n===t.length-1?"small":"",children:s},n))},s))})]})}function i(e){return(0,c.jsx)("div",{style:{display:e.isFlex?"flex":"block"},children:e.columns.map((e,t)=>(0,c.jsx)("div",{children:e},t))})}},88062(e,t,s){s(96540),s(47022);var n=s(74848);function c(e){return(0,n.jsx)("div",{className:"black-tip",onClick:()=>{e.click&&e.click(e)},onContextMenu:t=>{t.stopPropagation(),t.nativeEvent.stopImmediatePropagation(),e.onContextMenu&&e.onContextMenu(t,e)},children:e.name})}const o=e=>(0,n.jsxs)("li",{children:[e.click?(0,n.jsx)(c,{...e.node,name:e.render?e.render(e.node):e.node.name,click:e.click,onContextMenu:e.onContextMenu}):(0,n.jsx)("div",{children:e.render?e.render(e.node):e.node.name}),e.node.children&&e.node.children.length>0&&(0,n.jsx)("ul",{children:e.node.children.map((t,s)=>(0,n.jsx)(o,{node:t,click:e.click,onContextMenu:e.onContextMenu,render:e.render},s))})]}),i=e=>(0,n.jsx)("div",{className:"card-tree-view",children:(0,n.jsx)("ul",{children:e.list&&e.list.map((t,s)=>(0,n.jsx)(o,{node:t,click:e.click,onContextMenu:e.onContextMenu,render:e.render},s))})});s.d(t,["A",0,i])},57180(e,t,s){s.r(t),s.d(t,{default:()=>Q});var n=s(96540),c=s(75725),o=s(70447),i=s(22081),r=s(92275),l=s(14944),a=s(14284),d=s(57952),h=s(85997),x=s(77481),u=s(53459),p=s(34899),j=s(34843),f=s(82893),m=s(74777),_=s(62042),w=s(61443),g=s(74848);function y(e){const{t}=(0,p.Bd)(),[s,i]=(0,j.fp)(f.AG.disk),[r,l]=(0,n.useState)({}),[m,_]=(0,n.useState)([]),w=[t("名字"),t("当前值"),t("历史最低"),t("临界值")];return(0,n.useEffect)(()=>{(async()=>{const s=await a.Yu.post("sys/disk/info",{name:e.name});if(s.code===u.m.Success){const e=[];for(const n of s.data.ata_smart_attributes??[]){let s;n[1]>=n[2]?s="var(--icon-green)":n[1]<=n[3]&&(s="var(--icon-red)"),n[0]=(0,g.jsx)("span",{style:{color:s},children:t(n[0])}),e.push(n)}_(s.data.ata_smart_attributes),l(s.data)}})()},[]),(0,g.jsxs)("div",{children:[(0,g.jsx)(d.A,{children:(0,g.jsx)(h.rA,{icon:"close",title:t("关闭"),onClick:()=>{i({})}})}),(0,g.jsx)(c.jW,{isFull:!0,more:!0,children:(0,g.jsx)(c.NN,{children:(0,g.jsxs)(c.fI,{children:[(0,g.jsxs)(c.VP,{widthPer:30,children:[(0,g.jsx)(c.xh,{children:(0,g.jsxs)(o.Zp,{title:t("基本信息"),children:[(0,g.jsx)(c.Yh,{left:t("名字"),right:e.name}),(0,g.jsx)(c.Yh,{left:t("厂商名称"),right:e.typeName}),(0,g.jsx)(c.Yh,{left:t("类型"),right:e.type}),(0,g.jsx)(c.Yh,{left:t("容量"),right:e.total})]})}),(0,g.jsx)(c.xh,{children:(0,g.jsxs)(o.Zp,{title:t("物理信息"),children:[(0,g.jsx)(c.Yh,{left:t("是否健康"),right:!0===r.smart_status?"是":"否"}),(0,g.jsx)(c.Yh,{left:t("设备型号"),right:r.model_name}),(0,g.jsx)(c.Yh,{left:t("序列号"),right:r.serial_number}),(0,g.jsx)(c.Yh,{left:t("固件版本"),right:r.firmware_version}),(0,g.jsx)(c.Yh,{left:t("转速(每分钟)"),right:r.rotation_rate}),(0,g.jsx)(c.Yh,{left:t("通电时长(小时)"),right:r.power_on_time_hours}),(0,g.jsx)(c.Yh,{left:t("通电次数"),right:r.power_cycle_count}),(0,g.jsx)(c.Yh,{left:t("温度(°C)"),right:r.temperature}),(0,g.jsx)(c.Yh,{left:t("通信协议"),right:r.device_protocol})]})})]}),(0,g.jsx)(c.VP,{widthPer:50,children:(0,g.jsxs)(c.xh,{children:[m?.length?(0,g.jsx)(o.uF,{title:t("ATA/SATA详细信息"),children:(0,g.jsx)(x.X,{headers:w,rows:m,width:"10rem"})}):(0,g.jsx)(g.Fragment,{}),r.nvme_smart?(0,g.jsxs)(o.Zp,{title:t("NVME详细信息"),children:[(0,g.jsx)(c.Yh,{left:t("NVMe 可用备用块(%)"),right:r.nvme_smart.available_spare}),(0,g.jsx)(c.Yh,{left:t("NVMe 已使用寿命(%)"),right:r.nvme_smart.percentage_used}),(0,g.jsx)(c.Yh,{left:t("NVMe 读取量"),right:r.nvme_smart.data_units_read}),(0,g.jsx)(c.Yh,{left:t("NVMe 写入量"),right:r.nvme_smart.data_units_written}),(0,g.jsx)(c.Yh,{left:t("NVMe 通电次数"),right:r.nvme_smart.power_cycles}),(0,g.jsx)(c.Yh,{left:t("NVMe 通电时长(小时)"),right:r.nvme_smart.power_on_hours}),(0,g.jsx)(c.Yh,{left:t("NVMe 非正常关机"),right:r.nvme_smart.unsafe_shutdowns}),(0,g.jsx)(c.Yh,{left:t("NVMe 媒体错误"),right:r.nvme_smart.media_errors}),(0,g.jsx)(c.Yh,{left:t("NVMe 错误日志数"),right:r.nvme_smart.num_err_log_entries})]}):(0,g.jsx)(g.Fragment,{})]})})]})})})]})}let k=function(e){return e[e.mount=0]="mount",e}({});var v=s(88062),S=s(78247),A=s(23430);const C=e=>(0,g.jsxs)("div",{style:{border:"2px solid black",padding:"10px",width:"300px",height:"300px",position:"relative"},children:[e.name,e.lvms.map((e,t)=>(0,g.jsx)("div",{style:{margin:"5px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid "},children:e.name},t))]});function b(){return(0,g.jsx)("div",{style:{position:"relative",height:"300px",margin:"10px",width:"30px",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,g.jsx)("div",{style:{width:0,height:0,borderTop:"10px solid transparent",borderBottom:"10px solid transparent",borderLeft:"10px solid black"}})})}function P(){const{t:e}=(0,p.Bd)(),[t,s]=(0,j.fp)(f.AG.disk),[i,r]=(0,n.useState)({}),[l,m]=(0,n.useState)([]),[w,y]=(0,n.useState)([]),[P,Y]=(0,j.fp)(f.AG.showPrompt),{check_user_auth:V}=(0,S.MH)(),[F,M]=(0,n.useState)([]),{click_file:$}=(0,S.kZ)(),[I,K]=(0,j.fp)(f.AG.prompt_card),E=[e("挂载点"),"uuid",e("类型"),e("文件系统类型"),e("文件系统容量"),e("卷容量"),e("设备路径"),e("分区表类型")],N=async()=>{const e=await a.Yu.get("disk/blk");return e.code===u.m.Success&&m(e.data),e.code};(0,n.useEffect)(()=>{(async()=>{N()})()},[]);const H=[(0,g.jsx)(h.rA,{icon:"info",title:e("提示"),onClick:async()=>{K({open:!0,title:"信息",context_div:(0,g.jsx)("div",{children:(0,g.jsxs)("ul",{children:[(0,g.jsxs)("li",{children:["通用格式:","<文件系统> <挂载点> <类型> <挂载选项> <dump> <fsck> "]}),(0,g.jsxs)("li",{children:["文件系统,有多种格式",(0,g.jsxs)("ul",{children:[(0,g.jsx)("li",{children:"1(usb口默认名称)./dev/sda1"}),(0,g.jsx)("li",{children:"2(唯一Id).UUID=123e4567-e89b-12d3-a456-426614174000"}),(0,g.jsx)("li",{children:"3.LABEL=DATA"})]})]}),(0,g.jsx)("li",{children:"挂载点,就是文件路径,例如 /mnt/data ,这个目录要提前创建,且为空"}),(0,g.jsx)("li",{children:"类型,就是文件系统类型,对于系统不支持的类型,例如ntfs需要额外前提安装ntfs-3g(linux 5.15内核以后自带 ntfs)"}),(0,g.jsxs)("li",{children:['挂载选项的值只能是以下这些,可以用 "," 同时使用多个选项',(0,g.jsxs)("ul",{children:[(0,g.jsx)("li",{children:"defaults:使用默认挂载选项"}),(0,g.jsx)("li",{children:"noatime:不更新访问时间,提高性能"}),(0,g.jsx)("li",{children:"auto:系统启动时自动挂载"}),(0,g.jsx)("li",{children:"rw:以读写方式挂载"}),(0,g.jsx)("li",{children:"nofail:防止启动阻塞,挂载失败系统继续执行"}),(0,g.jsx)("li",{children:"...等"})]})]}),(0,g.jsx)("li",{children:"dump 0是需要备份 1是不需要备份"}),(0,g.jsx)("li",{children:"Fsck 整数值0是不检查,文件系统检查顺序越小越先检查"}),(0,g.jsx)("li",{children:"提示:只有含有文件系统的逻辑卷,或者分区才可以进行挂载。"})]})})})}}),(0,g.jsx)(h.rA,{icon:"update",title:e("更新挂载"),onClick:async()=>{(await a.Yu.post("cmd/exe",{type:k.mount})).code===u.m.Success&&(0,_.SK)("挂载文件已生效")}},1)],G=async()=>(await a.Yu.get("get_fstab")).data,Z=async e=>{await a.Yu.post("save_fstab",{content:e})};return(0,g.jsxs)("div",{children:[(0,g.jsx)(d.A,{children:(0,g.jsx)(h.rA,{icon:"close",title:e("关闭"),onClick:()=>{s({})}})}),(0,g.jsx)(c.jW,{isFull:!0,more:!0,children:(0,g.jsx)(c.NN,{children:(0,g.jsxs)(c.fI,{children:[(0,g.jsx)(c.VP,{widthPer:40,children:(0,g.jsxs)(o.Zp,{title:e("物理块(硬盘)设备、逻辑卷、物理卷"),titleCom:(0,g.jsxs)("div",{children:[V(A.oV.sys_disk_mount)&&(0,g.jsx)(h.rA,{icon:"file_open",title:e("打开挂载文件"),onClick:async()=>{$({name:"fstab(谨慎修改,内容错误会导致系统无法启动)",model:"text",get_file_fun:G,save_file_fun:Z,menu_list:H})}}),(0,g.jsx)(h.rA,{icon:"update",title:e("刷新"),onClick:async()=>{await N()===u.m.Success&&(0,_.SK)("刷新成功")}})]}),children:[(0,g.jsx)(x.X,{headers:E,rows:w,width:"10rem"}),(0,g.jsx)(v.A,{list:l,render:e=>{let t=e.name;return e.label&&(t+=`(${e.label})`),e.mountpoint?(0,g.jsxs)("span",{children:[t,(0,g.jsx)("span",{style:{color:"green"},children:"(已挂载)"})]}):t},onContextMenu:(e,t)=>{e.preventDefault()},click:t=>{let s="";if(t.mountpoint)for(let e=0;e<t.mountpoints.length;e++)s+=t.mountpoints[e]+";";y([[(0,g.jsx)(o.xP,{children:s}),(0,g.jsx)(o.xP,{children:t.uuid}),e(t.type),e(t.fstype),t.fssize,t.size,(0,g.jsx)(o.xP,{children:t.path}),t.pttype]])}})]})}),(0,g.jsx)(c.VP,{widthPer:60,children:F.map((t,s)=>{const n=[];for(const e of t.pv_list)n.push({name:`${e.name}---(${e.size})---(${e.free_size})`});const i=[];for(const e of t.lv_list)i.push({name:`${e.name}---(${e.size})`});return(0,g.jsx)(o.Zp,{children:(0,g.jsxs)(c.n5,{children:[(0,g.jsx)(C,{name:e("物理卷"),lvms:n}),(0,g.jsx)(b,{}),(0,g.jsx)(C,{name:`${e("逻辑卷")}---(${t.name})---size(${t.size})`,lvms:[]}),(0,g.jsx)(b,{}),(0,g.jsx)(C,{name:e("逻辑卷"),lvms:i})]})},s)})})]})})})]})}var Y=s(88815);let V=!0;function F(e){const{t}=(0,p.Bd)(),s=[t("名字"),t("厂商名称"),t("类型"),t("容量")],w=[t("名字"),t("物理硬盘"),t("文件系统类型"),t("挂载位置"),t("总容量"),t("剩余容量")],[k,v]=(0,j.fp)(f.AG.user_base_info),[S,C]=(0,n.useState)(0),[b,F]=(0,n.useState)(0),[M,$]=(0,n.useState)(0),[I,K]=(0,n.useState)(0),[E,N]=(0,n.useState)(0),[H,G]=(0,n.useState)({}),[Z,B]=(0,n.useState)(!1),[W,z]=(0,n.useState)(!1),[X,L]=(0,n.useState)(!1),[T,q]=(0,n.useState)(V),[D,U]=(0,n.useState)(null),[O,J]=(0,n.useState)([]),[R,Q]=(0,n.useState)([]),[ee,te]=(0,j.fp)(f.AG.user_base_info),[se,ne]=(0,j.fp)(f.AG.disk),ce=async()=>{if(!V)return;const e=new r.hf(r.HK.sys_get);await l.ws.send(e),l.ws.addMsg(r.HK.sys_getting,e=>{K(e.context?.cpu_currentLoad);const t=e.context?.memLeft,s=e.context?.memTotal;F(t),$(s),C((s-t)/s*100),U(e.context?.node_memory_usage),N(e.context?.node_cpu_usage)})};return(0,n.useEffect)(()=>((async()=>{await ce()})(),()=>{l.ws.sendData(r.HK.sys_cancel,{})}),[]),(0,g.jsxs)("div",{children:[(0,g.jsxs)(d.A,{children:[k.sys===A.XM.linux&&(0,g.jsx)(h.rA,{icon:"sd_card",title:"硬盘挂载",onClick:()=>{ne({type:"mount"})}}),(0,g.jsx)(h.Z$,{defaultStatus:!1,text:t("基本信息"),clickFun:e=>{B(e),e&&(async()=>{const e=await a.Yu.get("base");if(e.code===u.m.Success){const t=e.data;G(t)}})()}}),(0,g.jsx)(h.Z$,{defaultStatus:!1,text:t("物理硬盘"),clickFun:e=>{z(e),e&&(async()=>{const e=await a.Yu.get("disk");if(e.code===u.m.Success){const s=e.data,n=[];let c=!0;ee.sysSoftWare&&ee.sysSoftWare[m.jk.smartmontools]&&ee.sysSoftWare[m.jk.smartmontools].installed||(c=!1);for(const e of s??[])n.push([(0,g.jsx)(o.xP,{context:e.name}),e.typeName,e.type,e.total,(0,g.jsx)(h.rA,{icon:"health_and_safety",title:t("查看健康信息"),onClick:()=>{c?ne({type:"check",data:e}):(0,_.zN)("没有安装smartmontools")}})]);J(n)}})()}}),(0,g.jsx)(h.Z$,{defaultStatus:!1,text:t("文件硬盘"),clickFun:e=>{L(e),e&&(async()=>{const e=await a.Yu.get("filedisk");if(e.code===u.m.Success){const t=e.data,s=[];for(const e of t??[])s.push([(0,g.jsx)(o.xP,{context:e.name}),(0,g.jsx)(o.xP,{context:e.device_name}),e.fsType,(0,g.jsx)(o.xP,{context:e.mount}),e.total,e.available]);Q(s)}})()}}),(0,g.jsx)(h.Z$,{defaultStatus:T,text:t("实时信息"),clickFun:e=>{q(e),V=e,ce()}})]}),(0,g.jsxs)(c.xh,{children:[T&&(0,g.jsxs)(c.fI,{children:[(0,g.jsx)(c.VP,{widthPer:33,maxWidth:"30rem",children:(0,g.jsx)(o.Zp,{title:"Sys "+t("内存"),children:(0,g.jsxs)(c.fI,{children:[(0,g.jsx)(c.VP,{children:(0,g.jsx)(i.A,{percentage:S})}),(0,g.jsx)(c.VP,{children:(0,g.jsxs)(c.fI,{children:[(0,g.jsx)(c.VP,{widthPer:100,children:(0,g.jsx)("div",{children:(0,g.jsx)(c.Yh,{left:t("总容量"),center:`${M}G`})})}),(0,g.jsx)(c.VP,{widthPer:100,children:(0,g.jsx)(c.Yh,{left:t("剩余"),center:`${b}G`})})]})})]})})}),(0,g.jsx)(c.VP,{widthPer:33,maxWidth:"30rem",children:(0,g.jsx)(o.Zp,{title:"Sys cpu",children:(0,g.jsxs)(c.fI,{children:[(0,g.jsx)(c.VP,{children:(0,g.jsx)(i.A,{percentage:I})}),(0,g.jsx)(c.VP,{children:(0,g.jsx)(c.fI,{children:(0,g.jsx)(c.Yh,{left:t("使用率"),center:I})})})]})})}),(0,g.jsx)(c.VP,{widthPer:33,maxWidth:"30rem",children:(0,g.jsx)(o.Zp,{title:"FileCat",children:(0,g.jsxs)(c.fI,{children:[(0,g.jsxs)(c.VP,{children:[(0,g.jsx)(c.qV,{content:t("内存")}),(0,g.jsx)(c.qV,{content:"total: "+(0,Y.v7)(D?.rss)}),(0,g.jsx)(c.qV,{content:"object: "+(0,Y.v7)(D?.heapTotal)}),(0,g.jsx)(c.qV,{content:"obj-use: "+(0,Y.v7)(D?.heapUsed)}),(0,g.jsx)(c.qV,{content:"external: "+(0,Y.v7)(D?.external)}),(0,g.jsx)(c.qV,{content:"buffer: "+(0,Y.v7)(D?.arrayBuffers)})]}),(0,g.jsx)(c.VP,{children:(0,g.jsx)(c.qV,{content:"cpu growth rate: "+E})})]})})})]}),(0,g.jsxs)(c.fI,{children:[Z&&(0,g.jsx)(c.VP,{children:(0,g.jsxs)(o.Zp,{title:t("基本信息"),children:[(0,g.jsx)(c.Yh,{left:t("总内存"),right:H.mem_total}),(0,g.jsx)(c.Yh,{left:`cpu ${t("制造商")}`,right:H.cpu_manufacturer}),(0,g.jsx)(c.Yh,{left:`cpu ${t("品牌")}`,right:H.cpu_brand}),(0,g.jsx)(c.Yh,{left:`cpu ${t("逻辑核心")}`,right:H.cpu_core_num}),(0,g.jsx)(c.Yh,{left:`cpu ${t("物理核心")}`,right:H.cpu_phy_core_num}),(0,g.jsx)(c.Yh,{left:`cpu ${t("最大")}hz`,right:H.cpu_speed_hz}),(0,g.jsx)(c.Yh,{left:`${t("当前系统")}:pid;ppid`,right:H.pid_ppid}),(0,g.jsx)(c.Yh,{left:t("运行用户"),right:H.user})]})}),W&&(0,g.jsx)(c.VP,{children:(0,g.jsx)(o.uF,{title:t("物理硬盘"),children:(0,g.jsx)(x.X,{headers:s,rows:O,width:"10rem"})})}),X&&(0,g.jsx)(c.VP,{children:(0,g.jsx)(o.uF,{title:t("文件硬盘"),children:(0,g.jsx)(x.X,{headers:w,rows:R,width:"10rem"})})})]})]}),se&&"check"===se.type&&(0,g.jsx)(y,{...se.data}),se&&"mount"===se.type&&(0,g.jsx)(P,{})]})}var M=s(75007),$=s(97856),I=s(64405);const K=n.lazy(()=>Promise.all([s.e(2543),s.e(5614)]).then(s.bind(s,85614)));function E(e){const[t,s]=(0,n.useState)(null),[c,o]=(0,j.fp)(f.AG.dockerShellShow),[i,a]=(0,j.fp)(f.AG.user_base_info),d=i.user_data.theme?.includes("dark")?"#FFFFFF":"#000000",h=()=>{(async()=>{t&&(t.writeln("[38;2;29;153;243mclose![0m "),t.dispose(),s(null))})()};(0,n.useEffect)(()=>{c.show?(async()=>{const e=new $.Terminal({fontFamily:"Monaco, Menlo, Consolas, 'Courier New', monospace",theme:{background:"#FFFFFF",foreground:d,cursor:d,selectionBackground:"#a6d2ff"},cursorBlink:!0,cursorStyle:"bar",scrollback:1e3,scrollSensitivity:1,tabStopWidth:4,convertEol:!0});let t;l.ws.subscribeUnconnect(h);const n=t=>{e.write(t)};t=s=>{e.clear(),e.write(s),t=n},l.ws.addMsg("logs"===c.type?r.HK.docker_shell_logs_getting:r.HK.docker_shell_exec_getting,e=>{"error"===e.context&&h(),t(e.context)}),"exec"===c.type&&e.onData(async e=>{const t=new r.hf(r.HK.docker_shell_exec);t.context=e,await l.ws.send(t)}),s(e)})():h()},[c]),(0,n.useEffect)(()=>()=>{h()},[]);return(0,g.jsx)(K,{show:c.show,terminal:t,init:(e,s)=>{t.writeln("[38;2;29;153;243mconnect...[0m ");const n=new I.n;let o;n.rows=e,n.cols=s,n.dockerId=c.dockerId,o="logs"===c.type?new r.hf(r.HK.docker_shell_logs):new r.hf(r.HK.docker_shell_exec_open),o.context=n,l.ws.send(o)}})}var N=s(27690);let H="",G=[],Z=!1;function B(e){const{t}=(0,p.Bd)(),[s,i]=(0,n.useState)({}),[m,y]=(0,n.useState)([]),[k,v]=(0,n.useState)([]),{check_user_auth:C}=(0,S.MH)(),[b,P]=(0,j.fp)(f.AG.dockerShellShow),[Y,V]=(0,j.fp)(f.AG.showPrompt),[F,$]=(0,j.fp)(f.AG.confirm),[I,K]=(0,n.useState)(H),[B,W]=(0,n.useState)(["id",t("名字"),t("镜像"),t("命令"),t("状态"),t("内存"),"cpu%",t("选择")]),[z,X]=(0,n.useState)([]),[L,T]=(0,n.useState)(void 0),[q,D]=(0,n.useState)(!1),U=["id",t("name"),t("create时间"),t("大小"),(0,g.jsxs)("span",{children:["选中",(0,g.jsx)(h.rA,{icon:"check_box",title:"全选",onClick:()=>{Z=!Z;const e={};for(let t=0;t<k.length&&Z;t++)e[k[t][0].props.context]=1;i(e)}})]})],O=async()=>{y([]),X([]);const e=new r.hf(r.HK.docker_get);await l.ws.send(e),l.ws.addMsg(r.HK.docker_getting,e=>{const t=[];if(H){for(const s of e.context)for(const e of s)if(`${e}`.includes(H)){t.push(s);break}}else t.push(...e.context);y(t.map(e=>{const t=e.map(e=>(0,g.jsx)(o.xP,{context:e}));return t.push((0,g.jsx)(h.rA,{icon:"place",title:"选中",onClick:()=>{X(t)}})),t}))})};(0,n.useEffect)(()=>(K(H),O(),()=>{(async()=>{P({show:!1,type:"",dockerId:""})})()}),[]),(0,n.useEffect)(()=>{H=I},[I]);const J=()=>{const e=new r.hf("logs"===b.type?r.HK.docker_shell_logs_cancel:r.HK.docker_shell_exec_cancel);e.context="",l.ws.send(e)},R=e=>{const t=new r.hf(r.HK.docker_switch);t.context={type:e,dockerId:z[0].props.context},X([]),l.ws.send(t)},Q=async()=>{const e=await a.Yu.get("docker/images");if(e.code===u.m.Success){const t=e.data??[],s=[];for(let e=0;e<t.length;e++){const n=t[e],c=[(0,g.jsx)(o.xP,{context:n[0]}),(0,g.jsx)(o.xP,{context:n[1]}),n[2],n[3],""];s.push(c)}G=s,v(s)}};return(0,g.jsxs)("div",{children:[(0,g.jsxs)(d.A,{left_children:(0,g.jsx)(h.Z$,{defaultStatus:!1,text:t("docker镜像"),clickFun:e=>{D(e),e?(Q(),X([])):(O(),v([]),i({}))}}),children:[Object.keys(s).length>0&&(0,g.jsx)(h.rA,{icon:"delete",title:t("删除镜像"),onClick:async()=>{$({open:!0,title:t("确定删除选中的镜像吗"),handle:async()=>{const e=Object.keys(s),t=await a.Yu.post("docker/check/delete",{ids:e});if(t.code===u.m.Success)if(0===t.data.length){(await a.Yu.post("docker/delete",{ids:e})).code===u.m.Success&&((0,_.SK)("删除完成"),Q(),$({open:!1,handle:null}))}else(0,_.N9)(`有镜像正在运行${JSON.stringify(t.data)}`)}})}}),z.length>0&&(0,g.jsx)("div",{children:z[1].props.context}),z.length>0&&(0,g.jsxs)("div",{children:[C(A.oV.docker_container_update)&&(0,g.jsx)(h.rA,{icon:"delete",title:t("删除容器"),onClick:()=>{V({show:!0,overlay:!0,type:N.PromptEnum.DockerDel,data:{dockerId:z[0].props.context,name:z[1].props.context}})}}),(0,g.jsx)(h.rA,{icon:"print",title:t("打印日志"),onClick:()=>{b.show?(P({show:!1,type:"",dockerId:""}),J()):P({show:!0,dockerId:z[0].props.context,type:"logs"})}}),C(A.oV.docker_container_update)&&(0,g.jsx)(h.rA,{icon:"personal_video",title:t("执行命令"),onClick:()=>{b.show?(P({show:!1,type:"",dockerId:""}),J()):P({show:!0,dockerId:z[0].props.context,type:"exec"})}}),C(A.oV.docker_container_update)&&z[4].props.context.includes("Up")&&(0,g.jsx)(h.rA,{icon:"stop",title:t("停止"),onClick:()=>R("stop")}),C(A.oV.docker_container_update)&&!z[4].props.context.includes("Up")&&(0,g.jsx)(h.rA,{icon:"play_arrow",title:t("开启"),onClick:()=>{R("start")}})]}),(0!==m.length||I)&&!q&&(0,g.jsx)(h.rA,{icon:"refresh",title:t("列表更新"),onClick:async()=>{const e=new r.hf(r.HK.docker_get);await l.ws.send(e)}})]}),(0,g.jsxs)(c.xh,{children:[q&&(0,g.jsx)(c.fI,{children:(0,g.jsx)(c.VP,{widthPer:80,children:(0,g.jsx)(o.uF,{title:`${t("镜像")} (${k.length})`,titleCom:(0,g.jsx)(w.Sm,{placeholder:t("过滤镜像"),value:L,handleInputChange:e=>{T(e)},handlerEnter:()=>{const e=[];if(L){for(const t of k)(t[0].props.context.includes(L)||t[1].props.context.includes(L))&&e.push(t);v(e)}else v(G)}}),children:(0,g.jsx)(x.X,{headers:U,rows:k.map((e,n)=>(e[4]=(0,g.jsx)(w.GL,{context:t(""),selected:s[e[0].props.context],onchange:()=>{(e=>{const t={};Object.assign(t,s),t[e]?delete t[e]:t[e]=1,i(t)})(e[0].props.context)}}),e)),width:"10rem"})})})}),0===m.length&&!I&&!q&&(0,g.jsx)(M.h,{context:t("检测不到docker,主机可能没有安装docker or 容器为空")}),(0!==m.length||I)&&!q&&(0,g.jsx)(c.fI,{children:(0,g.jsx)(c.VP,{widthPer:80,children:(0,g.jsx)(o.uF,{title:`${t("容器")} (${m.length})`,titleCom:(0,g.jsx)(w.Sm,{placeholder:t("过滤"),value:I,handleInputChange:e=>{K(e)}}),children:(0,g.jsx)(x.X,{headers:B,rows:m,width:"10rem"})})})})]}),(0,g.jsx)(E,{})]})}var W=s(64694);let z="",X=!1,L=!1;function T(e){const{t}=(0,p.Bd)(),[s,i]=(0,n.useState)([]),[a,u]=(0,n.useState)([]),[j,f]=(0,n.useState)(0),[m,_]=(0,n.useState)(""),[y,k]=(0,n.useState)(["pid",t("名字"),t("创建用户"),(0,g.jsxs)("span",{children:[t("内存"),(0,g.jsx)(h.rA,{icon:"sort",title:t("升序"),onClick:()=>{X=!X}})]}),(0,g.jsxs)("span",{children:["cpu%",(0,g.jsx)(h.rA,{icon:"sort",title:t("升序"),onClick:()=>{L=!L}})]}),t("选择")]),{check_user_auth:v}=(0,S.MH)();(0,n.useEffect)(()=>{_(z),(async()=>{i([]),f(0),u([]);const e=new r.hf(r.HK.process_get);await l.ws.send(e),l.ws.addMsg(r.HK.process_getting,e=>{const s=[];if(z){for(const t of e.context)for(const e of t)if(`${e}`.includes(z)){s.push(t);break}}else s.push(...e.context);X&&(0,W.di)(s,e=>e[3],!1),L&&(0,W.di)(s,e=>e[4],!1);const n=s.map(e=>{const s=e.map((e,t)=>(0,g.jsx)(o.xP,{context:3===t?(0,Y.v7)(e):e}));return s.push((0,g.jsx)(h.rA,{icon:"place",title:t("选中"),onClick:()=>{u(s)}})),s});f(s.length),i(n)})})()},[]),(0,n.useEffect)(()=>{z=m},[m]);return(0,g.jsxs)("div",{children:[(0,g.jsxs)(d.A,{children:[a.length>0&&(0,g.jsx)("div",{children:a[1].props.context}),a.length>0&&v(A.oV.sys_process_close)&&(0,g.jsx)("div",{children:(0,g.jsx)(h.rA,{icon:"stop",title:t("停止"),onClick:()=>{const e=new r.hf(r.HK.process_close);e.context={pid:a[0].props.context},u([]),l.ws.send(e)}})})]}),(0,g.jsx)(c.xh,{children:0!==s.length||z?(0,g.jsx)(c.fI,{children:(0,g.jsx)(c.VP,{widthPer:80,children:(0,g.jsx)(o.uF,{title:`${t("进程")} (${j})`,titleCom:(0,g.jsx)(w.Sm,{placeholder:t("过滤"),value:m,handleInputChange:e=>{_(e)}}),children:(0,g.jsx)(x.X,{headers:y,rows:s,width:"10rem"})})})}):(0,g.jsx)(M.h,{context:t("加载中请等待...")})})]})}const q=n.lazy(()=>Promise.all([s.e(2543),s.e(5614)]).then(s.bind(s,85614)));function D(e){const[t,s]=(0,n.useState)(null),[c,o]=(0,j.fp)(f.AG.systemd_shell_show),[i,a]=(0,j.fp)(f.AG.user_base_info),d=i.user_data.theme?.includes("dark")?"#FFFFFF":"#000000",h=()=>{(async()=>{t&&(t.writeln("[38;2;29;153;243mclose![0m "),t.dispose(),s(null))})()};(0,n.useEffect)(()=>{if(!c.show)return void h();(async()=>{const e=new $.Terminal({fontFamily:"Monaco, Menlo, Consolas, 'Courier New', monospace",theme:{background:"#FFFFFF",foreground:d,cursor:d,selectionBackground:"#a6d2ff"},cursorBlink:!0,cursorStyle:"bar",scrollback:1e3,scrollSensitivity:1,tabStopWidth:4,convertEol:!0});l.ws.subscribeUnconnect(h),l.ws.addMsg(r.HK.systemd_logs_getting,t=>{"error"===t.context&&h(),e.write(t.context)}),s(e)})();const e=e=>{};return document.addEventListener("cancel_systemd_logs",e),()=>{document.removeEventListener("cancel_systemd_logs",e)}},[c]),(0,n.useEffect)(()=>()=>{h()},[]);return(0,g.jsx)(q,{show:c.show,terminal:t,init:(e,s)=>{t.writeln("[38;2;29;153;243mconnect...[0m ");const n={unit_name:c.unit_name},o=new r.hf(r.HK.systemd_logs_get);o.context=n,l.ws.send(o)}})}let U,O="";function J(e){const{t}=(0,p.Bd)(),{check_user_auth:s}=(0,S.MH)(),[i,m]=(0,j.fp)(f.AG.systemd_shell_show),[y,k]=(0,j.fp)(f.AG.confirm),[v,C]=(0,n.useState)(["pid","name","process",t("创建用户"),t("内存"),t("cpu%"),t("active状态"),t("选择")]),[b,P]=(0,n.useState)(["单元名字","加载状态",t("active(sub)状态"),t("描述"),t("选择")]),[V,F]=(0,n.useState)([]),[$,I]=(0,n.useState)([]),[K,E]=(0,n.useState)([]),[N,H]=(0,n.useState)(!1),[G,Z]=(0,n.useState)([]),[B,W]=(0,n.useState)(""),[z,X]=(0,n.useState)(""),[L,T]=(0,n.useState)(new Set),[q,J]=(0,j.fp)(f.AG.editorSetting);(0,n.useEffect)(()=>{X(O),(async()=>{F([]),E([]);const e=new r.hf(r.HK.systemd_inside_get);await l.ws.send(e),l.ws.addMsg(r.HK.systemd_inside_getting,e=>{const t=[];if(O){for(const s of e.context)for(const e of s)if(`${e}`.includes(O)){t.push(s);break}}else t.push(...e.context);F(t.map(e=>{const t=e.map((e,t)=>(0,g.jsx)(o.xP,{context:4===t?(0,Y.v7)(e):e}));return t.push((0,g.jsx)(h.rA,{icon:"place",title:"选中",onClick:()=>{E(t)}})),t}))})})()},[]),(0,n.useEffect)(()=>{O=z},[z]);const R=e=>{if(i.show){m({show:!1,unit_name:""});const e=new CustomEvent("cancel_systemd_logs",{detail:{}});document.dispatchEvent(e)}else m({show:!0,unit_name:e})};return(0,g.jsxs)("div",{children:[(0,g.jsxs)(d.A,{left_children:(0,g.jsx)(h.Z$,{defaultStatus:!1,text:t("系统systemd单元"),clickFun:e=>{H(e),e?((async()=>{I([]),Z([]);const e=await a.Yu.get("systemd/inside/all");if(e.code!==u.m.Success)return;T(new Set(e.data));const t=await a.Yu.get("systemd/allget");if(t.code===u.m.Success){const e=t.data,s=[];for(const t of e??[]){const e=[(0,g.jsx)(o.xP,{context:t.unit}),t.load,`${t.active}(${t.sub})`,(0,g.jsx)(o.xP,{context:t.description})];s.push([...e,(0,g.jsx)(h.rA,{icon:"place",title:"添加",onClick:()=>{Z([...e])}})])}U=s,I(s)}})(),E([])):Z([])}}),children:[K.length>0&&(0,g.jsx)("div",{children:K[1].props.context}),G.length>0&&(0,g.jsx)("div",{children:G[0].props.context}),K.length>0&&(0,g.jsxs)("div",{children:[s(A.oV.systemd_update)&&(0,g.jsx)(h.rA,{icon:"delete",title:"从实时监控删除",onClick:()=>{(async e=>{k({open:!0,handle:async()=>{(await a.Yu.post("systemd/delete",{unit_name:e})).code===u.m.Success&&((0,_.SK)("删除成功"),k({open:!1,handle:null}))}})})(K[1].props.context)}}),(0,g.jsx)(h.rA,{icon:"print",title:"打印日志",onClick:()=>{R(K[1].props.context)}})]}),G.length>0&&(0,g.jsxs)("div",{children:[s(A.oV.systemd_update)&&(0,g.jsx)(h.rA,{icon:"delete",title:"删除系统上的sytemd",onClick:()=>{(async e=>{k({open:!0,handle:async()=>{(await a.Yu.post("systemd/sys/delete",{unit_name:e})).code===u.m.Success&&((0,_.SK)("删除成功"),k({open:!1,handle:null}))}})})(G[0].props.context)}}),(0,g.jsx)(h.rA,{icon:"print",title:"打印日志",onClick:()=>{R(G[0].props.context)}}),s(A.oV.systemd_update)&&(0,g.jsx)(h.rA,{icon:"text_fields",title:"sytemd文件内容",onClick:()=>{(async t=>{const s=await a.Yu.post("systemd/get/context",{unit_name:t});s.code===u.m.Success&&(J({model:"text",open:!0,fileName:e.name,save:async e=>{const n={unit_name:t,path:s.data.path,context:e};(await a.Yu.post("systemd/sys/save",n)).code===u.m.Success&&(S.xK.set_value_temp(""),J({open:!1,model:"",fileName:"",save:null}))}}),S.xK.set_value_temp(s.data.context))})(G[0].props.context)}}),s(A.oV.systemd_update)&&!L.has(G[0].props.context)&&(0,g.jsx)(h.rA,{icon:"plus_one",title:"添加到管理",onClick:()=>(async e=>{const t=await a.Yu.post("systemd/add",{unit_name:e});t.code===u.m.Success&&(T(new Set(t.data)),(0,_.SK)("添加成功"))})(G[0].props.context)})]})]}),(0,g.jsxs)(c.xh,{children:[N&&(0,g.jsx)(c.fI,{children:(0,g.jsx)(c.VP,{widthPer:80,children:(0,g.jsx)(o.uF,{title:`systemd系统单元(${$.length})`,titleCom:(0,g.jsx)(w.Sm,{placeholder:"过滤单元",value:B,handleInputChange:e=>{W(e)},handlerEnter:()=>{const e=[];if(B){for(const t of U)(t[0].props.context.includes(B)||t[3].props.context.includes(B))&&e.push(t);I(e)}else I(U)}}),children:(0,g.jsx)(x.X,{headers:b,rows:$,width:"10rem"})})})}),0===V.length&&!N&&(0,g.jsx)(M.h,{context:"没有管理的单元 or 加载中请等待..."}),0!==V.length&&!N&&(0,g.jsx)(c.fI,{children:(0,g.jsx)(c.VP,{widthPer:80,children:(0,g.jsx)(o.uF,{title:`filecat监控单元(${V.length})`,titleCom:(0,g.jsx)(w.Sm,{placeholder:"过滤单元",value:z,handleInputChange:e=>{X(e)}}),children:(0,g.jsx)(x.X,{headers:v,rows:V,width:"10rem"})})})})]}),(0,g.jsx)(D,{})]})}var R=s(87361);function Q(e){const{t}=(0,p.Bd)(),[s,n]=(0,j.fp)(f.AG.user_base_info),o=[{index:1,name:t("系统性能"),rto:"sys/",component:(0,g.jsx)(F,{})},{index:2,name:t("系统进程"),rto:"process/",component:(0,g.jsx)(T,{})},{index:3,name:t("docker容器"),rto:"docker/",component:(0,g.jsx)(B,{})}];return s.sys===A.XM.linux&&o.push({index:4,name:t("systemd"),rto:"systemd/",component:(0,g.jsx)(J,{})}),(0,g.jsx)(c.W1,{optionList:o,father_route:R.o.info})}}}]);
|