UNPKG

filecat

Version:
2 lines 9.42 kB
/*! For license information please see 603.7217c0bd2aed442c0820.js.LICENSE.txt */ "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[603],{8603(e,t,n){n.r(t),n.d(t,{default:()=>T});var r=n(6540),o=n(5725),i=n(447),a=n(7444),l=n(6417),c=n(96),u=n(5997),s=n(4251),f=n(4289),m=n(7361),d=n(4284),h=n(3459),v=n(3033),_=n(2389),p=n(2042),y=n(7952),b=n(9214),w=n(6960),g=n(8815),E=n(8247),k=n(505),x=n(3430),S=n(4694),A=n(4976);function j(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var c=r&&r.prototype instanceof l?r:l,u=Object.create(c.prototype);return F(u,"_invoke",function(n,r,o){var i,l,c,u=0,s=o||[],f=!1,m={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function(t,n){return i=t,l=0,c=e,m.n=n,a}};function d(n,r){for(l=n,c=r,t=0;!f&&u&&!o&&t<s.length;t++){var o,i=s[t],d=m.p,h=i[2];n>3?(o=h===r)&&(c=i[(l=i[4])?5:(l=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=n<2&&d<i[1])?(l=0,m.v=r,m.n=i[1]):d<h&&(o=n<3||i[0]>r||r>h)&&(i[4]=n,i[5]=r,m.n=h,l=0))}if(o||n>1)return a;throw f=!0,r}return function(o,s,h){if(u>1)throw TypeError("Generator is already running");for(f&&1===s&&d(s,h),l=s,c=h;(t=l<2?e:c)||!f;){i||(l?l<3?(l>1&&(m.n=-1),d(l,c)):m.n=c:m.v=c);try{if(u=2,i){if(l||(o="next"),t=i[o]){if(!(t=t.call(i,c)))throw TypeError("iterator result is not an object");if(!t.done)return t;c=t.value,l<2&&(l=0)}else 1===l&&(t=i.return)&&t.call(i),l<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),l=1);i=e}else if((t=(f=m.n<0)?c:n.call(r,m))!==a)break}catch(t){i=e,l=1,c=t}finally{u=1}}return{value:t,done:f}}}(n,o,i),!0),u}var a={};function l(){}function c(){}function u(){}t=Object.getPrototypeOf;var s=[][r]?t(t([][r]())):(F(t={},r,function(){return this}),t),f=u.prototype=l.prototype=Object.create(s);function m(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,u):(e.__proto__=u,F(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return c.prototype=u,F(f,"constructor",u),F(u,"constructor",c),c.displayName="GeneratorFunction",F(u,o,"GeneratorFunction"),F(f),F(f,o,"Generator"),F(f,r,function(){return this}),F(f,"toString",function(){return"[object Generator]"}),(j=function(){return{w:i,m}})()}function F(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}F=function(e,t,n,r){function i(t,n){F(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},F(e,t,n,r)}function O(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=G(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,l=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){l=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(l)throw i}}}}function N(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){return void n(e)}l.done?t(c):Promise.resolve(c).then(r,o)}function z(e){return function(e){if(Array.isArray(e))return I(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||G(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function C(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,l=[],c=!0,u=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(l.push(r.value),l.length!==t);c=!0);}catch(e){u=!0,o=e}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(u)throw o}}return l}}(e,t)||G(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function G(e,t){if(e){if("string"==typeof e)return I(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?I(e,t):void 0}}function I(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function T(){var e=C((0,r.useState)(null),2),t=e[0],n=e[1],F=(0,r.useRef)(""),G=(0,r.useRef)(""),I=C((0,a.L4)(l.AG.prompt_card),2),T=(I[0],I[1]),L=C((0,a.L4)(l.AG.share_sort_type),2),M=L[0],$=L[1],P=(0,_.Bd)().t,U=C((0,a.L4)(l.AG.selectedFileList),2),W=U[0],V=U[1],D=C((0,a.L4)(l.AG.clickFileList),2),R=(D[0],D[1]),B=(0,E.kZ)().click_file,H=C((0,A.ok)(),1)[0],Q=(0,b.oT)(),X=(0,b.xp)(),Z=(0,b.Vs)(!0),q=(0,r.useMemo)(function(){var e,n=z(null!==(e=null==t?void 0:t.items)&&void 0!==e?e:[]),r=function(e){var t;return Number(null!==(t=e.mtime)&&void 0!==t?t:0)};return M===x.t8.time_minx_max?n.sort(function(e,t){return r(e)-r(t)}):M===x.t8.time_max_min&&n.sort(function(e,t){return r(t)-r(e)}),n},[null==t?void 0:t.items,M]),J=function(){var e,t=(e=j().m(function e(){var t,o,i,a,l,c,u,s,f;return j().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,d.$M.post("share",{id:F.current,token:G.current});case 1:if((t=e.v).code===h.m.Success){(i={is_dir:t.data.is_dir}).items=null!==(o=t.data.files)&&void 0!==o?o:[],a=O(i.items);try{for(a.s();!(l=a.n()).done;)(c=l.value).origin_size=c.size,c.show_mtime=c.mtime?(0,w.s)(c.mtime):"",c.size=(0,g.v7)(c.size)}catch(e){a.e(e)}finally{a.f()}if(i.is_dir||(u=t.data.files[0],i.name=u.name,i.size=u.size,i.show_mtime=u.show_mtime),localStorage.setItem("file_share_token_".concat(F.current),G.current),s=H.get("share_preview_file_name"))try{f=t.data.files.find(function(e){return e.name===s}),B({file_path:f.path,file_url:d.$M.getDownloadUrlV2(f.path,"share_download",{share_id:F.current,share_token:G.current}),name:f.name,size:f.origin_size,opt_shell:!0,mtime:f.mtime,not_type_tip:P("未知类型,请下载查看"),close:function(){Q("share_preview_file_name",null)}})}catch(e){(0,p.zN)((null==e?void 0:e.message)||e)}else n(i)}else t.code===h.m.need_token_share&&(localStorage.removeItem("file_share_token_".concat(F.current)),(0,p.zN)("需要正确的访问token"),T({open:!0,title:"share file",confirm:function(){T({open:!1}),J()},context_div:r.createElement("div",{className:"card-content"},r.createElement(v.Sm,{placeholderOut:P("请输入访问token"),value:"",handleInputChange:function(e){G.current=e}}))}));case 2:return e.a(2)}},e)}),function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){N(i,r,o,a,l,"next",e)}function l(e){N(i,r,o,a,l,"throw",e)}a(void 0)})});return function(){return t.apply(this,arguments)}}();if((0,r.useEffect)(function(){var e=(0,f.oW)("".concat((0,f.GG)(m.o.share,(0,f.vX)())));F.current=e,G.current=localStorage.getItem("file_share_token_".concat(e)),J()},[H]),!t)return r.createElement(o.jW,{isFull:!0},r.createElement("div",{className:"common-box common-box-center"},"Loading..."));return r.createElement(r.Fragment,null,r.createElement(y.A,{left_children:r.createElement(r.Fragment,null,r.createElement("h2",null,"Share ",t.is_dir?"Folder":"File"))},W.length>0&&r.createElement(u.rA,{icon:"download",title:P("下载"),onClick:function(){for(var e=[],t=0;t<W.length;t++){var n=q[W[t]];e.push(encodeURIComponent(n.path))}var r=d.$M.getDownloadUrlV2(e,"share_download",{share_id:F.current,share_token:G.current});window.open(r)}}),t.is_dir&&r.createElement(u.rA,{icon:"grid_view",title:P("切换样式"),onClick:Z}),t.is_dir&&r.createElement(u.rA,{icon:"schedule",title:M===x.t8.time_minx_max?P("时间逆序"):P("时间顺序"),onClick:function(){var e=(0,S.jH)([x.t8.time_max_min,x.t8.time_minx_max,x.t8.defualt],M);$(e),V([]),R([])}})),r.createElement(o.xh,null,r.createElement(o.jW,{isFull:!0},r.createElement("div",{className:"common-box "},t.is_dir?r.createElement(c.QW,{share:{share_id:F.current,share_token:G.current},handleContextMenu:function(){},file_list:q,clickBlank:function(e){e.target===e.currentTarget&&(V([]),R([]))}}):r.createElement(i.uF,null,r.createElement("div",{style:{height:"25rem"},className:"common-box common-box-center"},r.createElement("div",{className:"file-icons"},r.createElement("div",{"data-type":(0,s.uL)(t.name),"data-dir":t.is_dir,"aria-label":t.name},r.createElement("i",{className:"material-icons",style:{fontSize:"10rem",display:"inline-block",lineHeight:1},"aria-label":t.name}))),r.createElement("div",{className:""},t.name),r.createElement("div",{className:""},t.size),r.createElement("div",{className:""},t.show_mtime),r.createElement(u.C3,{text:"download",clickFun:function(){var e=q[0],t=d.$M.getDownloadUrlV2(e.path,"share_download",{share_id:F.current,share_token:G.current});window.open(t)}}),r.createElement(u.C3,{text:"copy url",clickFun:function(){var e=q[0],t=d.$M.getDownloadUrlV2(e.path,"share_download",{share_id:F.current,share_token:G.current}),n=d.$M.get_full_url(t);(0,k.lW)(n),(0,p.LW)(n)}}),r.createElement(u.C3,{text:"preview",clickFun:function(){var e=q[0];X(e.name)}})))))))}}}]);