filecat 7.32.0 → 7.32.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dist/1852.16cec79aa004d7d496ee.js +1 -0
- package/build/dist/2515.df3393e66df975984e10.js +1 -0
- package/build/dist/26.63fd77a3075a6e071bc8.js +1 -0
- package/build/dist/3187.03c9284e30214b476487.js +1 -0
- package/build/dist/3322.36f73d119334675d9bc4.js +1 -0
- package/build/dist/{3355.80b3ed1fdc66b35bd95a.js → 3355.fe615f78b2015ec080c2.js} +1 -1
- package/build/dist/4350.7412b41befe12857677f.js +1 -0
- package/build/dist/{4598.4d016ea700f650cd1023.js → 4598.7f2b7c8ee1751b912cc6.js} +1 -1
- package/build/dist/{47.8c46e919a7977a77bc14.js → 47.d5cc6abee0da2951a189.js} +1 -1
- package/build/dist/{4935.d07d9ef7e03632dcb51c.js → 4935.72f92a4a0e80fd72c68d.js} +1 -1
- package/build/dist/{6097.da228e297f45f3ec882d.js → 6097.fa01bd2ab412cdcb52df.js} +1 -1
- package/build/dist/{6439.f3ddea3c0ef57dcbf23c.js → 6439.e984788ff732b4eeaed8.js} +1 -1
- package/build/dist/{7678.926d8c2225731a655537.js → 7678.954622f85bb32a50ad25.js} +1 -1
- package/build/dist/{9260.7fbe354ea4e6bee93817.js → 9260.fd785c5b4418123dd54f.js} +1 -1
- package/build/dist/9546.0893b1435016a3c7b5e6.js +1 -0
- package/build/dist/{9765.7f02ad22213339511811.js → 9765.046a87c8c6ed9427eb45.js} +1 -1
- package/build/dist/index.html +1 -1
- package/build/dist/main.89376a85f16c77177628.js +2 -0
- package/build/main.js +1 -1
- package/package.json +1 -1
- package/build/dist/2091.8324e03dcf28985539eb.js +0 -1
- package/build/dist/3187.67ad7348b6b7231e657d.js +0 -1
- package/build/dist/4350.799e1d3b7382a15d295b.js +0 -1
- package/build/dist/7212.a825bc171875985e1aab.js +0 -1
- package/build/dist/9546.fde8cbe4ebe2dafb6c27.js +0 -1
- package/build/dist/main.b0bcf1b153b849530789.js +0 -2
- /package/build/dist/{main.b0bcf1b153b849530789.js.LICENSE.txt → main.89376a85f16c77177628.js.LICENSE.txt} +0 -0
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[2091],{22091(e,t,n){n.r(t),n.d(t,{default:()=>b});var o=n(96540),r=n(34843),c=n(82893),i=n(42562),s=n(39290),a=n(33036);const l=15;function d(e){const t=e.getBoundingClientRect().top,n=[],o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);let r=null;for(;o.nextNode();){const e=o.currentNode,c=e.textContent??"";if(!c.trim())continue;const i=document.createRange();for(let o=0;o<c.length;o++){i.setStart(e,o),i.setEnd(e,o+1);const c=i.getBoundingClientRect();0!==c.height&&((null===r||Math.abs(c.top-r)>1)&&(null!==r&&n.push(c.top-t),r=c.top))}}return null!==r&&n.push(e.offsetHeight),0===n.length&&n.push(e.offsetHeight),n}var u=n(74848);function f(e){const t=(0,s.OE)(e);if(!t)throw new Error(`docx 命令不存在: ${e}`);return t}function h(e){const{model:t,on_change:n,bind_save:r}=e,c=(0,o.useRef)(null),i=(0,o.useRef)([]),h=(0,o.useRef)(),p=(0,o.useRef)(new Map),m=(0,o.useRef)(""),g=(0,o.useCallback)(()=>{const e=c.current,n=t.selection?.focus;if(!e||!n)return;const o=e.querySelector(`[data-wk-block="${n.block}"]`);if(!o)return;let r=o;if(void 0!==n.inline){const e=o.querySelector(`[data-wk-inline="${n.inline}"]`);e&&(r=e)}const i=r.firstChild;if(!i)return;const s=document.createRange(),a=Math.min(n.offset??0,i.textContent?.length??0);s.setStart(i,a),s.collapse(!0);const l=window.getSelection();l?.removeAllRanges(),l?.addRange(s)},[t]),v=(0,o.useCallback)((e=!1)=>{const n=c.current;if(!n)return;let o=-1;const r=window.getSelection();if(r&&r.anchorNode&&n.contains(r.anchorNode)){const e=1===r.anchorNode.nodeType?r.anchorNode:r.anchorNode.parentElement,t=e?.closest("[data-wk-block]");t&&(o=Number(t.getAttribute("data-wk-block")))}const a=document.createElement("div");a.innerHTML=(0,s.j7)(t.document);const d=Array.from(a.children).map(e=>e.outerHTML),u=i.current;if(e||u.length!==d.length)n.innerHTML=a.innerHTML,p.current.clear(),Array.from(n.children).forEach(e=>{const t=e,n=Number(t.getAttribute("data-wk-block"));Number.isNaN(n)||p.current.set(n,t)});else for(let e=0;e<d.length;e++){if(u[e]===d[e])continue;const t=p.current.get(e);if(t)if(e===o)t.innerHTML=a.children[e].innerHTML;else{t.outerHTML=d[e];const o=n.querySelector(`[data-wk-block="${e}"]`);o&&p.current.set(e,o)}}i.current=d,h.current??=function(e){const t=(0,s.yj)(e);return{width:t.width/l,height:t.height/l,top:t.top/l,right:t.right/l,bottom:t.bottom/l,left:t.left/l,body_height:(t.height-t.top-t.bottom)/l}}(t.document);const f=h.current,{heights:m,lines:g}=b(d.length,f),v=function(e,t,n,o){const r=(0,s.Bv)(e),c=(0,s.w$)(e),i=r.map((e,o)=>{const r=t[o]??0;return{height:r,section:0,lines:()=>n[o]??[r]}}),a=c.map(()=>({start:"continuous",columns:1,titlePage:!1,vAlign:"top",bodyHeight:()=>o.body_height}));return(0,s.En)(i,a,{evenAndOddHeaders:!1,noteSeparatorHeight:0}).map(e=>{const n=[];for(const o of e.regions)for(const e of o.columns)for(const o of e.fragments)"block"===o.kind?n.push({block:o.block,from:0,to:t[o.block]??o.height}):"slice"===o.kind&&n.push({block:o.block,from:o.from,to:o.to});return{fragments:n,number:e.number}})}(t.document,m,g,f);y(n,v,f)},[t]),b=(0,o.useCallback)((e,t)=>{const n=document.createElement("div");n.className="docx-page",n.style.cssText=[`width:${t.width}px`,`padding:${t.top}px ${t.right}px ${t.bottom}px ${t.left}px`,"position:absolute","left:-99999px","top:0","visibility:hidden","pointer-events:none"].join(";");const o=document.createElement("div");o.className="docx-page__body",n.appendChild(o),document.body.appendChild(n);const r=[];for(let t=0;t<e;t++){const e=p.current.get(t);if(!e){const e=document.createElement("div");o.appendChild(e),r.push(e);continue}o.appendChild(e),r.push(e)}const c=[],i=[],s=o.scrollHeight;for(let e=0;e<r.length;e++){const t=r[e],n=t.offsetTop,o=e+1<r.length?r[e+1].offsetTop:s;let a=Math.max(0,o-n);e===r.length-1&&(a+=parseFloat(getComputedStyle(t).marginBottom)||0),c[e]=a,i[e]=d(t)}return n.remove(),{heights:c,lines:i}},[]),y=(0,o.useCallback)((e,t,n)=>{const o=t.map(e=>e.fragments.map(e=>e.block).join(",")).join("|");if(m.current!==o){m.current=o,e.innerHTML="";for(const o of t){const t=document.createElement("div");t.className="docx-page",t.style.width=`${n.width}px`,t.style.height=`${n.height}px`,t.style.padding=`${n.top}px ${n.right}px ${n.bottom}px ${n.left}px`;const r=document.createElement("div");r.className="docx-page__body",t.appendChild(r);const c=document.createElement("div");c.className="docx-page__number",c.textContent=String(o.number),t.appendChild(c);for(const e of o.fragments){const t=p.current.get(e.block);if(!t)continue;if(0===e.from&&e.to>=t.offsetHeight-1){r.appendChild(t);continue}const n=document.createElement("div");n.className="docx-page__slice",n.style.height=e.to-e.from+"px",n.style.overflow="hidden";const o=t.cloneNode(!0);o.style.marginTop=-e.from+"px",n.appendChild(o),r.appendChild(n)}e.appendChild(t)}e.querySelectorAll(".docx-page__body").forEach(e=>{e.setAttribute("contenteditable","true"),e.setAttribute("suppresscontenteditablewarning","true")})}},[]);(0,o.useEffect)(()=>{v(!0);const e=t.subscribe(()=>{const e=c.current,t=window.getSelection(),o=!!(e&&t&&t.anchorNode&&e.contains(t.anchorNode));v(!1),o&&g(),n?.(!0)});return()=>{e()}},[t,v,g,n]),(0,o.useEffect)(()=>{r?.(()=>function(e){return(0,a.FoA)(e.document)}(t))},[t,r]);const x=(0,o.useCallback)(()=>{const e=(0,s.Ff)(document);if(!e)return!1;const n=t.selection;return n&&JSON.stringify(n.anchor)===JSON.stringify(e.anchor)&&JSON.stringify(n.focus)===JSON.stringify(e.focus)||t.setSelection(e),!0},[t]),k=(0,o.useCallback)((e,n)=>{x(),(0,s.d1)(t,f(e),n)},[t,x]),_=(0,o.useCallback)(()=>{(0,s.d1)(t,f("structure.insertText"),{text:""})},[t]),N=(0,o.useCallback)(e=>{if(!x())return;const n=t.selection;if(!n)return;const{anchor:o,focus:r}=n;if(o.block!==r.block||o.inline!==r.inline||o.offset!==r.offset)return void _();const c=o.offset;if(e&&c<=0)return void(0,s.d1)(t,f("structure.mergeBack"),void 0);const i=e?c-1:c,a=e?c:c+1,l={block:o.block,para:o.para,cell:o.cell,inline:o.inline};t.setSelection({anchor:(0,s.zf)({...l,offset:i}).anchor,focus:(0,s.zf)({...l,offset:a}).anchor}),_()},[t,x,_]),w=(0,o.useCallback)(e=>{x(),(0,s.d1)(t,f("structure.insertText"),{text:e})},[t,x]);return(0,o.useEffect)(()=>{const e=c.current;if(!e)return;const n=n=>{const o=window.getSelection();if(o&&o.anchorNode&&e.contains(o.anchorNode)){if(n.ctrlKey||n.metaKey){const e=n.key.toLowerCase();return n.shiftKey||"b"!==e&&"i"!==e&&"u"!==e?"z"===e?(n.preventDefault(),void((n.shiftKey?t.canRedo():t.canUndo())&&(n.shiftKey?t.redo():t.undo()))):void 0:(n.preventDefault(),void k("b"===e?"text.bold":"i"===e?"text.italic":"text.underline"))}return"Enter"===n.key?(n.preventDefault(),void k("structure.insertParagraph")):"Backspace"===n.key?(n.preventDefault(),void N(!0)):"Delete"===n.key?(n.preventDefault(),void N(!1)):void(1!==n.key.length||n.altKey||(n.preventDefault(),w(n.key)))}},o=t=>{const n=window.getSelection();n&&n.anchorNode&&e.contains(n.anchorNode)&&t.data&&w(t.data)},r=t=>{const n=window.getSelection();if(!n||!n.anchorNode||!e.contains(n.anchorNode))return;t.preventDefault();const o=t.clipboardData?.getData("text/plain");o&&w(o)};return e.addEventListener("keydown",n),e.addEventListener("compositionend",o),e.addEventListener("paste",r),()=>{e.removeEventListener("keydown",n),e.removeEventListener("compositionend",o),e.removeEventListener("paste",r)}},[t,k,N,w]),(0,u.jsx)("div",{className:"docx-body",children:(0,u.jsx)("div",{className:"docx-pages",ref:c})})}var p=n(99018);function m(e){const{url:t,save_path:n,on_dirty:r,bind_save:c}=e,[i,a]=(0,o.useState)(),[l,d]=(0,o.useState)(""),[f,m]=(0,o.useState)(!0),[g,v]=(0,o.useState)(!1),b=(0,o.useRef)();return(0,o.useEffect)(()=>{if(!t)return;let e=!0;return m(!0),d(""),v(!1),a(void 0),(0,p.PQ)(t).then(t=>{e&&a(function(e){return(0,s.k3)(e)}(t))}).catch(t=>e&&d(String(t?.message??t))).finally(()=>e&&m(!1)),()=>{e=!1}},[t]),(0,o.useEffect)(()=>{r?.(g)},[g,r]),(0,o.useEffect)(()=>{c?.(async()=>{if(!b.current)return!1;const e=await(0,p.GB)(n,b.current());return e&&v(!1),e})},[n,c]),l?(0,u.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:l}):f||!i?(0,u.jsx)("div",{className:"office-editor__tip",children:"读取中…"}):(0,u.jsx)(h,{model:i,on_change:v,bind_save:e=>b.current=e})}var g=n(93245),v=n(23430);function b(){const[e,t]=(0,r.fp)(c.AG.docx_editor),[n,s]=(0,o.useState)(!1),[a,l]=(0,o.useState)(!1),d=(0,o.useRef)(),f=async()=>{if(!d.current)return!1;l(!0);try{return await d.current()}finally{l(!1)}},h=(0,o.useRef)(n);return h.current=n,(0,g.a)(v.nE.docx,()=>h.current,()=>f()),(0,u.jsx)(i.A,{name:e.name,dirty:n,loading:!1,error:"",saving:a,on_save:f,on_close:()=>{const n=e.close;t({}),n?.()},children:e.url&&(0,u.jsx)(m,{url:e.url,save_path:(0,p.Vi)(e.name??""),on_dirty:s,bind_save:e=>d.current=e})})}},42562(e,t,n){n.d(t,{A:()=>s});var o=n(96540),r=n(85997),c=n(45907),i=n(74848);function s(e){const{name:t,dirty:n,loading:s,error:a,saving:l,on_save:d,on_close:u,children:f,extra:h}=e,p=(0,c.y)(),m=(0,o.useRef)(u),g=(0,o.useRef)(d),v=(0,o.useRef)(n);m.current=u,g.current=d,v.current=n;const b=()=>{v.current?p({title:"关闭",sub_title:"有未保存的修改,确定关闭吗?",confirm_fun:()=>m.current?.()}):m.current?.()};return(0,o.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"s"===e.key.toLowerCase()?(e.preventDefault(),e.stopPropagation(),g.current?.()):"Escape"===e.key&&b()};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[]),(0,i.jsxs)("div",{className:"office-editor",children:[(0,i.jsxs)("div",{className:"office-editor__topbar",children:[(0,i.jsxs)("div",{className:"office-editor__name",children:[t,n&&(0,i.jsx)("span",{className:"office-editor__dirty",title:"有未保存的修改"})]}),(0,i.jsxs)("div",{className:"office-editor__ops",children:[h,l&&(0,i.jsx)("span",{className:"office-editor__saving",children:"保存中…"}),d&&(0,i.jsx)(r.rA,{icon:"save",title:"保存 (Ctrl+S)",onClick:()=>d()}),(0,i.jsx)(r.rA,{icon:"close",title:"关闭 (Esc)",onClick:b})]})]}),(0,i.jsxs)("div",{className:"office-editor__body",children:[s&&(0,i.jsx)("div",{className:"office-editor__tip",children:"加载中…"}),!s&&a&&(0,i.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:a}),!s&&!a&&f]})]})}},99018(e,t,n){n.d(t,{GB:()=>l,PQ:()=>a,Vi:()=>s});var o=n(14284),r=n(57889),c=n(34289),i=n(62042);function s(e){return`${encodeURIComponent((0,c.GG)("file",(0,c.vX)()))}${e}`}async function a(e){return r.l.get_bytes_url(e)}function l(e,t){return async function(e,t){const n=await o.$M.post(`save_bin/${e}`,{base64:d(t)});return 0===n.code||((0,i.zN)(n.message??"保存失败"),!1)}(function(e){const t=e.lastIndexOf("/");return t<0?encodeURIComponent(e):encodeURIComponent(e.slice(0,t))+e.slice(t)}(e),t)}function d(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[3187,4935],{42562(e,t,n){n.d(t,{A:()=>c});var r=n(96540),s=n(85997),l=n(45907),o=n(74848);function c(e){const{name:t,dirty:n,loading:c,error:a,saving:i,on_save:u,on_close:f,children:d,extra:h}=e,m=(0,l.y)(),g=(0,r.useRef)(f),x=(0,r.useRef)(u),p=(0,r.useRef)(n);g.current=f,x.current=u,p.current=n;const y=()=>{p.current?m({title:"关闭",sub_title:"有未保存的修改,确定关闭吗?",confirm_fun:()=>g.current?.()}):g.current?.()};return(0,r.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"s"===e.key.toLowerCase()?(e.preventDefault(),e.stopPropagation(),x.current?.()):"Escape"===e.key&&y()};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[]),(0,o.jsxs)("div",{className:"office-editor",children:[(0,o.jsxs)("div",{className:"office-editor__topbar",children:[(0,o.jsxs)("div",{className:"office-editor__name",children:[t,n&&(0,o.jsx)("span",{className:"office-editor__dirty",title:"有未保存的修改"})]}),(0,o.jsxs)("div",{className:"office-editor__ops",children:[h,i&&(0,o.jsx)("span",{className:"office-editor__saving",children:"保存中…"}),u&&(0,o.jsx)(s.rA,{icon:"save",title:"保存 (Ctrl+S)",onClick:()=>u()}),(0,o.jsx)(s.rA,{icon:"close",title:"关闭 (Esc)",onClick:y})]})]}),(0,o.jsxs)("div",{className:"office-editor__body",children:[c&&(0,o.jsx)("div",{className:"office-editor__tip",children:"加载中…"}),!c&&a&&(0,o.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:a}),!c&&!a&&d]})]})}},43187(e,t,n){n.r(t),n.d(t,{default:()=>d});var r=n(96540),s=n(34843),l=n(82893),o=n(42562),c=n(24935),a=n(99018),i=n(93245),u=n(23430),f=n(74848);function d(){const[e,t]=(0,s.fp)(l.AG.excel_editor),[n,d]=(0,r.useState)(!1),[h,m]=(0,r.useState)(!1),g=(0,r.useRef)(),x=async()=>{if(!g.current)return!1;m(!0);try{return await g.current()}finally{m(!1)}},p=(0,r.useRef)(n);return p.current=n,(0,i.a)(u.nE.excel,()=>p.current,()=>x()),(0,f.jsx)(o.A,{name:e.name,dirty:n,loading:!1,error:"",saving:h,on_save:x,on_close:()=>{const n=e.close;t({}),n?.()},children:e.url&&(0,f.jsx)(c.default,{url:e.url,save_path:(0,a.Vi)(e.name??""),on_dirty:d,bind_save:e=>g.current=e})})}},24935(e,t,n){n.r(t),n.d(t,{default:()=>b});var r=n(96540),s=n(47049),l=n(8890);const o=e=>Math.round(7*e+5),c=e=>Math.round(4*e/3);function a(e){return{toBytes:async()=>e}}function i(e,t){if(e){if(e.rgb){const t=String(e.rgb);return"#"+(8===t.length?t.slice(2):t)}return void 0!==e.theme&&t[e.theme]?"#"+function(e,t){if(!t)return e;const n=parseInt(e,16);return[n>>16&255,n>>8&255,255&n].map(e=>{const n=t<0?e*(1+t):e*(1-t)+255*t;return Math.round(n).toString(16).padStart(2,"0")}).join("").toUpperCase()}(t[e.theme],e.tint??0):void 0}}function u(e){const t=Math.round(864e5*(e-25569));return new Date(t)}function f(e,t){const n=e=>String(e).padStart(2,"0"),r=e.getUTCFullYear(),s=r%100,l=e.getUTCMonth()+1,o=e.getUTCDate(),c="日一二三四五六"[e.getUTCDay()];return t.replace(/;.*$/,"").replace(/\[[^\]]*\]/g,"").replace(/"[^"]*"/g,e=>e.slice(1,-1)).replace(/\\/g,"").replace(/yyyy/g,String(r)).replace(/yy/g,n(s)).replace(/(?<!m)m(?!m)/g,String(l)).replace(/mm/g,n(l)).replace(/d(?!d)/g,String(o)).replace(/dd/g,n(o)).replace(/aaaa/g,`星期${c}`)}const d=e=>!!e&&/[ymd]/i.test(e.replace(/"[^"]*"/g,""))&&!/[#0]/.test(e.replace(/"[^"]*"/g,""));function h(e,t,n){const r=e?.value;if(null==r)return{text:null};if("object"==typeof r){if(Array.isArray(r.runs)){const e=r.runs.map(e=>({text:e.text??"",color:i(e.font?.color,t)}));return{text:e.map(e=>e.text).join("")||null,runs:e.some(e=>e.color)?e:void 0}}if("string"==typeof r.text)return{text:r.text};const e=r.cachedValue??r.result;return void 0!==e?"number"==typeof e&&d(n)?{text:f(u(e),n)}:{text:String(e)}:{text:null}}return"number"==typeof r&&d(n)?{text:f(u(r),n)}:{text:String(r)}}function m(e,t,n){const r=e?.styleId;if(void 0===r)return;const s=t.cellXfs?.[r];if(!s)return;const l=t.fills?.[s.fillId],o=t.fonts?.[s.fontId],c={};"solid"===l?.patternType&&(c.bg=i(l.fgColor,n)),c.color=i(o?.color,n),o?.bold&&(c.bold=!0),o?.italic&&(c.italic=!0),o?.size&&(c.fontSize=o.size),o?.name&&(c.fontFamily=o.name),o?.underline&&(c.underline=!0),o?.strike&&(c.strike=!0);const a=s.alignment;return a?.horizontal&&["left","center","right"].includes(a.horizontal)&&(c.align=a.horizontal),a?.vertical&&(c.valign="center"===a.vertical?"middle":a.vertical),a?.wrapText&&(c.wrap=!0),a?.indent&&(c.indent=a.indent),Object.keys(c).length?c:void 0}function g(e,t){const n=e?.styleId;if(void 0===n)return;const r=t.cellXfs?.[n];if(!r)return;const s=r.numFmtId;if(void 0===s||0===s)return;const l={14:"m/d/yy",15:"d-mmm-yy",16:"d-mmm",17:"mmm-yy",18:"h:mm AM/PM",19:"h:mm:ss AM/PM",20:"h:mm",21:"h:mm:ss",22:"m/d/yy h:mm",27:'yyyy"年"m"月"',28:'m"月"d"日"',29:'m"月"d"日"',30:"m-d-yy",31:'yyyy"年"m"月"d"日"',32:'h"时"mm"分"',33:'h"时"mm"分"ss"秒"',34:'上午/下午h"时"mm"分"',35:'上午/下午h"时"mm"分"ss"秒"',36:'yyyy"年"m"月"'};if(l[s])return l[s];const o=t.numFmts;return o instanceof Map?o.get(s):void 0}async function x(e){const t=await(0,s.a)(a(e)),n=function(e){const t=["FFFFFF","000000","EEECE1","1F497D","4F81BD","C0504D","9BBB59","8064A2","4BACC6","F79646"];if(!e)return t;const n="string"==typeof e?e:(new TextDecoder).decode(e),r=/<a:clrScheme[\s\S]*?<\/a:clrScheme>/.exec(n)?.[0];if(!r)return t;const s=[],l=/<a:(dk1|lt1|dk2|lt2|accent[1-6]|hlink|folHlink)>([\s\S]*?)<\/a:\1>/g,o=new Map;let c;for(;c=l.exec(r);){const e=/(?:lastClr|val)="([0-9A-Fa-f]{6})"/.exec(c[2])?.[1];e&&o.set(c[1],e.toUpperCase())}return["lt1","dk1","lt2","dk2","accent1","accent2","accent3","accent4","accent5","accent6"].forEach((e,n)=>s[n]=o.get(e)??t[n]),s}(t.themeXml);return t.sheets.map(e=>{const r=e.sheet,s=t.styles;let l=0,a=0;r.rows.forEach((e,t)=>{e.size&&(l=Math.max(l,t),e.forEach((e,t)=>{a=Math.max(a,t)}))});const i=[],u=new Map;for(let e=1;e<=l;e++){const t=[],l=r.rows.get(e);for(let r=1;r<=a;r++){const o=l?.get(r),c=h(o,n,g(o,s));t.push(c.text);const a=m(o,s,n);c.runs&&(a?a.runs=c.runs:u.set(`${e-1}_${r-1}`,{runs:c.runs})),a&&u.set(`${e-1}_${r-1}`,a)}i.push(t)}const f=o(r.defaultColumnWidth??8.43),d=new Array(a).fill(f);r.columnDimensions?.forEach(e=>{const t=o(e.width??8.43);for(let n=e.min;n<=e.max;n++)n-1<d.length&&(d[n-1]=t)});const x=c(r.defaultRowHeight??15),p=new Array(l).fill(x),y=new Set;r.rowDimensions?.forEach((e,t)=>{t-1<p.length&&e.height&&(p[t-1]=c(e.height)),e.hidden&&t-1<l&&y.add(t-1)});const _=(r.mergedCells??[]).map(e=>[(e.minRow??e.start?.row??1)-1,(e.minCol??e.start?.col??1)-1,(e.maxRow??e.end?.row??1)-1,(e.maxCol??e.end?.col??1)-1]);return{title:r.title,values:i,styles:u,col_widths:d,row_heights:p,hidden_rows:y,merges:_}})}var p=n(74848);function y(e){const{bytes:t,on_change:n,bind_save:o}=e,[c,i]=(0,r.useState)([]),[u,f]=(0,r.useState)(0),[,d]=(0,r.useState)(0),[h,m]=(0,r.useState)(""),g=(0,r.useRef)(!1),y=(0,r.useRef)(null),[w,b]=(0,r.useState)({r0:0,r1:40,c0:0,c1:20});(0,r.useEffect)(()=>{let e=!0;return m(""),x(t).then(t=>e&&i(t)).catch(t=>e&&m(String(t?.message??t))),()=>{e=!1}},[t]);const S=(0,r.useCallback)(()=>{g.current||(g.current=!0,n(!0))},[n]);(0,r.useEffect)(()=>{o(async()=>{const e=await async function(e,t){const n=await(0,s.a)(a(e));return t.forEach((e,t)=>{const r=n.sheets[t];if(!r)return;const s=r.sheet;e.values.forEach((e,t)=>{e.forEach((e,n)=>{const r=t+1,l=n+1;let o=s.rows.get(r);o||(o=new Map,s.rows.set(r,o));const c=o.get(l);null!==e&&""!==e?c?c.value=e:o.set(l,{row:r,col:l,value:e}):c&&(c.value=null)})})}),await(0,l.n)(n)}(t,c);return g.current=!1,n(!1),e})},[c,t,o,n]),(0,r.useEffect)(()=>{e.bind_view?.({get_state:()=>({sheet:u,scroll_left:y.current?.scrollLeft??0,scroll_top:y.current?.scrollTop??0}),set_state:e=>{"number"==typeof e.sheet&&e.sheet>=0&&e.sheet<c.length&&f(e.sheet);const t=y.current;t&&(t.scrollLeft=e.scroll_left??0,t.scrollTop=e.scroll_top??0)}})},[u,c.length,e.bind_view]);const C=c[u],{col_x:j,row_y:E,total_w:k,total_h:M}=r.useMemo(()=>{const e=C?.col_widths??[],t=C?.row_heights??[],n=[0];e.forEach((e,t)=>n.push(n[t]+(C?.hidden_rows.has(t)?0:e)));const r=[0];return t.forEach((e,t)=>r.push(r[t]+e)),{col_x:n,row_y:r,total_w:n[n.length-1]??0,total_h:r[r.length-1]??0}},[C]),N=(e,t)=>{let n=0,r=e.length-1;for(;n<r;){const s=n+r>>1;e[s]<t?n=s+1:r=s}return n},$=(0,r.useCallback)(()=>{const e=y.current;if(!e||!j.length)return;const t=Math.max(0,N(j,e.scrollLeft)-1),n=Math.max(0,N(E,e.scrollTop)-1);b({c0:t,c1:Math.min(j.length-1,N(j,e.scrollLeft+e.clientWidth)+2),r0:n,r1:Math.min(E.length-1,N(E,e.scrollTop+e.clientHeight)+2)})},[j,E]);(0,r.useEffect)(()=>{$()},[C,$]);if(h)return(0,p.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:h});if(!c.length)return(0,p.jsx)("div",{className:"office-editor__tip",children:"解析中…"});const F=C?.values??[],A=(E.length,j.length,new Set);C.merges.forEach(([e,t,n,r])=>{for(let s=e;s<=n;s++)for(let n=t;n<=r;n++)s===e&&n===t||A.add(`${s}_${n}`)});const D=(e,t)=>{const n=F[e]?.[t];return(null==n||""===n)&&!C.styles.get(`${e}_${t}`)?.bg};return(0,p.jsxs)("div",{className:"xlsx-body",children:[(0,p.jsx)("div",{className:"xlsx-tabs",children:c.map((e,t)=>(0,p.jsx)("div",{className:"xlsx-tab "+(t===u?"xlsx-tab--active":""),onClick:()=>{f(t),y.current&&(y.current.scrollTop=0,y.current.scrollLeft=0)},children:e.title},e.title+t))}),(0,p.jsx)("div",{className:"xlsx-scroll",ref:y,onScroll:$,children:(0,p.jsxs)("div",{className:"xlsx-grid",style:{width:46+k,height:24+M},children:[Array.from({length:Math.max(0,w.c1-w.c0)}).map((e,t)=>{const n=w.c0+t;return(0,p.jsx)("div",{className:"xlsx-head",style:{left:46+j[n],top:0,width:j[n+1]-j[n],height:24},children:v(n)},"ch"+n)}),Array.from({length:Math.max(0,w.r1-w.r0)}).map((e,t)=>{const n=w.r0+t;return(0,p.jsxs)(r.Fragment,{children:[(0,p.jsx)("div",{className:"xlsx-head xlsx-head--row",style:{left:0,top:24+E[n],width:46,height:E[n+1]-E[n]},children:n+1}),Array.from({length:Math.max(0,w.c1-w.c0)}).map((e,t)=>{const r=w.c0+t;if(A.has(`${n}_${r}`))return null;const s=C.merges.find(e=>e[0]===n&&e[1]===r),l=s?j[s[3]+1]-j[s[1]]:j[r+1]-j[r],o=s?E[s[2]+1]-E[s[0]]:E[n+1]-E[n];return(0,p.jsx)(_,{value:F[n]?.[r]??"",cell_style:C.styles.get(`${n}_${r}`),spillable:D(n,r+1),style:{left:46+j[r],top:24+E[n],width:l,height:o,zIndex:s?2:1},on_change:e=>((e,t,n)=>{const r=c[u];r&&(r.values[e][t]=""===n?null:n,S(),d(e=>e+1))})(n,r,e)},r)})]},n)})]})})]})}function _(e){const{value:t,cell_style:n,style:s,spillable:l,on_change:o}=e,[c,a]=(0,r.useState)(!1),[i,u]=(0,r.useState)(""),f=(0,r.useRef)(null);(0,r.useEffect)(()=>{c&&f.current&&(f.current.focus(),f.current.select())},[c]);const d=()=>{a(!1),i!==(t??"")&&o(i)},h={};return n?.bg&&(h.backgroundColor=n.bg),n?.color&&(h.color=n.color),n?.bold&&(h.fontWeight=600),n?.italic&&(h.fontStyle="italic"),n?.fontSize&&(h.fontSize=Math.round(4*n.fontSize/3*10)/10+"px"),n?.fontFamily&&(h.fontFamily=`"${n.fontFamily}", "PingFang SC", sans-serif`),n?.underline&&(h.textDecoration="underline"),n?.strike&&(h.textDecoration=h.textDecoration?`${h.textDecoration} line-through`:"line-through"),n?.align&&(h.textAlign=n.align,h.justifyContent="center"===n.align?"center":"right"===n.align?"flex-end":"flex-start"),n?.valign&&(h.alignItems="middle"===n.valign?"center":"bottom"===n.valign?"flex-end":"flex-start"),n?.wrap&&(h.whiteSpace="pre-wrap"),n?.indent&&(h.paddingLeft=.35+1.4*n.indent+"em"),(0,p.jsx)("div",{className:`xlsx-cell ${n?.wrap?"xlsx-cell--wrap":""} ${l?"xlsx-cell--spill":""}`,style:{...s,...h,"--cell-h":n?.wrap?"1.4":s.height-1+"px"},onDoubleClick:()=>{u(t??""),a(!0)},children:c?(0,p.jsx)("textarea",{ref:f,className:"xlsx-cell__input",value:i,onChange:e=>u(e.target.value),onBlur:d,onKeyDown:e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&a(!1):(e.preventDefault(),d())}}):n?.runs?(0,p.jsx)("span",{children:n.runs.map((e,t)=>(0,p.jsx)("span",{style:e.color?{color:e.color}:void 0,children:e.text},t))}):t})}function v(e){let t="",n=e+1;for(;n>0;){const e=(n-1)%26;t=String.fromCharCode(65+e)+t,n=Math.floor((n-1)/26)}return t}var w=n(99018);function b(e){const{url:t,save_path:n,on_dirty:s,bind_save:l}=e,[o,c]=(0,r.useState)(),[a,i]=(0,r.useState)(""),[u,f]=(0,r.useState)(!0),[d,h]=(0,r.useState)(!1),m=(0,r.useRef)();return(0,r.useEffect)(()=>{if(!t)return;let e=!0;return f(!0),i(""),h(!1),c(void 0),(0,w.PQ)(t).then(t=>e&&c(t)).catch(t=>e&&i(String(t?.message??t))).finally(()=>e&&f(!1)),()=>{e=!1}},[t]),(0,r.useEffect)(()=>{s?.(d)},[d,s]),(0,r.useEffect)(()=>{l?.(async()=>{if(!m.current)return!1;const e=await m.current(),t=await(0,w.GB)(n,e);return t&&(c(e),h(!1)),t})},[n,l]),a?(0,p.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:a}):u||!o?(0,p.jsx)("div",{className:"office-editor__tip",children:"读取中…"}):(0,p.jsx)(y,{bytes:o,on_change:h,bind_save:e=>m.current=e,bind_view:e.bind_view})}},99018(e,t,n){n.d(t,{GB:()=>i,PQ:()=>a,Vi:()=>c});var r=n(14284),s=n(57889),l=n(34289),o=n(62042);function c(e){return`${encodeURIComponent((0,l.GG)("file",(0,l.vX)()))}${e}`}async function a(e){return s.l.get_bytes_url(e)}function i(e,t){return async function(e,t){const n=await r.$M.post(`save_bin/${e}`,{base64:u(t)});return 0===n.code||((0,o.zN)(n.message??"保存失败"),!1)}(function(e){const t=e.lastIndexOf("/");return t<0?encodeURIComponent(e):encodeURIComponent(e.slice(0,t))+e.slice(t)}(e),t)}function u(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[4350],{34350(e,t,n){n.r(t),n.d(t,{default:()=>T});var s=n(96540),o=n(82893),i=n(34843),l=n(85997),a=n(57952),r=n(3198),c=n(14284),d=n(34289),u=n(53459),m=n(32768),p=n(78247),h=n(62042),f=n(2543),_=n(34251),v=n(78150),x=n(22022),w=n(88815),y=n(52671),g=n(23430),j=n(87361),k=n(99214);const S="filecat_studio_view_state";function C(e,t){return`${e}::${t}`}function b(){try{const e=localStorage.getItem(S);if(!e)return{};const t=JSON.parse(e);return t&&"object"==typeof t?t:{}}catch(e){return{}}}function R(e){try{localStorage.setItem(S,JSON.stringify(e))}catch(e){}}function A(e,t){if(t)return b()[C(e,t)]}function $(e,t,n){if(!t)return;const s=b();s[C(e,t)]=n,R(s)}var I=n(72458),N=n(74848);const E=s.lazy(()=>Promise.all([n.e(122),n.e(4091)]).then(n.bind(n,84091))),M=s.lazy(()=>Promise.all([n.e(1384),n.e(1075),n.e(1142)]).then(n.bind(n,71142))),P=s.lazy(()=>n.e(4877).then(n.bind(n,64877))),U=s.lazy(()=>Promise.all([n.e(3277),n.e(9345)]).then(n.bind(n,49345))),z=s.lazy(()=>Promise.all([n.e(3140),n.e(5744)]).then(n.bind(n,16575))),D=s.lazy(()=>Promise.all([n.e(8725),n.e(2728),n.e(2130),n.e(5602),n.e(8781),n.e(6404)]).then(n.bind(n,35304))),F=s.lazy(()=>Promise.resolve().then(n.bind(n,20892))),L=s.lazy(()=>Promise.all([n.e(9861),n.e(1922),n.e(4935)]).then(n.bind(n,24935)));function G(e){return(0,_.uL)(e)===m.Iw.md}function K(e){return(0,_.uL)(e)===m.Iw.excalidraw}function W(e){return(0,_.uL)(e)===m.Iw.mind}function B(e){return(0,_.uL)(e)===m.Iw.timeline}function J(e){return(0,_.uL)(e)===m.Iw.excel}function T(e){const[t,n]=(0,s.useState)([]),[C,b]=(0,s.useState)(""),[R,T]=(0,s.useState)(!1),[X,H]=(0,s.useState)({path:"",name:""}),[O,V]=(0,s.useState)(0),[Y,Z]=(0,s.useState)([]),[q,Q]=(0,s.useState)(""),ee=(0,s.useRef)(""),te=(0,s.useRef)({path:"",name:""}),[ne,se]=(0,i.fp)(o.AG.confirm),[oe,ie]=(0,s.useState)(!1),[le,ae]=(0,i.fp)(o.AG.fileShellShow),[re,ce]=(0,i.fp)(o.AG.file_shell_hidden),de=(0,k.Cf)(),ue=(0,s.useRef)(null),me=(0,s.useRef)(null),[pe,he]=(0,s.useState)(!1),[fe,_e]=(0,s.useState)(16),[ve,xe]=(0,i.fp)(o.AG.showPrompt),{t:we}=(0,x.Bd)(),ye=(0,y.Zp)(),ge=G(X.name),je=K(X.name),ke=W(X.name),Se=B(X.name),Ce=J(X.name),be=(0,s.useRef)(null),Re=(0,s.useRef)(null),Ae=(0,s.useRef)(null),$e=(0,s.useRef)(null),Ie=(0,s.useRef)(null),Ne=(0,s.useRef)(null),Ee=(0,s.useRef)(null),[Me,Pe]=(0,s.useState)([]),[Ue,ze]=(0,s.useState)(-1),De=(0,s.useCallback)(()=>{const e=ee.current,t=te.current.name;if(!e)return;let n="ace";G(t)?n="md":K(t)?n="draw":W(t)?n="mind":B(t)?n="timeline":J(t)&&(n="excel");const s="ace"===n?Re.current:"draw"===n?Ae.current:"mind"===n?$e.current:"timeline"===n?Ie.current:"md"===n?be.current?{get_view_state:()=>({scroll:be.current?.get_scroll()??0})}:null:"excel"===n?Ee.current:null,o=s?.get_view_state?.();o&&$(n,e,o)},[]),[Fe,Le]=(0,s.useState)("folder"),[Ge,Ke]=(0,s.useState)(!0),We=(0,k.oT)(),[Be]=(0,y.ok)(),Je="1"===Be.get("chat_open"),[Te,Xe]=(0,i.fp)(o.AG.studio_chat_width),He=(0,s.useRef)(null),[Oe,Ve]=(0,s.useState)(!1),[Ye,Ze]=(0,s.useState)(void 0),[qe,Qe]=(0,i.fp)(o.AG.ai_chat_session_by_cwd),et=(0,y.zy)(),tt=(()=>{const e=`${j.o.studio_page}/`,t=et.pathname.startsWith(e)?et.pathname.slice(e.length):"",n=(0,d.GG)("file",decodeURIComponent(t));return n.endsWith("/")?n:`${n}/`})(),{check_user_auth:nt}=(0,p.MH)(),[st]=(0,i.fp)(o.AG.user_base_info),ot=nt(g.oV.ai_agent_page);(0,s.useEffect)(()=>{st?.user_data&&Je&&!ot&&We("chat_open",null)},[Je,ot,st]);const it=(0,I.Jn)(g.nM.get_now_dir(st),tt);(0,k.rJ)(it);const lt=async()=>{const e=tt;b(e);const t=await c.$M.post("studio/get/item",{path:e});if(t.code===u.m.Success){const e=[],s=[];for(const n of t.data.list)"folder"===n.type?e.push(n):"file"===n.type&&s.push(n);n([...e,...s])}},at=(e,t)=>e===t||e.startsWith(t+"/");(0,s.useEffect)(()=>{ie(!1),H({path:"",name:""}),Q(""),p.xK.set_value_temp(""),Z([]),lt()},[et]);const rt=async(e,t)=>{if(De(),p.xK.set_value_temp(""),!J(e)){const e=await c.$M.get(`${encodeURIComponent(t)}`);p.xK.set_value_temp(e.data)}H({path:t,name:e}),Q(t),ee.current=t,te.current={path:t,name:e},Le("folder"),ie(!1)},ct=(e,t)=>{e.size>w.o5?se({open:!0,handle:()=>{rt(e.name,t),se({open:!1,handle:null}),ie(!1)},title:"超过20MB了还要打开吗?"}):rt(e.name,t)};function dt(){Re.current?.save()}const ut=e=>{if(e.ctrlKey&&"s"===e.key){if(e.preventDefault(),ge||je||ke||Se||Ce)return;oe&&dt()}};(0,s.useEffect)(()=>(document.addEventListener("keydown",ut),()=>{document.removeEventListener("keydown",ut)}),[oe,ge,je,ke,Se,Ce]);const mt=(0,s.useCallback)(f.throttle(e=>{const t=parseFloat(getComputedStyle(me.current).fontSize),n=window.innerWidth/t-4,s=e.clientX/t,o=2.25+ue.current.offsetWidth/t;s<=n&&s>=o&&_e(parseFloat(s.toFixed(2)))},32),[]),pt=()=>{he(!1),me.current.removeEventListener("pointermove",mt)},ht=(0,s.useCallback)(f.throttle(e=>{const t=He.current;if(!t)return;const n=parseFloat(getComputedStyle(t).fontSize),s=t.parentElement.getBoundingClientRect().right-e.clientX,o=Math.min(Math.max(s,0),t.parentElement.getBoundingClientRect().width);Xe(parseFloat((o/n).toFixed(2)))},32),[]),ft=()=>{Ve(!1),document.removeEventListener("pointermove",ht)},_t=[{r:we("创建文件"),v:"创建文件"},{r:we("创建目录"),v:"创建目录"},{r:we("重命名"),v:"重命名"},{r:we("删除"),v:"删除"}],vt=[{r:we("重命名"),v:"重命名"},{r:we("删除"),v:"删除"}],xt=(e,t,n,s,o)=>{e.preventDefault();const i=new _.ik;i.path=n,i.filename=t,i.x=e.clientX,i.y=e.clientY,i.items=s?_t:vt,o===lt&&(i.items=i.items.slice(0,2)),i.type=s?m.Iw.studio_folder:m.Iw.studio_file;const l=e=>{o(e)};i.textClick=e=>{switch(e){case"创建文件":xe({show:!0,type:v.PromptEnum.FileNew,overlay:!0,data:{dir:n,call:l}});break;case"创建目录":xe({show:!0,type:v.PromptEnum.DirNew,overlay:!0,data:{dir:n,call:l}});break;case"删除":if(oe&&(X.path===n||X.path.includes(n))){const e=()=>{l(s),ie(!1),H({}),p.xK.set_value_temp("")};xe({show:!0,type:v.PromptEnum.FilesDelete,overlay:!0,data:{path:n,call:e,filename:t}});break}xe({show:!0,type:v.PromptEnum.FilesDelete,overlay:!0,data:{path:n,filename:t,call:s?()=>{l(!0)}:l}});break;case"重命名":xe({show:!0,type:v.PromptEnum.FileRename,overlay:!0,data:{path:n,dir:(0,d.Yp)(n),call:(e,t)=>{((e,t)=>{if(q&&at(q,e)){const n=t+q.slice(e.length);Q(n),H({path:n,name:(0,d.mH)(n)})}const n=(0,d.oW)(tt);if(at(n,e)){const s=t+n.slice(e.length);return void ye(`${j.o.studio_page}/${encodeURIComponent(`/file/${s}`)}`,{replace:!0})}V(e=>e+1),lt()})(e,t)},filename:t}})}},xe({show:!0,type:v.PromptEnum.FileMenu,overlay:!1,data:i})};const wt=ge&&"outline"===Fe;return(0,N.jsxs)("div",{className:"studio studio--file",children:[(0,N.jsxs)(a.A,{ignore_tags:!0,left_children:[(0,N.jsx)(l.rA,{title:"取消",icon:"close",onClick:()=>{De(),function(){try{localStorage.removeItem(S)}catch(e){}}(),ae({show:!1,path:""}),ce(void 0),ye(-1)}},1),(0,N.jsx)("div",{children:X.name},2)],children:[(0,N.jsx)("title",{children:X.name}),(0,N.jsx)(l.rA,{title:"侧边栏",icon:"list",onClick:()=>Ke(e=>!e),selected:Ge}),ge&&[(0,N.jsx)(l.rA,{icon:"source"===be.current?.mode()?"edit":"code",title:"source"===be.current?.mode()?we("实时编辑模式"):we("源码模式"),onClick:()=>be.current?.toggle_mode()},"mode"),(0,N.jsx)(l.rA,{title:we("导出PDF"),icon:"print",onClick:()=>be.current?.export_pdf()},"pdf")],!ge&&(0,_.zr)(X.name)&&(0,N.jsx)(l.rA,{title:"格式化",icon:"data_object",onClick:function(){p.xK.get_editor()?.formatCode()}}),de.can_terminal&&(0,N.jsx)(l.rA,{icon:"terminal",title:"shell",onClick:function(){!0!==re&&!1!==re?le.show?ae({show:!1,path:""}):(ae({show:!0,path:tt}),ce(!1)):ce(!re)}}),nt(g.oV.ai_agent_page)&&de.ai_chat_available&&(0,N.jsx)(l.rA,{title:we("AI 聊天"),icon:"smart_toy",selected:Je,onClick:()=>We("chat_open",!Je?"1":null)}),oe&&(ge?(0,N.jsx)(l.rA,{title:we("保存"),icon:"save",onClick:()=>be.current?.save()}):je?(0,N.jsx)(l.rA,{title:we("保存"),icon:"save",onClick:()=>Ae.current?.save()}):ke?(0,N.jsx)(l.rA,{title:we("保存"),icon:"save",onClick:()=>$e.current?.save()}):Se?(0,N.jsx)(l.rA,{title:we("保存"),icon:"save",onClick:()=>Ie.current?.save()}):Ce?(0,N.jsx)(l.rA,{title:we("保存"),icon:"save",onClick:()=>Ne.current?.save()}):(0,N.jsx)(l.rA,{title:we("保存"),icon:"save",onClick:dt}))]}),(0,N.jsxs)("div",{className:"studio-body",ref:me,children:[(0,N.jsxs)("div",{className:"studio-nav",style:{display:Ge?void 0:"none",width:fe-1+"em"},onContextMenu:e=>{xt(e,X.name,tt,!0,lt)},children:[(0,N.jsx)("div",{className:"studio-nav-outline",style:{display:wt?void 0:"none"},children:(0,N.jsx)(P,{items:Me,active_pos:Ue,on_click:e=>be.current?.goto_heading(e)})}),(0,N.jsx)("div",{className:"studio-nav-folder",style:{display:wt?"none":void 0},children:(0,N.jsx)(s.Fragment,{children:(0,N.jsx)(r.z,{pre_path:C,list:t,click:async(e,t,n)=>{if("folder"===e.type){Z(e=>e.includes(n)?e:[...e,n]);const e=await c.$M.post("studio/get/item",{path:`${n}`});if(e.code===u.m.Success){const n=[],s=[];for(const t of e.data.list)"folder"===t.type?n.push(t):"file"===t.type&&s.push(t);t([...n,...s])}}else{if(oe)return void se({open:!0,handle:()=>{se({open:!1,handle:null}),ie(!1),ct(e,n)},title:"确定不保存就切换吗?"});ct(e,n)}},active_path:q,expand_paths:Y,handleContextMenu:xt,fatherNowToggleExpansion:lt})},O)}),ge&&(0,N.jsx)("div",{className:"studio-nav-switch",children:(0,N.jsx)(l.rA,{icon:wt?"folder":"list",title:we(wt?"文件目录":"大纲"),onClick:()=>Le(wt?"folder":"outline")})})]}),Ge&&(0,N.jsx)("div",{className:"studio__divider",ref:ue,onPointerDown:()=>{he(!0),me.current.addEventListener("pointermove",mt)},onPointerUp:pt}),pe&&(0,N.jsx)("div",{className:"shell__overlay",onPointerUp:pt}),ge?(0,N.jsx)("div",{className:"studio-editor studio-editor--md",children:(0,N.jsx)(s.Suspense,{fallback:null,children:(0,N.jsx)(M,{pane:{path:q,url:c.$M.getDownloadUrl(encodeURIComponent(q)),name:X.name,on_dirty:ie,on_outline:(e,t)=>{Pe(e),ze(t)},register:e=>{be.current=e;const t=A("md",q);if(!t?.scroll)return;const n=t.scroll;let s=0;const o=()=>{++s>40||(e.set_scroll(n),e.get_scroll()!==n&&window.setTimeout(o,50))};window.setTimeout(o,50)}}})})},q):je?(0,N.jsx)("div",{className:"studio-editor studio-editor--draw",children:(0,N.jsx)(s.Suspense,{fallback:null,children:(0,N.jsx)(z,{reset_key:q,view_state:A("draw",q),url:c.$M.getDownloadUrl(encodeURIComponent(q)),save_path:q,on_dirty:ie,on_saved:()=>ie(!1),register:e=>{Ae.current=e}})})},q):ke?(0,N.jsx)("div",{className:"studio-editor studio-editor--mind",children:(0,N.jsx)(s.Suspense,{fallback:null,children:(0,N.jsx)(D,{reset_key:q,view_state:A("mind",q),url:c.$M.getDownloadUrl(encodeURIComponent(q)),on_dirty:ie,on_saved:()=>ie(!1),register:e=>{$e.current=e},on_save:async e=>(await c.$M.post(`save/${encodeURIComponent(q)}`,{context:e})).code===u.m.Success})})},q):Se?(0,N.jsx)("div",{className:"studio-editor studio-editor--timeline",children:(0,N.jsx)(s.Suspense,{fallback:null,children:(0,N.jsx)(F,{reset_key:q,view_state:A("timeline",q),url:c.$M.getDownloadUrl(encodeURIComponent(q)),on_dirty:ie,register:e=>{Ie.current=e},on_save:async e=>(await c.$M.post(`save/${encodeURIComponent(q)}`,{context:e})).code===u.m.Success})})},q):Ce?(0,N.jsx)("div",{className:"studio-editor studio-editor--excel",children:(0,N.jsx)(s.Suspense,{fallback:null,children:(0,N.jsx)(L,{url:c.$M.getDownloadUrl(encodeURIComponent(q)),save_path:q,on_dirty:ie,bind_save:e=>{Ne.current={save:e}},bind_view:e=>{const t=A("excel",q);Ee.current={get_view_state:()=>{const t=e.get_state();return{sheet:t.sheet,scroll_x:t.scroll_left,scroll_y:t.scroll_top}}},t&&e.set_state({sheet:t.sheet,scroll_left:t.scroll_x,scroll_top:t.scroll_y})}})})},q):(0,N.jsx)("div",{className:"studio-editor",children:X.name&&(0,N.jsx)(s.Suspense,{fallback:null,children:(0,N.jsx)(E,{name:X.name,on_dirty:ie,view_state:A("ace",q),on_view_state:e=>$("ace",q,e),register:e=>{Re.current=e},save:async e=>{const t={context:p.xK.get_editor_value()},n=await c.$M.post(`save/${encodeURIComponent(q)}`,t);return n.code===u.m.Success||e||(0,h.zN)(we("保存失败")),n.code===u.m.Success}})})},q),Je&&(0,N.jsxs)(s.Fragment,{children:[(0,N.jsx)("div",{className:"studio__divider studio__divider--chat",ref:He,onPointerDown:e=>{e.preventDefault(),Ve(!0),document.addEventListener("pointermove",ht),document.addEventListener("pointerup",ft,{once:!0})}}),(0,N.jsx)("div",{className:"studio-chat-panel",style:{width:`${Te}em`},children:(0,N.jsx)(s.Suspense,{fallback:null,children:(0,N.jsx)(U,{inline_header:!0,sync_url:!1,file_cwd_path:it,session_id:Ye??(yt=it,o.AG.get_ai_chat_session(qe,yt)),on_session_change:e=>{Ze(e),((e,t)=>{Qe({...qe,[e]:t})})(it,e)}})})})]})]})]});var yt}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[7212],{42562(e,t,r){r.d(t,{A:()=>a});var n=r(96540),s=r(85997),i=r(45907),c=r(74848);function a(e){const{name:t,dirty:r,loading:a,error:o,saving:u,on_save:f,on_close:l,children:d,extra:_}=e,p=(0,i.y)(),v=(0,n.useRef)(l),m=(0,n.useRef)(f),y=(0,n.useRef)(r);v.current=l,m.current=f,y.current=r;const h=()=>{y.current?p({title:"关闭",sub_title:"有未保存的修改,确定关闭吗?",confirm_fun:()=>v.current?.()}):v.current?.()};return(0,n.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"s"===e.key.toLowerCase()?(e.preventDefault(),e.stopPropagation(),m.current?.()):"Escape"===e.key&&h()};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[]),(0,c.jsxs)("div",{className:"office-editor",children:[(0,c.jsxs)("div",{className:"office-editor__topbar",children:[(0,c.jsxs)("div",{className:"office-editor__name",children:[t,r&&(0,c.jsx)("span",{className:"office-editor__dirty",title:"有未保存的修改"})]}),(0,c.jsxs)("div",{className:"office-editor__ops",children:[_,u&&(0,c.jsx)("span",{className:"office-editor__saving",children:"保存中…"}),f&&(0,c.jsx)(s.rA,{icon:"save",title:"保存 (Ctrl+S)",onClick:()=>f()}),(0,c.jsx)(s.rA,{icon:"close",title:"关闭 (Esc)",onClick:h})]})]}),(0,c.jsxs)("div",{className:"office-editor__body",children:[a&&(0,c.jsx)("div",{className:"office-editor__tip",children:"加载中…"}),!a&&o&&(0,c.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:o}),!a&&!o&&d]})]})}},47212(e,t,r){r.r(t),r.d(t,{default:()=>_});var n=r(96540),s=r(34843),i=r(82893),c=r(42562),a=r(50610),o=r(99018),u=r(74848);function f(e){const{url:t,save_path:r,file_name:s,on_dirty:i,bind_save:c}=e,f=(0,n.useRef)(null),l=(0,n.useRef)(),[d,_]=(0,n.useState)(""),[p,v]=(0,n.useState)(!0);return(0,n.useEffect)(()=>{if(!t)return;const e=f.current;if(!e)return;let n,i=!0;return v(!0),_(""),(0,o.PQ)(t).then(t=>{i&&(n=(0,a.t)(e,{source:t,fileName:s,onSave:async e=>await(0,o.GB)(r,e),autoSave:!0,compact:!0}))}).catch(e=>{i&&_(String(e?.message??e))}).finally(()=>i&&v(!1)),()=>{i=!1,n?.destroy(),l.current=void 0}},[t,s,r]),(0,n.useEffect)(()=>{c?.(async()=>{const e=l.current;return!!e&&(await e.save(),!e.dirty)})},[c]),(0,u.jsxs)("div",{className:"pptx-pane",children:[d&&(0,u.jsx)("div",{className:"office-editor__tip office-editor__tip--error",children:d}),p&&!d&&(0,u.jsx)("div",{className:"office-editor__tip",children:"读取中…"}),(0,u.jsx)("div",{className:"pptx-pane__host",ref:f})]})}var l=r(93245),d=r(23430);function _(){const[e,t]=(0,s.fp)(i.AG.pptx_editor),[r,a]=(0,n.useState)(!1),[_,p]=(0,n.useState)(!1),v=(0,n.useRef)(),m=async()=>{if(!v.current)return!1;p(!0);try{return await v.current()}finally{p(!1)}},y=(0,n.useRef)(r);return y.current=r,(0,l.a)(d.nE.pptx,()=>y.current,()=>m()),(0,u.jsx)(c.A,{name:e.name,dirty:r,loading:!1,error:"",saving:_,on_save:m,on_close:()=>{const r=e.close;t({}),r?.()},children:e.url&&(0,u.jsx)(f,{url:e.url,file_name:e.name??"",save_path:(0,o.Vi)(e.name??""),on_dirty:a,bind_save:e=>v.current=e})})}},99018(e,t,r){r.d(t,{GB:()=>u,PQ:()=>o,Vi:()=>a});var n=r(14284),s=r(57889),i=r(34289),c=r(62042);function a(e){return`${encodeURIComponent((0,i.GG)("file",(0,i.vX)()))}${e}`}async function o(e){return s.l.get_bytes_url(e)}function u(e,t){return async function(e,t){const r=await n.$M.post(`save_bin/${e}`,{base64:f(t)});return 0===r.code||((0,c.zN)(r.message??"保存失败"),!1)}(function(e){const t=e.lastIndexOf("/");return t<0?encodeURIComponent(e):encodeURIComponent(e.slice(0,t))+e.slice(t)}(e),t)}function f(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[9546],{74777(e,t,s){s.d(t,{Gd:()=>o,Hb:()=>i,Mu:()=>c,aM:()=>n,jk:()=>r});let n=function(e){return e[e.close=0]="close",e[e.length=1]="length",e[e.forver=2]="forver",e}({}),i=function(e){return e[e.independent=0]="independent",e[e.reuse=1]="reuse",e[e.single=2]="single",e}({});class o{mode;length;persist;session_mode}let r=function(e){return e.ffmpeg="ffmpeg",e.smartmontools="smartctl",e.ufw="ufw",e}({});let c=function(e){return e[e.auth=0]="auth",e[e.cmd=1]="cmd",e[e.cyc=2]="cyc",e[e.sys_env=3]="sys_env",e[e.private_sys_env=4]="private_sys_env",e[e.auto_upgrade=6]="auto_upgrade",e}({})},75007(e,t,s){s.d(t,{h:()=>o});s(96540);var n=s(85997),i=s(74848);function o(e){return(0,i.jsxs)("h2",{className:"message",children:[(0,i.jsx)(n.In,{icon:"sentiment_dissatisfied"}),(0,i.jsx)("span",{children:e.context})]})}},22081(e,t,s){s.d(t,{A:()=>r});var n=s(96540),i=s(16349),o=s(74848);const r=({percentage:e})=>{const t=(0,n.useRef)(null),[s,r]=(0,n.useState)(null);return(0,n.useEffect)(()=>{const s=t.current.getContext("2d"),n=new i.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 r(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})})}},77481(e,t,s){s.d(t,{S:()=>c,X:()=>r});var n=s(96540),i=s(61443),o=s(74848);function r(e){const[t,s]=n.useState([]),r=(0,n.useRef)(-1),[c,l]=(0,n.useState)(-1),[a,d]=(0,n.useState)(-1);(0,n.useEffect)(()=>{e.children?s(Array.isArray(e.children)?e.children:[e.children]):s(e.rows)},[e.rows,e.children]);const u=()=>{r.current=-1,l(-1),d(-1)};return(0,o.jsxs)("table",{children:[(0,o.jsx)("thead",{children:(0,o.jsx)("tr",{children:e.headers?.map((t,s)=>{const n=!!e.filter&&(e.filter.column??0)===s;let r=t;if(n){const s=e.filter,n=s.options.find(e=>e.value===s.value);null!=s.value&&n&&(r=`${t} (${n.label})`)}return(0,o.jsx)("th",{className:n?"table-filter-col":"",children:n?(0,o.jsx)(i.l6,{value:e.filter.value,options:e.filter.options,onChange:e.filter.onChange,bare:!0,trigger_label:r}):t},s)})})}),(0,o.jsx)("tbody",{children:t.map((t,s)=>{const n=!!e.onRowDrag;return(0,o.jsx)("tr",{className:n?(c===s?"row-dragging":"")+(a===s?" row-drop-target":""):"",draggable:n,onContextMenu:()=>{e.handleContextMenu&&e.handleContextMenu(t)},onDragStart:e=>{n&&(r.current=s,l(s),e.dataTransfer.effectAllowed="move")},onDragOver:e=>{!n||r.current<0||(e.preventDefault(),e.dataTransfer.dropEffect="move",d(s))},onDrop:t=>{n&&(t.preventDefault(),(()=>{const t=r.current,s=a;u(),t<0||s<0||t===s||e.onRowDrag?.(t,s)})())},onDragEnd:u,children:t.map((s,n)=>{const i=n===t.length-1?"small":"";return(0,o.jsx)("td",{className:i,style:{width:e.width??"auto"},children:s},n)})},s)})})]})}function c(e){return(0,o.jsx)("div",{style:{display:e.isFlex?"flex":"block"},children:e.columns.map((e,t)=>(0,o.jsx)("div",{children:e},t))})}},88062(e,t,s){s.d(t,{A:()=>r});s(96540),s(32768);var n=s(74848);function i(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)(i,{...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))})]}),r=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))})})},59546(e,t,s){s.r(t),s.d(t,{default:()=>le});var n=s(96540),i=s(75725),o=s(7572),r=s(22081),c=s(92275),l=s(14944),a=s(14284),d=s(4412),u=s(85997),h=s(77481),x=s(53459),p=s(22022),m=s(34843),f=s(82893),j=s(74777),g=s(62042),_=s(61443),y=s(74848);function w(e){const{t}=(0,p.Bd)(),[s,r]=(0,m.fp)(f.AG.disk),[c,l]=(0,n.useState)({}),[j,g]=(0,n.useState)([]),_=[t("名字"),t("当前值"),t("历史最低"),t("临界值")];return(0,n.useEffect)(()=>{(async()=>{const s=await a.Yu.post("sys/disk/info",{name:e.name});if(s.code===x.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,y.jsx)("span",{style:{color:s},children:t(n[0])}),e.push(n)}g(s.data.ata_smart_attributes),l(s.data)}})()},[]),(0,y.jsxs)("div",{children:[(0,y.jsx)(d.aZ,{position:"right",children:(0,y.jsx)(u.rA,{icon:"close",title:t("关闭"),onClick:()=>{r({})}})}),(0,y.jsx)(i.jW,{isFull:!0,more:!0,children:(0,y.jsx)(i.NN,{children:(0,y.jsxs)(i.fI,{children:[(0,y.jsxs)(i.VP,{widthPer:30,children:[(0,y.jsx)(i.xh,{children:(0,y.jsxs)(o.Zp,{title:t("基本信息"),children:[(0,y.jsx)(i.Yh,{left:t("名字"),right:e.name}),(0,y.jsx)(i.Yh,{left:t("厂商名称"),right:e.typeName}),(0,y.jsx)(i.Yh,{left:t("类型"),right:e.type}),(0,y.jsx)(i.Yh,{left:t("容量"),right:e.total})]})}),(0,y.jsx)(i.xh,{children:(0,y.jsxs)(o.Zp,{title:t("物理信息"),children:[(0,y.jsx)(i.Yh,{left:t("是否健康"),right:!0===c.smart_status?"是":"否"}),(0,y.jsx)(i.Yh,{left:t("设备型号"),right:c.model_name}),(0,y.jsx)(i.Yh,{left:t("序列号"),right:c.serial_number}),(0,y.jsx)(i.Yh,{left:t("固件版本"),right:c.firmware_version}),(0,y.jsx)(i.Yh,{left:t("转速(每分钟)"),right:c.rotation_rate}),(0,y.jsx)(i.Yh,{left:t("通电时长(小时)"),right:c.power_on_time_hours}),(0,y.jsx)(i.Yh,{left:t("通电次数"),right:c.power_cycle_count}),(0,y.jsx)(i.Yh,{left:t("温度(°C)"),right:c.temperature}),(0,y.jsx)(i.Yh,{left:t("通信协议"),right:c.device_protocol})]})})]}),(0,y.jsx)(i.VP,{widthPer:50,children:(0,y.jsxs)(i.xh,{children:[j?.length?(0,y.jsx)(o.uF,{title:t("ATA/SATA详细信息"),children:(0,y.jsx)(h.X,{headers:_,rows:j,width:"10rem"})}):(0,y.jsx)(y.Fragment,{}),c.nvme_smart?(0,y.jsxs)(o.Zp,{title:t("NVME详细信息"),children:[(0,y.jsx)(i.Yh,{left:t("NVMe 可用备用块(%)"),right:c.nvme_smart.available_spare}),(0,y.jsx)(i.Yh,{left:t("NVMe 已使用寿命(%)"),right:c.nvme_smart.percentage_used}),(0,y.jsx)(i.Yh,{left:t("NVMe 读取量"),right:c.nvme_smart.data_units_read}),(0,y.jsx)(i.Yh,{left:t("NVMe 写入量"),right:c.nvme_smart.data_units_written}),(0,y.jsx)(i.Yh,{left:t("NVMe 通电次数"),right:c.nvme_smart.power_cycles}),(0,y.jsx)(i.Yh,{left:t("NVMe 通电时长(小时)"),right:c.nvme_smart.power_on_hours}),(0,y.jsx)(i.Yh,{left:t("NVMe 非正常关机"),right:c.nvme_smart.unsafe_shutdowns}),(0,y.jsx)(i.Yh,{left:t("NVMe 媒体错误"),right:c.nvme_smart.media_errors}),(0,y.jsx)(i.Yh,{left:t("NVMe 错误日志数"),right:c.nvme_smart.num_err_log_entries})]}):(0,y.jsx)(y.Fragment,{})]})})]})})})]})}let v=function(e){return e[e.mount=0]="mount",e}({});var k=s(88062),S=s(78247),b=s(23430),C=s(99214);const A=e=>(0,y.jsxs)("div",{style:{border:"2px solid black",padding:"10px",width:"300px",height:"300px",position:"relative"},children:[e.name,e.lvms.map((e,t)=>(0,y.jsx)("div",{style:{margin:"5px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid "},children:e.name},t))]});function V(){return(0,y.jsx)("div",{style:{position:"relative",height:"300px",margin:"10px",width:"30px",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,y.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,m.fp)(f.AG.disk),[r,c]=(0,n.useState)({}),[l,j]=(0,n.useState)([]),[_,w]=(0,n.useState)([]),[P,$]=(0,m.fp)(f.AG.showPrompt),{check_user_auth:Y}=(0,S.MH)(),[F,I]=(0,n.useState)([]),{click_file:N}=(0,C.kZ)(),[E,M]=(0,m.fp)(f.AG.prompt_card),K=[e("挂载点"),"uuid",e("类型"),e("文件系统类型"),e("文件系统容量"),e("卷容量"),e("设备路径"),e("分区表类型")],B=async()=>{const e=await a.Yu.get("disk/blk");return e.code===x.m.Success&&j(e.data),e.code};(0,n.useEffect)(()=>{(async()=>{B()})()},[]);const H=[(0,y.jsx)(u.rA,{icon:"info",title:e("提示"),onClick:async()=>{M({open:!0,title:"信息",context_div:(0,y.jsx)("div",{children:(0,y.jsxs)("ul",{children:[(0,y.jsxs)("li",{children:["通用格式:","<文件系统> <挂载点> <类型> <挂载选项> <dump> <fsck> "]}),(0,y.jsxs)("li",{children:["文件系统,有多种格式",(0,y.jsxs)("ul",{children:[(0,y.jsx)("li",{children:"1(usb口默认名称)./dev/sda1"}),(0,y.jsx)("li",{children:"2(唯一Id).UUID=123e4567-e89b-12d3-a456-426614174000"}),(0,y.jsx)("li",{children:"3.LABEL=DATA"})]})]}),(0,y.jsx)("li",{children:"挂载点,就是文件路径,例如 /mnt/data ,这个目录要提前创建,且为空"}),(0,y.jsx)("li",{children:"类型,就是文件系统类型,对于系统不支持的类型,例如ntfs需要额外前提安装ntfs-3g(linux 5.15内核以后自带 ntfs)"}),(0,y.jsxs)("li",{children:['挂载选项的值只能是以下这些,可以用 "," 同时使用多个选项',(0,y.jsxs)("ul",{children:[(0,y.jsx)("li",{children:"defaults:使用默认挂载选项"}),(0,y.jsx)("li",{children:"noatime:不更新访问时间,提高性能"}),(0,y.jsx)("li",{children:"auto:系统启动时自动挂载"}),(0,y.jsx)("li",{children:"rw:以读写方式挂载"}),(0,y.jsx)("li",{children:"nofail:防止启动阻塞,挂载失败系统继续执行"}),(0,y.jsx)("li",{children:"...等"})]})]}),(0,y.jsx)("li",{children:"dump 0是需要备份 1是不需要备份"}),(0,y.jsx)("li",{children:"Fsck 整数值0是不检查,文件系统检查顺序越小越先检查"}),(0,y.jsx)("li",{children:"提示:只有含有文件系统的逻辑卷,或者分区才可以进行挂载。"})]})})})}}),(0,y.jsx)(u.rA,{icon:"update",title:e("更新挂载"),onClick:async()=>{(await a.Yu.post("cmd/exe",{type:v.mount})).code===x.m.Success&&(0,g.SK)(e("挂载文件已生效"))}},1)],Z=async()=>(await a.Yu.get("get_fstab")).data,G=async e=>{await a.Yu.post("save_fstab",{content:e})};return(0,y.jsxs)("div",{children:[(0,y.jsx)(d.aZ,{position:"right",children:(0,y.jsx)(u.rA,{icon:"close",title:e("关闭"),onClick:()=>{s({})}})}),(0,y.jsx)(i.jW,{isFull:!0,more:!0,children:(0,y.jsx)(i.NN,{children:(0,y.jsxs)(i.fI,{children:[(0,y.jsx)(i.VP,{widthPer:40,children:(0,y.jsxs)(o.Zp,{title:e("物理块(硬盘)设备、逻辑卷、物理卷"),rightTopCom:(0,y.jsxs)("div",{children:[Y(b.oV.sys_disk_mount)&&(0,y.jsx)(u.rA,{icon:"file_open",title:e("打开挂载文件"),onClick:async()=>{N({name:"fstab(谨慎修改,内容错误会导致系统无法启动)",model:"text",get_file_fun:Z,save_file_fun:G,menu_list:H})}}),(0,y.jsx)(u.rA,{icon:"update",title:e("刷新"),onClick:async()=>{await B()===x.m.Success&&(0,g.SK)(e("刷新成功"))}})]}),children:[(0,y.jsx)(h.X,{headers:K,rows:_,width:"10rem"}),(0,y.jsx)(k.A,{list:l,render:e=>{let t=e.name;return e.label&&(t+=`(${e.label})`),e.mountpoint?(0,y.jsxs)("span",{children:[t,(0,y.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]+";";w([[(0,y.jsx)(o.xP,{children:s}),(0,y.jsx)(o.xP,{children:t.uuid}),e(t.type),e(t.fstype),t.fssize,t.size,(0,y.jsx)(o.xP,{children:t.path}),t.pttype]])}})]})}),(0,y.jsx)(i.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 r=[];for(const e of t.lv_list)r.push({name:`${e.name}---(${e.size})`});return(0,y.jsx)(o.Zp,{children:(0,y.jsxs)(i.n5,{children:[(0,y.jsx)(A,{name:e("物理卷"),lvms:n}),(0,y.jsx)(V,{}),(0,y.jsx)(A,{name:`${e("逻辑卷")}---(${t.name})---size(${t.size})`,lvms:[]}),(0,y.jsx)(V,{}),(0,y.jsx)(A,{name:e("逻辑卷"),lvms:r})]})},s)})})]})})})]})}var $=s(88815);let Y=!0;function F(e){const{t}=(0,p.Bd)(),s=[t("名字"),t("厂商名称"),t("类型"),t("容量")],_=[t("名字"),t("物理硬盘"),t("文件系统类型"),t("挂载位置"),t("总容量"),t("剩余容量")],[v,k]=(0,m.fp)(f.AG.user_base_info),[S,C]=(0,n.useState)(0),[A,V]=(0,n.useState)(0),[F,I]=(0,n.useState)(0),[N,E]=(0,n.useState)(0),[M,K]=(0,n.useState)(0),[B,H]=(0,n.useState)({}),[Z,G]=(0,n.useState)(!1),[D,z]=(0,n.useState)(!1),[T,W]=(0,n.useState)(!1),[X,q]=(0,n.useState)(Y),[U,L]=(0,n.useState)(null),[R,O]=(0,n.useState)([]),[J,Q]=(0,n.useState)([]),[ee,te]=(0,m.fp)(f.AG.user_base_info),[se,ne]=(0,m.fp)(f.AG.disk),ie=async()=>{Y&&(await l.ws.addMsg(c.HK.sys_getting,e=>{E(e.context?.cpu_currentLoad);const t=e.context?.memLeft,s=e.context?.memTotal;V(t),I(s),C((s-t)/s*100),L(e.context?.node_memory_usage),K(e.context?.node_cpu_usage)}),await l.ws.send(new c.hf(c.HK.sys_get)))};return(0,n.useEffect)(()=>((async()=>{await ie()})(),()=>{l.ws.sendData(c.HK.sys_cancel,{})}),[]),(0,y.jsxs)("div",{children:[(0,y.jsxs)(d.aZ,{position:"right",children:[v.sys===b.XM.linux&&(0,y.jsx)(u.rA,{icon:"sd_card",title:"硬盘挂载",onClick:()=>{ne({type:"mount"})}}),(0,y.jsx)(u.Z$,{defaultStatus:!1,text:t("基本信息"),clickFun:e=>{G(e),e&&(async()=>{const e=await a.Yu.get("base");if(e.code===x.m.Success){const t=e.data;H(t)}})()}}),(0,y.jsx)(u.Z$,{defaultStatus:!1,text:t("物理硬盘"),clickFun:e=>{z(e),e&&(async()=>{const e=await a.Yu.get("disk");if(e.code===x.m.Success){const s=e.data,n=[];let i=!0;ee.sysSoftWare&&ee.sysSoftWare[j.jk.smartmontools]&&ee.sysSoftWare[j.jk.smartmontools].installed||(i=!1);for(const e of s??[])n.push([(0,y.jsx)(o.xP,{context:e.name}),e.typeName,e.type,e.total,(0,y.jsx)(u.rA,{icon:"health_and_safety",title:t("查看健康信息"),onClick:()=>{i?ne({type:"check",data:e}):(0,g.zN)(t("没有安装smartmontools"))}})]);O(n)}})()}}),(0,y.jsx)(u.Z$,{defaultStatus:!1,text:t("文件硬盘"),clickFun:e=>{W(e),e&&(async()=>{const e=await a.Yu.get("filedisk");if(e.code===x.m.Success){const t=e.data,s=[];for(const e of t??[])s.push([(0,y.jsx)(o.xP,{context:e.name}),(0,y.jsx)(o.xP,{context:e.device_name}),e.fsType,(0,y.jsx)(o.xP,{context:e.mount}),e.total,e.available]);Q(s)}})()}}),(0,y.jsx)(u.Z$,{defaultStatus:X,text:t("实时信息"),clickFun:e=>{q(e),Y=e,ie()}})]}),(0,y.jsxs)(i.xh,{children:[X&&(0,y.jsxs)(i.fI,{children:[(0,y.jsx)(i.VP,{widthPer:33,maxWidth:"30rem",children:(0,y.jsx)(o.Zp,{title:"Sys "+t("内存"),children:(0,y.jsxs)(i.fI,{children:[(0,y.jsx)(i.VP,{children:(0,y.jsx)(r.A,{percentage:S})}),(0,y.jsx)(i.VP,{children:(0,y.jsxs)(i.fI,{children:[(0,y.jsx)(i.VP,{widthPer:100,children:(0,y.jsx)("div",{children:(0,y.jsx)(i.Yh,{left:t("总容量"),center:`${F}G`})})}),(0,y.jsx)(i.VP,{widthPer:100,children:(0,y.jsx)(i.Yh,{left:t("剩余"),center:`${A}G`})})]})})]})})}),(0,y.jsx)(i.VP,{widthPer:33,maxWidth:"30rem",children:(0,y.jsx)(o.Zp,{title:"Sys cpu",children:(0,y.jsxs)(i.fI,{children:[(0,y.jsx)(i.VP,{children:(0,y.jsx)(r.A,{percentage:N})}),(0,y.jsx)(i.VP,{children:(0,y.jsx)(i.fI,{children:(0,y.jsx)(i.Yh,{left:t("使用率"),center:N})})})]})})}),(0,y.jsx)(i.VP,{widthPer:33,maxWidth:"30rem",children:(0,y.jsx)(o.Zp,{title:"FileCat",children:(0,y.jsxs)(i.fI,{children:[(0,y.jsxs)(i.VP,{children:[(0,y.jsx)(i.qV,{content:t("内存")}),(0,y.jsx)(i.qV,{content:"total: "+(0,$.v7)(U?.rss)}),(0,y.jsx)(i.qV,{content:"object: "+(0,$.v7)(U?.heapTotal)}),(0,y.jsx)(i.qV,{content:"obj-use: "+(0,$.v7)(U?.heapUsed)}),(0,y.jsx)(i.qV,{content:"external: "+(0,$.v7)(U?.external)}),(0,y.jsx)(i.qV,{content:"buffer: "+(0,$.v7)(U?.arrayBuffers)})]}),(0,y.jsx)(i.VP,{children:(0,y.jsx)(i.qV,{content:"cpu growth rate: "+M})})]})})})]}),(0,y.jsxs)(i.fI,{children:[Z&&(0,y.jsx)(i.VP,{children:(0,y.jsxs)(o.Zp,{title:t("基本信息"),children:[(0,y.jsx)(i.Yh,{left:t("总内存"),right:B.mem_total}),(0,y.jsx)(i.Yh,{left:`cpu ${t("制造商")}`,right:B.cpu_manufacturer}),(0,y.jsx)(i.Yh,{left:`cpu ${t("品牌")}`,right:B.cpu_brand}),(0,y.jsx)(i.Yh,{left:`cpu ${t("逻辑核心")}`,right:B.cpu_core_num}),(0,y.jsx)(i.Yh,{left:`cpu ${t("物理核心")}`,right:B.cpu_phy_core_num}),(0,y.jsx)(i.Yh,{left:`cpu ${t("最大")}hz`,right:B.cpu_speed_hz}),(0,y.jsx)(i.Yh,{left:`${t("当前系统")}:pid;ppid`,right:B.pid_ppid}),(0,y.jsx)(i.Yh,{left:t("运行用户"),right:B.user})]})}),D&&(0,y.jsx)(i.VP,{children:(0,y.jsx)(o.uF,{title:t("物理硬盘"),children:(0,y.jsx)(h.X,{headers:s,rows:R,width:"10rem"})})}),T&&(0,y.jsx)(i.VP,{children:(0,y.jsx)(o.uF,{title:t("文件硬盘"),children:(0,y.jsx)(h.X,{headers:_,rows:J,width:"10rem"})})})]})]}),se&&"check"===se.type&&(0,y.jsx)(w,{...se.data}),se&&"mount"===se.type&&(0,y.jsx)(P,{})]})}var I=s(75007),N=s(97856),E=s(64405);const M=n.lazy(()=>Promise.all([s.e(2543),s.e(5614)]).then(s.bind(s,85614)));function K(e){const[t,s]=(0,n.useState)(null),[i,o]=(0,m.fp)(f.AG.dockerShellShow),[r,a]=(0,m.fp)(f.AG.user_base_info),d=r.user_data.theme?.includes("dark")?"#FFFFFF":"#000000",u=()=>{(async()=>{t&&(t.writeln("[38;2;29;153;243mclose![0m "),t.dispose(),s(null))})()};(0,n.useEffect)(()=>{i.show?(async()=>{const e=new N.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(u);const n=t=>{e.write(t)};t=s=>{e.clear(),e.write(s),t=n},l.ws.addMsg("logs"===i.type?c.HK.docker_shell_logs_getting:c.HK.docker_shell_exec_getting,e=>{"error"===e.context&&u(),t(e.context)}),"exec"===i.type&&e.onData(async e=>{const t=new c.hf(c.HK.docker_shell_exec);t.context=e,await l.ws.send(t)}),s(e)})():u()},[i]),(0,n.useEffect)(()=>()=>{u()},[]);return(0,y.jsx)(M,{show:i.show,terminal:t,init:(e,s)=>{t.writeln("[38;2;29;153;243mconnect...[0m ");const n=new E.n;let o;n.rows=e,n.cols=s,n.dockerId=i.dockerId,o="logs"===i.type?new c.hf(c.HK.docker_shell_logs):new c.hf(c.HK.docker_shell_exec_open),o.context=n,l.ws.send(o)}})}var B=s(78150),H=s(52671),Z=s(87361);let G="",D=[],z=!1;function T(e){const{t}=(0,p.Bd)(),s=(0,H.Zp)(),[r]=(0,m.fp)(f.AG.user_base_info),[j,w]=(0,n.useState)({}),[v,k]=(0,n.useState)([]),[C,A]=(0,n.useState)([]),{check_user_auth:V}=(0,S.MH)(),[P,$]=(0,m.fp)(f.AG.dockerShellShow),[Y,F]=(0,m.fp)(f.AG.showPrompt),[N,E]=(0,m.fp)(f.AG.confirm),[M,T]=(0,n.useState)(G),[W,X]=(0,n.useState)(["id",t("名字"),t("镜像"),t("命令"),t("状态"),t("内存"),"cpu%",t("选择")]),[q,U]=(0,n.useState)([]),[L,R]=(0,n.useState)(void 0),[O,J]=(0,n.useState)(!1),Q=["id",t("name"),t("create时间"),t("大小"),(0,y.jsxs)("span",{children:["选中",(0,y.jsx)(u.rA,{icon:"check_box",title:"全选",onClick:()=>{z=!z;const e={};for(let t=0;t<C.length&&z;t++)e[C[t][0].props.context]=1;w(e)}})]})],ee=(0,n.useRef)(()=>{}),te=async()=>{k([]),U([]),l.ws.off_message(`message_${c.HK.docker_getting}`,ee.current);const e=e=>{k((e=>{const t=[];if(G){for(const s of e)for(const e of s)if(`${e}`.includes(G)){t.push(s);break}}else t.push(...e);return t.map(e=>{const t=e.map(e=>(0,y.jsx)(o.xP,{context:e}));return t.push((0,y.jsx)(u.rA,{icon:"place",title:"选中",onClick:()=>{U(t)}})),t})})(e.context??[]))};ee.current=e,l.ws.addMsg(c.HK.docker_getting,e);const t=new c.hf(c.HK.docker_get);await l.ws.send(t)};(0,n.useEffect)(()=>(T(G),te(),()=>{(async()=>{l.ws.off_message(`message_${c.HK.docker_getting}`,ee.current),$({show:!1,type:"",dockerId:""})})()}),[]),(0,n.useEffect)(()=>{G=M},[M]);const se=()=>{const e=new c.hf("logs"===P.type?c.HK.docker_shell_logs_cancel:c.HK.docker_shell_exec_cancel);e.context="",l.ws.send(e)},ne=e=>{const t=new c.hf(c.HK.docker_switch);t.context={type:e,dockerId:q[0].props.context},U([]),l.ws.send(t)},ie=async()=>{const e=await a.Yu.get("docker/images");if(e.code===x.m.Success){const t=e.data??[],s=[];for(let e=0;e<t.length;e++){const n=t[e],i=[(0,y.jsx)(o.xP,{context:n[0]}),(0,y.jsx)(o.xP,{context:n[1]}),n[2],n[3],""];s.push(i)}D=s,A(s)}};return(0,y.jsxs)("div",{children:[(0,y.jsx)(d.aZ,{children:(0,y.jsx)(u.Z$,{defaultStatus:!1,text:t("doc_img"),clickFun:e=>{J(e),e?(ie(),U([])):(te(),A([]),w({}))}})}),(0,y.jsxs)(d.aZ,{position:"right",children:[r.sys===b.XM.linux&&(0,y.jsx)(u.rA,{icon:"settings",title:t("doc_cfg"),onClick:()=>s(Z.o.docker_setting_page)}),Object.keys(j).length>0&&(0,y.jsx)(u.rA,{icon:"delete",title:t("删除镜像"),onClick:async()=>{E({open:!0,title:t("doc_icf"),handle:async()=>{const e=Object.keys(j),s=await a.Yu.post("docker/check/delete",{ids:e});if(s.code===x.m.Success)if(0===s.data.length){(await a.Yu.post("docker/delete",{ids:e})).code===x.m.Success&&((0,g.SK)(t("删除完成")),ie(),E({open:!1,handle:null}))}else(0,g.N9)(`有镜像正在运行${JSON.stringify(s.data)}`)}})}}),q.length>0&&(0,y.jsx)("div",{children:q[1].props.context}),q.length>0&&(0,y.jsxs)("div",{children:[V(b.oV.docker_container_update)&&(0,y.jsx)(u.rA,{icon:"delete",title:t("删除容器"),onClick:()=>{F({show:!0,overlay:!0,type:B.PromptEnum.DockerDel,data:{dockerId:q[0].props.context,name:q[1].props.context}})}}),(0,y.jsx)(u.rA,{icon:"print",title:t("打印日志"),onClick:()=>{P.show?($({show:!1,type:"",dockerId:""}),se()):$({show:!0,dockerId:q[0].props.context,type:"logs"})}}),V(b.oV.docker_container_update)&&(0,y.jsx)(u.rA,{icon:"personal_video",title:t("执行命令"),onClick:()=>{P.show?($({show:!1,type:"",dockerId:""}),se()):$({show:!0,dockerId:q[0].props.context,type:"exec"})}}),V(b.oV.docker_container_update)&&q[4].props.context.includes("Up")&&(0,y.jsx)(u.rA,{icon:"stop",title:t("停止"),onClick:()=>ne("stop")}),V(b.oV.docker_container_update)&&!q[4].props.context.includes("Up")&&(0,y.jsx)(u.rA,{icon:"play_arrow",title:t("开启"),onClick:()=>{ne("start")}})]}),(0!==v.length||M)&&!O&&(0,y.jsx)(u.rA,{icon:"refresh",title:t("列表更新"),onClick:async()=>{const e=new c.hf(c.HK.docker_get);await l.ws.send(e)}})]}),(0,y.jsxs)(i.xh,{children:[O&&(0,y.jsx)(i.fI,{children:(0,y.jsx)(i.VP,{widthPer:80,children:(0,y.jsx)(o.uF,{title:`${t("镜像")} (${C.length})`,rightTopCom:(0,y.jsx)(_.Sm,{placeholder:t("过滤镜像"),value:L,handleInputChange:e=>{R(e)},handlerEnter:()=>{const e=[];if(L){for(const t of C)(t[0].props.context.includes(L)||t[1].props.context.includes(L))&&e.push(t);A(e)}else A(D)}}),children:(0,y.jsx)(h.X,{headers:Q,rows:C.map((e,s)=>(e[4]=(0,y.jsx)(_.GL,{context:t(""),selected:j[e[0].props.context],onchange:()=>{(e=>{const t={};Object.assign(t,j),t[e]?delete t[e]:t[e]=1,w(t)})(e[0].props.context)}}),e)),width:"10rem"})})})}),0===v.length&&!M&&!O&&(0,y.jsx)(I.h,{context:t("dc_nne")}),(0!==v.length||M)&&!O&&(0,y.jsx)(i.fI,{children:(0,y.jsx)(i.VP,{widthPer:80,children:(0,y.jsx)(o.uF,{title:`${t("容器")} (${v.length})`,rightTopCom:(0,y.jsx)(_.Sm,{placeholder:t("过滤"),value:M,handleInputChange:e=>{T(e)}}),children:(0,y.jsx)(h.X,{headers:W,rows:v,width:"10rem"})})})})]}),(0,y.jsx)(K,{})]})}var W=s(64694);let X="",q=!1,U=!1;function L(e){const{t}=(0,p.Bd)(),[s,r]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[m,f]=(0,n.useState)(0),[j,g]=(0,n.useState)(""),[w,v]=(0,n.useState)(["pid",t("名字"),t("创建用户"),(0,y.jsxs)("span",{children:[t("内存"),(0,y.jsx)(u.rA,{icon:"sort",title:t("升序"),onClick:()=>{q=!q}})]}),(0,y.jsxs)("span",{children:["cpu%",(0,y.jsx)(u.rA,{icon:"sort",title:t("升序"),onClick:()=>{U=!U}})]}),t("选择")]),{check_user_auth:k}=(0,S.MH)();(0,n.useEffect)(()=>{g(X),(async()=>{r([]),f(0),x([]);const e=new c.hf(c.HK.process_get);await l.ws.send(e),l.ws.addMsg(c.HK.process_getting,e=>{const s=[];if(X){for(const t of e.context)for(const e of t)if(`${e}`.includes(X)){s.push(t);break}}else s.push(...e.context);q&&(0,W.di)(s,e=>e[3],!1),U&&(0,W.di)(s,e=>e[4],!1);const n=s.map(e=>{const s=e.map((e,t)=>(0,y.jsx)(o.xP,{context:3===t?(0,$.v7)(e):e}));return s.push((0,y.jsx)(u.rA,{icon:"place",title:t("选中"),onClick:()=>{x(s)}})),s});f(s.length),r(n)})})()},[]),(0,n.useEffect)(()=>{X=j},[j]);return(0,y.jsxs)("div",{children:[(0,y.jsxs)(d.aZ,{position:"right",children:[a.length>0&&(0,y.jsx)("div",{children:a[1].props.context}),a.length>0&&k(b.oV.sys_process_close)&&(0,y.jsx)("div",{children:(0,y.jsx)(u.rA,{icon:"stop",title:t("停止"),onClick:()=>{const e=new c.hf(c.HK.process_close);e.context={pid:a[0].props.context},x([]),l.ws.send(e)}})})]}),(0,y.jsx)(i.xh,{children:0!==s.length||X?(0,y.jsx)(i.fI,{children:(0,y.jsx)(i.VP,{widthPer:80,children:(0,y.jsx)(o.uF,{title:`${t("进程")} (${m})`,rightTopCom:(0,y.jsx)(_.Sm,{placeholder:t("过滤"),value:j,handleInputChange:e=>{g(e)}}),children:(0,y.jsx)(h.X,{headers:w,rows:s,width:"10rem"})})})}):(0,y.jsx)(I.h,{context:t("ld_wait")})})]})}const R=n.lazy(()=>Promise.all([s.e(2543),s.e(5614)]).then(s.bind(s,85614)));function O(e){const[t,s]=(0,n.useState)(null),[i,o]=(0,m.fp)(f.AG.systemd_shell_show),[r,a]=(0,m.fp)(f.AG.user_base_info),d=r.user_data.theme?.includes("dark")?"#FFFFFF":"#000000",u=()=>{(async()=>{t&&(t.writeln("[38;2;29;153;243mclose![0m "),t.dispose(),s(null))})()};(0,n.useEffect)(()=>{if(!i.show)return void u();(async()=>{const e=new N.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(u),l.ws.addMsg(c.HK.systemd_logs_getting,t=>{"error"===t.context&&u(),e.write(t.context)}),s(e)})();const e=e=>{};return document.addEventListener("cancel_systemd_logs",e),()=>{document.removeEventListener("cancel_systemd_logs",e)}},[i]),(0,n.useEffect)(()=>()=>{u()},[]);return(0,y.jsx)(R,{show:i.show,terminal:t,init:(e,s)=>{t.writeln("[38;2;29;153;243mconnect...[0m ");const n={unit_name:i.unit_name},o=new c.hf(c.HK.systemd_logs_get);o.context=n,l.ws.send(o)}})}const J=[{title:"no(不自动重启)",value:"no"},{title:"always(总是重启)",value:"always"},{title:"on-failure(失败才重启)",value:"on-failure"},{title:"on-abnormal(异常才重启)",value:"on-abnormal"}],Q=[{title:"simple",value:"simple"},{title:"forking",value:"forking"},{title:"oneshot",value:"oneshot"},{title:"notify",value:"notify"}],ee=[{title:"multi-user.target",value:"multi-user.target"},{title:"network.target",value:"network.target"}];function te(e,t){const s=[];s.push("[Unit]"),t.description.trim()?s.push(`Description=${t.description.trim()}`):s.push(`Description=${e}`),s.push(""),s.push("[Service]"),s.push(`Type=${t.type.trim()||"simple"}`),t.exec_start.trim()&&s.push(`ExecStart=${t.exec_start.trim()}`),t.working_dir.trim()&&s.push(`WorkingDirectory=${t.working_dir.trim()}`),t.user_.trim()&&s.push(`User=${t.user_.trim()}`);for(const e of t.env){const t=e.key.trim();if(!t)continue;const n=e.value??"",i=`${t}=${n}`,o=/[\s"'\\]/.test(n);s.push(`Environment=${o?`"${i.replace(/"/g,'\\"')}"`:i}`)}return t.restart&&"no"!==t.restart&&s.push(`Restart=${t.restart.trim()}`),s.push(""),s.push("[Install]"),s.push(`WantedBy=${t.wanted.trim()||"multi-user.target"}`),s.push(""),s.join("\n")}function se(e){const t={description:"",type:"simple",exec_start:"",working_dir:"",user_:"root",restart:"no",wanted:"multi-user.target",env:[]},s=(t,s)=>{const n=e.split(/\r?\n/);let i=!1;for(const e of n){const n=e.trim(),o=n.match(/^\[(.*)\]$/);if(o){i=(o[1]||"").trim()===t;continue}if(!i)continue;const r=n.match(new RegExp(`^${s}\\s*=\\s*(.*)$`,"i"));if(r)return r[1].trim()}return""};t.description=s("Unit","Description"),t.type=s("Service","Type")||"simple",t.exec_start=s("Service","ExecStart"),t.working_dir=s("Service","WorkingDirectory"),t.user_=s("Service","User"),t.restart=s("Service","Restart")||"no",t.wanted=s("Install","WantedBy")||"multi-user.target";let n=!1;for(const s of e.split(/\r?\n/)){const e=s.trim(),i=e.match(/^\[(.*)\]$/);if(i){n="Service"===(i[1]||"").trim();continue}if(!n)continue;const o=e.match(/^Environment\s*=\s*(.*)$/i);if(!o)continue;const r=o[1].trim();if(!r)continue;const c=[];let l=0;for(;l<r.length;){const e=r[l];if(/\s/.test(e))l++;else if('"'===e||"'"===e){const t=e;l++;const s=l;for(;l<r.length&&r[l]!==t;)l++;c.push({text:r.slice(s,l),quoted:!0}),l++}else{const e=l;for(;l<r.length&&!/\s/.test(r[l]);)l++;c.push({text:r.slice(e,l),quoted:!1})}}for(const e of c){const s=e.text,n=s.indexOf("=");n>0?t.env.push({key:s.slice(0,n).trim(),value:s.slice(n+1)}):t.env.length&&(t.env[t.env.length-1].value+=" "+s)}}return t}function ne(e){const{t}=(0,p.Bd)(),[s,i]=(0,n.useState)("form"),[o,r]=(0,n.useState)(()=>(e.unit_name||"").replace(/\.service$/i,"")),[c,l]=(0,n.useState)({description:"",type:"simple",exec_start:"",working_dir:"",user_:"root",restart:"no",wanted:"multi-user.target",env:[]}),[d,u]=(0,n.useState)(""),[h,j]=(0,n.useState)(""),[w,v]=(0,n.useState)(!1),[k,S]=(0,m.fp)(f.AG.confirm);(0,n.useEffect)(()=>{"edit"===e.mode&&e.unit_name&&(async()=>{v(!0);try{const t=await a.Yu.post("systemd/get/context",{unit_name:e.unit_name});if(t.code!==x.m.Success)return;const s=t.data.context??"",n=t.data.path??"";j(n),u(s),l(se(s))}finally{v(!1)}})()},[e.mode,e.unit_name]);const b=e=>{e!==s&&("text"===e?u(te(o,c)):l(se(d)),i(e))},C=e=>t=>{l(s=>({...s,[e]:t}))},A=(e,t,s)=>{l(n=>{const i=[...n.env];return i[e]={...i[e],[t]:s},{...n,env:i}})};return(0,y.jsxs)("div",{children:[(0,y.jsxs)("div",{style:{display:"flex",gap:"0.4rem",marginBottom:"0.6rem"},children:[(0,y.jsx)("button",{className:"button button--flat "+("form"===s?"":"button--grey"),onClick:()=>b("form"),children:t("表单")}),(0,y.jsx)("button",{className:"button button--flat "+("text"===s?"":"button--grey"),onClick:()=>b("text"),children:t("文本")})]}),w?(0,y.jsx)("div",{children:t("加载中...")}):"form"===s?(0,y.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"0.6rem"},children:[(0,y.jsx)(_.BC,{label:t("服务名称"),children:(0,y.jsx)(_.Sm,{placeholder:t("服务名称"),value:o,disabled:"edit"===e.mode,handleInputChange:e=>r(e),width:"100%"})}),(0,y.jsx)(_.BC,{label:t("服务描述"),children:(0,y.jsx)(_.Sm,{placeholder:t("服务描述"),value:c.description,handleInputChange:C("description"),width:"100%"})}),(0,y.jsx)(_.BC,{label:t("启动命令"),required:!0,children:(0,y.jsx)(_.Sm,{placeholder:t("ExecStart 启动命令,必填"),value:c.exec_start,handleInputChange:C("exec_start"),width:"100%"})}),(0,y.jsx)(_.BC,{label:t("运行类型"),children:(0,y.jsx)(_.l6,{options:Q,value:c.type,onChange:C("type")})}),(0,y.jsx)(_.BC,{label:t("工作目录"),children:(0,y.jsx)(_.Sm,{placeholder:t("工作目录(可选)"),value:c.working_dir,handleInputChange:C("working_dir"),width:"100%"})}),(0,y.jsx)(_.BC,{label:t("运行用户"),children:(0,y.jsx)(_.Sm,{placeholder:t("运行用户(可选)"),value:c.user_,handleInputChange:C("user_"),width:"100%"})}),(0,y.jsx)(_.BC,{label:t("重启策略"),children:(0,y.jsx)(_.l6,{options:J,value:c.restart,onChange:C("restart")})}),(0,y.jsx)(_.BC,{label:t("安装目标"),children:(0,y.jsx)(_.l6,{options:ee,value:c.wanted,onChange:C("wanted")})}),(0,y.jsxs)("div",{className:"div-row",style:{justifyContent:"space-between"},children:[(0,y.jsx)("span",{children:t("环境变量")}),(0,y.jsx)("button",{className:"button button--flat button--grey",onClick:()=>l(e=>({...e,env:[...e.env,{key:"",value:""}]})),children:t("添加")})]}),0===c.env.length&&(0,y.jsx)("div",{className:"text-secondary",style:{fontSize:"0.85rem"},children:t("暂无环境变量")}),c.env.map((e,s)=>(0,y.jsxs)("div",{className:"div-row",style:{gap:"0.4rem"},children:[(0,y.jsx)(_.Sm,{placeholder:"KEY",value:e.key,width:"35%",handleInputChange:e=>A(s,"key",e)}),(0,y.jsx)(_.Sm,{placeholder:"value",value:e.value,width:"50%",handleInputChange:e=>A(s,"value",e)}),(0,y.jsx)("button",{className:"button button--flat button--grey",onClick:()=>(e=>{l(t=>({...t,env:t.env.filter((t,s)=>s!==e)}))})(s),children:t("删除")})]},s))]}):(0,y.jsx)(_.Z2,{style:{width:"100%",minHeight:"16rem",fontFamily:"monospace",fontSize:"0.85rem",boxSizing:"border-box"},value:d,onChange:e=>u(e.target.value),spellCheck:!1}),(0,y.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.4rem",marginTop:"0.6rem"},children:[(0,y.jsx)("button",{className:"button button--flat button--grey",disabled:w,onClick:e.onClose,children:t("取消")}),(0,y.jsx)("button",{className:"button button--flat",disabled:w,onClick:async()=>{if(!o.trim())return void(0,g.zN)(t("请填写服务名称"));const n=(i=o).trim().endsWith(".service")?i.trim():`${i.trim()}.service`;var i;const r="text"===s?d:te(n,c);if(r.includes("ExecStart=")){if("form"===s){if(c.env.find(e=>!e.key.trim()&&""!==(e.value??"").trim()))return void(0,g.zN)(t("环境变量的 KEY 不能为空"))}v(!0);try{if("create"===e.mode){const s=`/etc/systemd/system/${n}`;await a.Yu.post("systemd/sys/save",{unit_name:n,path:s,context:r}),await a.Yu.post("systemd/sys/enable",{unit_name:n}),await a.Yu.post("systemd/add",{unit_name:n}),(0,g.SK)(t("添加成功")),e.onClose(),e.onDone?.()}else await a.Yu.post("systemd/sys/save",{unit_name:n,path:h,context:r}),(0,g.SK)(t("保存成功")),e.onClose(),e.onDone?.(),S({open:!0,title:t("配置已保存,是否立即重启该服务让新配置生效?"),handle:async()=>{(await a.Yu.post("systemd/sys/restart",{unit_name:n})).code===x.m.Success&&((0,g.SK)(t("重启成功")),S({open:!1,handle:null}))}})}catch(e){console.error("systemd 保存失败",e)}finally{v(!1)}}else(0,g.zN)(t("请至少填写 ExecStart 启动命令"))},children:t("保存")})]})]})}let ie,oe="";function re(e){const{t}=(0,p.Bd)(),{check_user_auth:s}=(0,S.MH)(),[r,j]=(0,m.fp)(f.AG.systemd_shell_show),[w,v]=(0,m.fp)(f.AG.confirm),[k,C]=(0,n.useState)(["pid","name","process",t("创建用户"),t("内存"),t("cpu%"),t("active状态"),t("选择")]),[A,V]=(0,n.useState)(["单元名字","加载状态",t("active(sub)状态"),t("描述"),t("选择")]),[P,Y]=(0,n.useState)([]),[F,N]=(0,n.useState)([]),[E,M]=(0,n.useState)([]),[K,B]=(0,n.useState)(!1),[H,Z]=(0,n.useState)([]),[G,D]=(0,n.useState)(""),[z,T]=(0,n.useState)(""),[W,X]=(0,n.useState)(new Set),[q,U]=(0,m.fp)(f.AG.editorSetting),[L,R]=(0,m.fp)(f.AG.prompt_card);(0,n.useEffect)(()=>{T(oe),(async()=>{Y([]),M([]);const e=new c.hf(c.HK.systemd_inside_get);await l.ws.send(e),l.ws.addMsg(c.HK.systemd_inside_getting,e=>{const t=[];if(oe){for(const s of e.context)for(const e of s)if(`${e}`.includes(oe)){t.push(s);break}}else t.push(...e.context);Y(t.map(e=>{const t=e.map((e,t)=>(0,y.jsx)(o.xP,{context:4===t?(0,$.v7)(e):e}));return t.push((0,y.jsx)(u.rA,{icon:"place",title:"选中",onClick:()=>{M(t)}})),t}))})})()},[]),(0,n.useEffect)(()=>{oe=z},[z]);const J=e=>{if(r.show){j({show:!1,unit_name:""});const e=new CustomEvent("cancel_systemd_logs",{detail:{}});document.dispatchEvent(e)}else j({show:!0,unit_name:e})},Q=async e=>{v({open:!0,handle:async()=>{(await a.Yu.post("systemd/sys/restart",{unit_name:e})).code===x.m.Success&&((0,g.SK)(t("重启成功")),v({open:!1,handle:null}))}})},ee=async()=>{N([]),Z([]);const e=await a.Yu.get("systemd/inside/all");if(e.code!==x.m.Success)return;X(new Set(e.data));const t=await a.Yu.get("systemd/allget");if(t.code===x.m.Success){const e=t.data,s=[];for(const t of e??[]){const e=[(0,y.jsx)(o.xP,{context:t.unit}),t.load,`${t.active}(${t.sub})`,(0,y.jsx)(o.xP,{context:t.description})];s.push([...e,(0,y.jsx)(u.rA,{icon:"place",title:"添加",onClick:()=>{Z([...e])}})])}ie=s,N(s)}},te=(e,s)=>{R({open:!0,title:t("create"===e?"新建 systemd 服务":"编辑 systemd 服务"),context_div:(0,y.jsx)(ne,{mode:e,unit_name:s,onClose:()=>R({open:!1}),onDone:()=>{R({open:!1}),l.ws.send(new c.hf(c.HK.systemd_inside_get)),K&&ee(),M([]),Z([])}})})};return(0,y.jsxs)("div",{children:[(0,y.jsx)(d.aZ,{children:(0,y.jsx)(u.Z$,{defaultStatus:!1,text:t("系统systemd单元"),clickFun:e=>{B(e),e?(ee(),M([])):Z([])}})}),(0,y.jsxs)(d.aZ,{position:"right",children:[s(b.oV.systemd)&&(0,y.jsx)("div",{children:(0,y.jsx)(u.rA,{icon:"add_circle",title:t("添加 systemd"),onClick:()=>{te("create")}})}),E.length>0&&(0,y.jsx)("div",{children:E[1].props.context}),H.length>0&&(0,y.jsx)("div",{children:H[0].props.context}),E.length>0&&(0,y.jsxs)("div",{children:[s(b.oV.systemd)&&(0,y.jsx)(u.rA,{icon:"remove",title:"从实时监控删除",onClick:()=>{(async e=>{v({open:!0,handle:async()=>{(await a.Yu.post("systemd/delete",{unit_name:e})).code===x.m.Success&&((0,g.SK)(t("删除成功")),v({open:!1,handle:null}))}})})(E[1].props.context)}}),s(b.oV.systemd)&&(0,y.jsx)(u.rA,{icon:"edit",title:"可视化编辑",onClick:()=>{te("edit",E[1].props.context)}}),s(b.oV.systemd)&&W.has(E[1].props.context)&&(0,y.jsx)(u.rA,{icon:"restart_alt",title:t("重启服务"),onClick:()=>{Q(E[1].props.context)}}),(0,y.jsx)(u.rA,{icon:"print",title:"打印日志",onClick:()=>{J(E[1].props.context)}})]}),H.length>0&&(0,y.jsxs)("div",{children:[s(b.oV.systemd)&&(0,y.jsx)(u.rA,{icon:"delete",title:"删除系统上的sytemd",onClick:()=>{(async e=>{v({open:!0,handle:async()=>{(await a.Yu.post("systemd/sys/delete",{unit_name:e})).code===x.m.Success&&((0,g.SK)(t("删除成功")),v({open:!1,handle:null}))}})})(H[0].props.context)}}),(0,y.jsx)(u.rA,{icon:"print",title:"打印日志",onClick:()=>{J(H[0].props.context)}}),s(b.oV.systemd)&&(0,y.jsx)(u.rA,{icon:"restart_alt",title:t("重启服务"),onClick:()=>{Q(H[0].props.context)}}),s(b.oV.systemd)&&(0,y.jsx)(u.rA,{icon:"text_fields",title:"sytemd文件内容",onClick:()=>{(async t=>{const s=await a.Yu.post("systemd/get/context",{unit_name:t});s.code===x.m.Success&&(U({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===x.m.Success&&S.xK.set_value_temp("")}}),S.xK.set_value_temp(s.data.context))})(H[0].props.context)}}),s(b.oV.systemd)&&!W.has(H[0].props.context)&&(0,y.jsx)(u.rA,{icon:"plus_one",title:"添加到管理",onClick:()=>(async e=>{const s=await a.Yu.post("systemd/add",{unit_name:e});s.code===x.m.Success&&(X(new Set(s.data)),(0,g.SK)(t("添加成功")))})(H[0].props.context)})]})]}),(0,y.jsxs)(i.xh,{children:[K&&(0,y.jsx)(i.fI,{children:(0,y.jsx)(i.VP,{widthPer:80,children:(0,y.jsx)(o.uF,{title:`systemd系统单元(${F.length})`,rightTopCom:(0,y.jsx)(_.Sm,{placeholder:"过滤单元",value:G,handleInputChange:e=>{D(e)},handlerEnter:()=>{const e=[];if(G){for(const t of ie)(t[0].props.context.includes(G)||t[3].props.context.includes(G))&&e.push(t);N(e)}else N(ie)}}),children:(0,y.jsx)(h.X,{headers:A,rows:F,width:"10rem"})})})}),0===P.length&&!K&&(0,y.jsx)(I.h,{context:"没有管理的单元 or 加载中请等待..."}),0!==P.length&&!K&&(0,y.jsx)(i.fI,{children:(0,y.jsx)(i.VP,{widthPer:80,children:(0,y.jsx)(o.uF,{title:`filecat监控单元(${P.length})`,rightTopCom:(0,y.jsx)(_.Sm,{placeholder:"过滤单元",value:z,handleInputChange:e=>{T(e)}}),children:(0,y.jsx)(h.X,{headers:k,rows:P,width:"10rem"})})})})]}),(0,y.jsx)(O,{})]})}function ce(){const{t:e}=(0,p.Bd)(),t=[{title:e("放行"),value:"allow"},{title:e("拒绝"),value:"deny"},{title:e("限速"),value:"limit"},{title:e("拒绝响应"),value:"reject"}],s=[{title:e("入站"),value:"in"},{title:e("出站"),value:"out"}],[r,c]=(0,n.useState)(null),[l,j]=(0,n.useState)("allow"),[w,v]=(0,n.useState)("in"),[k,S]=(0,n.useState)("tcp"),[b,C]=(0,n.useState)(""),[A,V]=(0,n.useState)(""),[P,$]=(0,n.useState)("list"),[Y,F]=(0,n.useState)([]),[N,E]=(0,n.useState)(""),[M,K]=(0,n.useState)(!1),[B,H]=(0,m.fp)(f.AG.confirm),Z=async()=>{try{const e=await a.V_.get("status");e.code===x.m.Success&&c(e.data)}catch(e){}},G=async()=>{K(!0);try{const e=await a.V_.get("rules");if(e.code===x.m.Success){const t=e.data;F(t?.rules??[]),E(t?.raw??"")}}catch(e){F([]),E("")}finally{K(!1)}};(0,n.useEffect)(()=>{Z(),G()},[]);const D=!0===r?.installed,z=!0===r?.active;return(0,y.jsxs)("div",{children:[(0,y.jsxs)(d.aZ,{position:"right",children:[(0,y.jsxs)("div",{children:[e("已安装"),": ",D?(0,y.jsx)("span",{style:{color:"green"},children:"✓"}):(0,y.jsx)("span",{style:{color:"red"},children:"✗"})]}),(0,y.jsxs)("div",{children:[e("已启用"),": ",z?(0,y.jsx)("span",{style:{color:"green"},children:"✓"}):(0,y.jsx)("span",{style:{color:"gray"},children:"✗"})]}),D&&(0,y.jsx)(u.rA,{icon:"power_settings_new",title:e(z?"停用":"启用"),onClick:()=>(async t=>{try{const s=await a.V_.post("enable",{enabled:t});if(s.code!==x.m.Success)return void(0,g.zN)(s.message||e("操作失败"));(0,g.SK)(s.data||e(t?"已启用":"已停用")),Z(),G()}catch(e){}})(!z)}),(0,y.jsx)(u.rA,{icon:"refresh",title:e("刷新规则"),onClick:G})]}),(0,y.jsxs)(i.xh,{children:[(0,y.jsx)(i.fI,{children:(0,y.jsx)(i.VP,{widthPer:35,children:(0,y.jsxs)(o.uF,{title:e("添加ufw规则"),rightTopCom:(0,y.jsx)(u.rA,{icon:"add",title:e("添加"),onClick:async()=>{if(b.trim())try{const t=await a.V_.post("rule/add",{action:l,direction:w,proto:k,port:b.trim(),from:"in"===w&&A.trim()||void 0});if(t.code!==x.m.Success)return void(0,g.zN)(t.message||e("操作失败"));(0,g.SK)(t.data||e("已添加")),G()}catch(e){}else(0,g.zN)(e("请填写端口号"))}}),children:[(0,y.jsx)(_.BC,{label:e("动作"),label_width:"4rem",input_max_width:"8rem",children:(0,y.jsx)(_.l6,{options:t,value:l,onChange:e=>j(e),defaultValue:"allow"})}),(0,y.jsx)(_.BC,{label:e("方向"),label_width:"4rem",input_max_width:"8rem",children:(0,y.jsx)(_.l6,{options:s,value:w,onChange:e=>v(e),defaultValue:"in"})}),(0,y.jsx)(_.BC,{label:e("协议"),label_width:"4rem",input_max_width:"8rem",children:(0,y.jsx)(_.l6,{options:[{title:"tcp",value:"tcp"},{title:"udp",value:"udp"}],value:k,onChange:e=>S(e),defaultValue:"tcp"})}),(0,y.jsx)(_.BC,{label:e("端口"),label_width:"4rem",required:!0,children:(0,y.jsx)(_.Sm,{maxWidth:"20rem",placeholder:e("可填范围如 1000:2000"),value:b,handleInputChange:e=>C(e)})}),"in"===w&&(0,y.jsx)(_.BC,{label:e("来源"),label_width:"4rem",children:(0,y.jsx)(_.Sm,{maxWidth:"20rem",placeholder:e("IP/网段,可选"),value:A,handleInputChange:e=>V(e)})})]})})}),(0,y.jsx)(i.fI,{children:(0,y.jsx)(i.VP,{widthPer:80,children:(0,y.jsxs)(o.uF,{title:e("规则列表"),rightTopCom:(0,y.jsxs)("div",{style:{display:"flex",gap:"0.4rem"},children:[(0,y.jsx)(u.C3,{text:e("名单视图"),clickFun:()=>$("list")}),(0,y.jsx)(u.C3,{text:e("文本视图"),clickFun:()=>$("text")})]}),children:[M&&(0,y.jsx)(I.h,{context:e("加载中...")}),!M&&"list"===P&&(0===Y.length?(0,y.jsx)(I.h,{context:e("暂无规则")}):(0,y.jsx)(h.X,{headers:[e("编号"),e("目标(To)"),e("动作"),e("fw_from"),e("备注"),e("操作")],rows:Y.map(t=>[t.number,(0,y.jsx)(o.xP,{context:t.to,tip_context:t.to}),t.action,t.from?(0,y.jsx)(o.xP,{context:t.from,tip_context:t.from}):"",t.description||"",(0,y.jsx)(u.rA,{icon:"delete",title:e("删除规则"),onClick:()=>(async(t,s,n)=>{H({open:!0,title:e("确定删除吗?"),sub_title:e(`${s} ${n}`),handle:async()=>{try{const s=await a.V_.post("ufw/rule/del",{number:t});if(s.code!==x.m.Success)return void(0,g.zN)(s.message||e("操作失败"));(0,g.SK)(s.data||e("规则已删除")),H({open:!1,handle:null}),G()}catch(e){}}})})(t.number,t.to,t.from)})]),width:"8rem"})),!M&&"text"===P&&(N?(0,y.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-all",fontSize:"0.85rem",margin:0},children:N}):(0,y.jsx)(I.h,{context:e("暂无规则")}))]})})})]})]})}function le(e){const{t}=(0,p.Bd)(),[s,n]=(0,m.fp)(f.AG.user_base_info),o=[{index:1,name:t("系统性能"),rto:"sys/",component:(0,y.jsx)(F,{})},{index:2,name:t("系统进程"),rto:"process/",component:(0,y.jsx)(L,{})},{index:3,name:t("doc_ct"),rto:"docker/",component:(0,y.jsx)(T,{})}];if(s.sys===b.XM.linux){(s.user_data?.is_root||(s.user_data?.auth_list??[]).includes(b.oV.systemd))&&o.push({index:4,name:t("systemd"),rto:"systemd/",component:(0,y.jsx)(re,{})});(s.user_data?.is_root||(s.user_data?.auth_list??[]).includes(b.oV.firewall))&&s.sysSoftWare?.[j.jk.ufw]?.installed&&o.push({index:5,name:t("防火墙"),rto:"firewall/",component:(0,y.jsx)(ce,{})})}return(0,y.jsx)(i.W1,{optionList:o,father_route:Z.o.info})}}}]);
|