filecat 7.1.0 → 7.2.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/1149.e3a538a30556fbad25dd.js +1 -0
- package/build/dist/1384.8d1ae0401cf32bf88b83.js +1 -0
- package/build/dist/2091.5bc71c19b26140f00a48.js +1 -0
- package/build/dist/2851.b30185a469835aca77d0.js +1 -0
- package/build/dist/{3328.98c3000736863aaa904f.js → 3328.2d65fbe893d02787f48a.js} +1 -1
- package/build/dist/3659.97898b4c2bc7765a91f7.js +1 -0
- package/build/dist/4476.bd49273fea4a2679f45e.js +1 -0
- package/build/dist/4903.bf39a395daf5bc283e4a.js +1 -0
- package/build/dist/5308.bff6efb3c9335ad227da.js +1 -0
- package/build/dist/6805.6b181f3ae37028391d63.js +1 -0
- package/build/dist/7200.d4aa731754f2359a4f7b.js +1 -0
- package/build/dist/8603.d7eea8d253cff5aef62c.js +1 -0
- package/build/dist/8765.ca9ec23eec760dab2bec.js +1 -0
- package/build/dist/9299.4ee1fc7465badad59aa6.js +1 -0
- package/build/dist/9546.de5433de4cead0a0e4b1.js +1 -0
- package/build/dist/{3426.b4464d74998fb12ec5ac.js → 9878.39d098f7cdb90f45bbfd.js} +1 -1
- package/build/dist/index.html +1 -1
- package/build/dist/main.b8e4dd383adfa223d84e.js +2 -0
- package/build/main.js +1 -1
- package/package.json +1 -1
- package/build/dist/1149.cbeaf4f434dffe8aa534.js +0 -1
- package/build/dist/1384.edbad9c24d883a59724d.js +0 -1
- package/build/dist/2851.965eb7476fea48962f44.js +0 -1
- package/build/dist/3659.f0dbf1eed0113cfeb0d2.js +0 -1
- package/build/dist/4903.72481ee04812f34d5e96.js +0 -1
- package/build/dist/5308.78bd4ed591fdfdcd82e7.js +0 -1
- package/build/dist/6805.fc152a28ee35083b9cf9.js +0 -1
- package/build/dist/6966.2432063a0d9349aff6b4.js +0 -1
- package/build/dist/8603.5b96680516f93196c2c0.js +0 -1
- package/build/dist/8714.8fcad52f220ca72a1b6f.js +0 -1
- package/build/dist/8765.4b41dd887f09c4c1a556.js +0 -1
- package/build/dist/9546.421e124c9297955f5a4d.js +0 -1
- package/build/dist/main.f7d3e41cbec1e3c89682.js +0 -2
- /package/build/dist/{main.f7d3e41cbec1e3c89682.js.LICENSE.txt → main.b8e4dd383adfa223d84e.js.LICENSE.txt} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[7200],{7200(e,t,n){n.r(t),n.d(t,{default:()=>Ye});var r=n(96540),s=n(7523),o=n(34843),c=n(82893),a=n(78247),l=n(23430),i=n(85997),u=n(57952),d=n(62042),m=n(53459),h=n(14284),f=n(57889),p=n(23496),g=n(86149),_=n(42845),v=n(1575),y=n(89781),k=n(61396),w=n(46762),b=n(73337),x=n(89552),$=n(86059),M=n(58903);const S=(0,$.of)({tableGroup:"block",cellContent:"block+",cellAttributes:{}}),j={align:{default:null}},E={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",attrs:j,parseDOM:[{tag:"p"}],toDOM:e=>["p",e.attrs.align?{style:`text-align:${e.attrs.align}`}:{},0]},heading:{content:"inline*",group:"block",attrs:{level:{default:1},...j},defining:!0,parseDOM:[1,2,3,4,5,6].map(e=>({tag:`h${e}`,attrs:{level:e}})),toDOM(e){const t=e.attrs.align?{style:`text-align:${e.attrs.align}`}:{};return[`h${e.attrs.level}`,t,0]}},bullet_list:{group:"block",content:"list_item+",parseDOM:[{tag:"ul"}],toDOM:()=>["ul",0]},ordered_list:{group:"block",content:"list_item+",attrs:{order:{default:1}},parseDOM:[{tag:"ol",getAttrs:e=>({order:Number(e.getAttribute("start")??1)})}],toDOM:e=>1===e.attrs.order?["ol",0]:["ol",{start:e.attrs.order},0]},list_item:{content:"paragraph block*",defining:!0,attrs:{checked:{default:null}},parseDOM:[{tag:"li",getAttrs:e=>{const t=e,n=t.querySelector("input[type=checkbox]");if(n)return{checked:n.checked};const r=t.getAttribute("data-checked");return{checked:null===r?null:"true"===r}}}],toDOM:e=>null!==e.attrs.checked?["li",{"data-checked":String(e.attrs.checked)},0]:["li",0]},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:()=>["blockquote",0]},code_block:{content:"text*",group:"block",marks:"",defining:!0,attrs:{language:{default:""}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>{const t=e.querySelector("code"),n=/language-([\w-]+)/.exec(t?.className??"");return{language:n?n[1]:""}}}],toDOM:e=>["pre",{"data-language":e.attrs.language},["code",0]]},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>["hr"]},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>["br"]},image:{inline:!0,group:"inline",draggable:!0,attrs:{src:{},alt:{default:null},title:{default:null}},parseDOM:[{tag:"img[src]",getAttrs:e=>{const t=e;return{src:t.getAttribute("src"),alt:t.getAttribute("alt"),title:t.getAttribute("title")}}}],toDOM(e){const{src:t,alt:n,title:r}=e.attrs,s={src:t};return n&&(s.alt=n),r&&(s.title=r),["img",s]}},text:{group:"inline"},...S},A={strong:{parseDOM:[{tag:"strong"},{tag:"b"},{style:"font-weight=bold"}],toDOM:()=>["strong",0]},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"}],toDOM:()=>["em",0]},strike:{parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"}],toDOM:()=>["s",0]},code:{parseDOM:[{tag:"code",getAttrs:e=>"PRE"!==e.parentElement?.tagName&&null}],toDOM:()=>["code",0]},link:{attrs:{href:{},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:e=>{const t=e;return{href:t.getAttribute("href"),title:t.getAttribute("title")}}}],toDOM(e){const{href:t,title:n}=e.attrs;return["a",{href:t,title:n,rel:"noopener noreferrer",target:"_blank"},0]}}},C=new M.Sj({nodes:E,marks:A});const O=new(n(22091).A)({html:!0,linkify:!0,breaks:!1,typographer:!1});function D(e){const t=O.render(e??""),n=document.createElement("div");return n.innerHTML=t,M.S4.fromSchema(C).parse(n)}function N(e){let t="";return e.forEach(e=>{if(e.isText){let n=e.marks.some(e=>"code"===e.type.name)?e.text??"":function(e){return e.replace(/([\\`*_[\]<>])/g,"\\$1")}(e.text??"");for(const t of e.marks)switch(t.type.name){case"code":n=`\`${e.text??""}\``;break;case"strong":n=`**${n}**`;break;case"em":n=`*${n}*`;break;case"strike":n=`~~${n}~~`;break;case"link":n=`[${n}](${t.attrs.href}${t.attrs.title?` "${t.attrs.title}"`:""})`}t+=n}else if("image"===e.type.name){const{src:n,alt:r,title:s}=e.attrs;t+=``}else"hard_break"===e.type.name&&(t+=" \n")}),t}function L(e){const t=[];if(e.forEach(e=>{const n=[],r=[];e.forEach(e=>{var t;n.push((t=e.textContent,t.replace(/\|/g,"\\|").replace(/\n/g," ")).trim()),r.push("table_header"===e.type.name)}),t.push({cells:n,header_flags:r})}),0===t.length)return"";const n=Math.max(...t.map(e=>e.cells.length)),r=t[0].header_flags.some(e=>e),s=Array.from({length:n},(e,n)=>Math.max(3,...t.map(e=>z(e.cells[n]??"")))),o=e=>`| ${Array.from({length:n},(t,n)=>{return r=e[n]??"",o=s[n],r+" ".repeat(Math.max(0,o-z(r)));var r,o}).join(" | ")} |`,c=[];if(r){c.push(o(t[0].cells)),c.push(`| ${s.map(e=>"-".repeat(e)).join(" | ")} |`);for(let e=1;e<t.length;e++)c.push(o(t[e].cells))}else{c.push(o(new Array(n).fill(""))),c.push(`| ${s.map(e=>"-".repeat(e)).join(" | ")} |`);for(const e of t)c.push(o(e.cells))}return c.join("\n")}function z(e){let t=0;for(const n of e){const e=n.codePointAt(0)??0;t+=e>=4352&&e<=4447||e>=11904&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65072&&e<=65135||e>=65280&&e<=65376||e>=65504&&e<=65510?2:1}return t}function R(e,t=""){switch(e.type.name){case"paragraph":default:return t+N(e);case"heading":return`${t}${"#".repeat(e.attrs.level)} ${N(e)}`;case"blockquote":return G(e,"").split("\n").map(e=>`${t}> ${e}`).join("\n");case"code_block":{const n=e.attrs.language??"";return`${t}\`\`\`${n}\n${e.textContent}\n${t}\`\`\``}case"horizontal_rule":return`${t}---`;case"bullet_list":{const n=[];return e.forEach((e,r,s)=>{n.push(F(e,t,`${t}- `,`${t} `,s))}),n.join("\n")}case"ordered_list":{const n=[],r=e.attrs.order??1;return e.forEach((e,s,o)=>{n.push(F(e,t,`${t}${r+o}. `,`${t} `,o))}),n.join("\n")}case"table":return L(e).split("\n").map(e=>t+e).join("\n")}}function F(e,t,n,r,s){const o=e.attrs.checked,c=null===o?"":o?"[x] ":"[ ] ",a=[];e.forEach((e,t,n)=>{a.push(R(e,0===n?"":r))});const l=a.join("\n").split("\n");return n+c+l[0]+(l.length>1?"\n"+l.slice(1).join("\n"):"")}function G(e,t=""){const n=[];return e.forEach(e=>{n.push(R(e,t))}),n.join("\n\n")}function T(e){return G(e).trim()+"\n"}var P=n(74848);function I(e){const{t}=(0,g.B)(),[n,s]=(0,r.useState)(new Set),o=(0,r.useMemo)(()=>function(e){const t=[],n=[];for(const r of e){const e={...r,children:[]};for(;n.length>0&&n[n.length-1].level>=e.level;)n.pop();0===n.length?t.push(e):n[n.length-1].children.push(e),n.push(e)}return t}(e.items),[e.items]),c=(r,o)=>r.map(r=>{const a=r.children.length>0,l=n.has(r.pos),i=r.pos===e.active_pos;return(0,P.jsxs)("div",{children:[(0,P.jsxs)("div",{className:`md-outline-item md-outline-item--h${r.level}${i?" md-outline-item--active":""}`,style:{paddingLeft:.4+.75*o+"em"},title:r.text,onClick:()=>e.on_click(r),children:[(0,P.jsx)("i",{className:"material-icons md-outline-arrow"+(a?"":" md-outline-arrow--empty"),onClick:a?e=>{return t=r.pos,e.stopPropagation(),void s(e=>{const n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n});var t}:void 0,children:a?l?"arrow_right":"arrow_drop_down":""}),(0,P.jsx)("span",{className:"md-outline-text",children:r.text||t("未命名标题")})]}),a&&!l&&c(r.children,o+1)]},r.pos)});return 0===e.items.length?(0,P.jsxs)("div",{className:"md-outline md-outline--empty",children:[(0,P.jsx)("div",{className:"md-outline-header",children:t("大纲")}),(0,P.jsx)("div",{className:"md-outline-tip",children:t("no_head")})]}):(0,P.jsxs)("div",{className:"md-outline",children:[(0,P.jsx)("div",{className:"md-outline-header",children:t("大纲")}),(0,P.jsx)("div",{className:"md-outline-list",children:c(o,0)})]})}var W=n(19878);const q=new _.hs("md_source_highlight");let B=!1;function V(e){B=e}function K(e,t,n){let r=t;for(const t of e){if("string"==typeof t){r+=t.length;continue}const e=r;Array.isArray(t.children)&&(r=K(t.children,r,n)),t.scope&&n.push({from:e,to:r,cls:`hljs-${t.scope}`})}return r}function X(e,t){const n=e.textContent;if(!n)return[];let r;try{r=W.A.highlight(n,{language:"markdown",ignoreIllegals:!0})}catch{return[]}const s=[],o=r._emitter?.rootNode;o?.children&&K(o.children,0,s);const c=t+1,a=[];for(const e of s){const t=Math.min(e.from,n.length),r=Math.min(e.to,n.length);t>=r||a.push(v.NZ.inline(c+t,c+r,{class:e.cls}))}return a}function H(e){const t=[];return e.descendants((e,n)=>"code_block"!==e.type.name||(t.push(...X(e,n)),!1)),v.zF.create(e,t)}var U=n(38341),J=n(3772);function Y(e,t){return new U.fV(e,(e,n,r,s)=>{const o=e.schema.marks[t],c=n[1];if(!o||!c)return null;const a=n[0].indexOf(c);if(a<0)return null;const l=r+a,i=l+c.length,u=e.tr;return u.delete(i,s),u.delete(r,l),u.addMark(r,r+c.length,o.create()),u.removeStoredMark(o),u})}function Z(){const e=C;return(0,U.sM)({rules:[(0,U.JJ)(/^(#{1,6})\s$/,e.nodes.heading,e=>({level:e[1].length})),(0,U.JJ)(/^#([1-6])\s$/,e.nodes.heading,e=>({level:Number(e[1])})),(0,U.JJ)(/^```([\w-]*)\s$/,e.nodes.code_block,e=>({language:e[1]??""})),(0,U.tG)(/^\s*>\s$/,e.nodes.blockquote),(0,U.tG)(/^\s*([-+*])\s$/,e.nodes.bullet_list),(0,U.tG)(/^(\d+)\.\s$/,e.nodes.ordered_list,e=>({order:Number(e[1])})),Y(/(?:\*\*)([^*]+)(?:\*\*)$/,"strong"),Y(/(?:__)([^_]+)(?:__)$/,"strong"),Y(/(?<![*])\*([^*]+)\*$/,"em"),Y(/(?<![_])_([^_]+)_$/,"em"),Y(/(?:~~)([^~]+)(?:~~)$/,"strike"),Y(/(?:`)([^`]+)(?:`)$/,"code"),...U.Fr,U.gO]})}const Q=(e,t)=>{const{$from:n,empty:r}=e.selection;if(!r||"paragraph"!==n.parent.type.name)return!1;const s=n.parent.textContent;if(!s.trim())return!1;const o=function(e){const t=e.trim(),n=/^#([1-6])$/.exec(t);if(n)return{type:"heading",attrs:{level:Number(n[1])}};const r=/^(#{1,6})$/.exec(t);if(r)return{type:"heading",attrs:{level:r[1].length}};const s=/^```([\w-]*)$/.exec(t);return s?{type:"code_block",attrs:{language:s[1]??""}}:/^(?:-{3,}|\*{3,}|_{3,})$/.test(t.replace(/\s+/g,""))?{type:"horizontal_rule"}:/^>\s*$/.test(t)?{type:"blockquote"}:/^[-+*]\s*$/.test(t)?{type:"bullet_list"}:/^\d+[.)]?$/.test(t)?{type:"ordered_list"}:null}(s);if(!o)return!1;if("blockquote"===o.type&&n.depth>1)return!1;const c=e.schema.nodes[o.type];if(!c)return!1;const a=n.before(n.depth),l=n.after(n.depth);if(t){const n=e.tr,r=c.createAndFill(o.attrs)??c.create(o.attrs);n.replaceWith(a,l,r),n.scrollIntoView(),t(n)}return!0};function ee(e){return(t,n)=>{const r=t.schema.marks[e];return!!r&&(0,w.wh)(r)(t,n)}}function te(e,t={}){return(n,r)=>{const s=n.schema.nodes[e];if(!s)return!1;const{$from:o,$to:c}=n.selection,a=o.blockRange(c);if(!a)return!1;const l=o.parent,i=l.type===s&&Object.entries(t).every(([e,t])=>l.attrs[e]===t),u=i?n.schema.nodes.paragraph:s,d=i?{}:t;return r&&r(n.tr.setBlockType(a.start,a.end,u,d)),!0}}const ne=(e,t)=>(0,J.Sd)(e.schema.nodes.bullet_list)(e,t),re=(e,t)=>(0,J.Sd)(e.schema.nodes.ordered_list)(e,t),se=(e,t)=>{const{blockquote:n}=e.schema.nodes,{$from:r,$to:s}=e.selection,o=r.blockRange(s);if(!o)return!1;if(o.parent.type===n&&o.depth>0){const n=r.before(o.depth),s=e.tr.doc.nodeAt(n);if(s&&1===s.childCount)return t&&t(e.tr.replaceWith(n,n+s.nodeSize,s.child(0)).scrollIntoView()),!0;if(t){const n=e.tr,s=r.parent,c=r.after(o.depth);n.delete(o.start,o.end),n.insert(c,s),t(n.scrollIntoView())}return!0}return t&&t(e.tr.wrap(o,[{type:n}]).scrollIntoView()),!0},oe={sink:(0,J.$B)(C.nodes.list_item),lift:(0,J.T2)(C.nodes.list_item),split:(0,J.wn)(C.nodes.list_item),wrap_bullet:ne,wrap_ordered:re};n(41631),n(50576),n(70432);function ce(e){return 0===e?te("paragraph"):te("heading",{level:e})}function ae(e){return!(!e.ctrlKey&&!e.metaKey)}function le(e,t){return(0,$.D8)(1)(e,t)}function ie(e){if(1!==e.childCount)return!1;const t=e.firstChild;return!!t&&"code_block"===t.type.name&&"markdown"===t.attrs.language}const ue=r.forwardRef(function(e,t){const n=(0,r.useRef)(null),s=(0,r.useRef)(null),o=(0,r.useRef)(e.on_change),c=(0,r.useRef)(e.on_save),a=(0,r.useRef)(e.on_selection_change),l=(0,r.useRef)(e.on_source_mode_change);return(0,r.useEffect)(()=>{o.current=e.on_change,c.current=e.on_save,a.current=e.on_selection_change,l.current=e.on_source_mode_change}),(0,r.useEffect)(()=>{if(!n.current)return;const r=_.$t.create({doc:D(e.value??""),plugins:[(0,y.b6)(),new _.k_({key:q,state:{init:(e,t)=>v.zF.empty,apply:(e,t,n,r)=>B?e.docChanged?H(r.doc):q.getState(r)??v.zF.empty:v.zF.empty},props:{decorations(e){if(!B)return null;const t=q.getState(e);return t&&t.find().length?t:H(e.doc)}}}),Z(),(0,k.w)({"Mod-z":y.tN,"Mod-y":y.ZS,"Mod-Shift-z":y.ZS,"Mod-b":ee("strong"),"Mod-i":ee("em"),"Mod-Shift-x":ee("strike"),"Mod-`":ee("code"),"Mod-1":(e,t)=>ce(1)(e,t),"Mod-2":(e,t)=>ce(2)(e,t),"Mod-3":(e,t)=>ce(3)(e,t),"Mod-0":(e,t)=>ce(0)(e,t),"Mod-Shift-8":ne,"Mod-Shift-9":re,"Mod-Shift-.":se,Tab:oe.sink,"Shift-Tab":oe.lift,"Mod-Enter":le,"Mod-s":()=>(c.current?.(),!0)}),(0,$.LF)({allowTableNodeSelection:!0}),(0,$.AL)(),(0,b.A)({color:"var(--primary, #1a73e8)",width:2}),(0,x.z)(),(0,k.w)({Enter:(0,w.st)(Q,w.pC,oe.split,w.Z1,w.iz,w.aw),"Shift-Enter":(e,t)=>{const{hard_break:n}=e.schema.nodes;return t&&t(e.tr.replaceSelectionWith(n.create()).scrollIntoView()),!0},"Mod-Enter":w.I$}),(0,k.w)(w.RV)]}),i=new v.Lz(n.current,{state:r,editable:()=>!1!==e.editable,handleClickOn(e,t,n,r,s){if(!ae(s))return!1;const o=function(e){if(!(e instanceof Element))return null;const t=e.closest("a[href]"),n=t?.getAttribute("href");return n||null}(s.target)??function(e,t){const n=e.doc.content.size,r=Math.max(0,Math.min(t,n));let s;try{s=e.doc.resolve(r)}catch{return null}for(const t of[1,-1]){const s=1===t?r:r-1;if(!(s<0||s>=n))try{const t=e.doc.resolve(s).marks().find(e=>"link"===e.type.name);if(t?.attrs?.href)return t.attrs.href}catch{}}try{const e=s.parent.marks.find(e=>"link"===e.type.name);if(e?.attrs?.href)return e.attrs.href}catch{}return null}(e.state,t);return!!o&&(window.open(o,"_blank","noopener,noreferrer"),!0)},handleDOMEvents:{keydown:(e,t)=>{if(ae(t)&&e.dom.classList.add("md-ctrl-down"),ie(e.state.doc)&&"Enter"===t.key&&!t.ctrlKey&&!t.metaKey&&!t.altKey){t.preventDefault();const{from:n,to:r}=e.state.selection;return e.dispatch(e.state.tr.insertText("\n",n,r).scrollIntoView()),!0}return!1},keyup:(e,t)=>(ae(t)||e.dom.classList.remove("md-ctrl-down"),!1),blur:e=>(e.dom.classList.remove("md-ctrl-down"),!1),beforeinput:(e,t)=>{if(!ie(e.state.doc))return!1;const n=t;if("insertText"!==n.inputType)return!1;const r=n.data;if(null==r)return!1;n.preventDefault();const{from:s,to:o}=e.state.selection;return e.dispatch(e.state.tr.insertText(r.replace(/\r\n?/g,"\n"),s,o).scrollIntoView()),!0}},dispatchTransaction(e){const t=i.state.apply(e);i.updateState(t);const n=ie(t.doc);V(n),n?i.dom.classList.add("md-source-mode"):i.dom.classList.remove("md-source-mode"),n!==ie(e.before)&&l.current?.(n),e.docChanged&&o.current?.(n?t.doc.textContent:T(t.doc)),(e.selectionSet||e.docChanged)&&a.current?.()},attributes:{class:"md-wysiwyg-content",spellcheck:"false"}});if(s.current=i,e.initial_source_mode&&!ie(i.state.doc)){const e=T(i.state.doc),t=i.state.schema.nodes.code_block.create({language:"markdown"},e?i.state.schema.text(e):null),n=i.state.tr;n.replaceWith(0,i.state.doc.content.size,t),n.setMeta("addToHistory",!1),i.dispatch(n)}const u={get_markdown:()=>ie(i.state.doc)?i.state.doc.textContent:T(i.state.doc),set_markdown:e=>{const t=D(e);i.dispatch(i.state.tr.replaceWith(0,i.state.doc.content.size,t.content))},focus:()=>i.focus(),get_view:()=>s.current,in_table:()=>function(e){const{$from:t}=e.selection;for(let e=t.depth;e>0;e--){if("table"===t.node(e).type.name)return!0}return!1}(i.state),active_marks:()=>(i.state.storedMarks??i.state.selection.$from.marks()).map(e=>e.type.name),active_block:()=>{const{$from:e}=i.state.selection;for(let t=e.depth;t>0;t--){const n=e.node(t);if("heading"===n.type.name)return{name:"heading",level:n.attrs.level};if("paragraph"===n.type.name)return{name:"paragraph"}}return{name:"paragraph"}},insert_table:(e=3,t=3)=>{const n=function(e,t,n){const r=(0,$.e)(e),s=r.table,o=r.row,c=r.cell,a=r.header_cell??r.cell;if(!s||!o||!c)return null;const l=e=>o.create(null,Array.from({length:t},()=>e.createAndFill())),i=l(a),u=Array.from({length:n},()=>l(c));return s.create(null,[i,...u])}(i.state.schema,e,t);if(!n)return;const{from:r}=i.state.selection,s=i.state.doc.resolve(r);let o=r;for(let e=s.depth;e>0;e--)if("table"===s.node(e).type.name){o=s.after(e);break}const c=i.state.tr;o===r?c.replaceSelectionWith(n):c.insert(o,n),i.dispatch(c.scrollIntoView());const a=i.state.doc.resolve(Math.min(o+3,i.state.doc.content.size));try{i.dispatch(i.state.tr.setSelection(i.state.selection.constructor.near(a)))}catch{}},get_headings:()=>function(e){const t=[];return e.doc.descendants((e,n)=>("heading"!==e.type.name||t.push({level:e.attrs.level,text:e.textContent,pos:n}),!0)),t}(i.state),scroll_to_pos:e=>{const t=i.state.doc.content.size,n=Math.max(0,Math.min(e,t)),r=i.state.doc.nodeAt(n);let s;try{s=r?_.U3.near(i.state.doc.resolve(n+1),1):_.U3.near(i.state.doc.resolve(n),1)}catch{s=_.U3.near(i.state.doc.resolve(0),1)}i.dispatch(i.state.tr.setSelection(s).scrollIntoView()),i.focus()},is_source_mode:()=>ie(i.state.doc),enter_source_mode:()=>{if(ie(i.state.doc))return;const e=T(i.state.doc),t=i.state.schema.nodes.code_block.create({language:"markdown"},e?i.state.schema.text(e):null),n=i.state.tr;n.replaceWith(0,i.state.doc.content.size,t),V(!0),i.dispatch(n),i.dom.classList.add("md-source-mode")},exit_source_mode:()=>{if(!ie(i.state.doc))return;const e=D(i.state.doc.textContent),t=i.state.tr;t.replaceWith(0,i.state.doc.content.size,e.content),V(!1),i.dispatch(t),i.dom.classList.remove("md-source-mode")}};return"function"==typeof t?t(u):t&&(t.current=u),e.on_ready?.(u),()=>{i.destroy(),s.current=null}},[]),(0,P.jsx)("div",{className:"md-wysiwyg",ref:n})});function de(e){const{t}=(0,g.B)(),n=(0,r.useRef)(null),[s,o]=(0,r.useState)({marks:[],block:{name:"paragraph"}}),[c,a]=(0,r.useState)(null),l=(0,r.useCallback)(()=>{const t=e.get_view();if(!t)return;const n=t.state.selection,r=t.state.storedMarks??n.$from.marks();if(o({marks:r.map(e=>e.type.name),block:me(n.$from)}),n.empty)return void a(null);const s=t.coordsAtPos(n.from),c=t.coordsAtPos(n.to),l=(Math.min(s.left,c.left)+Math.max(s.right,c.right))/2,i=Math.min(s.top,c.top),u=Math.max(s.bottom,c.bottom);a({top:i,bottom:u,left:l})},[e.get_view]);(0,r.useEffect)(()=>{l();const t=e.get_view();if(!t)return;const n=()=>l();t.dom.addEventListener("keyup",n),t.dom.addEventListener("mouseup",n),document.addEventListener("selectionchange",n);const r=t.dom.closest(".md-editor-context");return r?.addEventListener("scroll",n,{passive:!0}),window.addEventListener("resize",n),()=>{t.dom.removeEventListener("keyup",n),t.dom.removeEventListener("mouseup",n),document.removeEventListener("selectionchange",n),r?.removeEventListener("scroll",n),window.removeEventListener("resize",n)}},[l,e.get_view,e.refresh_key]);const i=t=>{const n=e.get_view();n&&(t(n.state,n.dispatch),n.focus(),l())},u=e=>s.marks.includes(e),d=e=>"heading"===s.block.name&&s.block.level===e,[m,h]=(0,r.useState)({w:0,h:36});if((0,r.useLayoutEffect)(()=>{if(!c||!n.current)return;const e=n.current.offsetWidth,t=n.current.offsetHeight;h(n=>n.w===e&&n.h===t?n:{w:e,h:t})},[c,e.refresh_key]),!c)return null;const f=(e,n,r,s,o=!1)=>(0,P.jsx)("button",{className:"mdtb__btn"+(o?" mdtb__btn--on":""),title:t(r),onMouseDown:e=>e.preventDefault(),onClick:s,children:n},e),p=m.w/2,_=p+4,v=Math.max(_,window.innerWidth-p-4),y=document.querySelector(".header")?.getBoundingClientRect().bottom??0,k=c.top-m.h-8,w=k<y+4,b={top:w?Math.min(c.bottom+8,window.innerHeight-m.h-4):k,left:Math.min(v,Math.max(_,c.left))};return(0,P.jsxs)("div",{className:"mdtb mdtb--floating"+(w?" mdtb--below":""),ref:n,style:b,children:[f("h1","H1","一级标题",()=>i(te("heading",{level:1})),d(1)),f("h2","H2","二级标题",()=>i(te("heading",{level:2})),d(2)),f("h3","H3","三级标题",()=>i(te("heading",{level:3})),d(3)),(0,P.jsx)("span",{className:"mdtb__sep"}),f("b","B","加粗",()=>i(ee("strong")),u("strong")),f("i","I","斜体",()=>i(ee("em")),u("em")),f("s","S","删除线",()=>i(ee("strike")),u("strike")),f("code","</>","行内代码",()=>i(ee("code")),u("code")),(0,P.jsx)("span",{className:"mdtb__sep"}),f("ul","≔","无序列表",()=>i(ne)),f("ol","1.","有序列表",()=>i(re)),f("quote","❝","引用",()=>i(se))]})}function me(e){for(let t=e.depth;t>0;t--){const n=e.node(t).type.name;if("heading"===n)return{name:"heading",level:e.node(t).attrs.level};if("paragraph"===n)return{name:"paragraph"}}return{name:"paragraph"}}var he=n(75725);const fe="cut",pe="copy",ge="paste",_e="strong",ve="em",ye="strike",ke="code",we="h1",be="h2",xe="h3",$e="paragraph",Me="bullet",Se="ordered",je="quote",Ee="code_block",Ae="clean",Ce="row_before",Oe="row_after",De="row_delete",Ne="col_before",Le="col_after",ze="col_delete",Re="header_toggle",Fe="cell_merge",Ge="cell_split",Te="table_delete",Pe="table_insert",Ie="select_all";function We(e){const{t}=(0,g.B)(),[n,s]=(0,r.useState)(null),o=(0,r.useRef)(e.get_view);o.current=e.get_view,(0,r.useEffect)(()=>{const e=e=>{const t=o.current();if(!t)return;const n=e.target;if(!n||!n.closest(".md-wysiwyg-content"))return;e.preventDefault();const r=t.posAtCoords({left:e.clientX,top:e.clientY});if(r){const e=t.state.selection;if(r.pos<e.from||r.pos>e.to){const{TextSelection:e}=t.state.selection.constructor;try{t.dispatch(t.state.tr.setSelection(e.near(t.state.doc.resolve(r.pos))))}catch{}}}const c=!!n.closest("td, th");s({x:e.clientX,y:e.clientY,in_table:c||(0,$.aH)(t.state)})};return document.addEventListener("contextmenu",e,!0),()=>document.removeEventListener("contextmenu",e,!0)},[]);const c=()=>s(null),a=(0,r.useCallback)(e=>{const t=o.current();t&&(e(t.state,t.dispatch),t.focus(),c())},[]),l=e=>{const t=o.current();t?.focus(),document.execCommand(e),c()};if(!n)return null;const i=n.in_table?[{r:t("上方插入行"),v:Ce},{r:t("下方插入行"),v:Oe},{r:t("左侧插入列"),v:Ne},{r:t("右侧插入列"),v:Le},{r:t("删除行"),v:De},{r:t("删除列"),v:ze},{r:t("切换表头行"),v:Re},{r:t("合并单元格"),v:Fe},{r:t("拆分单元格"),v:Ge},{r:t("删除表格"),v:Te}]:[],u=[{r:t("剪切"),v:fe},{r:t("复制"),v:pe},{r:t("粘贴"),v:ge},{r:t("格式"),v:"format",items:[{r:t("加粗"),v:_e},{r:t("斜体"),v:ve},{r:t("删除线"),v:ye},{r:t("行内代码"),v:ke}]},{r:t("段落"),v:"block",items:[{r:t("一级标题"),v:we},{r:t("二级标题"),v:be},{r:t("三级标题"),v:xe},{r:t("正文"),v:$e}]},{r:t("插入"),v:"insert",items:[{r:t("无序列表"),v:Me},{r:t("有序列表"),v:Se},{r:t("引用"),v:je},{r:t("代码块"),v:Ee},{r:t("插入表格"),v:Pe}]},...i.length?[{r:t("表格"),v:"table",items:i}]:[],{r:t("清除格式"),v:Ae},{r:t("全选"),v:Ie}];return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(he.rY,{click:c}),(0,P.jsx)(he.Pu,{x:n.x,y:n.y,items:u,click:t=>{switch(t){case fe:return l("cut");case pe:return l("copy");case ge:return l("paste");case _e:return a(ee("strong"));case ve:return a(ee("em"));case ye:return a(ee("strike"));case ke:return a(ee("code"));case we:return a(te("heading",{level:1}));case be:return a(te("heading",{level:2}));case xe:return a(te("heading",{level:3}));case $e:return a(te("paragraph"));case Me:return a(ne);case Se:return a(re);case je:return a(se);case Ee:return a(te("code_block"));case Pe:return c(),void e.on_insert_table?.();case Ce:return a($.JD);case Oe:return a($.gC);case Ne:return a($.RC);case Le:return a($.GU);case De:return a($.aR);case ze:return a($.gR);case Re:return a($.uC);case Fe:return a($.w7);case Ge:return a($.L0);case Te:return a($.kG);case Ae:return a((e,t)=>{const{from:n,to:r}=e.selection;let s=e.tr;return e.doc.nodesBetween(n,r,(e,t)=>{if(e.isText)for(const n of e.marks)s=s.removeMark(t,t+e.nodeSize,n.type)}),t?.(s),!0});case Ie:return a((e,t)=>{const{TextSelection:n}=e.selection.constructor;return t?.(e.tr.setSelection(n.create(e.doc,0,e.doc.content.size))),!0})}}})]})}function qe(e){const t=[];if(!e)return t;const n=e.split(/(\n)/);let r=null,s=0;for(let e=0;e<n.length;e+=2){const o=n[e],c=s;s+=o.length+(n[e+1]?.length??0);const a=o.endsWith("\r")?o.slice(0,-1):o,l=a.trimStart(),i=/^(`{3,}|~{3,})/.exec(l);if(i){const e=i[1][0];null===r?r=e:r===e&&(r=null);continue}if(null!==r)continue;const u=/^ {0,3}(#{1,6})\s+(.*)$/.exec(a);if(!u)continue;const d=u[1].length,m=u[2].replace(/\s+#+\s*$/,"").trim();t.push({level:d,text:m,pos:c})}return t}var Be=n(69918),Ve=n(96763),Ke=n(40505);function Xe(e){const{t}=(0,g.B)(),[n,s]=(0,r.useState)(!1),[a,l]=(0,r.useState)({x:0,y:0}),[u,d]=(0,r.useState)([]),[m]=(0,o.fp)(c.AG.user_base_info);(0,r.useEffect)(()=>{if(!n)return;let e=!1;return(0,Ve.Kz)().then(t=>{e||d(t)}),()=>{e=!0}},[n]);const h=(e,t)=>(0,P.jsx)("div",{style:{...(0,Ke.ok)(t===m?.user_data?.md_editor_theme)},children:e});return(0,P.jsxs)(r.Fragment,{children:[(0,P.jsx)(i.rA,{icon:"palette",title:t("主题"),onClick:e=>{l({x:e.clientX,y:e.clientY}),s(!0)}}),n&&(0,P.jsx)(he.rY,{click:()=>s(!1),children:(0,P.jsx)(he.Pu,{x:a.x,y:a.y,items:[{r:h(t("follow_sys"),""),v:""},...u.map(e=>({r:h(e.id,e.id),v:e.id}))],click:t=>{s(!1),e.on_change(t)}})})]})}var He=n(2543),Ue=n(86090),Je=n(87361);function Ye(){const{t:e}=(0,g.B)(),t=(0,Ue.Zp)(),{check_user_auth:n}=(0,a.MH)(),_=n(l.oV.md_editor_setting),[v,y]=(0,o.fp)(c.AG.md_editor),k=(0,o.fp)(c.AG.md_editor_last_context)[1],w=(0,r.useRef)(null),[b,x]=(0,r.useState)(null),[$,M]=(0,r.useState)(!1),[S,j]=(0,r.useState)(!1),[E,A]=(0,r.useState)(0),C=(0,r.useRef)(null),[O,D]=(0,r.useState)([]),[N,L]=(0,r.useState)(-1),[z,R]=(0,r.useState)(15),[F,G]=(0,r.useState)(!1),T=(0,r.useRef)(null),W=(0,r.useRef)(null),[q,B]=(0,o.fp)(c.AG.md_editor_show_outline),[V,K]=(0,o.fp)(c.AG.md_editor_mode),X=(0,r.useCallback)(()=>{const e="wysiwyg"===V?"source":"wysiwyg",t=C.current;t&&("source"===e?t.enter_source_mode():t.exit_source_mode(),K(e))},[V]),[H]=(0,o.fp)(c.AG.md_editor_setting),[U,J]=(0,o.fp)(c.AG.md_theme_css),[Y]=(0,o.fp)(c.AG.user_base_info),{initUserInfo:Z}=(0,r.useContext)(s.F),Q=(0,r.useRef)(null),ee=(0,r.useRef)(null);(0,r.useEffect)(()=>{ee.current},[Y]),(0,r.useEffect)(()=>{(0,Be.Ce)(Q.current,H)},[H]);(0,r.useEffect)(()=>{(0,Ve.bN)("editor",U,"#md-editor-container .md-editor-sheet")},[U]),(0,r.useEffect)(()=>{const e=()=>{(0,Ve.sO)().then(J)};return window.addEventListener(Ve.o3,e),()=>window.removeEventListener(Ve.o3,e)},[]);const te=(0,r.useRef)([]),ne=(0,r.useCallback)(()=>{const e=C.current;if(!e)return;const t=e.is_source_mode()?qe(e.get_markdown()):e.get_headings();te.current=t,D(t)},[]),re=(0,r.useCallback)(()=>{const e=C.current,t=e?.get_view();if(!e||!t)return;const n=e.is_source_mode()?t.state.selection.from-1:t.state.selection.from;let r=-1;for(const e of te.current){if(!(e.pos<=n))break;r=e.pos}L(r)},[]);(0,r.useEffect)(()=>{let t=!1;if(v?.url)return j(!1),M(!0),f.l.get(v.url).then(e=>{if(t)return;x(e??"")}).catch(()=>{t||((0,d.zN)(e("打开失败")),x(""))}).finally(()=>{t||M(!1)}),()=>{t=!0};x(null)},[v?.url]),(0,r.useEffect)(()=>{const e=()=>A(e=>e+1);return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)},[]);const se=(0,r.useRef)(X);se.current=X,(0,r.useEffect)(()=>{const e=e=>{(e.ctrlKey||e.metaKey)&&"/"===e.key&&(e.preventDefault(),e.stopPropagation(),se.current())};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[]),(0,r.useEffect)(()=>{ne(),re()},[E,V,ne,re]);const oe=(0,r.useCallback)(He.throttle(e=>{if(!T.current||!W.current)return;const t=parseFloat(getComputedStyle(T.current).fontSize),n=e.clientX/t,r=window.innerWidth/t-4,s=2.25+W.current.offsetWidth/t;n<=r&&n>=s&&R(parseFloat(n.toFixed(2)))},32),[]),ce=()=>{G(!1),T.current?.removeEventListener("pointermove",oe)},ae=async()=>{if(!v?.name||!v?.path)return;const t=C.current?.get_markdown();if(void 0===t)return;const n=v.path.slice(0,v.path.length-v.name.length),r=`${encodeURIComponent(n)}${v.name}`;(await h.$M.post(`save/${r}`,{context:t})).code===m.m.Success?(j(!1),(0,d.SK)(e("保存成功"))):(0,d.zN)(e("保存失败"))},le=(0,r.useRef)(ae);le.current=ae;const ie=()=>{y({}),j(!1),x(null),C.current=null,v?.close?.()},me=(0,r.useMemo)(()=>v?.url??"md_editor",[v?.url]);return v?.name?(0,P.jsxs)("div",{id:"md-editor-container",ref:Q,children:[(0,P.jsx)(u.A,{ignore_tags:!0,left_children:[(0,P.jsx)(i.rA,{title:e("关闭"),icon:"close",onClick:ie},1),(0,P.jsx)("div",{className:"md-editor-title",children:v.name},3),...S?[(0,P.jsx)(i.rA,{title:e("保存"),icon:"save",onClick:ae},2)]:[],(0,P.jsx)(i.rA,{title:e("大纲"),icon:"list",onClick:()=>B(e=>!e),selected:q},4),(0,P.jsx)(i.rA,{title:e("wysiwyg"===V?"源码模式":"实时编辑模式"),icon:"wysiwyg"===V?"code":"edit",onClick:X},5),(0,P.jsx)(Xe,{on_change:async t=>{const n=await h.wm.post(p.s.user_save_private_attr,{is_md_theme:!0,md_editor_theme:t});n?.code===m.m.Success?(ee.current=t,await Z(),(0,d.SK)(e("保存成功"))):(0,d.zN)(e("保存失败"))}},8),(0,P.jsx)(i.rA,{title:e("导出PDF"),icon:"print",onClick:()=>{window.print()}},7),..._?[(0,P.jsx)(i.rA,{title:e("编辑器设置"),icon:"settings",onClick:()=>{ie(),t(Je.o.md_editor_setting_page)}},6)]:[]]}),(0,P.jsxs)("div",{className:"md-editor-context",ref:T,children:[$&&(0,P.jsxs)("div",{className:"common-box common-box-center",children:[e("加载中"),"..."]}),!$&&null!==b&&(0,P.jsxs)(r.Fragment,{children:[q&&(0,P.jsx)("div",{className:"md-outline-panel",style:{width:`${z}em`},children:(0,P.jsx)(I,{items:O,active_pos:N,on_click:e=>{const t=C.current;t&&(t.scroll_to_pos(t.is_source_mode()?e.pos+1:e.pos),L(e.pos))}})}),q&&(0,P.jsx)("div",{className:"md-editor-divider",ref:W,onPointerDown:()=>{G(!0),T.current?.addEventListener("pointermove",oe)},onPointerUp:ce}),F&&(0,P.jsx)("div",{className:"md-editor-drag-overlay",onPointerUp:ce}),(0,P.jsx)("div",{className:"md-editor-scroll",children:(0,P.jsxs)("div",{className:"md-editor-sheet",children:["wysiwyg"===V&&(0,P.jsx)(de,{get_view:()=>C.current?.get_view()??null,refresh_key:E}),(0,P.jsx)(ue,{value:b,ref:C,initial_source_mode:"source"===V,on_ready:e=>{const t=e.is_source_mode()?qe(e.get_markdown()):e.get_headings();te.current=t,D(t),L(-1)},on_change:()=>{S||j(!0),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{const e=C.current?.get_markdown()??"";e&&k(e)},800)},on_save:()=>le.current(),on_selection_change:()=>A(e=>e+1),on_source_mode_change:e=>{K(e?"source":"wysiwyg"),A(e=>e+1)}},me),"wysiwyg"===V&&(0,P.jsx)(We,{get_view:()=>C.current?.get_view()??null,on_insert_table:()=>{C.current?.insert_table(3,3),j(!0)}})]})})]})]})]}):null}},69918(e,t,n){n.d(t,{Ce:()=>l,FG:()=>r.FG,fy:()=>a,gC:()=>c});var r=n(18840),s=n(14284),o=n(53459);async function c(){try{const e=await s.XO.get("md_editor_setting/get");return{...r.FG,...e?.data??{}}}catch(e){return{...r.FG}}}async function a(e){const t=await s.XO.post("md_editor_setting/save",e);return t?.code!==o.m.Success?null:{...r.FG,...t.data??e}}function l(e,t){e&&(e.style.setProperty("--md-editor-max-width",t.content_max_width),e.style.setProperty("--md-editor-padding",t.content_padding),e.style.setProperty("--md-editor-font-size",t.font_size),e.style.setProperty("--md-editor-line-height",t.line_height))}},96763(e,t,n){n.d(t,{Kz:()=>c,P7:()=>i,_8:()=>m,_D:()=>d,bN:()=>o,sO:()=>u});var r=n(14284),s=n(53459);function o(e,t,n){const r="md-theme-style-"+e,s=document.getElementById(r);if(!t)return void s?.remove();let o=s;o||(o=document.createElement("style"),o.id=r,document.head.appendChild(o)),o.textContent=function(e,t){let n=String(e??"");return n=n.replace(/\/\*[\s\S]*?\*\//g,""),n=n.replace(/^\s*@include-when-export[^;]*;?/gim,""),n=n.replace(/^\s*@import[^;]*;?/gim,""),n.replace(/(^|})\s*([^{}@]+?)\s*\{/g,(e,n,r)=>`${n}\n${String(r).split(",").map(e=>e.trim()).filter(Boolean).map(e=>"#write"===e||"html"===e||"body"===e||":root"===e||"content"===e?t:e.startsWith("#write")?t+e.slice(6):/^(html|body)\b/.test(e)?t+e.replace(/^(html|body)/,""):`${t} ${e}`).join(", ")} {`)}(t,n)}async function c(){try{const e=await r.XO.get("md_theme/list");return e?.code===s.m.Success?e.data??[]:[]}catch(e){return[]}}const a="md-theme-change";function l(){window.dispatchEvent(new Event(a))}async function i(e){try{const t=await r.XO.get(`md_theme/get?id=${encodeURIComponent(e)}`);return t?.code===s.m.Success?t.data??"":""}catch(e){return""}}async function u(){try{const e=await r.XO.get("md_theme/active");return e?.code===s.m.Success?e.data??"":""}catch(e){return""}}async function d(e){const t=await r.XO.post("md_theme/save",e);return t?.code!==s.m.Success?null:(l(),t.data)}async function m(e){const t=await r.XO.post("md_theme/del",{id:e});return t?.code===s.m.Success&&(l(),!0)}n.d(t,["o3",0,a])}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[8603],{58603(e,t,i){i.r(t),i.d(t,{default:()=>N});var n=i(96540),s=i(75725),r=i(70447),a=i(34843),o=i(82893),l=i(60096),c=i(85997),d=i(34251),m=i(34289),h=i(87361),_=i(14284),u=i(53459),x=i(61443),f=i(86149),p=i(62042),j=(i(47022),i(4412)),k=i(99214),g=i(6960),w=i(88815),v=i(40505),z=i(23430),F=i(64694),b=i(86090),C=i(74848);function N(){const[e,t]=(0,n.useState)(null),i=(0,n.useRef)(""),N=(0,n.useRef)(""),[$,y]=(0,a.fp)(o.AG.prompt_card),[S,M]=(0,a.fp)(o.AG.share_sort_type),{t:A}=(0,f.B)(),[G,I]=(0,a.fp)(o.AG.selectedFileList),[U,V]=(0,a.fp)(o.AG.clickFileList),{click_file:W}=(0,k.kZ)(),[D]=(0,b.ok)(),L=(0,k.oT)(),R=(0,k.xp)(),Z=(0,k.Vs)(!0),B=(0,n.useMemo)(()=>{const t=[...e?.items??[]],i=e=>Number(e.mtime??0);return S===z.t8.time_minx_max?t.sort((e,t)=>i(e)-i(t)):S===z.t8.time_max_min&&t.sort((e,t)=>i(t)-i(e)),t},[e?.items,S]),H=async()=>{const e=await _.$M.post("share",{id:i.current,token:N.current});if(e.code===u.m.Success){const n={is_dir:e.data.is_dir};n.items=e.data.files??[];for(const e of n.items)e.origin_size=e.size,e.show_mtime=e.mtime?(0,g.s)(e.mtime):"",e.size=(0,w.v7)(e.size);if(!n.is_dir){const t=e.data.files[0];n.name=t.name,n.size=t.size,n.show_mtime=t.show_mtime}localStorage.setItem(`file_share_token_${i.current}`,N.current);const s=D.get("share_preview_file_name");if(s)try{const t=e.data.files.find(e=>e.name===s);W({file_path:t.path,file_url:_.$M.getDownloadUrlV2(t.path,"share_download",{share_id:i.current,share_token:N.current}),name:t.name,size:t.origin_size,opt_shell:!0,mtime:t.mtime,not_type_tip:A("未知类型,请下载查看"),close:()=>{L("share_preview_file_name",null)}})}catch(e){(0,p.zN)(e?.message||e)}else t(n)}else e.code===u.m.need_token_share&&(localStorage.removeItem(`file_share_token_${i.current}`),(0,p.zN)("需要正确的访问token"),y({open:!0,title:"share file",confirm:()=>{y({open:!1}),H()},context_div:(0,C.jsx)("div",{className:"card-content",children:(0,C.jsx)(x.Sm,{placeholderOut:A("请输入访问token"),value:"",handleInputChange:e=>{N.current=e}})})}))};if((0,n.useEffect)(()=>{const e=(0,m.oW)(`${(0,m.GG)(h.o.share,(0,m.vX)())}`);i.current=e,N.current=localStorage.getItem(`file_share_token_${e}`),H()},[D]),!e)return(0,C.jsx)(s.jW,{isFull:!0,children:(0,C.jsx)("div",{className:"common-box common-box-center",children:"Loading..."})});return(0,C.jsxs)(n.Fragment,{children:[(0,C.jsx)(j.aZ,{children:(0,C.jsx)(C.Fragment,{children:(0,C.jsxs)("h2",{children:["Share ",e.is_dir?"Folder":"File"]})})}),(0,C.jsxs)(j.aZ,{position:"right",children:[G.length>0&&(0,C.jsx)(c.rA,{icon:"download",title:A("下载"),onClick:function(){const e=[];for(let t=0;t<G.length;t++){const i=B[G[t]];e.push(encodeURIComponent(i.path))}const t=_.$M.getDownloadUrlV2(e,"share_download",{share_id:i.current,share_token:N.current});window.open(t)}}),e.is_dir&&(0,C.jsx)(c.rA,{icon:"grid_view",title:A("切换样式"),onClick:Z}),e.is_dir&&(0,C.jsx)(c.rA,{icon:"schedule",title:S===z.t8.time_minx_max?A("时间逆序"):A("时间顺序"),onClick:()=>{const e=(0,F.jH)([z.t8.time_max_min,z.t8.time_minx_max,z.t8.defualt],S);M(e),I([]),V([])}})]}),(0,C.jsx)(s.xh,{children:(0,C.jsx)(s.jW,{isFull:!0,children:(0,C.jsx)("div",{className:"common-box ",children:e.is_dir?(0,C.jsx)(l.QW,{share:{share_id:i.current,share_token:N.current},handleContextMenu:()=>{},file_list:B,clickBlank:e=>{e.target===e.currentTarget&&(I([]),V([]))}}):(0,C.jsx)(r.uF,{children:(0,C.jsxs)("div",{style:{height:"25rem"},className:"common-box common-box-center",children:[(0,C.jsx)("div",{className:"file-icons",children:(0,C.jsx)("div",{"data-type":(0,d.uL)(e.name),"data-dir":e.is_dir,"aria-label":e.name,children:(0,C.jsx)(c.In,{icon:"",style:{fontSize:"10rem",display:"inline-block",lineHeight:1},aria_label:e.name})})}),(0,C.jsx)("div",{className:"",children:e.name}),(0,C.jsx)("div",{className:"",children:e.size}),(0,C.jsx)("div",{className:"",children:e.show_mtime}),(0,C.jsx)(c.C3,{text:"download",clickFun:()=>{const e=B[0],t=_.$M.getDownloadUrlV2(e.path,"share_download",{share_id:i.current,share_token:N.current});window.open(t)}}),(0,C.jsx)(c.C3,{text:"copy url",clickFun:()=>{const e=B[0],t=_.$M.getDownloadUrlV2(e.path,"share_download",{share_id:i.current,share_token:N.current}),n=_.$M.get_full_url(t);(0,v.lW)(n),(0,p.SK)(n)}}),(0,C.jsx)(c.C3,{text:"preview",clickFun:()=>{const e=B[0];R(e.name)}})]})})})})})]})}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[8765],{60096(e,i,t){t.d(i,{QW:()=>z,Ic:()=>b,t$:()=>F,$J:()=>$});var n=t(96540),s=t(47022),l=t(34843),o=t(82893),a=t(86090),r=t(64694),d=t(14284),c=t(34289),m=t(23430),f=t(62042),h=t(99214),p=t(85997),u=t(86149),_=t(74848);function x(e){const[i,t]=(0,l.fp)(o.AG.selectedFileList),[n,a]=(0,l.fp)(o.AG.nowFileList),[c,x]=(0,l.fp)(o.AG.confirm),[g,y]=(0,l.fp)(o.AG.user_base_info),{t:w}=(0,u.B)();return(0,_.jsxs)("div",{...e.extraAttr,onClick:()=>{!async function(i){e.click&&e.click(i,e.name)}(e.index)},className:e.mount?"item mount-item":"item",role:"button","data-type":e.isLink?"invalid_link":e.type,"data-dir":!e.type||e.type===s.Iw.folder,"data-mount":e.mount?"true":void 0,"aria-selected":null!==(0,r.kW)(i,e.index),"aria-label":e.name,style:{"--filewidth":e.itemWidth??"33%"},onDragStart:n=>{return s=e.index,void(i.find(e=>e===s)||t([...i,s]));var s},onDrop:t=>((t,l)=>{const o=t.dataTransfer;let a,r=!1;for(let e=0;e<o.items.length;e++)if("file"===o.items[e].kind){r=!0;break}if(r)return;if(g?.user_data?.file_list_pagination_mode===m.yM.pagination){if(a=n.files[l],n.files[l]?.type!==s.Iw.folder)return}else if(a=n.folders[l],n.folders.length<=l)return;(0,h.ib)(n,i).some(e=>e?.name===a?.name)?(0,f.zN)(w("mv_self")):x({open:!0,title:`确定将文件移动并覆盖到${a?.name}吗?`,handle:async()=>{await e.draggable_handle(a?.name)}})})(t,e.index),draggable:void 0!==e.draggable_handle,children:[void 0===e.icon&&(0,_.jsx)("div",{children:e.type!==s.Iw.image||null==e.path||g?.user_data?.not_pre_show_image?(0,_.jsx)(p.In,{icon:""}):(0,_.jsx)("img",{loading:"lazy",src:d.$M.getDownloadUrl(e.path,{mtime:e.mtime,cache:1}),alt:e.name})}),void 0!==e.icon&&(0,_.jsx)("div",{className:"rotating-div",children:(0,_.jsx)("span",{className:"material-icons",children:e.icon})}),(0,_.jsxs)("div",{children:[(0,_.jsxs)("p",{className:"name",children:[(0,_.jsx)("span",{children:e.name}),e.mount_readonly&&(0,_.jsx)("span",{className:"mount-readonly-tag",children:w("只读")})]}),e.size?(0,_.jsx)("p",{children:e.size}):(0,_.jsx)("p",{children:"—"}),(0,_.jsx)("p",{children:e.show_mtime})]}),e.children]})}var g=t(83529),y=t(34251);function w(e){const[i,t]=(0,l.fp)(o.AG.selectedFileList),[n,m]=(0,l.fp)(o.AG.nowFileList),[f,p]=(0,l.fp)(o.AG.confirm),[w,k]=(0,l.fp)(o.AG.file_page),[v,j]=(0,l.fp)(o.AG.enterKey),{click_file:A}=(0,h.kZ)(),{t:G}=(0,u.B)(),z=(0,a.Zp)();(0,a.zy)();const b=(0,h.A9)(),{clickDouble:F}=(0,h.xI)(),[$,C]=(0,l.fp)(o.AG.showPrompt);return(0,_.jsx)(x,{extraAttr:{onContextMenu:t=>{((t,n,l,o)=>{t.preventDefault(),t.stopPropagation();const a=new y.ik;a.path=(0,r.IO)((0,c.vX)(),n),a.filename=n,a.x=t.clientX,a.y=t.clientY,a.type=l?s.Iw.folder:(0,y.uL)(n),a.size=o,a.useSelectedList=i.includes(e.index),C({show:!0,type:g.PromptEnum.FileMenu,overlay:!1,data:a})})(t,e.name,e.type===s.Iw.folder,e.origin_size)}},draggable_handle:async e=>{const s=(0,h.ib)(n,i).map(e=>(0,h.Ok)(e.name));await d.$M.post("cut",{files:s,to:`${(0,c.GG)("file",(0,c.vX)())}/${e}`});t([]),p({open:!1,handle:null}),z((0,c.vX)())},name:e.name,index:e.index,mtime:e.mtime,size:e.size,type:e.type,isLink:e.isLink,path:e.path,icon:e.icon,show_mtime:e.show_mtime,mount:e.mount,mount_driver:e.mount_driver,mount_color:e.mount_color,mount_readonly:e.mount_readonly,click:(n,l)=>{if(F(n,()=>{e.type===s.Iw.folder?b(l):A({name:l,size:e.origin_size,opt_shell:!0,mtime:e.mtime})}))return;if(null!==(0,r.kW)(i,n))t((0,r.P1)(i,n));else if("ctrl"===v)t([...i,n]);else if("shift"===v){const{max:e,min:s}=(0,r.a7)(i),l=[];if(n>=e)for(let i=e;i<=n;i++)l.push(i);else for(let e=s;e>=n;e--)l.push(e);t(l)}else t([n])},itemWidth:e.itemWidth})}var k=t(78247),v=(t(38240),t(64405)),j=t(88815);function A(e){const[i,t]=(0,l.fp)(o.AG.selectedFileList),[n,m]=(0,l.fp)(o.AG.editorSetting),[p,g]=(0,l.fp)(o.AG.shellNowDir),[y,w]=(0,l.fp)(o.AG.sshInfo),[A,G]=(0,l.fp)(o.AG.nowFileList),[z,b]=(0,l.fp)(o.AG.enterKey),[F,$]=(0,l.fp)(o.AG.confirm),C=(0,a.Zp)(),{t:I}=(0,u.B)(),{clickDouble:W}=(0,h.xI)();return(0,_.jsx)(x,{draggable_handle:async n=>{const s=new v.x;Object.assign(s,y),s.target=(0,r.HS)(...p,n);const l=(0,h.ib)(A,i).map(e=>(0,r.HS)(...p,e.name));for(const e of l)if(s.source=e,!await d.Fg.post("move",s))return!1;t([]),$({open:!1,handle:null}),await e.fileHandler()},name:e.name,index:e.index,mtime:e.mtime,size:e.size,type:e.type,itemWidth:e.itemWidth,show_mtime:e.show_mtime,click:(n,l)=>{if(W(n,()=>{if(e.type===s.Iw.folder){const e=new v.x;return e.key=y.key,e.dir=`/${(0,c.GG)("remoteShell",(0,c.vX)())}${l}`,C((0,r.IO)((0,c.vX)(),l)),t([]),void G({files:[],folders:[]})}const i=async()=>{const i=new v.x;i.key=y.key,i.file=`/${(0,c.GG)("remoteShell",(0,c.vX)())}${l}`;const t=await d.Fg.post("get/file/text",i);let n;l.endsWith(s.Iw.workflow_act)?n="ace/mode/yaml":(l.endsWith(s.Iw.draw)||l.endsWith(s.Iw.excalidraw))&&(n="ace/mode/json"),m({model:n,open:!0,fileName:e.name,save:async e=>{i.context=e;0===(await d.Fg.post("update/file/text",i)).code&&(k.xK.set_value_temp(""),(0,f.SK)("success"))}}),k.xK.set_value_temp(t.data)};"number"==typeof e.origin_size&&e.origin_size>j.o5?$({open:!0,title:I("提示"),sub_title:"文件超过20MB了确定要打开吗?",handle:async()=>{$({open:!1,handle:null}),await i()}}):i()}))return;if(null!==(0,r.kW)(i,n))t((0,r.P1)(i,n));else if("ctrl"===z)t([...i,n]);else if("shift"===z){const{max:e,min:s}=(0,r.a7)(i),l=[];if(n>=e)for(let i=e;i<=n;i++)l.push(i);else for(let e=s;e>=n;e--)l.push(e);t(l)}else t([n])}})}function G(e){const[i,t]=(0,l.fp)(o.AG.selectedFileList),[n,a]=(0,l.fp)(o.AG.enterKey),{click_file:c}=(0,h.kZ)(),[m,f]=(0,l.fp)(o.AG.nowFileList),{t:p}=(0,u.B)(),[w,k]=(0,l.fp)(o.AG.showPrompt),v=((0,h.oT)(),(0,h.xp)()),{clickDouble:j}=(0,h.xI)();return(0,_.jsx)(x,{extraAttr:{onContextMenu:i=>{((i,t,n,l)=>{i.preventDefault(),i.stopPropagation();const o=new y.ik,a=e.item_list;for(const e of a)if(e.name===t){o.path=e.path;break}o.is_share=!0,o.filename=t,o.x=i.clientX,o.y=i.clientY,o.type=n?s.Iw.folder:(0,y.uL)(t),o.size=l,o.share_token=e.share.share_token,o.share_id=e.share.share_id,k({show:!0,type:g.PromptEnum.FileMenu,overlay:!1,data:o})})(i,e.name,e.type===s.Iw.folder,e.origin_size)}},name:e.name,index:e.index,mtime:e.mtime,size:e.size,type:e.type,itemWidth:e.itemWidth,show_mtime:e.show_mtime,click:(l,o)=>{if(j(l,()=>{e.type!==s.Iw.folder&&(v(o)||c({file_path:e.item_list[l].path,file_url:d.$M.getDownloadUrlV2(e.item_list[l].path,"share_download",{share_id:e.share.share_id,share_token:e.share.share_token}),name:o,size:e.origin_size,opt_shell:!0,mtime:e.mtime,not_type_tip:p("未知类型,请下载查看")}))}))return;if(null!==(0,r.kW)(i,l))t((0,r.P1)(i,l));else if("ctrl"===n)t([...i,l]);else if("shift"===n){const{max:e,min:n}=(0,r.a7)(i),s=[];if(l>=e)for(let i=e;i<=l;i++)s.push(i);else for(let e=n;e>=l;e--)s.push(e);t(s)}else t([l])}})}function z({handleContextMenu:e,file_list:i,clickBlank:t,share:s}){const[a,r]=(0,l.fp)(o.AG.user_base_info),d=(0,n.useRef)(null),{t:c}=(0,u.B)(),m=(0,h.OJ)(),{file_is_running:f}=(0,k.hg)();return(0,h.UK)(i,[],d),(0,_.jsx)("div",{onContextMenu:e,id:"listing",style:{paddingBottom:"10rem"},className:`mosaic file-icons ${a?.user_data?.file_list_show_type??""}`,ref:d,children:(0,_.jsx)("div",{onClick:t,children:i.map((e,t)=>(0,_.jsx)(n.Fragment,{children:(0,_.jsx)(G,{share:s,item_list:i,icon:f(e.name)?"refresh":void 0,itemWidth:m,index:t+0,...e})},t+0))})})}function b({handleContextMenu:e,file_list:i,folder_list:t,clickBlank:s,fileHandler:a}){const[r,d]=(0,l.fp)(o.AG.user_base_info),c=(0,n.useRef)(null),{t:m}=(0,u.B)(),f=(0,h.OJ)(),{file_is_running:p}=(0,k.hg)(),[x,y]=(0,l.fp)(o.AG.fileShellShow),w=(0,n.useMemo)(()=>t?.length??0,[t]);return(0,h.ei)(c,g.PromptEnum.SshUpload),(0,h.UK)(i,t,c),(0,n.useEffect)(()=>()=>{x.show&&y({show:!1,path:""})},[]),(0,_.jsxs)("div",{onContextMenu:e,id:"listing",style:{paddingBottom:"10rem"},className:`mosaic file-icons ${r?.user_data?.file_list_show_type??""}`,ref:c,children:[t&&t.length>0&&(0,_.jsx)("h2",{children:m("文件夹")}),t&&(0,_.jsx)("div",{onClick:s,children:t.map((e,i)=>(0,_.jsx)(n.Fragment,{children:(0,_.jsx)(A,{fileHandler:a,itemWidth:f,index:i,...e})},i))}),i&&i.length>0&&(0,_.jsx)("h2",{onClick:s,children:m("文件")}),i&&(0,_.jsx)("div",{onClick:s,children:i.map((e,i)=>(0,_.jsx)(n.Fragment,{children:(0,_.jsx)(A,{fileHandler:a,icon:p(e.name)?"refresh":void 0,itemWidth:f,index:i+w,...e})},i+w))})]})}function F({handleContextMenu:e,file_list:i,folder_list:t,clickBlank:s}){const[a,r]=(0,l.fp)(o.AG.user_base_info),d=(0,n.useRef)(null),{t:c}=(0,u.B)(),[m]=(0,l.fp)(o.AG.zoom_style_by_percent),f=(0,h.OJ)(),{file_is_running:p}=(0,k.hg)(),[x,y]=(0,l.fp)(o.AG.fileShellShow),v=(0,n.useMemo)(()=>t?.length??0,[t]),j=(0,h.pi)(m);return(0,h.ei)(d,g.PromptEnum.FilesUpload),(0,h.UK)(i,t,d),(0,n.useEffect)(()=>()=>{x.show&&y({show:!1,path:""})},[]),(0,_.jsxs)("div",{onContextMenu:e,id:"listing",style:{paddingBottom:"10rem",fontSize:j.fontSize},className:`mosaic file-icons ${a?.user_data?.file_list_show_type??""}`,ref:d,children:[t&&t.length>0&&(0,_.jsx)("h2",{children:c("文件夹")}),t&&(0,_.jsx)("div",{onClick:s,children:t.map((e,i)=>(0,_.jsx)(n.Fragment,{children:(0,_.jsx)(w,{itemWidth:f,index:i,...e})},i))}),i&&i.length>0&&(0,_.jsx)("h2",{onClick:s,children:c("文件")}),i&&(0,_.jsx)("div",{onClick:s,children:i.map((e,i)=>(0,_.jsx)(n.Fragment,{children:(0,_.jsx)(w,{icon:p(e.name)?"refresh":void 0,itemWidth:f,index:i+v,...e})},i+v))})]})}function $({handleContextMenu:e,list:i,clickBlank:t}){const[s,a]=(0,l.fp)(o.AG.user_base_info),r=(0,n.useRef)(null),{t:d}=(0,u.B)(),[c]=(0,l.fp)(o.AG.zoom_style_by_percent),m=(0,h.OJ)(),{file_is_running:f}=(0,k.hg)(),[p,x]=(0,l.fp)(o.AG.fileShellShow),[y,v]=(0,l.fp)(o.AG.enterKey),[j,A]=(0,l.fp)(o.AG.selectedFileList),[G,z]=(0,l.fp)(o.AG.file_page),b=(0,h.pi)(c);return(0,h.UK)(i,[],r),(0,h.ei)(r,g.PromptEnum.FilesUpload),(0,h.SQ)(r,()=>{z(e=>e.page_num<0?e:{page_size:e.page_size,page_num:e.page_num+1})},()=>{}),(0,n.useEffect)(()=>()=>{p.show&&x({show:!1,path:""})},[]),(0,_.jsx)("div",{onContextMenu:e,id:"listing",style:{paddingBottom:"10rem",fontSize:b.fontSize},className:`mosaic file-icons ${s?.user_data?.file_list_show_type??""}`,ref:r,children:i&&(0,_.jsx)("div",{onClick:t,children:i.map((e,i)=>(0,_.jsx)(n.Fragment,{children:(0,_.jsx)(w,{icon:f(e.name)?"refresh":void 0,itemWidth:m,index:i,...e})},i))})})}},6960(e,i,t){t.d(i,{s:()=>o});var n=t(72635);const s=1440,l=525600;function o(e){e=e>1e12?e:1e3*e;const i=Date.now(),t=Math.abs(i-e)/6e4;return t<1?n.Ay.t("小于一分钟"):t<60?`${t.toFixed(0)} ${n.Ay.t("分钟前")}`:t<s?`${(t/60).toFixed(0)} ${n.Ay.t("小时前")}`:t<43200?`${(t/s).toFixed(0)} ${n.Ay.t("天前")}`:t<l?`${(t/43200).toFixed(0)} ${n.Ay.t("月前")}`:`${(t/l).toFixed(0)} ${n.Ay.t("年前")}`}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[9299],{47374(e,t,i){i.d(t,{e:()=>f});var n=i(96540),s=i(86090),o=i(64694),a=i(34289),l=i(61443),r=i(75725),c=i(86149),d=i(85997),_=i(74848);function f(e){let t=(0,s.zy)();const[i,f]=(0,n.useState)([]),[p,h]=(0,n.useState)("/"),[u,m]=(0,n.useState)(void 0),{t:w,i18n:v}=(0,c.B)();n.useEffect(()=>{let t="",i=(0,a.vX)().split("/");i=i.filter(e=>e);const n=i.indexOf(e.baseRoute),s=[];if(-1!=n){t=(0,o.IO)(i.slice(0,n),e.baseRoute);const a=i.slice(n+1);for(let e=0;e<a.length;e++){const i=a[e];s.push({value:i,href:0===e?`${t}${i}/`:(0,o.IO)(s[e-1].href,i)})}h(t),f(s)}},[t]);const x=t=>{t.stopPropagation(),e.clickFun(t)};return(0,_.jsx)("div",{className:"breadcrumbs",onClick:e=>{m(void 0!==u?void 0:"")},children:(0,_.jsx)(n.Fragment,{children:void 0===u?(0,_.jsxs)(n.Fragment,{children:[(0,_.jsx)("span",{className:"chevron",children:(0,_.jsx)(s.N_,{to:p,onClick:x,children:(0,_.jsx)(d.In,{icon:"home"})})}),i.map((e,t)=>(0,_.jsxs)("span",{className:"chevron",children:[(0,_.jsx)(d.In,{icon:"keyboard_arrow_right"}),(0,_.jsx)(s.N_,{to:e.href,onClick:x,children:decodeURIComponent(e.value)})]},t))]}):(0,_.jsx)(r.QM,{click:()=>{m(void 0)},children:(0,_.jsx)(l.Sm,{width:"100%",placeholder:w("输入跳转的目录"),handlerEnter:t=>{e.input_path_enter&&e.input_path_enter(t),m(void 0)}})})})})}},77481(e,t,i){i.d(t,{S:()=>l,X:()=>a});var n=i(96540),s=i(61443),o=i(74848);function a(e){const[t,i]=n.useState([]),a=(0,n.useRef)(-1),[l,r]=(0,n.useState)(-1),[c,d]=(0,n.useState)(-1);(0,n.useEffect)(()=>{e.children?i(Array.isArray(e.children)?e.children:[e.children]):i(e.rows)},[e.rows,e.children]);const _=()=>{a.current=-1,r(-1),d(-1)};return(0,o.jsxs)("table",{children:[(0,o.jsx)("thead",{children:(0,o.jsx)("tr",{children:e.headers?.map((t,i)=>{const n=!!e.filter&&(e.filter.column??0)===i;let a=t;if(n){const i=e.filter,n=i.options.find(e=>e.value===i.value);null!=i.value&&n&&(a=`${t} (${n.label})`)}return(0,o.jsx)("th",{className:n?"table-filter-col":"",children:n?(0,o.jsx)(s.l6,{value:e.filter.value,options:e.filter.options,onChange:e.filter.onChange,bare:!0,trigger_label:a}):t},i)})})}),(0,o.jsx)("tbody",{children:t.map((t,i)=>{const n=!!e.onRowDrag;return(0,o.jsx)("tr",{className:n?(l===i?"row-dragging":"")+(c===i?" row-drop-target":""):"",draggable:n,onContextMenu:()=>{e.handleContextMenu&&e.handleContextMenu(t)},onDragStart:e=>{n&&(a.current=i,r(i),e.dataTransfer.effectAllowed="move")},onDragOver:e=>{!n||a.current<0||(e.preventDefault(),e.dataTransfer.dropEffect="move",d(i))},onDrop:t=>{n&&(t.preventDefault(),(()=>{const t=a.current,i=c;_(),t<0||i<0||t===i||e.onRowDrag?.(t,i)})())},onDragEnd:_,children:t.map((i,n)=>{const s=n===t.length-1?"small":"";return(0,o.jsx)("td",{className:s,style:{width:e.width??"auto"},children:i},n)})},i)})})]})}function l(e){return(0,o.jsx)("div",{style:{display:e.isFlex?"flex":"block"},children:e.columns.map((e,t)=>(0,o.jsx)("div",{children:e},t))})}},19299(e,t,i){i.r(t),i.d(t,{default:()=>q});var n=i(96540),s=i(47374),o=i(34843),a=i(82893),l=i(14284),r=i(86090),c=i(4412),d=i(83529),_=i(34289),f=i(53459),p=i(99214),h=i(61443),u=i(47022),m=i(62042),w=i(86149),v=i(7523),x=i(78247),g=i(88815),y=i(6960),j=i(47071),k=i(14944),G=i(92275),A=i(23430);var b=i(34251),C=i(60096),z=i(87361),M=i(76559),S=i(85997),$=i(77481),D=i(70447),P=i(74848);const F=500;function N(e){const{t}=(0,w.B)(),i=(0,r.Zp)(),[,s]=(0,o.fp)(a.AG.prompt_card),[l,c]=(0,n.useState)(""),[d,_]=(0,n.useState)(!1),[f,p]=(0,n.useState)([]),[u,m]=(0,n.useState)(0),[v,x]=(0,n.useState)(!1),g=(0,n.useMemo)(()=>new M.I(window.location.host,"file_deep_search"),[]),y=(0,n.useRef)(!1),j=decodeURIComponent(e.base_path);(0,n.useEffect)(()=>{let e=[],t=null;const i=()=>{if(t=null,y.current||!e.length)return;const i=e;e=[],m(e=>e+i.length),p(e=>e.length>=F?e:[...e,...i].slice(0,F))},n=()=>{y.current||_(!1)};return g.addMsg(G.HK.file_deep_search_data,n=>{y.current||(e.push(...n.context??[]),null===t&&(t=setTimeout(i,100)))}),g.addMsg(G.HK.file_deep_search_end,()=>{y.current||(i(),_(!1))}),g.on_message("close",n),()=>{y.current=!0,clearTimeout(t),g.sendData(G.HK.file_deep_search_cancel,{}).catch(()=>{}),g.off_message("close",n),g.close()}},[]);const k=()=>{const t=l.trim();if(!t||d)return;p([]),m(0),x(!0),_(!0);const i={param_path:e.base_path,keyword:t};g.sendData(G.HK.file_deep_search,i).catch(()=>{})},A=e=>{let t=e.is_dir?e.path:e.path.slice(0,e.path.lastIndexOf("/")+1);t.endsWith("/")||(t+="/"),s({open:!1}),i(z.o.file+t.split("/").map(encodeURIComponent).join("/"))};return(0,P.jsxs)("div",{className:"file-deep-search",children:[(0,P.jsxs)("div",{className:"file-deep-search__bar",children:[(0,P.jsx)(h.$Z,{icon:"search",value:l,placeholder:t("搜文件名"),handleInputChange:e=>c(e),handleEnterPress:k}),(0,P.jsx)("button",{className:"button button--flat",onClick:d?()=>{g.sendData(G.HK.file_deep_search_cancel,{}).catch(()=>{}),_(!1)}:k,children:t(d?"取消":"搜索")})]}),(0,P.jsxs)("div",{className:"file-deep-search__hint",children:[(0,P.jsxs)("span",{children:[t("范围"),":",j]}),u>0&&(0,P.jsx)("span",{className:"file-deep-search__count",children:u>F?`${t("已显示")} 500 / ${u}`:`${u}`})]}),(0,P.jsxs)("div",{className:"file-deep-search__body",children:[f.length>0&&(0,P.jsx)($.X,{headers:[t("名称"),t("路径"),""],rows:f.map(e=>{const i=e.path.slice(0,e.path.lastIndexOf("/")+1);return[e.is_dir?(0,P.jsx)("span",{className:"file-deep-search__dir",children:e.name}):e.name,(0,P.jsx)(D.xP,{context:i}),(0,P.jsx)(S.rA,{icon:"folder_open",title:t("打开所在目录"),onClick:()=>A(e)})]})}),d&&(0,P.jsxs)("div",{className:"file-deep-search__empty",children:[(0,P.jsx)("span",{className:"chat-session-running",title:t("搜索中")}),t("搜索中")]}),!d&&u>F&&(0,P.jsx)("div",{className:"file-deep-search__more",children:t("结果过多")}),!d&&0===f.length&&(0,P.jsx)("div",{className:"file-deep-search__empty",children:t(v?"无匹配":"输入后搜")})]})]})}var I=i(23496),E=i(12730),X=i(75725),K=i(40505);let R={};function H(){const{t:e}=(0,w.B)();let t=(0,r.zy)();const i=(0,r.Zp)(),{check_user_auth:s}=(0,x.MH)(),[c,f]=(0,o.fp)(a.AG.nowFileList),[h,g]=(0,o.fp)(a.AG.uploadFiles),[y,j]=(0,o.fp)(a.AG.showPrompt),[C,M]=(0,o.fp)(a.AG.selectedFileList),[$,F]=(0,o.fp)(a.AG.copyedFileList),[N,I]=(0,o.fp)(a.AG.cutedFileList),[K,H]=(0,o.fp)(a.AG.selectedFileList),[L,Y]=(0,o.fp)(a.AG.clickFileList),[U,Z]=(0,o.fp)(a.AG.fileShellShow),[B]=(0,o.fp)(a.AG.current_mount),[O,W]=(0,o.fp)(a.AG.file_root_list),[T,q]=(0,o.fp)(a.AG.file_root_index),[V,J]=(0,n.useState)(void 0),[Q,ee]=(0,n.useState)(""),[te,ie]=(0,o.fp)(a.AG.workflow_show),[ne,se]=(0,o.fp)(a.AG.workflow_realtime_show),[oe,ae]=(0,o.fp)(a.AG.work_flow_show),{initUserInfo:le}=(0,n.useContext)(v.F),[re,ce]=(0,o.fp)(a.AG.user_base_info),{click_file:de}=(0,p.kZ)(),[_e,fe]=(0,o.fp)(a.AG.prompt_card),pe=(0,n.useMemo)(()=>c.files.reduce((e,t)=>e+(t.type!==u.Iw.folder?1:0),0),[c]),he=(0,n.useMemo)(()=>c.files.reduce((e,t)=>e+(t.type===u.Iw.folder?1:0),0)+(c.folders?.length??0),[c]);function ue(e){(0,m.SK)(e)}(0,n.useEffect)(()=>{R={}},[t]),(0,n.useEffect)(()=>()=>{Z({show:!1,path:""})},[]);const me=(0,p.Vs)(),we=t=>{fe({open:!0,title:e("信息"),context_div:(0,P.jsxs)("div",{style:{maxWidth:"25rem"},children:[(0,P.jsx)(X.Yh,{left:e("挂载位置磁盘"),right:t?.total_size}),(0,P.jsx)(X.Yh,{left:`${e("磁盘剩余")}`,right:t?.left_size}),(0,P.jsx)(X.Yh,{left:`${e("文件系统")}`,right:t?.fs_type}),(0,P.jsx)(X.Yh,{left:`${e("文件夹数")}`,right:he}),(0,P.jsx)(X.Yh,{left:`${e("文件数")}`,right:pe}),(0,P.jsx)(X.Yh,{left:`${e("当前位置")}`,right:(0,P.jsx)(D.xP,{context:t?.now_absolute_path})})]}),cancel:()=>{k.ws.removeMsg(G.HK.file_info)}})};return(0,P.jsxs)(n.Fragment,{children:[C.length>0&&(0,P.jsx)(S.rA,{icon:"delete",title:e("删除"),onClick:()=>{j({show:!0,type:d.PromptEnum.FilesDelete,overlay:!0,data:{}})}}),C.length>0&&(0,P.jsx)(S.rA,{icon:"content_copy",title:e("复制"),onClick:function(){const e=(0,p.ib)(c,C);F(e.map(e=>(0,p.Ok)(e.name))),I([]),ue("已复制")}}),C.length>0&&(0,P.jsx)(S.rA,{icon:"content_cut",title:e("剪切"),onClick:function(){const e=(0,p.ib)(c,C);I(e.map(e=>(0,p.Ok)(e.name))),F([]),ue("已剪切")}}),($.length>0||N.length>0)&&(0,P.jsx)(S.rA,{onClick:function(){j({show:!0,type:d.PromptEnum.Confirm,overlay:!0,data:{}})},icon:"content_paste",title:e("粘贴到此处"),tip:$.length+N.length}),C.length>0&&(0,P.jsx)(S.rA,{icon:"download",title:e("下载"),onClick:function(){const e=(0,p.ib)(c,C);for(let t=0;t<e.length;t++){const i=e[t];e[t]=encodeURIComponent((0,p.Ok)(i.name))}const t=l.$M.getDownloadUrl(e);window.open(t)}}),C.length>0&&(0,P.jsx)(S.rA,{icon:"compress",title:e("压缩"),onClick:function(){const e=(0,p.ib)(c,C);for(let t=0;t<e.length;t++){const i=e[t];e[t]=(0,p.Ok)(i.name)}e&&0!==e.length?j({show:!0,type:d.PromptEnum.Compress,overlay:!0,data:{files:e}}):(0,m.zN)("没有选中")}}),1===C.length&&(0,P.jsx)(S.rA,{icon:"edit_attributes",title:e("重命名"),onClick:function(){j({show:!0,type:d.PromptEnum.FileRename,overlay:!0,data:{}})}}),oe&&(0,P.jsx)(S.rA,{icon:"api",title:"workflow",onClick:()=>{ie(!te)}}),!B&&(0,P.jsx)(S.rA,{icon:"terminal",title:"shell",onClick:function(){U.show?Z({show:!1,path:""}):Z({show:!0,path:(0,_.GG)("file",(0,_.vX)())})}}),s(A.oV.share_file)&&(0,P.jsx)(S.rA,{icon:"share",title:e("文件分享"),onClick:()=>{i(`${z.o.share_list_setting_page}`)}}),(0,P.jsx)(S.rA,{icon:"grid_view",title:e("切换样式"),onClick:me}),(0,P.jsx)(S.rA,{icon:"create_new_folder",title:e("创建文件夹"),onClick:function(){j({show:!0,type:d.PromptEnum.DirNew,overlay:!0,data:{dir:(0,_.GG)("file",(0,_.vX)())}})}}),(0,P.jsx)(S.rA,{icon:"note_add",title:e("创建文本文件"),onClick:function(){j({show:!0,type:d.PromptEnum.FileNew,overlay:!0,data:{dir:(0,_.GG)("file",(0,_.vX)())}})}}),(0,P.jsx)(S.rA,{icon:"upload_file",title:e("上传"),onClick:()=>{j({show:!0,type:d.PromptEnum.UploadFile,overlay:!0,data:{call:e=>{let t=e.currentTarget?.files;if(!t)return;let i=!!t[0].webkitRelativePath;const n=[],s=new Set;for(let e=0;e<t.length;e++){const o=t[e],a=i?o.webkitRelativePath:`${o.webkitRelativePath}${o.name}`;o.fullPath=a,i&&s.add((0,E.S)(a)),n.push(o)}const o=[];if(i)for(const e of s)o.push({isDir:!0,fullPath:e,name:e});o.push(...n),g(o),j({show:!0,type:d.PromptEnum.FilesUpload,overlay:!1,data:{}})}}})}}),(0,P.jsx)(S.rA,{icon:"info",title:e("信息"),onClick:async()=>{let e;if(!R.now_absolute_path){k.ws.addMsg(G.HK.file_info,t=>{const i=t.context;e&&(R={...R,...i},k.ws.removeMsg(G.HK.file_info),we(R))});const t=await k.ws.sendData(G.HK.file_info,{type:u.Iw.folder,path:(0,_.GG)("file",(0,_.vX)())});e=t.context,R=e,we(R)}we(R)}}),(0,P.jsx)(S.rA,{icon:"more_vert",title:e("切换目录"),onClick:t=>{const n=new b.ik;n.x=t.clientX,n.y=t.clientY,n.type=u.Iw.directory,n.items=O,n.item_pre_value=T,n.textClick=async t=>{if(-1===t)return i(`${z.o.setting_private_env_setting}`),j({data:void 0,overlay:!1,type:"",show:!1}),void(0,m.N9)(e("请配置 文件夹路径"));(async e=>{q(e),await l.$M.post("base_switch",{root_index:e}),await le(),i("/file/"),H([]),Y([])})(t),j({data:void 0,overlay:!1,type:"",show:!1})},j({show:!0,type:d.PromptEnum.FileMenu,overlay:!1,data:n})}})]})}var L=i(2543),Y=i(21499),U=i(64694),Z=i(17903);const B=n.lazy(()=>Promise.all([i.e(7856),i.e(6349),i.e(3659)]).then(()=>i(63659))),O=n.lazy(()=>Promise.all([i.e(7856),i.e(1636)]).then(()=>i(81636)));let W,T="";function q(){const[e,t]=(0,o.fp)(a.AG.editorSetting),[i,m]=(0,o.fp)(a.AG.file_preview),{t:M}=(0,w.B)();let $=(0,r.zy)();const D=(0,r.Zp)(),[F,E]=(0,o.fp)(a.AG.nowFileList),[X]=(0,o.fp)(a.AG.file_list_refresh),[R]=(0,o.fp)(a.AG.mount_enabled),[q,V]=(0,o.fp)(a.AG.current_mount),[J,Q]=(0,o.fp)(a.AG.showPrompt),[ee,te]=(0,o.fp)(a.AG.selectedFileList),[ie,ne]=(0,o.fp)(a.AG.clickFileList),[se,oe]=(0,o.fp)(a.AG.fileShellShow),[ae,le]=(0,n.useState)(""),[re,ce]=(0,o.fp)(a.AG.workflow_show),[de,_e]=(0,o.fp)(a.AG.workflow_realtime_show),[fe,pe]=(0,o.fp)(a.AG.work_flow_show),{initUserInfo:he}=(0,n.useContext)(v.F),[ue,me]=(0,o.fp)(a.AG.user_base_info),{click_file:we}=(0,p.kZ)(),[ve,xe]=(0,o.fp)(a.AG.to_running_files),[ge,ye]=(0,o.fp)(a.AG.file_page),[je]=(0,o.fp)(a.AG.blank_search_mode),[,ke]=(0,o.fp)(a.AG.prompt_card),[Ge,Ae]=(0,o.fp)(a.AG.blank_search_mode_for_temp),be=function(){const[e,t]=(0,o.fp)(a.AG.user_base_info),{t:i}=(0,w.B)(),{check_user_auth:s}=(0,x.MH)(),[c,f]=(0,o.fp)(a.AG.router_jump),h=(0,r.Zp)(),{initUserInfo:m}=(0,n.useContext)(v.F),[g,y]=(0,o.fp)(a.AG.nowFileList),[j,C]=(0,o.fp)(a.AG.showPrompt),[M,S]=(0,o.fp)(a.AG.fileShellShow),[$,D]=(0,o.fp)(a.AG.blank_search_mode);return t=>{t.preventDefault(),t.stopPropagation();const n=new b.ik;n.x=t.clientX,n.y=t.clientY,n.type=u.Iw.directory;const o=[{r:(0,P.jsx)("span",{style:(0,K.ok)(e.user_data.dir_show_type===A.t8.time_minx_max),children:i("时间逆序")}),v:A.t8.time_minx_max},{r:(0,P.jsx)("span",{style:(0,K.ok)(e.user_data.dir_show_type===A.t8.time_max_min),children:i("时间顺序")}),v:A.t8.time_max_min}],a=[{r:(0,P.jsx)("span",{style:(0,K.ok)(e.user_data.dir_show_type===A.t8.size_min_max),children:i("大小顺序")}),v:A.t8.size_min_max},{r:(0,P.jsx)("span",{style:(0,K.ok)(e.user_data.dir_show_type===A.t8.size_max_min),children:i("大小逆序")}),v:A.t8.size_max_min}],r=[{r:(0,P.jsx)("span",{style:(0,K.ok)(!e.user_data.file_list_pagination_mode||e.user_data.file_list_pagination_mode===A.yM.all),children:i("全部加载文件")}),v:A.yM.all},{r:(0,P.jsx)("span",{style:(0,K.ok)(e.user_data.file_list_pagination_mode===A.yM.pagination),children:i("scrll_l")}),v:A.yM.pagination}],c=[{r:(0,P.jsx)("span",{style:(0,K.ok)(!e.user_data.file_time_show_type||e.user_data.file_time_show_type===A.KD.current),children:i("最近时间")}),v:A.KD.current},{r:(0,P.jsx)("span",{style:(0,K.ok)(e.user_data.file_time_show_type===A.KD.time),children:i("准确时间")}),v:A.KD.time}],w=[{r:i("文件列表展示"),items:[{r:i("文件排序"),v:"",items:[{r:(0,P.jsx)("span",{style:(0,K.ok)(!e.user_data.dir_show_type),children:i("系统默认")}),v:A.t8.defualt},{r:(0,P.jsx)("span",{style:(0,K.ok)(e.user_data.dir_show_type===A.t8.name),children:i("名字")}),v:A.t8.name},{r:(0,P.jsx)("span",{style:(0,K.ok)(e.user_data.dir_show_type===A.t8.time_minx_max||e.user_data.dir_show_type===A.t8.time_max_min),children:i("修改时间")}),v:!1,items:o},{r:(0,P.jsx)("span",{style:(0,K.ok)(e.user_data.dir_show_type===A.t8.size_min_max||e.user_data.dir_show_type===A.t8.size_max_min),children:i("文件大小")}),v:!1,items:a}]},{r:i("文件加载方式"),v:"",items:r},{r:i("时间展示"),v:"",items:c},{r:i("缩放调整"),v:"zoom_adjust"},{r:(0,P.jsx)("span",{style:(0,K.ok)($),children:i("srchbln")}),v:"blank_search_mode"}]},{r:i("以配置表方式打开目录"),v:"gcfg_dir_config"}];g?.folders?.find(e=>".git"===e.name)&&w.push({r:i("查看Git提交"),v:"git_page"}),s(A.oV.code_resource)&&w.push({r:i("add_rot"),v:"code_resource"}),s(A.oV.http_proxy)&&w.push({r:i("dl_here"),v:"http_resource"}),e?.user_data?.quick_cmd&&(0,p.LL)([...e.user_data.quick_cmd],w),n.items=w,n.textClick=async e=>{if(console.log(e),!1===e)return;const t={};if("gcfg_dir_config"===e){const e=(0,_.GG)("file",(0,_.vX)());return C({data:void 0,overlay:!1,type:"",show:!1}),void h(`${z.o.gcfg_page}/${encodeURIComponent(e)}`)}if("git_page"===e){const e=(0,_.GG)("file",(0,_.vX)());return C({data:void 0,overlay:!1,type:"",show:!1}),void h(`${z.o.git_page}/${encodeURIComponent(e)}`)}if("code_resource"===e){const e=await k.ws.sendData(G.HK.file_info,{path:(0,_.GG)("file",(0,_.vX)())});return f({page_self_router_api_data:[`/api/${Date.now()}`,e.context.now_absolute_path]}),C({data:void 0,overlay:!1,type:"",show:!1}),void h("/setting/customer_router/")}if("http_resource"===e){const e=await k.ws.sendData(G.HK.file_info,{path:(0,_.GG)("file",(0,_.vX)())});return f({http_download_map_path:e.context.now_absolute_path}),C({data:void 0,overlay:!1,type:"",show:!1}),void h("/proxy/http/")}if("zoom_adjust"===e)return C({data:void 0,overlay:!1,type:"",show:!1}),void setTimeout(()=>{C({show:!0,type:d.PromptEnum.ZoomAdjust,overlay:!1,data:{}})},0);if("object"==typeof e&&"quick_cmd"===e.tag){let t=e.cmd;t&&(t.endsWith("\r")||(t+="\r",S({show:!0,path:(0,_.GG)("file",(0,_.vX)()),cmd:t})))}else{if("blank_search_mode"===e)return D(!$),void C({data:void 0,overlay:!1,type:"",show:!1});if(e===A.yM.all||e===A.yM.pagination)t.is_pagination_mode=!0;else if(e===A.KD.current||e===A.KD.time)t.is_file_show_type=!0;else{if(e!==A.t8.defualt&&e!==A.t8.name&&e!==A.t8.size_max_min&&e!==A.t8.size_min_max&&e!==A.t8.time_max_min&&e!==A.t8.time_minx_max)return;t.is_dir_list_type=!0}}await l.wm.post(I.s.user_save_private_attr,{type:e,...t}),await m(),C({data:void 0,overlay:!1,type:"",show:!1}),h((0,_.vX)())},C({show:!0,type:d.PromptEnum.FileMenu,overlay:!1,data:n})}}(),Ce=async()=>{const e=new j.Nd;e.dir_path=`${(0,_.GG)("file",(0,_.vX)())}`,k.ws.addMsg(G.HK.workflow_realtime,e=>{const t=e.context;if(e.context){for(const e of t.sucess_file_list)(0,p.Ys)(e);for(const e of t.failed_file_list)(0,p.V$)(e);xe(new Set(t.running_file_list))}}),await k.ws.sendData(G.HK.workflow_realtime,e)},ze=async e=>{let t=!1;for(const i of e.files??[])i.origin_size=i.size,i.size=(0,g.v7)(i.size),ue.user_data.file_time_show_type===A.KD.time?i.show_mtime=i.mtime?(0,Y.Yq)(i.mtime):"":i.show_mtime=i.mtime?(0,y.s)(i.mtime):"",t||!i.name.endsWith(".workflow.yml")&&!i.name.endsWith(".act")||(t=!0,Promise.resolve().then(()=>{Ce()})),i.name===j.SB&&(t=!0);for(const i of e.folders??[])ue.user_data.file_time_show_type===A.KD.time?i.show_mtime=i.mtime?(0,Y.Yq)(i.mtime):"":i.show_mtime=i.mtime?(0,y.s)(i.mtime):"",i.name===j.SB&&(t=!0);pe(t)},Me=n.useRef(null),Se=async e=>{if(!0===R){if(Me.current!==e){Me.current=e;try{const t=await l.$M.post("file/mount_info",{param_path:e});V(t?.data??null)}catch(e){V(null)}}}else V(null)},$e=async()=>{const e=(0,_.GG)("file",(0,_.vX)());if(je||Ge)return;let t;if(Se(e),ue.user_data.file_list_pagination_mode===A.yM.pagination){if(T!==e){if(T=e,1!==ge.page_num)return void ye({page_size:ge.page_size,page_num:1})}else if(ge.page_num<0)return;if(t=await l.$M.post("file_get_page",{param_path:e,page_num:ge.page_num,page_size:ge.page_size}),t.code!==f.m.Success)return;const i=t.data;return ze(i),i.files?.length?(E(e=>{const t=(0,L.cloneDeep)(1===ge.page_num?i.files:[...e?.files??[],...i.files]),n={...e,files:t};return(0,p.yC)(n,ue.user_data.dir_show_type),n}),void(W=t.data)):void ye({page_size:ge.page_size,page_num:-1})}if(t=await l.$M.get(e),t.code!==f.m.Success)return;const i=t.data;(0,p.yC)(i,ue.user_data.dir_show_type),ze(t.data),E(t.data),W=t.data};(0,n.useEffect)(()=>async()=>{xe(new Set)},[]);(0,n.useEffect)(()=>{$e(),t({open:!1}),m({open:!1}),pe(!1)},[$,ge]),(0,n.useEffect)(()=>{X>0&&$e()},[X]);const De=n.useRef(!1);(0,n.useEffect)(()=>{if(null!==R)return De.current?void(!0===R?Se((0,_.GG)("file",(0,_.vX)())):V(null)):(De.current=!0,void(!0===R&&null===q&&Se((0,_.GG)("file",(0,_.vX)()))))},[R]);const Pe=e=>{e.target===e.currentTarget&&(te([]),ne([]))};return(0,P.jsxs)(n.Fragment,{children:[(0,P.jsx)(c.aZ,{children:(0,P.jsx)(h.$Z,{handleEnterPress:async()=>{if(je||Ge){if(te([]),ne([]),!ae||!ae.trim())return void E({files:[],folders:[]});const e=(0,_.GG)("file",(0,_.vX)()),t=await l.$M.post("file_get_page",{param_path:e,page_num:1,page_size:1e4,search:ae.trim()});if(t.code!==f.m.Success)return;const i=t.data;return(0,p.yC)(i,ue.user_data.dir_show_type),ze(i),E(i),void(W=i)}if(!W)return;te([]),ne([]);const e=[],t=[];for(const t of W.files??[])t.name.includes(ae)&&e.push(t);for(const e of W.folders??[])e.name.includes(ae)&&t.push(e);E({files:e,folders:t})},placeholder:M("搜索当前目录"),icon:"search",value:"",mobile_hidden:!0,handleIconClick:()=>{const e=(0,_.GG)("file",(0,_.vX)());ke({open:!0,title:M("深搜"),context_div:(0,P.jsx)(N,{base_path:e})})},handleInputChange:e=>{le(e)},max_width:"25em"})}),(0,P.jsxs)(c.aZ,{position:"right",children:[(0,P.jsx)("div",{className:"mobile-context-btn",children:(0,P.jsx)(S.rA,{icon:"more_horiz",title:M("右键"),onClick:()=>{const e=ee[ee.length-1];if(void 0!==e){const t=[...F.folders??[],...F.files??[]][e];if(t){const i=document.querySelectorAll(".item")[e],n=i?i.getBoundingClientRect():{left:window.innerWidth/2,bottom:100},s={preventDefault:()=>{},stopPropagation:()=>{},clientX:n.left+10,clientY:n.bottom??100},o=new b.ik;o.path=(0,U.IO)((0,_.vX)(),t.name),o.filename=t.name,o.x=s.clientX,o.y=s.clientY,o.type=t.type===u.Iw.folder?u.Iw.folder:(0,b.uL)(t.name),o.size=t.origin_size,Q({show:!0,type:d.PromptEnum.FileMenu,overlay:!1,data:o})}}else{const e={preventDefault:()=>{},stopPropagation:()=>{},clientX:window.innerWidth/2,clientY:window.innerHeight/2};be(e)}}})}),(0,P.jsx)(H,{})]}),(0,P.jsx)(s.e,{baseRoute:"file",clickFun:function(){if(te([]),ne([]),ue.user_data.file_list_pagination_mode===A.yM.pagination){const e=document.getElementById("listing");e&&(e.scrollTop=0),ye({page_size:ge.page_size,page_num:1})}},input_path_enter:e=>{var t;te([]),ne([]),E({files:[],folders:[]}),!function(e){return"string"==typeof e&&0!==e.length&&(/^[a-zA-Z]:[\\\/]/.test(e)||/^\\\\[^\\/]+[\\/]/.test(e)||/^\//.test(e))}(e)?D(function(e,t){let i=function(e){let t="\\";for(const i of e)if("/"===i||"\\"===i){t=i;break}return t}(e);if("."===t)return e;if(".."===t){if(e.length>1){let t=e[e.length-1]===i?1:0;for(let n=e.length-1-t;n>=0;n--)if(e[n]===i)return e.substring(0,n+1)}return e}return e.endsWith(i)&&t.startsWith(i)?e.slice(0,-1)+t:e.endsWith(i)||t.startsWith(i)?e+t:e+i+t}((0,_.vX)(),e)):(e=e.replace(0===(t=ue.user_data).folder_item_now||void 0===t.folder_item_now?t.cwd:t.folder_items[t.folder_item_now-1].path,""),D(e))}}),q&&(0,P.jsxs)("div",{className:"mount-tip-bar",style:{borderLeftColor:q.color},children:[(0,P.jsx)("span",{className:"material-icons",style:{color:q.color},children:"cloud"}),(0,P.jsxs)("span",{children:[M("当前为挂载目录"),":",q.name]}),(0,P.jsx)("span",{className:"mount-driver-tag",children:Z.C1.find(e=>e.value===q.driver)?.title??q.driver}),q.readonly&&(0,P.jsx)("span",{className:"mount-readonly-tag",children:M("只读")})]}),ue.user_data.file_list_pagination_mode===A.yM.pagination?(0,P.jsx)(C.$J,{handleContextMenu:be,clickBlank:Pe,list:F.files}):(0,P.jsx)(C.t$,{handleContextMenu:be,file_list:F.files,folder_list:F.folders,clickBlank:Pe}),re&&(0,P.jsx)(B,{}),de.open&&(0,P.jsx)(O,{})]})}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[9546],{75007(e,t,s){s.d(t,{h:()=>r});s(96540);var n=s(85997),i=s(74848);function r(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){var n=s(96540),i=s(16349),r=s(74848);const o=({percentage:e})=>{const t=(0,n.useRef)(null),[s,o]=(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 o(n),()=>{n.destroy()}},[]),(0,n.useEffect)(()=>{s&&(s.data.datasets[0].data=[e,100-e],s.update())},[e]),(0,r.jsx)("div",{style:{width:"8rem",overflow:"hidden"},children:(0,r.jsx)("canvas",{ref:t})})};s.d(t,["A",0,o])},77481(e,t,s){s.d(t,{S:()=>c,X:()=>o});var n=s(96540),i=s(61443),r=s(74848);function o(e){const[t,s]=n.useState([]),o=(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=()=>{o.current=-1,l(-1),d(-1)};return(0,r.jsxs)("table",{children:[(0,r.jsx)("thead",{children:(0,r.jsx)("tr",{children:e.headers?.map((t,s)=>{const n=!!e.filter&&(e.filter.column??0)===s;let o=t;if(n){const s=e.filter,n=s.options.find(e=>e.value===s.value);null!=s.value&&n&&(o=`${t} (${n.label})`)}return(0,r.jsx)("th",{className:n?"table-filter-col":"",children:n?(0,r.jsx)(i.l6,{value:e.filter.value,options:e.filter.options,onChange:e.filter.onChange,bare:!0,trigger_label:o}):t},s)})})}),(0,r.jsx)("tbody",{children:t.map((t,s)=>{const n=!!e.onRowDrag;return(0,r.jsx)("tr",{className:n?(c===s?"row-dragging":"")+(a===s?" row-drop-target":""):"",draggable:n,onContextMenu:()=>{e.handleContextMenu&&e.handleContextMenu(t)},onDragStart:e=>{n&&(o.current=s,l(s),e.dataTransfer.effectAllowed="move")},onDragOver:e=>{!n||o.current<0||(e.preventDefault(),e.dataTransfer.dropEffect="move",d(s))},onDrop:t=>{n&&(t.preventDefault(),(()=>{const t=o.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,r.jsx)("td",{className:i,style:{width:e.width??"auto"},children:s},n)})},s)})})]})}function c(e){return(0,r.jsx)("div",{style:{display:e.isFlex?"flex":"block"},children:e.columns.map((e,t)=>(0,r.jsx)("div",{children:e},t))})}},88062(e,t,s){s(96540),s(47022);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 r=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)(r,{node:t,click:e.click,onContextMenu:e.onContextMenu,render:e.render},s))})]}),o=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)(r,{node:t,click:e.click,onContextMenu:e.onContextMenu,render:e.render},s))})});s.d(t,["A",0,o])},59546(e,t,s){s.r(t),s.d(t,{default:()=>le});var n=s(96540),i=s(75725),r=s(70447),o=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(86149),m=s(34843),j=s(82893),f=s(74777),_=s(62042),g=s(61443),w=s(74848);function y(e){const{t}=(0,p.B)(),[s,o]=(0,m.fp)(j.AG.disk),[c,l]=(0,n.useState)({}),[f,_]=(0,n.useState)([]),g=[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,w.jsx)("span",{style:{color:s},children:t(n[0])}),e.push(n)}_(s.data.ata_smart_attributes),l(s.data)}})()},[]),(0,w.jsxs)("div",{children:[(0,w.jsx)(d.aZ,{position:"right",children:(0,w.jsx)(u.rA,{icon:"close",title:t("关闭"),onClick:()=>{o({})}})}),(0,w.jsx)(i.jW,{isFull:!0,more:!0,children:(0,w.jsx)(i.NN,{children:(0,w.jsxs)(i.fI,{children:[(0,w.jsxs)(i.VP,{widthPer:30,children:[(0,w.jsx)(i.xh,{children:(0,w.jsxs)(r.Zp,{title:t("基本信息"),children:[(0,w.jsx)(i.Yh,{left:t("名字"),right:e.name}),(0,w.jsx)(i.Yh,{left:t("厂商名称"),right:e.typeName}),(0,w.jsx)(i.Yh,{left:t("类型"),right:e.type}),(0,w.jsx)(i.Yh,{left:t("容量"),right:e.total})]})}),(0,w.jsx)(i.xh,{children:(0,w.jsxs)(r.Zp,{title:t("物理信息"),children:[(0,w.jsx)(i.Yh,{left:t("是否健康"),right:!0===c.smart_status?"是":"否"}),(0,w.jsx)(i.Yh,{left:t("设备型号"),right:c.model_name}),(0,w.jsx)(i.Yh,{left:t("序列号"),right:c.serial_number}),(0,w.jsx)(i.Yh,{left:t("固件版本"),right:c.firmware_version}),(0,w.jsx)(i.Yh,{left:t("转速(每分钟)"),right:c.rotation_rate}),(0,w.jsx)(i.Yh,{left:t("通电时长(小时)"),right:c.power_on_time_hours}),(0,w.jsx)(i.Yh,{left:t("通电次数"),right:c.power_cycle_count}),(0,w.jsx)(i.Yh,{left:t("温度(°C)"),right:c.temperature}),(0,w.jsx)(i.Yh,{left:t("通信协议"),right:c.device_protocol})]})})]}),(0,w.jsx)(i.VP,{widthPer:50,children:(0,w.jsxs)(i.xh,{children:[f?.length?(0,w.jsx)(r.uF,{title:t("ATA/SATA详细信息"),children:(0,w.jsx)(h.X,{headers:g,rows:f,width:"10rem"})}):(0,w.jsx)(w.Fragment,{}),c.nvme_smart?(0,w.jsxs)(r.Zp,{title:t("NVME详细信息"),children:[(0,w.jsx)(i.Yh,{left:t("NVMe 可用备用块(%)"),right:c.nvme_smart.available_spare}),(0,w.jsx)(i.Yh,{left:t("NVMe 已使用寿命(%)"),right:c.nvme_smart.percentage_used}),(0,w.jsx)(i.Yh,{left:t("NVMe 读取量"),right:c.nvme_smart.data_units_read}),(0,w.jsx)(i.Yh,{left:t("NVMe 写入量"),right:c.nvme_smart.data_units_written}),(0,w.jsx)(i.Yh,{left:t("NVMe 通电次数"),right:c.nvme_smart.power_cycles}),(0,w.jsx)(i.Yh,{left:t("NVMe 通电时长(小时)"),right:c.nvme_smart.power_on_hours}),(0,w.jsx)(i.Yh,{left:t("NVMe 非正常关机"),right:c.nvme_smart.unsafe_shutdowns}),(0,w.jsx)(i.Yh,{left:t("NVMe 媒体错误"),right:c.nvme_smart.media_errors}),(0,w.jsx)(i.Yh,{left:t("NVMe 错误日志数"),right:c.nvme_smart.num_err_log_entries})]}):(0,w.jsx)(w.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,w.jsxs)("div",{style:{border:"2px solid black",padding:"10px",width:"300px",height:"300px",position:"relative"},children:[e.name,e.lvms.map((e,t)=>(0,w.jsx)("div",{style:{margin:"5px",height:"40px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid "},children:e.name},t))]});function P(){return(0,w.jsx)("div",{style:{position:"relative",height:"300px",margin:"10px",width:"30px",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,w.jsx)("div",{style:{width:0,height:0,borderTop:"10px solid transparent",borderBottom:"10px solid transparent",borderLeft:"10px solid black"}})})}function V(){const{t:e}=(0,p.B)(),[t,s]=(0,m.fp)(j.AG.disk),[o,c]=(0,n.useState)({}),[l,f]=(0,n.useState)([]),[g,y]=(0,n.useState)([]),[V,Y]=(0,m.fp)(j.AG.showPrompt),{check_user_auth:$}=(0,S.MH)(),[F,I]=(0,n.useState)([]),{click_file:M}=(0,C.kZ)(),[N,E]=(0,m.fp)(j.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&&f(e.data),e.code};(0,n.useEffect)(()=>{(async()=>{B()})()},[]);const H=[(0,w.jsx)(u.rA,{icon:"info",title:e("提示"),onClick:async()=>{E({open:!0,title:"信息",context_div:(0,w.jsx)("div",{children:(0,w.jsxs)("ul",{children:[(0,w.jsxs)("li",{children:["通用格式:","<文件系统> <挂载点> <类型> <挂载选项> <dump> <fsck> "]}),(0,w.jsxs)("li",{children:["文件系统,有多种格式",(0,w.jsxs)("ul",{children:[(0,w.jsx)("li",{children:"1(usb口默认名称)./dev/sda1"}),(0,w.jsx)("li",{children:"2(唯一Id).UUID=123e4567-e89b-12d3-a456-426614174000"}),(0,w.jsx)("li",{children:"3.LABEL=DATA"})]})]}),(0,w.jsx)("li",{children:"挂载点,就是文件路径,例如 /mnt/data ,这个目录要提前创建,且为空"}),(0,w.jsx)("li",{children:"类型,就是文件系统类型,对于系统不支持的类型,例如ntfs需要额外前提安装ntfs-3g(linux 5.15内核以后自带 ntfs)"}),(0,w.jsxs)("li",{children:['挂载选项的值只能是以下这些,可以用 "," 同时使用多个选项',(0,w.jsxs)("ul",{children:[(0,w.jsx)("li",{children:"defaults:使用默认挂载选项"}),(0,w.jsx)("li",{children:"noatime:不更新访问时间,提高性能"}),(0,w.jsx)("li",{children:"auto:系统启动时自动挂载"}),(0,w.jsx)("li",{children:"rw:以读写方式挂载"}),(0,w.jsx)("li",{children:"nofail:防止启动阻塞,挂载失败系统继续执行"}),(0,w.jsx)("li",{children:"...等"})]})]}),(0,w.jsx)("li",{children:"dump 0是需要备份 1是不需要备份"}),(0,w.jsx)("li",{children:"Fsck 整数值0是不检查,文件系统检查顺序越小越先检查"}),(0,w.jsx)("li",{children:"提示:只有含有文件系统的逻辑卷,或者分区才可以进行挂载。"})]})})})}}),(0,w.jsx)(u.rA,{icon:"update",title:e("更新挂载"),onClick:async()=>{(await a.Yu.post("cmd/exe",{type:v.mount})).code===x.m.Success&&(0,_.SK)("挂载文件已生效")}},1)],Z=async()=>(await a.Yu.get("get_fstab")).data,G=async e=>{await a.Yu.post("save_fstab",{content:e})};return(0,w.jsxs)("div",{children:[(0,w.jsx)(d.aZ,{position:"right",children:(0,w.jsx)(u.rA,{icon:"close",title:e("关闭"),onClick:()=>{s({})}})}),(0,w.jsx)(i.jW,{isFull:!0,more:!0,children:(0,w.jsx)(i.NN,{children:(0,w.jsxs)(i.fI,{children:[(0,w.jsx)(i.VP,{widthPer:40,children:(0,w.jsxs)(r.Zp,{title:e("物理块(硬盘)设备、逻辑卷、物理卷"),titleCom:(0,w.jsxs)("div",{children:[$(b.oV.sys_disk_mount)&&(0,w.jsx)(u.rA,{icon:"file_open",title:e("打开挂载文件"),onClick:async()=>{M({name:"fstab(谨慎修改,内容错误会导致系统无法启动)",model:"text",get_file_fun:Z,save_file_fun:G,menu_list:H})}}),(0,w.jsx)(u.rA,{icon:"update",title:e("刷新"),onClick:async()=>{await B()===x.m.Success&&(0,_.SK)("刷新成功")}})]}),children:[(0,w.jsx)(h.X,{headers:K,rows:g,width:"10rem"}),(0,w.jsx)(k.A,{list:l,render:e=>{let t=e.name;return e.label&&(t+=`(${e.label})`),e.mountpoint?(0,w.jsxs)("span",{children:[t,(0,w.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,w.jsx)(r.xP,{children:s}),(0,w.jsx)(r.xP,{children:t.uuid}),e(t.type),e(t.fstype),t.fssize,t.size,(0,w.jsx)(r.xP,{children:t.path}),t.pttype]])}})]})}),(0,w.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 o=[];for(const e of t.lv_list)o.push({name:`${e.name}---(${e.size})`});return(0,w.jsx)(r.Zp,{children:(0,w.jsxs)(i.n5,{children:[(0,w.jsx)(A,{name:e("物理卷"),lvms:n}),(0,w.jsx)(P,{}),(0,w.jsx)(A,{name:`${e("逻辑卷")}---(${t.name})---size(${t.size})`,lvms:[]}),(0,w.jsx)(P,{}),(0,w.jsx)(A,{name:e("逻辑卷"),lvms:o})]})},s)})})]})})})]})}var Y=s(88815);let $=!0;function F(e){const{t}=(0,p.B)(),s=[t("名字"),t("厂商名称"),t("类型"),t("容量")],g=[t("名字"),t("物理硬盘"),t("文件系统类型"),t("挂载位置"),t("总容量"),t("剩余容量")],[v,k]=(0,m.fp)(j.AG.user_base_info),[S,C]=(0,n.useState)(0),[A,P]=(0,n.useState)(0),[F,I]=(0,n.useState)(0),[M,N]=(0,n.useState)(0),[E,K]=(0,n.useState)(0),[B,H]=(0,n.useState)({}),[Z,G]=(0,n.useState)(!1),[D,z]=(0,n.useState)(!1),[W,T]=(0,n.useState)(!1),[X,U]=(0,n.useState)($),[q,L]=(0,n.useState)(null),[R,O]=(0,n.useState)([]),[J,Q]=(0,n.useState)([]),[ee,te]=(0,m.fp)(j.AG.user_base_info),[se,ne]=(0,m.fp)(j.AG.disk),ie=async()=>{if(!$)return;const e=new c.hf(c.HK.sys_get);await l.ws.send(e),l.ws.addMsg(c.HK.sys_getting,e=>{N(e.context?.cpu_currentLoad);const t=e.context?.memLeft,s=e.context?.memTotal;P(t),I(s),C((s-t)/s*100),L(e.context?.node_memory_usage),K(e.context?.node_cpu_usage)})};return(0,n.useEffect)(()=>((async()=>{await ie()})(),()=>{l.ws.sendData(c.HK.sys_cancel,{})}),[]),(0,w.jsxs)("div",{children:[(0,w.jsxs)(d.aZ,{position:"right",children:[v.sys===b.XM.linux&&(0,w.jsx)(u.rA,{icon:"sd_card",title:"硬盘挂载",onClick:()=>{ne({type:"mount"})}}),(0,w.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,w.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[f.jk.smartmontools]&&ee.sysSoftWare[f.jk.smartmontools].installed||(i=!1);for(const e of s??[])n.push([(0,w.jsx)(r.xP,{context:e.name}),e.typeName,e.type,e.total,(0,w.jsx)(u.rA,{icon:"health_and_safety",title:t("查看健康信息"),onClick:()=>{i?ne({type:"check",data:e}):(0,_.zN)("没有安装smartmontools")}})]);O(n)}})()}}),(0,w.jsx)(u.Z$,{defaultStatus:!1,text:t("文件硬盘"),clickFun:e=>{T(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,w.jsx)(r.xP,{context:e.name}),(0,w.jsx)(r.xP,{context:e.device_name}),e.fsType,(0,w.jsx)(r.xP,{context:e.mount}),e.total,e.available]);Q(s)}})()}}),(0,w.jsx)(u.Z$,{defaultStatus:X,text:t("实时信息"),clickFun:e=>{U(e),$=e,ie()}})]}),(0,w.jsxs)(i.xh,{children:[X&&(0,w.jsxs)(i.fI,{children:[(0,w.jsx)(i.VP,{widthPer:33,maxWidth:"30rem",children:(0,w.jsx)(r.Zp,{title:"Sys "+t("内存"),children:(0,w.jsxs)(i.fI,{children:[(0,w.jsx)(i.VP,{children:(0,w.jsx)(o.A,{percentage:S})}),(0,w.jsx)(i.VP,{children:(0,w.jsxs)(i.fI,{children:[(0,w.jsx)(i.VP,{widthPer:100,children:(0,w.jsx)("div",{children:(0,w.jsx)(i.Yh,{left:t("总容量"),center:`${F}G`})})}),(0,w.jsx)(i.VP,{widthPer:100,children:(0,w.jsx)(i.Yh,{left:t("剩余"),center:`${A}G`})})]})})]})})}),(0,w.jsx)(i.VP,{widthPer:33,maxWidth:"30rem",children:(0,w.jsx)(r.Zp,{title:"Sys cpu",children:(0,w.jsxs)(i.fI,{children:[(0,w.jsx)(i.VP,{children:(0,w.jsx)(o.A,{percentage:M})}),(0,w.jsx)(i.VP,{children:(0,w.jsx)(i.fI,{children:(0,w.jsx)(i.Yh,{left:t("使用率"),center:M})})})]})})}),(0,w.jsx)(i.VP,{widthPer:33,maxWidth:"30rem",children:(0,w.jsx)(r.Zp,{title:"FileCat",children:(0,w.jsxs)(i.fI,{children:[(0,w.jsxs)(i.VP,{children:[(0,w.jsx)(i.qV,{content:t("内存")}),(0,w.jsx)(i.qV,{content:"total: "+(0,Y.v7)(q?.rss)}),(0,w.jsx)(i.qV,{content:"object: "+(0,Y.v7)(q?.heapTotal)}),(0,w.jsx)(i.qV,{content:"obj-use: "+(0,Y.v7)(q?.heapUsed)}),(0,w.jsx)(i.qV,{content:"external: "+(0,Y.v7)(q?.external)}),(0,w.jsx)(i.qV,{content:"buffer: "+(0,Y.v7)(q?.arrayBuffers)})]}),(0,w.jsx)(i.VP,{children:(0,w.jsx)(i.qV,{content:"cpu growth rate: "+E})})]})})})]}),(0,w.jsxs)(i.fI,{children:[Z&&(0,w.jsx)(i.VP,{children:(0,w.jsxs)(r.Zp,{title:t("基本信息"),children:[(0,w.jsx)(i.Yh,{left:t("总内存"),right:B.mem_total}),(0,w.jsx)(i.Yh,{left:`cpu ${t("制造商")}`,right:B.cpu_manufacturer}),(0,w.jsx)(i.Yh,{left:`cpu ${t("品牌")}`,right:B.cpu_brand}),(0,w.jsx)(i.Yh,{left:`cpu ${t("逻辑核心")}`,right:B.cpu_core_num}),(0,w.jsx)(i.Yh,{left:`cpu ${t("物理核心")}`,right:B.cpu_phy_core_num}),(0,w.jsx)(i.Yh,{left:`cpu ${t("最大")}hz`,right:B.cpu_speed_hz}),(0,w.jsx)(i.Yh,{left:`${t("当前系统")}:pid;ppid`,right:B.pid_ppid}),(0,w.jsx)(i.Yh,{left:t("运行用户"),right:B.user})]})}),D&&(0,w.jsx)(i.VP,{children:(0,w.jsx)(r.uF,{title:t("物理硬盘"),children:(0,w.jsx)(h.X,{headers:s,rows:R,width:"10rem"})})}),W&&(0,w.jsx)(i.VP,{children:(0,w.jsx)(r.uF,{title:t("文件硬盘"),children:(0,w.jsx)(h.X,{headers:g,rows:J,width:"10rem"})})})]})]}),se&&"check"===se.type&&(0,w.jsx)(y,{...se.data}),se&&"mount"===se.type&&(0,w.jsx)(V,{})]})}var I=s(75007),M=s(97856),N=s(64405);const E=n.lazy(()=>Promise.all([s.e(2543),s.e(5614)]).then(()=>s(85614)));function K(e){const[t,s]=(0,n.useState)(null),[i,r]=(0,m.fp)(j.AG.dockerShellShow),[o,a]=(0,m.fp)(j.AG.user_base_info),d=o.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 M.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,w.jsx)(E,{show:i.show,terminal:t,init:(e,s)=>{t.writeln("[38;2;29;153;243mconnect...[0m ");const n=new N.n;let r;n.rows=e,n.cols=s,n.dockerId=i.dockerId,r="logs"===i.type?new c.hf(c.HK.docker_shell_logs):new c.hf(c.HK.docker_shell_exec_open),r.context=n,l.ws.send(r)}})}var B=s(83529),H=s(86090),Z=s(87361);let G="",D=[],z=!1;function W(e){const{t}=(0,p.B)(),s=(0,H.Zp)(),[o]=(0,m.fp)(j.AG.user_base_info),[f,y]=(0,n.useState)({}),[v,k]=(0,n.useState)([]),[C,A]=(0,n.useState)([]),{check_user_auth:P}=(0,S.MH)(),[V,Y]=(0,m.fp)(j.AG.dockerShellShow),[$,F]=(0,m.fp)(j.AG.showPrompt),[M,N]=(0,m.fp)(j.AG.confirm),[E,W]=(0,n.useState)(G),[T,X]=(0,n.useState)(["id",t("名字"),t("镜像"),t("命令"),t("状态"),t("内存"),"cpu%",t("选择")]),[U,q]=(0,n.useState)([]),[L,R]=(0,n.useState)(void 0),[O,J]=(0,n.useState)(!1),Q=["id",t("name"),t("create时间"),t("大小"),(0,w.jsxs)("span",{children:["选中",(0,w.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;y(e)}})]})],ee=async()=>{k([]),q([]);const e=new c.hf(c.HK.docker_get);await l.ws.send(e),l.ws.addMsg(c.HK.docker_getting,e=>{const t=[];if(G){for(const s of e.context)for(const e of s)if(`${e}`.includes(G)){t.push(s);break}}else t.push(...e.context);k(t.map(e=>{const t=e.map(e=>(0,w.jsx)(r.xP,{context:e}));return t.push((0,w.jsx)(u.rA,{icon:"place",title:"选中",onClick:()=>{q(t)}})),t}))})};(0,n.useEffect)(()=>(W(G),ee(),()=>{(async()=>{Y({show:!1,type:"",dockerId:""})})()}),[]),(0,n.useEffect)(()=>{G=E},[E]);const te=()=>{const e=new c.hf("logs"===V.type?c.HK.docker_shell_logs_cancel:c.HK.docker_shell_exec_cancel);e.context="",l.ws.send(e)},se=e=>{const t=new c.hf(c.HK.docker_switch);t.context={type:e,dockerId:U[0].props.context},q([]),l.ws.send(t)},ne=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,w.jsx)(r.xP,{context:n[0]}),(0,w.jsx)(r.xP,{context:n[1]}),n[2],n[3],""];s.push(i)}D=s,A(s)}};return(0,w.jsxs)("div",{children:[(0,w.jsx)(d.aZ,{children:(0,w.jsx)(u.Z$,{defaultStatus:!1,text:t("doc_img"),clickFun:e=>{J(e),e?(ne(),q([])):(ee(),A([]),y({}))}})}),(0,w.jsxs)(d.aZ,{position:"right",children:[o.sys===b.XM.linux&&(0,w.jsx)(u.rA,{icon:"settings",title:t("doc_cfg"),onClick:()=>s(Z.o.docker_setting_page)}),Object.keys(f).length>0&&(0,w.jsx)(u.rA,{icon:"delete",title:t("删除镜像"),onClick:async()=>{N({open:!0,title:t("doc_icf"),handle:async()=>{const e=Object.keys(f),t=await a.Yu.post("docker/check/delete",{ids:e});if(t.code===x.m.Success)if(0===t.data.length){(await a.Yu.post("docker/delete",{ids:e})).code===x.m.Success&&((0,_.SK)("删除完成"),ne(),N({open:!1,handle:null}))}else(0,_.N9)(`有镜像正在运行${JSON.stringify(t.data)}`)}})}}),U.length>0&&(0,w.jsx)("div",{children:U[1].props.context}),U.length>0&&(0,w.jsxs)("div",{children:[P(b.oV.docker_container_update)&&(0,w.jsx)(u.rA,{icon:"delete",title:t("删除容器"),onClick:()=>{F({show:!0,overlay:!0,type:B.PromptEnum.DockerDel,data:{dockerId:U[0].props.context,name:U[1].props.context}})}}),(0,w.jsx)(u.rA,{icon:"print",title:t("打印日志"),onClick:()=>{V.show?(Y({show:!1,type:"",dockerId:""}),te()):Y({show:!0,dockerId:U[0].props.context,type:"logs"})}}),P(b.oV.docker_container_update)&&(0,w.jsx)(u.rA,{icon:"personal_video",title:t("执行命令"),onClick:()=>{V.show?(Y({show:!1,type:"",dockerId:""}),te()):Y({show:!0,dockerId:U[0].props.context,type:"exec"})}}),P(b.oV.docker_container_update)&&U[4].props.context.includes("Up")&&(0,w.jsx)(u.rA,{icon:"stop",title:t("停止"),onClick:()=>se("stop")}),P(b.oV.docker_container_update)&&!U[4].props.context.includes("Up")&&(0,w.jsx)(u.rA,{icon:"play_arrow",title:t("开启"),onClick:()=>{se("start")}})]}),(0!==v.length||E)&&!O&&(0,w.jsx)(u.rA,{icon:"refresh",title:t("列表更新"),onClick:async()=>{const e=new c.hf(c.HK.docker_get);await l.ws.send(e)}})]}),(0,w.jsxs)(i.xh,{children:[O&&(0,w.jsx)(i.fI,{children:(0,w.jsx)(i.VP,{widthPer:80,children:(0,w.jsx)(r.uF,{title:`${t("镜像")} (${C.length})`,titleCom:(0,w.jsx)(g.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,w.jsx)(h.X,{headers:Q,rows:C.map((e,s)=>(e[4]=(0,w.jsx)(g.GL,{context:t(""),selected:f[e[0].props.context],onchange:()=>{(e=>{const t={};Object.assign(t,f),t[e]?delete t[e]:t[e]=1,y(t)})(e[0].props.context)}}),e)),width:"10rem"})})})}),0===v.length&&!E&&!O&&(0,w.jsx)(I.h,{context:t("dc_nne")}),(0!==v.length||E)&&!O&&(0,w.jsx)(i.fI,{children:(0,w.jsx)(i.VP,{widthPer:80,children:(0,w.jsx)(r.uF,{title:`${t("容器")} (${v.length})`,titleCom:(0,w.jsx)(g.Sm,{placeholder:t("过滤"),value:E,handleInputChange:e=>{W(e)}}),children:(0,w.jsx)(h.X,{headers:T,rows:v,width:"10rem"})})})})]}),(0,w.jsx)(K,{})]})}var T=s(64694);let X="",U=!1,q=!1;function L(e){const{t}=(0,p.B)(),[s,o]=(0,n.useState)([]),[a,x]=(0,n.useState)([]),[m,j]=(0,n.useState)(0),[f,_]=(0,n.useState)(""),[y,v]=(0,n.useState)(["pid",t("名字"),t("创建用户"),(0,w.jsxs)("span",{children:[t("内存"),(0,w.jsx)(u.rA,{icon:"sort",title:t("升序"),onClick:()=>{U=!U}})]}),(0,w.jsxs)("span",{children:["cpu%",(0,w.jsx)(u.rA,{icon:"sort",title:t("升序"),onClick:()=>{q=!q}})]}),t("选择")]),{check_user_auth:k}=(0,S.MH)();(0,n.useEffect)(()=>{_(X),(async()=>{o([]),j(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);U&&(0,T.di)(s,e=>e[3],!1),q&&(0,T.di)(s,e=>e[4],!1);const n=s.map(e=>{const s=e.map((e,t)=>(0,w.jsx)(r.xP,{context:3===t?(0,Y.v7)(e):e}));return s.push((0,w.jsx)(u.rA,{icon:"place",title:t("选中"),onClick:()=>{x(s)}})),s});j(s.length),o(n)})})()},[]),(0,n.useEffect)(()=>{X=f},[f]);return(0,w.jsxs)("div",{children:[(0,w.jsxs)(d.aZ,{position:"right",children:[a.length>0&&(0,w.jsx)("div",{children:a[1].props.context}),a.length>0&&k(b.oV.sys_process_close)&&(0,w.jsx)("div",{children:(0,w.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,w.jsx)(i.xh,{children:0!==s.length||X?(0,w.jsx)(i.fI,{children:(0,w.jsx)(i.VP,{widthPer:80,children:(0,w.jsx)(r.uF,{title:`${t("进程")} (${m})`,titleCom:(0,w.jsx)(g.Sm,{placeholder:t("过滤"),value:f,handleInputChange:e=>{_(e)}}),children:(0,w.jsx)(h.X,{headers:y,rows:s,width:"10rem"})})})}):(0,w.jsx)(I.h,{context:t("ld_wait")})})]})}const R=n.lazy(()=>Promise.all([s.e(2543),s.e(5614)]).then(()=>s(85614)));function O(e){const[t,s]=(0,n.useState)(null),[i,r]=(0,m.fp)(j.AG.systemd_shell_show),[o,a]=(0,m.fp)(j.AG.user_base_info),d=o.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 M.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,w.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},r=new c.hf(c.HK.systemd_logs_get);r.context=n,l.ws.send(r)}})}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=[];return 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()}`),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"},s=(t,s)=>{const n=e.split(/\r?\n/);let i=!1;for(const e of n){const n=e.trim(),r=n.match(/^\[(.*)\]$/);if(r){i=(r[1]||"").trim()===t;continue}if(!i)continue;const o=n.match(new RegExp(`^${s}\\s*=\\s*(.*)$`,"i"));if(o)return o[1].trim()}return""};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",t}function ne(e){const{t}=(0,p.B)(),[s,i]=(0,n.useState)("form"),[r,o]=(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"}),[d,u]=(0,n.useState)(""),[h,m]=(0,n.useState)(""),[j,f]=(0,n.useState)(!1);(0,n.useEffect)(()=>{"edit"===e.mode&&e.unit_name&&(async()=>{f(!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??"";m(n),u(s),l(se(s))}finally{f(!1)}})()},[e.mode,e.unit_name]);const y=e=>{e!==s&&("text"===e?u(te(r,c)):l(se(d)),i(e))},v=e=>t=>{l(s=>({...s,[e]:t}))};return(0,w.jsxs)("div",{children:[(0,w.jsxs)("div",{style:{display:"flex",gap:"0.4rem",marginBottom:"0.6rem"},children:[(0,w.jsx)("button",{className:"button button--flat "+("form"===s?"":"button--grey"),onClick:()=>y("form"),children:t("表单")}),(0,w.jsx)("button",{className:"button button--flat "+("text"===s?"":"button--grey"),onClick:()=>y("text"),children:t("文本")})]}),j?(0,w.jsx)("div",{children:t("加载中...")}):"form"===s?(0,w.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"0.6rem"},children:[(0,w.jsx)(g.BC,{label:t("服务名称"),children:(0,w.jsx)(g.Sm,{placeholder:t("服务名称"),value:r,disabled:"edit"===e.mode,handleInputChange:e=>o(e),width:"100%"})}),(0,w.jsx)(g.BC,{label:t("服务描述"),children:(0,w.jsx)(g.Sm,{placeholder:t("服务描述"),value:c.description,handleInputChange:v("description"),width:"100%"})}),(0,w.jsx)(g.BC,{label:t("启动命令"),required:!0,children:(0,w.jsx)(g.Sm,{placeholder:t("ExecStart 启动命令,必填"),value:c.exec_start,handleInputChange:v("exec_start"),width:"100%"})}),(0,w.jsx)(g.BC,{label:t("运行类型"),children:(0,w.jsx)(g.l6,{options:Q,value:c.type,onChange:v("type")})}),(0,w.jsx)(g.BC,{label:t("工作目录"),children:(0,w.jsx)(g.Sm,{placeholder:t("工作目录(可选)"),value:c.working_dir,handleInputChange:v("working_dir"),width:"100%"})}),(0,w.jsx)(g.BC,{label:t("运行用户"),children:(0,w.jsx)(g.Sm,{placeholder:t("运行用户(可选)"),value:c.user_,handleInputChange:v("user_"),width:"100%"})}),(0,w.jsx)(g.BC,{label:t("重启策略"),children:(0,w.jsx)(g.l6,{options:J,value:c.restart,onChange:v("restart")})}),(0,w.jsx)(g.BC,{label:t("安装目标"),children:(0,w.jsx)(g.l6,{options:ee,value:c.wanted,onChange:v("wanted")})})]}):(0,w.jsx)("textarea",{className:"input--textarea input--no_border",style:{width:"100%",minHeight:"16rem",fontFamily:"monospace",fontSize:"0.85rem",boxSizing:"border-box"},value:d,onChange:e=>u(e.target.value),spellCheck:!1}),(0,w.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"0.4rem",marginTop:"0.6rem"},children:[(0,w.jsx)("button",{className:"button button--flat button--grey",disabled:j,onClick:e.onClose,children:t("取消")}),(0,w.jsx)("button",{className:"button button--flat",disabled:j,onClick:async()=>{if(!r.trim())return void(0,_.zN)(t("请填写服务名称"));const n=(i=r).trim().endsWith(".service")?i.trim():`${i.trim()}.service`;var i;const o="text"===s?d:te(n,c);if(o.includes("ExecStart=")){f(!0);try{if("create"===e.mode){const e=`/etc/systemd/system/${n}`;await a.Yu.post("systemd/sys/save",{unit_name:n,path:e,context:o}),await a.Yu.post("systemd/sys/enable",{unit_name:n}),await a.Yu.post("systemd/add",{unit_name:n}),(0,_.SK)(t("添加成功"))}else await a.Yu.post("systemd/sys/save",{unit_name:n,path:h,context:o}),(0,_.SK)(t("保存成功"));e.onClose(),e.onDone?.()}catch(e){console.error("systemd 保存失败",e)}finally{f(!1)}}else(0,_.zN)(t("请至少填写 ExecStart 启动命令"))},children:t("保存")})]})]})}let ie,re="";function oe(e){const{t}=(0,p.B)(),{check_user_auth:s}=(0,S.MH)(),[o,f]=(0,m.fp)(j.AG.systemd_shell_show),[y,v]=(0,m.fp)(j.AG.confirm),[k,C]=(0,n.useState)(["pid","name","process",t("创建用户"),t("内存"),t("cpu%"),t("active状态"),t("选择")]),[A,P]=(0,n.useState)(["单元名字","加载状态",t("active(sub)状态"),t("描述"),t("选择")]),[V,$]=(0,n.useState)([]),[F,M]=(0,n.useState)([]),[N,E]=(0,n.useState)([]),[K,B]=(0,n.useState)(!1),[H,Z]=(0,n.useState)([]),[G,D]=(0,n.useState)(""),[z,W]=(0,n.useState)(""),[T,X]=(0,n.useState)(new Set),[U,q]=(0,m.fp)(j.AG.editorSetting),[L,R]=(0,m.fp)(j.AG.prompt_card);(0,n.useEffect)(()=>{W(re),(async()=>{$([]),E([]);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(re){for(const s of e.context)for(const e of s)if(`${e}`.includes(re)){t.push(s);break}}else t.push(...e.context);$(t.map(e=>{const t=e.map((e,t)=>(0,w.jsx)(r.xP,{context:4===t?(0,Y.v7)(e):e}));return t.push((0,w.jsx)(u.rA,{icon:"place",title:"选中",onClick:()=>{E(t)}})),t}))})})()},[]),(0,n.useEffect)(()=>{re=z},[z]);const J=e=>{if(o.show){f({show:!1,unit_name:""});const e=new CustomEvent("cancel_systemd_logs",{detail:{}});document.dispatchEvent(e)}else f({show:!0,unit_name:e})},Q=async()=>{M([]),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,w.jsx)(r.xP,{context:t.unit}),t.load,`${t.active}(${t.sub})`,(0,w.jsx)(r.xP,{context:t.description})];s.push([...e,(0,w.jsx)(u.rA,{icon:"place",title:"添加",onClick:()=>{Z([...e])}})])}ie=s,M(s)}},ee=(e,s)=>{R({open:!0,title:t("create"===e?"新建 systemd 服务":"编辑 systemd 服务"),context_div:(0,w.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&&Q(),E([]),Z([])}})})};return(0,w.jsxs)("div",{children:[(0,w.jsx)(d.aZ,{children:(0,w.jsx)(u.Z$,{defaultStatus:!1,text:t("系统systemd单元"),clickFun:e=>{B(e),e?(Q(),E([])):Z([])}})}),(0,w.jsxs)(d.aZ,{position:"right",children:[s(b.oV.systemd)&&(0,w.jsx)("div",{children:(0,w.jsx)(u.rA,{icon:"add_circle",title:t("添加 systemd"),onClick:()=>{ee("create")}})}),N.length>0&&(0,w.jsx)("div",{children:N[1].props.context}),H.length>0&&(0,w.jsx)("div",{children:H[0].props.context}),N.length>0&&(0,w.jsxs)("div",{children:[s(b.oV.systemd)&&(0,w.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,_.SK)("删除成功"),v({open:!1,handle:null}))}})})(N[1].props.context)}}),s(b.oV.systemd)&&(0,w.jsx)(u.rA,{icon:"edit",title:"可视化编辑",onClick:()=>{ee("edit",N[1].props.context)}}),(0,w.jsx)(u.rA,{icon:"print",title:"打印日志",onClick:()=>{J(N[1].props.context)}})]}),H.length>0&&(0,w.jsxs)("div",{children:[s(b.oV.systemd)&&(0,w.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,_.SK)("删除成功"),v({open:!1,handle:null}))}})})(H[0].props.context)}}),(0,w.jsx)(u.rA,{icon:"print",title:"打印日志",onClick:()=>{J(H[0].props.context)}}),s(b.oV.systemd)&&(0,w.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&&(q({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(""),q({open:!1,model:"",fileName:"",save:null}))}}),S.xK.set_value_temp(s.data.context))})(H[0].props.context)}}),s(b.oV.systemd)&&!T.has(H[0].props.context)&&(0,w.jsx)(u.rA,{icon:"plus_one",title:"添加到管理",onClick:()=>(async e=>{const t=await a.Yu.post("systemd/add",{unit_name:e});t.code===x.m.Success&&(X(new Set(t.data)),(0,_.SK)("添加成功"))})(H[0].props.context)})]})]}),(0,w.jsxs)(i.xh,{children:[K&&(0,w.jsx)(i.fI,{children:(0,w.jsx)(i.VP,{widthPer:80,children:(0,w.jsx)(r.uF,{title:`systemd系统单元(${F.length})`,titleCom:(0,w.jsx)(g.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);M(e)}else M(ie)}}),children:(0,w.jsx)(h.X,{headers:A,rows:F,width:"10rem"})})})}),0===V.length&&!K&&(0,w.jsx)(I.h,{context:"没有管理的单元 or 加载中请等待..."}),0!==V.length&&!K&&(0,w.jsx)(i.fI,{children:(0,w.jsx)(i.VP,{widthPer:80,children:(0,w.jsx)(r.uF,{title:`filecat监控单元(${V.length})`,titleCom:(0,w.jsx)(g.Sm,{placeholder:"过滤单元",value:z,handleInputChange:e=>{W(e)}}),children:(0,w.jsx)(h.X,{headers:k,rows:V,width:"10rem"})})})})]}),(0,w.jsx)(O,{})]})}function ce(){const{t:e}=(0,p.B)(),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"}],[o,c]=(0,n.useState)(null),[l,f]=(0,n.useState)("allow"),[y,v]=(0,n.useState)("in"),[k,S]=(0,n.useState)("tcp"),[b,C]=(0,n.useState)(""),[A,P]=(0,n.useState)(""),[V,Y]=(0,n.useState)("list"),[$,F]=(0,n.useState)([]),[M,N]=(0,n.useState)(""),[E,K]=(0,n.useState)(!1),[B,H]=(0,m.fp)(j.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??[]),N(t?.raw??"")}}catch(e){F([]),N("")}finally{K(!1)}};(0,n.useEffect)(()=>{Z(),G()},[]);const D=!0===o?.installed,z=!0===o?.active;return(0,w.jsxs)("div",{children:[(0,w.jsxs)(d.aZ,{position:"right",children:[(0,w.jsxs)("div",{children:[e("已安装"),": ",D?(0,w.jsx)("span",{style:{color:"green"},children:"✓"}):(0,w.jsx)("span",{style:{color:"red"},children:"✗"})]}),(0,w.jsxs)("div",{children:[e("已启用"),": ",z?(0,w.jsx)("span",{style:{color:"green"},children:"✓"}):(0,w.jsx)("span",{style:{color:"gray"},children:"✗"})]}),D&&(0,w.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,_.zN)(s.message||e("操作失败"));(0,_.SK)(s.data||e(t?"已启用":"已停用")),Z(),G()}catch(e){}})(!z)}),(0,w.jsx)(u.rA,{icon:"refresh",title:e("刷新规则"),onClick:G})]}),(0,w.jsxs)(i.xh,{children:[(0,w.jsx)(i.fI,{children:(0,w.jsx)(i.VP,{widthPer:35,children:(0,w.jsxs)(r.uF,{title:e("添加ufw规则"),titleCom:(0,w.jsx)(u.rA,{icon:"add",title:e("添加"),onClick:async()=>{if(b.trim())try{const t=await a.V_.post("rule/add",{action:l,direction:y,proto:k,port:b.trim(),from:"in"===y&&A.trim()||void 0});if(t.code!==x.m.Success)return void(0,_.zN)(t.message||e("操作失败"));(0,_.SK)(t.data||e("已添加")),G()}catch(e){}else(0,_.zN)(e("请填写端口号"))}}),children:[(0,w.jsx)(g.BC,{label:e("动作"),label_width:"4rem",input_max_width:"8rem",children:(0,w.jsx)(g.l6,{options:t,value:l,onChange:e=>f(e),defaultValue:"allow"})}),(0,w.jsx)(g.BC,{label:e("方向"),label_width:"4rem",input_max_width:"8rem",children:(0,w.jsx)(g.l6,{options:s,value:y,onChange:e=>v(e),defaultValue:"in"})}),(0,w.jsx)(g.BC,{label:e("协议"),label_width:"4rem",input_max_width:"8rem",children:(0,w.jsx)(g.l6,{options:[{title:"tcp",value:"tcp"},{title:"udp",value:"udp"}],value:k,onChange:e=>S(e),defaultValue:"tcp"})}),(0,w.jsx)(g.BC,{label:e("端口"),label_width:"4rem",required:!0,children:(0,w.jsx)(g.Sm,{maxWidth:"20rem",placeholder:e("可填范围如 1000:2000"),value:b,handleInputChange:e=>C(e)})}),"in"===y&&(0,w.jsx)(g.BC,{label:e("来源"),label_width:"4rem",children:(0,w.jsx)(g.Sm,{maxWidth:"20rem",placeholder:e("IP/网段,可选"),value:A,handleInputChange:e=>P(e)})})]})})}),(0,w.jsx)(i.fI,{children:(0,w.jsx)(i.VP,{widthPer:80,children:(0,w.jsxs)(r.uF,{title:e("规则列表"),titleCom:(0,w.jsxs)("div",{style:{display:"flex",gap:"0.4rem"},children:[(0,w.jsx)(u.C3,{text:e("名单视图"),clickFun:()=>Y("list")}),(0,w.jsx)(u.C3,{text:e("文本视图"),clickFun:()=>Y("text")})]}),children:[E&&(0,w.jsx)(I.h,{context:e("加载中...")}),!E&&"list"===V&&(0===$.length?(0,w.jsx)(I.h,{context:e("暂无规则")}):(0,w.jsx)(h.X,{headers:[e("编号"),e("目标(To)"),e("动作"),e("fw_from"),e("备注"),e("操作")],rows:$.map(t=>[t.number,(0,w.jsx)(r.xP,{context:t.to,tip_context:t.to}),t.action,t.from?(0,w.jsx)(r.xP,{context:t.from,tip_context:t.from}):"",t.description||"",(0,w.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,_.zN)(s.message||e("操作失败"));(0,_.SK)(s.data||e("规则已删除")),H({open:!1,handle:null}),G()}catch(e){}}})})(t.number,t.to,t.from)})]),width:"8rem"})),!E&&"text"===V&&(M?(0,w.jsx)("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-all",fontSize:"0.85rem",margin:0},children:M}):(0,w.jsx)(I.h,{context:e("暂无规则")}))]})})})]})]})}function le(e){const{t}=(0,p.B)(),[s,n]=(0,m.fp)(j.AG.user_base_info),r=[{index:1,name:t("系统性能"),rto:"sys/",component:(0,w.jsx)(F,{})},{index:2,name:t("系统进程"),rto:"process/",component:(0,w.jsx)(L,{})},{index:3,name:t("doc_ct"),rto:"docker/",component:(0,w.jsx)(W,{})}];if(s.sys===b.XM.linux){(s.user_data?.is_root||(s.user_data?.auth_list??[]).includes(b.oV.systemd))&&r.push({index:4,name:t("systemd"),rto:"systemd/",component:(0,w.jsx)(oe,{})});(s.user_data?.is_root||(s.user_data?.auth_list??[]).includes(b.oV.firewall))&&s.sysSoftWare?.[f.jk.ufw]?.installed&&r.push({index:5,name:t("防火墙"),rto:"firewall/",component:(0,w.jsx)(ce,{})})}return(0,w.jsx)(i.W1,{optionList:r,father_route:Z.o.info})}}}]);
|