← Back
Editing: node-upload-legacy.js
!function(){function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return r(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)?r(e,t):void 0}}(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 r(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function n(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */n=function(){return r};var t,r={},i=Object.prototype,a=i.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},l="function"==typeof Symbol?Symbol:{},u=l.iterator||"@@iterator",s=l.asyncIterator||"@@asyncIterator",c=l.toStringTag||"@@toStringTag";function d(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{d({},"")}catch(t){d=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof b?t:b,a=Object.create(i.prototype),l=new O(n||[]);return o(a,"_invoke",{value:k(e,r,l)}),a}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}r.wrap=f;var h="suspendedStart",m="suspendedYield",v="executing",g="completed",y={};function b(){}function S(){}function w(){}var L={};d(L,u,(function(){return this}));var x=Object.getPrototypeOf,T=x&&x(x(P([])));T&&T!==i&&a.call(T,u)&&(L=T);var z=w.prototype=b.prototype=Object.create(L);function F(e){["next","throw","return"].forEach((function(t){d(e,t,(function(e){return this._invoke(t,e)}))}))}function E(t,r){function n(i,o,l,u){var s=p(t[i],t,o);if("throw"!==s.type){var c=s.arg,d=c.value;return d&&"object"==e(d)&&a.call(d,"__await")?r.resolve(d.__await).then((function(e){n("next",e,l,u)}),(function(e){n("throw",e,l,u)})):r.resolve(d).then((function(e){c.value=e,l(c)}),(function(e){return n("throw",e,l,u)}))}u(s.arg)}var i;o(this,"_invoke",{value:function(e,t){function a(){return new r((function(r,i){n(e,t,r,i)}))}return i=i?i.then(a,a):a()}})}function k(e,r,n){var i=h;return function(a,o){if(i===v)throw Error("Generator is already running");if(i===g){if("throw"===a)throw o;return{value:t,done:!0}}for(n.method=a,n.arg=o;;){var l=n.delegate;if(l){var u=_(l,n);if(u){if(u===y)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=v;var s=p(e,r,n);if("normal"===s.type){if(i=n.done?g:m,s.arg===y)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(i=g,n.method="throw",n.arg=s.arg)}}}function _(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,_(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),y;var a=p(i,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,y;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,y):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function j(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function P(r){if(r||""===r){var n=r[u];if(n)return n.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length)){var i=-1,o=function e(){for(;++i<r.length;)if(a.call(r,i))return e.value=r[i],e.done=!1,e;return e.value=t,e.done=!0,e};return o.next=o}}throw new TypeError(e(r)+" is not iterable")}return S.prototype=w,o(z,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:S,configurable:!0}),S.displayName=d(w,c,"GeneratorFunction"),r.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===S||"GeneratorFunction"===(t.displayName||t.name))},r.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,d(e,c,"GeneratorFunction")),e.prototype=Object.create(z),e},r.awrap=function(e){return{__await:e}},F(E.prototype),d(E.prototype,s,(function(){return this})),r.AsyncIterator=E,r.async=function(e,t,n,i,a){void 0===a&&(a=Promise);var o=new E(f(e,t,n,i),a);return r.isGeneratorFunction(t)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},F(z),d(z,c,"Generator"),d(z,u,(function(){return this})),d(z,"toString",(function(){return"[object Generator]"})),r.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},r.values=P,O.prototype={constructor:O,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!e)for(var r in this)"t"===r.charAt(0)&&a.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,i){return l.type="throw",l.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],l=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var u=a.call(o,"catchLoc"),s=a.call(o,"finallyLoc");if(u&&s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=e,o.arg=t,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),y},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),j(r),y}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;j(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:P(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),y}},r}function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function o(e,t,r,n,i,a,o){try{var l=e[a](o),u=l.value}catch(e){return void r(e)}l.done?t(u):Promise.resolve(u).then(n,i)}function l(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var a=e.apply(t,r);function l(e){o(a,n,i,l,u,"next",e)}function u(e){o(a,n,i,l,u,"throw",e)}l(void 0)}))}}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,c(n.key),n)}}function s(e,t,r){return(t=c(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function c(t){var r=function(t,r){if("object"!=e(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,r||"default");if("object"!=e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==e(r)?r:r+""}System.register(["./utils-lib-legacy.js?v=VERSION_NUMBER","./base-lib-legacy.js?v=VERSION_NUMBER","./index-legacy104.js?v=VERSION_NUMBER","./vue-virtual-scroller.esm-legacy.js?v=VERSION_NUMBER","./__commonjsHelpers__-legacy.js?v=VERSION_NUMBER"],(function(e,r){"use strict";var i,o,c,d,f,p,h,m,v,g,y,b,S,w,L,x,T,z,F,E,k,_,I,j,O,P,N,U,C,D,G,R,A,M,B,q,H,Y,K,X,J;return{setters:[function(e){i=e.w,o=e.l,c=e.e,d=e.bU,f=e.Y,p=e.a4,h=e.j0,m=e.n,v=e.b,g=e.ai,y=e.p,b=e.c},function(e){S=e.c,w=e.r,L=e.q,x=e.v,T=e.y,z=e.e,F=e.x,E=e.J,k=e.n,_=e.k,I=e.g,j=e.p,O=e.aD,P=e.H,N=e.I,U=e.F,C=e.A,D=e.B,G=e.C,R=e.z,A=e.K,M=e.M,B=e.ap,q=e.ao,H=e.an,Y=e.D,K=e.aQ},function(e){X=e._},function(e){J=e.s},null],execute:function(){var r={class:""},Q=c(S({__name:"file-cover-confirm",props:{compData:{default:function(){}}},setup:function(e,t){var n=t.expose,a=e,l=w([{label:"文件名",prop:"name"},{label:"文件差异(本地->线上)",render:function(e){return"".concat(i(e.locaSize)," -> ").concat(i(e.size))}}]);return n({onConfirm:function(e){return a.compData.confirm(e,!0),!1},onCancel:function(e){return a.compData.cancel(e,!1),!1}}),function(e,t){var n=o;return L(),x("div",{class:E(["confirm-default","text-dark relative p-2rem"])},[t[0]||(t[0]=T("div",{class:"content flex items-center mb-[10px]"},[T("i",{class:"svgtofont-el-warning text-[4rem] text-[#f0ad4e]"}),T("div",{class:"message flex flex-col flex-1 ml-4 py-[.3rem] leading-[2.4rem] text-[1.3rem]"},[T("div",{class:"text text-[1.4rem] text-[#666] leading-[2.5rem]"},"检测到上传目录包含重复文件,是否覆盖?")])],-1)),T("div",r,[z(n,{column:F(l),data:a.compData.data,"max-height":170},null,8,["column","data"])])])}}}),[["__scopeId","data-v-7012342e"]]),$=v(),V=function(){return e=function t(r){var o=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),s(this,"target",""),s(this,"uploadPath",""),s(this,"uploadElement",null),s(this,"loading",{close:function(){}}),s(this,"isUpload",!0),s(this,"isGetFiles",!1),s(this,"readFileTimeout",0),s(this,"limit",{size:32212254720,number:1e3}),s(this,"uploadStatus","paused"),s(this,"uploadLimitSize",2097152),s(this,"uploadList",[]),s(this,"uploadTime",{endTime:0,startTime:0}),s(this,"uploadInfo",{estimatedTime:0,uploadedSize:0,speedInterval:null,speedAverage:0,uploadTime:0,fileSize:0,startTime:0,endTime:0,success:0,error:0}),s(this,"fileList",[]),s(this,"fileTotalSize",0),s(this,"fileTotalNumber",0),s(this,"uploadInterval",0),s(this,"uploadCycleSize",[]),s(this,"speedLastTime",0),s(this,"timerSpeed",0),s(this,"uploadError",0),s(this,"nodeId",0),s(this,"isOpenCoverLayer",0),s(this,"uploadedFiles",[]),s(this,"initData",(function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];o.uploadStatus="paused",o.uploadList=[],o.isUpload=!0,o.uploadTime={endTime:0,startTime:0},o.isGetFiles=!1,o.uploadInfo={estimatedTime:0,uploadedSize:0,speedInterval:null,speedAverage:0,uploadTime:0,fileSize:0,startTime:0,endTime:0,success:0,error:0},o.fileList=[],o.fileTotalSize=0,o.fileTotalNumber=0,o.uploadInterval=0,o.uploadCycleSize=[],o.speedLastTime=0,o.timerSpeed=0,e&&o.watchFileUploadStatus({status:"paused",timeElapsed:0,averageSpeed:0,uploadSize:"0B",successNumber:0,errorNumber:0})})),s(this,"watchFileList",(function(e){return e})),s(this,"watchFileUploadSpeed",(function(e){return e})),s(this,"watchFileUploadStatus",(function(e){return e})),s(this,"fileUploadLimit",(function(e,t){var r=t;if(!o.isGetFiles)return!1;var n=e.name.split("."),a=(t=t||e.webkitRelativePath).split("/");t=("/"+a.slice(0,a.length-1).join("/")).replace("//","/");var l=!1;return o.fileList.forEach((function(t,n){if(t.path+t.name==r&&t.size==i(e.size))return $.error("该文件已存在"),l=!0})),!(!l&&(o.fileList=o.fileList.filter((function(e,t){return e.path+e.name!==r})),o.fileList.push({vid:d(8),file:e,path:t,name:e.name,size:i(e.size),type:n.length>1?n[n.length-1]:"txt",status:"paused",progress:0}),o.watchFileList(o.fileList),o.fileTotalSize+=e.size,o.fileTotalNumber++,o.fileTotalNumber>=o.limit.number?($.error("当前文件数量已超过文件上传上限".concat(o.limit.number,"个, 请压缩文件夹后重试!")),1):o.fileTotalSize>=o.limit.size&&($.error("当前文件大小已超过文件上传".concat(i(o.limit.size),"限制, 请使用SFTP/FTP等工具上传文件!")),1)))})),s(this,"uploadFile",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return 0!==o.fileList.length&&(0==e&&0==o.uploadList.length&&(o.isOpenCoverLayer=0,o.uploadStatus="uploading",o.uploadedFiles=[],o.uploadCycleSize=[],o.uploadTime.startTime=o.getTimeReal()),o.fileList.length===t?(clearTimeout(o.uploadInterval),o.uploadStatus="success",o.uploadTime.endTime=o.getTimeReal(),o.renderUploadSpeed(),o.initData(),!1):void o.uploadFileItem(e,t))})),s(this,"uploadFileItem",function(){var e=l(n().mark((function e(t,r){var i,l,u,s,c,d,h,m,v,g,y,b,S,w;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=o.fileList[r],l=0,null!=i){e.next=3;break}return e.abrupt("return",!1);case 3:return u=o.uploadInfo.uploadedSize,o.uploadInterval=setInterval((function(){4===o.uploadCycleSize.length&&o.uploadCycleSize.splice(0,1),o.uploadCycleSize.push(Math.abs(o.uploadInfo.uploadedSize-u))}),1e3),o.uploadInfo.endTime=o.getTimeReal(),s=(o.uploadInfo.endTime-o.uploadInfo.startTime)/1e3,o.timerSpeed=Number((o.uploadInfo.fileSize/s).toFixed(2)),o.uploadInfo.startTime=o.getTimeReal(),c=o.getUpdateSpeed(),d=o.uploadLimitSize,(h=Math.floor(c/o.uploadLimitSize))&&r>1&&(d*=h>4?4:h),0==t&&(o.uploadInfo.startTime=o.getTimeReal(),i=a(a({},i),{progress:0,upload:2,upload_size:"0B"})),l=Math.min(i.file.size,t+d),o.uploadInfo.fileSize=l-t,m=o.uploadPath+i.path,v=new FormData,g=f(),y=g.request_time,b=g.request_token,v.append("f_path",m),v.append("f_name",i.name),v.append("f_size",i.file.size),v.append("f_start",t.toString()),v.append("blob",i.file.slice(t,l)),v.append("node_id",o.nodeId.toString()),v.append("request_time","".concat(y)),v.append("request_token",b),e.prev=26,e.next=29,p({method:"post",url:""+o.target,headers:{"x-http-token":window.vite_public_request_token},data:v});case 29:return S=e.sent,w=S.data,e.next=33,o.watchUploadStatus(w,i,r,{fileStart:t,fileEnd:l});case 33:e.next=38;break;case 35:e.prev=35,e.t0=e.catch(26);case 38:case"end":return e.stop()}}),e,null,[[26,35]])})));return function(t,r){return e.apply(this,arguments)}}()),s(this,"fileSelectHandler",(function(e,t){var r;if(o.readFileTimeout=0,o.isGetFiles=!0,o.loading=$.load("正在获取上传文件,请稍候..."),null!==(r=e.target)&&void 0!==r&&r.files){var n,i=null===(n=e.target)||void 0===n?void 0:n.files;[].forEach.call(i,(function(e){o.traverseFileTree(e,t)}))}else if(e.dataTransfer.items){var a=e.dataTransfer.items;[].forEach.call(a,(function(e){var r=(e.webkitGetAsEntry||e.getAsEntry).call(e);if(r){if(!o.isUpload)return!1;o.traverseFileTree(r,t)}}))}})),s(this,"traverseFileTree",(function(e,t){var r=e.fullPath||"";if(e.isFile)e.file((function(e){o.isGetFiles=o.fileUploadLimit(e,r),clearTimeout(o.readFileTimeout),o.readFileTimeout=setTimeout((function(){if(o.loading.close(),!o.isGetFiles)return o.clearUploadFileList(),o.watchFileList(o.fileList),!1;t&&t(o.fileList)}),100)}));else if(e.isDirectory){var n=e.createReader(),i=function(e){[].forEach.call(e,(function(e){if(!o.isUpload)return!1;o.traverseFileTree(e,t)})),e.length>0&&n.readEntries(i)};n.readEntries(i),setTimeout((function(){if(0===o.fileList.length&&o.isGetFiles)return $.error("拖拽上传文件夹内容为空")}),500)}})),s(this,"watchUploadStatus",(function(e,t,r,n){"number"==typeof e?(o.renderUploadSpeed(r,a(a({},t),{progress:(e/t.file.size*100).toFixed(2),upload:2,upload_size:i(e)})),n.fileEnd!=e?o.uploadInfo.uploadedSize+=e:o.uploadInfo.uploadedSize+=parseInt((n.fileEnd-n.fileStart).toString()),setTimeout((function(){o.uploadFile(e,r)}),50)):(e.status?(o.uploadInfo.success++,o.uploadInfo.endTime=o.getTimeReal(),o.uploadInfo.uploadedSize+=parseInt((n.fileEnd-n.fileStart).toString()),o.renderUploadSpeed(r,a(a({},t),{upload:1,upload_size:t.size}))):(o.renderUploadSpeed(r,a(a({},t),{progress:100,upload:-1,errorMsg:e.msg})),o.uploadInfo.error++),o.uploadFile(0,++r))})),s(this,"getUpdateSpeed",(function(){for(var e=0,t=0;t<o.uploadCycleSize.length;t++)e+=o.uploadCycleSize[t];var r=e/o.uploadCycleSize.length;return isNaN(r)?0:r})),s(this,"renderUploadSpeed",(function(t,r){if(void 0!==t)try{var n=o.fileList[t];if(1===r.upload||-1===r.upload){n.is_upload=!0,o.uploadList.push(n);var a=document.querySelector(".file-upload-list");a&&(1===o.uploadList.length&&(a.scrollTop=0),o.uploadList.length>1&&(a.scrollTop+=45.5))}n.progress=r.progress,n.status=o.isUploadStatus(r.upload),n.message=r.errorMsg||"",o.watchFileList(o.fileList),o.watchFileUploadSpeed({totalProgress:(o.uploadInfo.uploadedSize/o.fileTotalSize*100).toFixed(2),currentSpeed:i(isNaN(o.timerSpeed)?0:o.timerSpeed),timeRemaining:o.time(parseInt(((o.fileTotalSize-o.uploadInfo.uploadedSize)/o.timerSpeed*1e3).toString())),uploadList:o.uploadList.length})}catch(e){}else{var l=o.getTimeReal();o.watchFileUploadStatus({status:"success",timeElapsed:o.diffTime(o.uploadTime.startTime,l),averageSpeed:o.toSize(o.uploadInfo.uploadedSize/((l-o.uploadTime.startTime)/1e3)),uploadSize:i(o.uploadInfo.uploadedSize),successNumber:o.uploadInfo.success,errorNumber:o.uploadInfo.error})}})),s(this,"getFileName",(function(e){return(e.path+"/"+e.name).replace(/\/\//,"/")})),s(this,"useFileUploadExistsConfirm",l(n().mark((function e(){var t,r,i,a,l;return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=o.fileList.map((function(e){return o.uploadPath+o.getFileName(e)})),e.next=3,h({files:t.join("\n"),node_id:o.nodeId.toString()});case 3:if(r=e.sent,i=r.data){e.next=7;break}return e.abrupt("return");case 7:if(a=[],o.fileList.forEach((function(e,t){var r=i[t];r.exists&&a.push({name:o.getFileName(e),size:r.size,locaSize:e.file.size})})),!a.length){e.next=15;break}return l=function(e,t){if(!t)for(var r=function(){var e=o.fileList[n];a.findIndex((function(t){return t.name.indexOf(e.name)>-1}))>=0&&o.fileList.splice(n,1)},n=o.fileList.length-1;n>=0;n--)r();k((function(){e(),o.fileList.length?o.uploadFile():o.clearUploadFileList()}))},e.next=13,m({title:"文件冲突确认",area:40,component:Q,compData:{data:a,confirm:l,cancel:l},showFooter:!0,cancelText:"跳过",confirmText:"覆盖"});case 13:e.next=16;break;case 15:o.fileList.length&&o.uploadFile();case 16:case"end":return e.stop()}}),e)})))),s(this,"cancelFile",(function(e){var t=o.fileList.filter((function(t,r){return t.vid!==e.vid}));o.fileList=t,o.watchFileList(o.fileList),0===o.fileList.length&&o.clearUploadFileList()})),s(this,"toSize",(function(e){for(var t=[" B"," KB"," MB"," GB"," TB"," PB"],r=0;r<t.length;r+=1){if(e<1024){var n=e.toFixed(2)+t[r];return isNaN(e.toFixed(2))||void 0===n?"0B":n}e/=1024}})),s(this,"time",(function(e){var t=Math.floor(e/36e5),r=Math.floor(e/6e4),n=e%6e4/1e3,i=n+"秒";return r>0&&(i="".concat(r,"分钟").concat(n.toFixed(0),"秒")),t>0&&(i="".concat(t,"小时").concat(Math.floor((e-36e5*t)/6e4),"分钟")),i})),this.target=r.target,this.uploadPath=r.uploadPath,this.nodeId=r.nodeId,this.watchFileList=r.renewalData,this.watchFileUploadSpeed=r.renewalSpeed,this.watchFileUploadStatus=r.renewalStatus,this.initData()},(t=[{key:"uploadStatusInfo",value:function(e){return{success:"上传成功",error:"上传失败",uploading:"上传中",paused:"等待上传",waiting:"等待上传"}[e]}},{key:"isUploadStatus",value:function(e){return{"-1":"error",0:"paused",1:"success",2:"uploading",3:"waiting"}[e]}},{key:"getTimeReal",value:function(){return(new Date).getTime()}},{key:"clearUploadFileList",value:function(){this.initData(!0),this.watchFileList(this.fileList)}},{key:"diffTime",value:function(e,t){"number"!=typeof e&&(e=e.getTime()),"number"!=typeof t&&(t=t.getTime());var r=t-e,n=Math.floor(r/6e4),i=r%6e4/1e3,a=i.toFixed(n>0?0:2)+"秒";return n>0&&(a=n+"分"+i.toFixed(0)+"秒"),a}}])&&u(e.prototype,t),r&&u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,r}(),W=function(e){e.preventDefault()},Z={id:"upload-mask"},ee={class:"p-[20px]"},te=["webkitdirectory"],re={class:"mb-[16px] flex justify-between"},ne={key:1,class:"upload-press"},ie={key:2,class:"upload-press"},ae={key:3,class:"upload-files-tips"},oe={key:4,class:"uploader-list"},le={class:"th"},ue={class:"td justify-end"},se={class:"uploader-file tr"},ce={class:"td-block"},de={class:"td !w-[55%] flex"},fe=["title"],pe={class:"td"},he={class:"td"},me={class:"truncate"},ve={key:0},ge={class:"td justify-end"},ye={class:"flex justify-end"},be=S({__name:"node-upload",props:{compData:{default:function(){return{path:"",nodeId:0,refresh:function(){}}}}},setup:function(e,r){var i=r.expose,o=e,u=v(),s=null,c=w(),d=w(!1),f=w("paused"),p=w([]),h=w(),m=w(!1),S=_({totalProgress:0,uploadList:0,sizeUploaded:0,currentSpeed:0,timeRemaining:0,timeElapsed:0,averageSpeed:0,errorNumber:0,successNumber:0,uploadSize:""}),k=new V({target:"/mod/node/file_transfer/file_upload",uploadPath:o.compData.path,nodeId:o.compData.nodeId,renewalData:function(e){p.value=t(e)},renewalSpeed:function(e){S.totalProgress=e.totalProgress,S.uploadList=e.uploadList,S.sizeUploaded=e.sizeUploaded,S.currentSpeed=e.currentSpeed,S.timeRemaining=e.timeRemaining},renewalStatus:function(e){f.value=e.status,S.timeElapsed=e.timeElapsed,S.averageSpeed=e.averageSpeed,S.uploadSize=e.uploadSize,S.successNumber=e.successNumber,S.errorNumber=e.errorNumber}}),Q=k.uploadStatusInfo,$=k.initData,be=k.fileUploadLimit,Se=k.cancelFile,we=I((function(){return!p.value.length})),Le=I((function(){return!p.value.length})),xe=function(e){return(e.path+"/"+e.name).replace(/\/\//,"/")},Te=function(e){if(e.isFolder)return"folder";var t=e.name.split(".").pop();return["zip","rar","gz","tar","war","tgz","bz2","7z","tar.gz"].includes(t)?"compress":t},ze=function(e){k.isGetFiles=!0,"file"!==e&&g(e)?m.value=!0:m.value=!1,setTimeout((function(){h.value.click()}),0)},Fe=function(e){for(var t=e.target.files,r=0;r<t.length;r++){var n="/".concat(""==t[r].webkitRelativePath?t[r].name:t[r].webkitRelativePath);if(!be(t[r],n))return!1}if(!k.isGetFiles)return!1},Ee=function(e){return"success"===e.status?{transform:"translateX(-0%)"}:{transform:"translateX(-".concat(100-e.progress,"%)")}},ke=function(){if(0===p.value.length)return u.error("请添加需要上传的文件");f.value="uploading",k.useFileUploadExistsConfirm()},_e=function(){$(),p.value=[],f.value="paused"},Ie=function(){d.value=!0,"success"===f.value&&_e()},je=function(){d.value=!1},Oe=function(e){d.value=!1,k.fileSelectHandler(e,(function(e){p.value=e||[]}))},Pe=function(){var e=l(n().mark((function e(){return n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!["uploading","paused"].includes(f.value)||!p.value.length){e.next=6;break}return e.next=4,y({title:"取消上传",width:"35rem",icon:"warning-filled",content:"是否取消上传,取消后将清空上传列表?"});case 4:return o.compData.refresh(),e.abrupt("return",!0);case 6:e.next=11;break;case 8:return e.prev=8,e.t0=e.catch(0),e.abrupt("return",!1);case 11:case"end":return e.stop()}}),e,null,[[0,8]])})));return function(){return e.apply(this,arguments)}}();return j((function(){var e,t;s=a({},(e={dragenter:Ie,dragleave:je,drop:Oe,dragover:function(){}},t=document.querySelector("#upload-mask"),window.addEventListener("dragenter",(function(t){W(t),e.dragenter(t)})),null==t||t.addEventListener("dragenter",(function(t){W(t),e.dragenter(t)})),null==t||t.addEventListener("dragleave",(function(t){W(t),e.dragleave(t)})),null==t||t.addEventListener("dragover",(function(t){W(t),e.dragover(t)})),null==t||t.addEventListener("drop",(function(t){W(t),e.drop(t)})),e))})),O((function(){var e,t;e=s,t=document.querySelector("#upload-mask"),window.removeEventListener("dragenter",e.dragenter),null==t||t.removeEventListener("dragenter",e.dragenter),null==t||t.removeEventListener("dragover",e.dragover),null==t||t.removeEventListener("dragleave",e.dragleave),null==t||t.removeEventListener("drop",e.drop)})),i({onCancel:Pe}),function(e,t){var r=B,n=q,i=H,a=Y,o=X,l=K,u=b;return L(),x("div",{class:"upload-file-view",ref_key:"upload",ref:c},[P(T("div",Z,"请将需要上传的文件/文件夹拖到此处",512),[[N,F(d)]]),T("div",ee,[F(f).indexOf("paused")>-1?(L(),x(U,{key:0},[T("input",{type:"file",ref_key:"uploadFileInput",ref:h,webkitdirectory:F(m),onChange:Fe,style:{display:"none"},multiple:""},null,40,te),T("div",re,[z(i,{"split-button":"",type:"default","show-timeout":50,"hide-timeout":50,onClick:ze,onCommand:ze},{dropdown:C((function(){return[z(n,{class:"w-[10rem]"},{default:C((function(){return[z(r,{command:"file"},{default:C((function(){return t[0]||(t[0]=[D("上传文件")])})),_:1}),z(r,{command:"dir"},{default:C((function(){return t[1]||(t[1]=[D("上传文件夹")])})),_:1})]})),_:1})]})),default:C((function(){return[t[2]||(t[2]=D(" 上传文件 "))]})),_:1}),z(a,{onClick:_e,disabled:F(we)},{default:C((function(){return t[3]||(t[3]=[D("清空列表")])})),_:1},8,["disabled"])])],64)):G("",!0),F(f).indexOf("uploading")>-1?(L(),x("div",ne,[T("span",null,"总进度:"+R(F(S).totalProgress)+"%",1),z(o),T("span",null,"正在上传:("+R("".concat(F(S).uploadList,"/").concat(F(p).length))+")",1),z(o),T("span",null,"上传速度:"+R(F(S).currentSpeed)+"/s",1),z(o),T("span",null,"预计耗时:"+R(F(S).timeRemaining),1)])):G("",!0),F(f).indexOf("success")>-1?(L(),x("div",ie,[T("span",null,"上传大小:"+R(F(S).uploadSize),1),z(o),T("span",null,"共耗时:"+R(F(S).timeElapsed),1),z(o),T("span",null,"平均上传速度:"+R(F(S).averageSpeed)+"/s",1),z(o),T("span",null,"上传成功:"+R(F(S).successNumber)+"个",1),P(z(o,null,null,512),[[N,F(S).errorNumber>0]]),P(T("span",null,"上传失败:"+R(F(S).errorNumber)+"个",513),[[N,F(S).errorNumber>0]])])):G("",!0),F(Le)?(L(),x("div",ae,t[4]||(t[4]=[T("span",null,"请将需要上传的文件/文件夹拖到此处",-1)]))):(L(),x("div",oe,[T("div",le,[t[5]||(t[5]=T("div",{class:"td !w-[55%]"},"文件名",-1)),t[6]||(t[6]=T("div",{class:"td"},"文件大小",-1)),t[7]||(t[7]=T("div",{class:"td"},"上传状态",-1)),P(T("div",ue,"操作",512),[[N,"success"!==F(f)]])]),T("div",null,[z(F(J),{class:E(["!mb-0 overflow-auto file-upload-list files-list","!h-[400px]"]),items:F(p),"item-size":45,buffer:800,"key-field":"vid"},{default:C((function(e){var r=e.item;return[T("div",se,[T("div",{class:E({"td-progress":!0,error:"error"===r.status,success:"success"===r.status}),style:A(Ee(r))},null,6),T("div",ce,[T("div",de,[T("i",{class:E(["icon-bg","".concat(Te(r),"-icon")])},null,2),T("span",{class:"flex-1 w-0 ml-[4px] truncate h-[20px] leading-[20px]",title:xe(r)},R(xe(r)),9,fe)]),T("div",pe,R(r.size),1),T("div",he,[P(z(l,{effect:"dark",content:"".concat(F(Q)(r.status)).concat(r.message?",".concat(r.message):""),placement:"right","show-after":200},{default:C((function(){return[P(T("span",me,[D(R(F(Q)(r.status))+" ",1),r.message?(L(),x("span",ve," ,"+R(r.message),1)):G("",!0)],512),[[N,"uploading"!==r.status]])]})),_:2},1032,["content"]),[[N,"uploading"!==r.status]]),P(T("span",null,[T("span",null,"上传中("+R(parseInt(r.progress))+"%)",1)],512),[[N,"uploading"===r.status]])]),P(T("div",ge,[P(z(u,{onClick:function(e){return F(Se)(r)}},{default:C((function(){return t[8]||(t[8]=[D("取消")])})),_:2},1032,["onClick"]),[[N,F(f).indexOf("paused")>-1]])],512),[[N,"success"!==F(f)]])])])]})),_:1},8,["items"])])])),T("div",ye,[F(f).indexOf("paused")>-1?(L(),M(a,{key:0,type:"primary",onClick:ke},{default:C((function(){return t[9]||(t[9]=[D(" 开始上传 ")])})),_:1})):G("",!0),["success","error"].includes(F(f))?(L(),M(a,{key:1,type:"primary",onClick:_e},{default:C((function(){return t[10]||(t[10]=[D(" 继续上传 ")])})),_:1})):G("",!0)])])],512)}}});e("default",c(be,[["__scopeId","data-v-0ca2a2b8"]]))}}}))}();
Save File
Cancel