fileuploadsdk 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +17 -2
- package/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("axios"),require("react")):"function"==typeof define&&define.amd?define(["exports","axios","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FileUploadSDK={},e.axios,e.React)}(this,function(e,t,n){"use strict";function i(e,t,n,i){return new(n||(n=Promise))(function(r,s){function o(e){try{l(i.next(e))}catch(e){s(e)}}function a(e){try{l(i.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(o,a)}l((i=i.apply(e,t||[])).next())})}function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}"function"==typeof SuppressedError&&SuppressedError;var s,o={exports:{}};var a=(s||(s=1,function(e){e.exports=function(e){var t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function n(e,t){var n=e[0],i=e[1],r=e[2],s=e[3];i=((i+=((r=((r+=((s=((s+=((n=((n+=(i&r|~i&s)+t[0]-680876936|0)<<7|n>>>25)+i|0)&i|~n&r)+t[1]-389564586|0)<<12|s>>>20)+n|0)&n|~s&i)+t[2]+606105819|0)<<17|r>>>15)+s|0)&s|~r&n)+t[3]-1044525330|0)<<22|i>>>10)+r|0,i=((i+=((r=((r+=((s=((s+=((n=((n+=(i&r|~i&s)+t[4]-176418897|0)<<7|n>>>25)+i|0)&i|~n&r)+t[5]+1200080426|0)<<12|s>>>20)+n|0)&n|~s&i)+t[6]-1473231341|0)<<17|r>>>15)+s|0)&s|~r&n)+t[7]-45705983|0)<<22|i>>>10)+r|0,i=((i+=((r=((r+=((s=((s+=((n=((n+=(i&r|~i&s)+t[8]+1770035416|0)<<7|n>>>25)+i|0)&i|~n&r)+t[9]-1958414417|0)<<12|s>>>20)+n|0)&n|~s&i)+t[10]-42063|0)<<17|r>>>15)+s|0)&s|~r&n)+t[11]-1990404162|0)<<22|i>>>10)+r|0,i=((i+=((r=((r+=((s=((s+=((n=((n+=(i&r|~i&s)+t[12]+1804603682|0)<<7|n>>>25)+i|0)&i|~n&r)+t[13]-40341101|0)<<12|s>>>20)+n|0)&n|~s&i)+t[14]-1502002290|0)<<17|r>>>15)+s|0)&s|~r&n)+t[15]+1236535329|0)<<22|i>>>10)+r|0,i=((i+=((r=((r+=((s=((s+=((n=((n+=(i&s|r&~s)+t[1]-165796510|0)<<5|n>>>27)+i|0)&r|i&~r)+t[6]-1069501632|0)<<9|s>>>23)+n|0)&i|n&~i)+t[11]+643717713|0)<<14|r>>>18)+s|0)&n|s&~n)+t[0]-373897302|0)<<20|i>>>12)+r|0,i=((i+=((r=((r+=((s=((s+=((n=((n+=(i&s|r&~s)+t[5]-701558691|0)<<5|n>>>27)+i|0)&r|i&~r)+t[10]+38016083|0)<<9|s>>>23)+n|0)&i|n&~i)+t[15]-660478335|0)<<14|r>>>18)+s|0)&n|s&~n)+t[4]-405537848|0)<<20|i>>>12)+r|0,i=((i+=((r=((r+=((s=((s+=((n=((n+=(i&s|r&~s)+t[9]+568446438|0)<<5|n>>>27)+i|0)&r|i&~r)+t[14]-1019803690|0)<<9|s>>>23)+n|0)&i|n&~i)+t[3]-187363961|0)<<14|r>>>18)+s|0)&n|s&~n)+t[8]+1163531501|0)<<20|i>>>12)+r|0,i=((i+=((r=((r+=((s=((s+=((n=((n+=(i&s|r&~s)+t[13]-1444681467|0)<<5|n>>>27)+i|0)&r|i&~r)+t[2]-51403784|0)<<9|s>>>23)+n|0)&i|n&~i)+t[7]+1735328473|0)<<14|r>>>18)+s|0)&n|s&~n)+t[12]-1926607734|0)<<20|i>>>12)+r|0,i=((i+=((r=((r+=((s=((s+=((n=((n+=(i^r^s)+t[5]-378558|0)<<4|n>>>28)+i|0)^i^r)+t[8]-2022574463|0)<<11|s>>>21)+n|0)^n^i)+t[11]+1839030562|0)<<16|r>>>16)+s|0)^s^n)+t[14]-35309556|0)<<23|i>>>9)+r|0,i=((i+=((r=((r+=((s=((s+=((n=((n+=(i^r^s)+t[1]-1530992060|0)<<4|n>>>28)+i|0)^i^r)+t[4]+1272893353|0)<<11|s>>>21)+n|0)^n^i)+t[7]-155497632|0)<<16|r>>>16)+s|0)^s^n)+t[10]-1094730640|0)<<23|i>>>9)+r|0,i=((i+=((r=((r+=((s=((s+=((n=((n+=(i^r^s)+t[13]+681279174|0)<<4|n>>>28)+i|0)^i^r)+t[0]-358537222|0)<<11|s>>>21)+n|0)^n^i)+t[3]-722521979|0)<<16|r>>>16)+s|0)^s^n)+t[6]+76029189|0)<<23|i>>>9)+r|0,i=((i+=((r=((r+=((s=((s+=((n=((n+=(i^r^s)+t[9]-640364487|0)<<4|n>>>28)+i|0)^i^r)+t[12]-421815835|0)<<11|s>>>21)+n|0)^n^i)+t[15]+530742520|0)<<16|r>>>16)+s|0)^s^n)+t[2]-995338651|0)<<23|i>>>9)+r|0,i=((i+=((s=((s+=(i^((n=((n+=(r^(i|~s))+t[0]-198630844|0)<<6|n>>>26)+i|0)|~r))+t[7]+1126891415|0)<<10|s>>>22)+n|0)^((r=((r+=(n^(s|~i))+t[14]-1416354905|0)<<15|r>>>17)+s|0)|~n))+t[5]-57434055|0)<<21|i>>>11)+r|0,i=((i+=((s=((s+=(i^((n=((n+=(r^(i|~s))+t[12]+1700485571|0)<<6|n>>>26)+i|0)|~r))+t[3]-1894986606|0)<<10|s>>>22)+n|0)^((r=((r+=(n^(s|~i))+t[10]-1051523|0)<<15|r>>>17)+s|0)|~n))+t[1]-2054922799|0)<<21|i>>>11)+r|0,i=((i+=((s=((s+=(i^((n=((n+=(r^(i|~s))+t[8]+1873313359|0)<<6|n>>>26)+i|0)|~r))+t[15]-30611744|0)<<10|s>>>22)+n|0)^((r=((r+=(n^(s|~i))+t[6]-1560198380|0)<<15|r>>>17)+s|0)|~n))+t[13]+1309151649|0)<<21|i>>>11)+r|0,i=((i+=((s=((s+=(i^((n=((n+=(r^(i|~s))+t[4]-145523070|0)<<6|n>>>26)+i|0)|~r))+t[11]-1120210379|0)<<10|s>>>22)+n|0)^((r=((r+=(n^(s|~i))+t[2]+718787259|0)<<15|r>>>17)+s|0)|~n))+t[9]-343485551|0)<<21|i>>>11)+r|0,e[0]=n+e[0]|0,e[1]=i+e[1]|0,e[2]=r+e[2]|0,e[3]=s+e[3]|0}function i(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}function r(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return n}function s(e){var t,r,s,o,a,l,c=e.length,u=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=c;t+=64)n(u,i(e.substring(t-64,t)));for(r=(e=e.substring(t-64)).length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<r;t+=1)s[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(n(u,s),t=0;t<16;t+=1)s[t]=0;return o=(o=8*c).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(o[2],16),l=parseInt(o[1],16)||0,s[14]=a,s[15]=l,n(u,s),u}function o(e){var t,i,s,o,a,l,c=e.length,u=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=c;t+=64)n(u,r(e.subarray(t-64,t)));for(i=(e=t-64<c?e.subarray(t-64):new Uint8Array(0)).length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<i;t+=1)s[t>>2]|=e[t]<<(t%4<<3);if(s[t>>2]|=128<<(t%4<<3),t>55)for(n(u,s),t=0;t<16;t+=1)s[t]=0;return o=(o=8*c).toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(o[2],16),l=parseInt(o[1],16)||0,s[14]=a,s[15]=l,n(u,s),u}function a(e){var n,i="";for(n=0;n<4;n+=1)i+=t[e>>8*n+4&15]+t[e>>8*n&15];return i}function l(e){var t;for(t=0;t<e.length;t+=1)e[t]=a(e[t]);return e.join("")}function c(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),e}function u(e,t){var n,i=e.length,r=new ArrayBuffer(i),s=new Uint8Array(r);for(n=0;n<i;n+=1)s[n]=e.charCodeAt(n);return t?s:r}function d(e){return String.fromCharCode.apply(null,new Uint8Array(e))}function p(e,t,n){var i=new Uint8Array(e.byteLength+t.byteLength);return i.set(new Uint8Array(e)),i.set(new Uint8Array(t),e.byteLength),i}function h(e){var t,n=[],i=e.length;for(t=0;t<i-1;t+=2)n.push(parseInt(e.substr(t,2),16));return String.fromCharCode.apply(String,n)}function f(){this.reset()}return l(s("hello")),"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function t(e,t){return(e=0|e||0)<0?Math.max(e+t,0):Math.min(e,t)}ArrayBuffer.prototype.slice=function(n,i){var r,s,o,a,l=this.byteLength,c=t(n,l),u=l;return i!==e&&(u=t(i,l)),c>u?new ArrayBuffer(0):(r=u-c,s=new ArrayBuffer(r),o=new Uint8Array(s),a=new Uint8Array(this,c,r),o.set(a),s)}}(),f.prototype.append=function(e){return this.appendBinary(c(e)),this},f.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,r=this._buff.length;for(t=64;t<=r;t+=64)n(this._hash,i(this._buff.substring(t-64,t)));return this._buff=this._buff.substring(t-64),this},f.prototype.end=function(e){var t,n,i=this._buff,r=i.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<r;t+=1)s[t>>2]|=i.charCodeAt(t)<<(t%4<<3);return this._finish(s,r),n=l(this._hash),e&&(n=h(n)),this.reset(),n},f.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},f.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},f.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},f.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},f.prototype._finish=function(e,t){var i,r,s,o=t;if(e[o>>2]|=128<<(o%4<<3),o>55)for(n(this._hash,e),o=0;o<16;o+=1)e[o]=0;i=(i=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),r=parseInt(i[2],16),s=parseInt(i[1],16)||0,e[14]=r,e[15]=s,n(this._hash,e)},f.hash=function(e,t){return f.hashBinary(c(e),t)},f.hashBinary=function(e,t){var n=l(s(e));return t?h(n):n},f.ArrayBuffer=function(){this.reset()},f.ArrayBuffer.prototype.append=function(e){var t,i=p(this._buff.buffer,e),s=i.length;for(this._length+=e.byteLength,t=64;t<=s;t+=64)n(this._hash,r(i.subarray(t-64,t)));return this._buff=t-64<s?new Uint8Array(i.buffer.slice(t-64)):new Uint8Array(0),this},f.ArrayBuffer.prototype.end=function(e){var t,n,i=this._buff,r=i.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<r;t+=1)s[t>>2]|=i[t]<<(t%4<<3);return this._finish(s,r),n=l(this._hash),e&&(n=h(n)),this.reset(),n},f.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},f.ArrayBuffer.prototype.getState=function(){var e=f.prototype.getState.call(this);return e.buff=d(e.buff),e},f.ArrayBuffer.prototype.setState=function(e){return e.buff=u(e.buff,!0),f.prototype.setState.call(this,e)},f.ArrayBuffer.prototype.destroy=f.prototype.destroy,f.ArrayBuffer.prototype._finish=f.prototype._finish,f.ArrayBuffer.hash=function(e,t){var n=l(o(new Uint8Array(e)));return t?h(n):n},f}()}(o)),o.exports),l=r(a);const c=e=>`${e.name}-${e.size}-${e.type}-${e.lastModified}`,u=e=>e.slice(e.lastIndexOf(".")+1),d=(e,t)=>{if(!t)return!0;const n=t.split(",").map(e=>e.trim()),i=e.type,r=u(e.name);return n.some(e=>{if(e.startsWith("."))return r===e.slice(1);if(e.includes("/")){const t=e.split("/")[0];return i.startsWith(t)}return i===e})},p=(e,t,n)=>!(t&&e.size>t)&&!(n&&e.size<n),h=(e,t)=>{const n=[];let i=0;for(;i<e.size;){const r=Math.min(i+t,e.size),s=e.slice(i,r);n.push(s),i=r}return n},f=e=>new Promise(t=>{const n=new l.ArrayBuffer,i=new FileReader,r=2097152,s=h(e,r);let o=0;i.onload=e=>{var i;n.append(null===(i=e.target)||void 0===i?void 0:i.result),o++,o<s.length?a():t(n.end())},i.onerror=()=>{t("")};const a=()=>{const t=o*r,n=t+r>=e.size?e.size:t+r;i.readAsArrayBuffer(e.slice(t,n))};a()});class m{constructor(e){this.fileList=[],this.abortControllers=new Map,this.config=Object.assign({method:"POST",headers:{},timeout:3e4,maxRetries:3,retryDelay:1e3,chunkSize:5242880,chunkRetry:3,concurrency:3,autoUpload:!0,multiple:!1,withCredentials:!1},e),this.axiosInstance=t.create({timeout:this.config.timeout,headers:this.config.headers,withCredentials:this.config.withCredentials})}addFile(e){var t,n;const i={uid:c(e),file:e,name:e.name,size:e.size,type:e.type,status:"pending",percent:0,uploadedSize:0};return this.fileList.push(i),null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList),this.config.autoUpload&&this.upload(i),i}addFiles(e){return e.map(e=>this.addFile(e))}removeFile(e){var t,n;const i=this.fileList.findIndex(t=>t.uid===e);-1!==i&&(this.abortUpload(e),this.fileList.splice(i,1),null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList))}clearFiles(){var e,t;this.fileList.forEach(e=>{this.abortUpload(e.uid)}),this.fileList=[],null===(t=(e=this.config).onFileListChange)||void 0===t||t.call(e,this.fileList)}getFileList(){return[...this.fileList]}uploadAll(){return i(this,void 0,void 0,function*(){const e=this.fileList.filter(e=>"pending"===e.status);yield Promise.all(e.map(e=>this.upload(e)))})}abortUpload(e){var t,n,i,r;const s=this.abortControllers.get(e);if(s){s.abort(),this.abortControllers.delete(e);const o=this.fileList.find(t=>t.uid===e);o&&(o.status="canceled",o.percent=0,null===(n=(t=this.config).onCancel)||void 0===n||n.call(t,o),null===(r=(i=this.config).onFileListChange)||void 0===r||r.call(i,this.fileList))}}retryUpload(e){return i(this,void 0,void 0,function*(){var t,n;const i=this.fileList.find(t=>t.uid===e);!i||"error"!==i.status&&"canceled"!==i.status||(i.status="pending",i.percent=0,i.error=void 0,null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList),yield this.upload(i))})}checkFastUpload(e){return i(this,void 0,void 0,function*(){if(!this.config.url)return{shouldUpload:!0};try{return(yield this.axiosInstance.post(`${this.config.url}/check`,{fileName:e.name,fileSize:e.size,lastModified:e.file.lastModified})).data}catch(e){return console.warn("秒传检查失败,继续正常上传:",e),{shouldUpload:!0}}})}updateProgress(e,t,n){var i,r;if(e.uploadedSize=t,e.percent=n>0?Math.round(t/n*100):0,this.config.onProgress){const e=new ProgressEvent("progress",{loaded:t,total:n,lengthComputable:!0});this.config.onProgress(e)}null===(r=(i=this.config).onFileListChange)||void 0===r||r.call(i,this.fileList)}request(e){return i(this,arguments,void 0,function*(e,t=this.config.maxRetries){var n,i;let r;for(let s=0;s<t;s++)try{const t=new AbortController;(null===(n=e.data)||void 0===n?void 0:n.uid)&&this.abortControllers.set(e.data.uid,t);const r=yield this.axiosInstance(Object.assign(Object.assign({},e),{signal:t.signal}));return(null===(i=e.data)||void 0===i?void 0:i.uid)&&this.abortControllers.delete(e.data.uid),r.data}catch(e){if(r=e,"ERR_CANCELED"===e.code)throw e;s<t-1&&(yield new Promise(e=>setTimeout(e,this.config.retryDelay*Math.pow(2,s))))}throw r})}}class g{value;next;constructor(e){this.value=e}}class y{#e;#t;#n;constructor(){this.clear()}enqueue(e){const t=new g(e);this.#e?(this.#t.next=t,this.#t=t):(this.#e=t,this.#t=t),this.#n++}dequeue(){const e=this.#e;if(e)return this.#e=this.#e.next,this.#n--,this.#e||(this.#t=void 0),e.value}peek(){if(this.#e)return this.#e.value}clear(){this.#e=void 0,this.#t=void 0,this.#n=0}get size(){return this.#n}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}*drain(){for(;this.#e;)yield this.dequeue()}}function v(e){b(e);const t=new y;let n=0;const i=()=>{n<e&&t.size>0&&(n++,t.dequeue()())},r=async(e,t,r)=>{const s=(async()=>e(...r))();t(s);try{await s}catch{}n--,i()},s=(s,...o)=>new Promise(a=>{((s,o,a)=>{new Promise(e=>{t.enqueue(e)}).then(r.bind(void 0,s,o,a)),n<e&&i()})(s,a,o)});return Object.defineProperties(s,{activeCount:{get:()=>n},pendingCount:{get:()=>t.size},clearQueue:{value(){t.clear()}},concurrency:{get:()=>e,set(r){b(r),e=r,queueMicrotask(()=>{for(;n<e&&t.size>0;)i()})}},map:{async value(e,t){const n=Array.from(e,(e,n)=>this(t,e,n));return Promise.all(n)}}}),s}function b(e){if(!Number.isInteger(e)&&e!==Number.POSITIVE_INFINITY||!(e>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up")}class x extends m{constructor(e){super(e),this.chunkSize=e.chunkSize||5242880}upload(e){return i(this,void 0,void 0,function*(){try{if(!(yield this.validateFile(e)))return;const t=yield this.checkFastUpload(e);if(!0===(null==t?void 0:t.fileExists))return void(yield this.handleFastUpload(e,t));e.hash=yield f(e.file);const n=h(e.file,this.chunkSize);e.chunkList=n.map((t,n)=>({index:n,chunk:t,hash:`${e.hash}-${n}`,size:t.size,progress:0,status:"pending"})),yield this.uploadChunks(e,t.uploadedList||[]),yield this.mergeChunks(e)}catch(t){this.handleUploadError(e,t)}})}validateFile(e){return i(this,void 0,void 0,function*(){var t,n;if(this.config.beforeUpload){if(!(yield Promise.resolve(this.config.beforeUpload(e.file))))return this.removeFile(e.uid),!1}return e.status="uploading",null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList),!0})}handleFastUpload(e,t){return i(this,void 0,void 0,function*(){var t,n;e.status="success",e.percent=100,e.response={message:"秒传成功"},this.config.onSuccess&&this.config.onSuccess(e.response,e),null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList)})}uploadChunks(e,t){return i(this,void 0,void 0,function*(){const{chunkList:n}=e;if(!n)return;const i=v(this.config.concurrency||3),r=[];n.filter(e=>!t.includes(e.hash)).forEach(t=>{const n=i(()=>this.uploadChunk(e,t));r.push(n)}),yield Promise.all(r)})}uploadChunk(e,t){return i(this,void 0,void 0,function*(){t.status="uploading";const n=new FormData;n.append("file",t.chunk),n.append("chunkIndex",t.index.toString()),n.append("chunkHash",t.hash),n.append("fileHash",e.hash),n.append("fileName",e.name),n.append("totalChunks",e.chunkList.length.toString()),n.append("uid",e.uid);try{yield this.request({method:this.config.method,url:this.config.url,data:n,onUploadProgress:n=>{const i=n.loaded,r=n.total||t.size;t.progress=Math.round(i/r*100);const s=e.chunkList.reduce((e,n)=>e+(n.index===t.index?i:n.size*(n.progress/100)),0),o=e.size;this.updateProgress(e,s,o)}},this.config.chunkRetry),t.status="success",t.progress=100}catch(e){throw t.status="error",e}})}mergeChunks(e){return i(this,void 0,void 0,function*(){var t,n;const i=yield this.request({method:"POST",url:`${this.config.url}/merge`,data:{fileName:e.name,fileHash:e.hash,totalChunks:e.chunkList.length,uid:e.uid}});e.status="success",e.percent=100,e.response=i,this.config.onSuccess&&this.config.onSuccess(i,e),null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList)})}handleUploadError(e,t){var n,i;e.status="error",e.error=t,this.config.onError&&this.config.onError(t,e),null===(i=(n=this.config).onFileListChange)||void 0===i||i.call(n,this.fileList)}resumeUpload(e){return i(this,void 0,void 0,function*(){const t=this.fileList.find(t=>t.uid===e);if(t&&"error"===t.status)try{const e=(yield this.request({method:"GET",url:`${this.config.url}/uploaded`,params:{fileHash:t.hash,fileName:t.name}})).uploadedList||[];yield this.uploadChunks(t,e),yield this.mergeChunks(t)}catch(e){this.handleUploadError(t,e)}})}}class j extends m{constructor(e){super(e),this.concurrent=e.concurrent||3}upload(e){return i(this,void 0,void 0,function*(){var t,n,i,r;try{if(!(yield this.validateFile(e)))return;e.status="uploading",null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList);const i=new FormData;i.append("file",e.file),i.append("fileName",e.name),i.append("uid",e.uid);const r=yield this.request({method:this.config.method,url:this.config.url,data:i,onUploadProgress:t=>{this.updateProgress(e,t.loaded,t.total||e.size)}});e.status="success",e.percent=100,e.response=r,this.config.onSuccess&&this.config.onSuccess(r,e)}catch(t){this.handleUploadError(e,t)}null===(r=(i=this.config).onFileListChange)||void 0===r||r.call(i,this.fileList)})}uploadAll(){return i(this,void 0,void 0,function*(){const e=this.fileList.filter(e=>"pending"===e.status),t=v(this.concurrent),n=e.map(e=>t(()=>this.upload(e)));yield Promise.all(n)})}validateFile(e){return i(this,void 0,void 0,function*(){if(this.config.beforeUpload){if(!(yield Promise.resolve(this.config.beforeUpload(e.file))))return this.removeFile(e.uid),!1}return!0})}handleUploadError(e,t){e.status="error",e.error=t,this.config.onError&&this.config.onError(t,e)}}var k,w={exports:{}},C={};var N,S,L={};
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("axios"),require("react"),require("vue")):"function"==typeof define&&define.amd?define(["exports","axios","react","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FileUploadSDK={},e.axios,e.React,e.Vue)}(this,function(e,t,n,r){"use strict";function i(e,t,n,r){return new(n||(n=Promise))(function(i,o){function a(e){try{l(r.next(e))}catch(e){o(e)}}function s(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}l((r=r.apply(e,t||[])).next())})}function o(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}"function"==typeof SuppressedError&&SuppressedError;var a,s={exports:{}};var l=(a||(a=1,function(e){e.exports=function(e){var t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function n(e,t){var n=e[0],r=e[1],i=e[2],o=e[3];r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[0]-680876936|0)<<7|n>>>25)+r|0)&r|~n&i)+t[1]-389564586|0)<<12|o>>>20)+n|0)&n|~o&r)+t[2]+606105819|0)<<17|i>>>15)+o|0)&o|~i&n)+t[3]-1044525330|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[4]-176418897|0)<<7|n>>>25)+r|0)&r|~n&i)+t[5]+1200080426|0)<<12|o>>>20)+n|0)&n|~o&r)+t[6]-1473231341|0)<<17|i>>>15)+o|0)&o|~i&n)+t[7]-45705983|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[8]+1770035416|0)<<7|n>>>25)+r|0)&r|~n&i)+t[9]-1958414417|0)<<12|o>>>20)+n|0)&n|~o&r)+t[10]-42063|0)<<17|i>>>15)+o|0)&o|~i&n)+t[11]-1990404162|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&i|~r&o)+t[12]+1804603682|0)<<7|n>>>25)+r|0)&r|~n&i)+t[13]-40341101|0)<<12|o>>>20)+n|0)&n|~o&r)+t[14]-1502002290|0)<<17|i>>>15)+o|0)&o|~i&n)+t[15]+1236535329|0)<<22|r>>>10)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[1]-165796510|0)<<5|n>>>27)+r|0)&i|r&~i)+t[6]-1069501632|0)<<9|o>>>23)+n|0)&r|n&~r)+t[11]+643717713|0)<<14|i>>>18)+o|0)&n|o&~n)+t[0]-373897302|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[5]-701558691|0)<<5|n>>>27)+r|0)&i|r&~i)+t[10]+38016083|0)<<9|o>>>23)+n|0)&r|n&~r)+t[15]-660478335|0)<<14|i>>>18)+o|0)&n|o&~n)+t[4]-405537848|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[9]+568446438|0)<<5|n>>>27)+r|0)&i|r&~i)+t[14]-1019803690|0)<<9|o>>>23)+n|0)&r|n&~r)+t[3]-187363961|0)<<14|i>>>18)+o|0)&n|o&~n)+t[8]+1163531501|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r&o|i&~o)+t[13]-1444681467|0)<<5|n>>>27)+r|0)&i|r&~i)+t[2]-51403784|0)<<9|o>>>23)+n|0)&r|n&~r)+t[7]+1735328473|0)<<14|i>>>18)+o|0)&n|o&~n)+t[12]-1926607734|0)<<20|r>>>12)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[5]-378558|0)<<4|n>>>28)+r|0)^r^i)+t[8]-2022574463|0)<<11|o>>>21)+n|0)^n^r)+t[11]+1839030562|0)<<16|i>>>16)+o|0)^o^n)+t[14]-35309556|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[1]-1530992060|0)<<4|n>>>28)+r|0)^r^i)+t[4]+1272893353|0)<<11|o>>>21)+n|0)^n^r)+t[7]-155497632|0)<<16|i>>>16)+o|0)^o^n)+t[10]-1094730640|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[13]+681279174|0)<<4|n>>>28)+r|0)^r^i)+t[0]-358537222|0)<<11|o>>>21)+n|0)^n^r)+t[3]-722521979|0)<<16|i>>>16)+o|0)^o^n)+t[6]+76029189|0)<<23|r>>>9)+i|0,r=((r+=((i=((i+=((o=((o+=((n=((n+=(r^i^o)+t[9]-640364487|0)<<4|n>>>28)+r|0)^r^i)+t[12]-421815835|0)<<11|o>>>21)+n|0)^n^r)+t[15]+530742520|0)<<16|i>>>16)+o|0)^o^n)+t[2]-995338651|0)<<23|r>>>9)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[0]-198630844|0)<<6|n>>>26)+r|0)|~i))+t[7]+1126891415|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[14]-1416354905|0)<<15|i>>>17)+o|0)|~n))+t[5]-57434055|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[12]+1700485571|0)<<6|n>>>26)+r|0)|~i))+t[3]-1894986606|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[10]-1051523|0)<<15|i>>>17)+o|0)|~n))+t[1]-2054922799|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[8]+1873313359|0)<<6|n>>>26)+r|0)|~i))+t[15]-30611744|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[6]-1560198380|0)<<15|i>>>17)+o|0)|~n))+t[13]+1309151649|0)<<21|r>>>11)+i|0,r=((r+=((o=((o+=(r^((n=((n+=(i^(r|~o))+t[4]-145523070|0)<<6|n>>>26)+r|0)|~i))+t[11]-1120210379|0)<<10|o>>>22)+n|0)^((i=((i+=(n^(o|~r))+t[2]+718787259|0)<<15|i>>>17)+o|0)|~n))+t[9]-343485551|0)<<21|r>>>11)+i|0,e[0]=n+e[0]|0,e[1]=r+e[1]|0,e[2]=i+e[2]|0,e[3]=o+e[3]|0}function r(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e.charCodeAt(t)+(e.charCodeAt(t+1)<<8)+(e.charCodeAt(t+2)<<16)+(e.charCodeAt(t+3)<<24);return n}function i(e){var t,n=[];for(t=0;t<64;t+=4)n[t>>2]=e[t]+(e[t+1]<<8)+(e[t+2]<<16)+(e[t+3]<<24);return n}function o(e){var t,i,o,a,s,l,c=e.length,d=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=c;t+=64)n(d,r(e.substring(t-64,t)));for(i=(e=e.substring(t-64)).length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<i;t+=1)o[t>>2]|=e.charCodeAt(t)<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(n(d,o),t=0;t<16;t+=1)o[t]=0;return a=(a=8*c).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(a[2],16),l=parseInt(a[1],16)||0,o[14]=s,o[15]=l,n(d,o),d}function a(e){var t,r,o,a,s,l,c=e.length,d=[1732584193,-271733879,-1732584194,271733878];for(t=64;t<=c;t+=64)n(d,i(e.subarray(t-64,t)));for(r=(e=t-64<c?e.subarray(t-64):new Uint8Array(0)).length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t=0;t<r;t+=1)o[t>>2]|=e[t]<<(t%4<<3);if(o[t>>2]|=128<<(t%4<<3),t>55)for(n(d,o),t=0;t<16;t+=1)o[t]=0;return a=(a=8*c).toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(a[2],16),l=parseInt(a[1],16)||0,o[14]=s,o[15]=l,n(d,o),d}function s(e){var n,r="";for(n=0;n<4;n+=1)r+=t[e>>8*n+4&15]+t[e>>8*n&15];return r}function l(e){var t;for(t=0;t<e.length;t+=1)e[t]=s(e[t]);return e.join("")}function c(e){return/[\u0080-\uFFFF]/.test(e)&&(e=unescape(encodeURIComponent(e))),e}function d(e,t){var n,r=e.length,i=new ArrayBuffer(r),o=new Uint8Array(i);for(n=0;n<r;n+=1)o[n]=e.charCodeAt(n);return t?o:i}function u(e){return String.fromCharCode.apply(null,new Uint8Array(e))}function p(e,t,n){var r=new Uint8Array(e.byteLength+t.byteLength);return r.set(new Uint8Array(e)),r.set(new Uint8Array(t),e.byteLength),r}function f(e){var t,n=[],r=e.length;for(t=0;t<r-1;t+=2)n.push(parseInt(e.substr(t,2),16));return String.fromCharCode.apply(String,n)}function h(){this.reset()}return l(o("hello")),"undefined"==typeof ArrayBuffer||ArrayBuffer.prototype.slice||function(){function t(e,t){return(e=0|e||0)<0?Math.max(e+t,0):Math.min(e,t)}ArrayBuffer.prototype.slice=function(n,r){var i,o,a,s,l=this.byteLength,c=t(n,l),d=l;return r!==e&&(d=t(r,l)),c>d?new ArrayBuffer(0):(i=d-c,o=new ArrayBuffer(i),a=new Uint8Array(o),s=new Uint8Array(this,c,i),a.set(s),o)}}(),h.prototype.append=function(e){return this.appendBinary(c(e)),this},h.prototype.appendBinary=function(e){this._buff+=e,this._length+=e.length;var t,i=this._buff.length;for(t=64;t<=i;t+=64)n(this._hash,r(this._buff.substring(t-64,t)));return this._buff=this._buff.substring(t-64),this},h.prototype.end=function(e){var t,n,r=this._buff,i=r.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)o[t>>2]|=r.charCodeAt(t)<<(t%4<<3);return this._finish(o,i),n=l(this._hash),e&&(n=f(n)),this.reset(),n},h.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},h.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},h.prototype.setState=function(e){return this._buff=e.buff,this._length=e.length,this._hash=e.hash,this},h.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},h.prototype._finish=function(e,t){var r,i,o,a=t;if(e[a>>2]|=128<<(a%4<<3),a>55)for(n(this._hash,e),a=0;a<16;a+=1)e[a]=0;r=(r=8*this._length).toString(16).match(/(.*?)(.{0,8})$/),i=parseInt(r[2],16),o=parseInt(r[1],16)||0,e[14]=i,e[15]=o,n(this._hash,e)},h.hash=function(e,t){return h.hashBinary(c(e),t)},h.hashBinary=function(e,t){var n=l(o(e));return t?f(n):n},h.ArrayBuffer=function(){this.reset()},h.ArrayBuffer.prototype.append=function(e){var t,r=p(this._buff.buffer,e),o=r.length;for(this._length+=e.byteLength,t=64;t<=o;t+=64)n(this._hash,i(r.subarray(t-64,t)));return this._buff=t-64<o?new Uint8Array(r.buffer.slice(t-64)):new Uint8Array(0),this},h.ArrayBuffer.prototype.end=function(e){var t,n,r=this._buff,i=r.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(t=0;t<i;t+=1)o[t>>2]|=r[t]<<(t%4<<3);return this._finish(o,i),n=l(this._hash),e&&(n=f(n)),this.reset(),n},h.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},h.ArrayBuffer.prototype.getState=function(){var e=h.prototype.getState.call(this);return e.buff=u(e.buff),e},h.ArrayBuffer.prototype.setState=function(e){return e.buff=d(e.buff,!0),h.prototype.setState.call(this,e)},h.ArrayBuffer.prototype.destroy=h.prototype.destroy,h.ArrayBuffer.prototype._finish=h.prototype._finish,h.ArrayBuffer.hash=function(e,t){var n=l(a(new Uint8Array(e)));return t?f(n):n},h}()}(s)),s.exports),c=o(l);const d=e=>`${e.name}-${e.size}-${e.type}-${e.lastModified}`,u=e=>e.slice(e.lastIndexOf(".")+1),p=(e,t)=>{if(!t)return!0;const n=t.split(",").map(e=>e.trim()),r=e.type,i=u(e.name);return n.some(e=>{if(e.startsWith("."))return i===e.slice(1);if(e.includes("/")){const t=e.split("/")[0];return r.startsWith(t)}return r===e})},f=(e,t,n)=>!(t&&e.size>t)&&!(n&&e.size<n),h=(e,t)=>{const n=[];let r=0;for(;r<e.size;){const i=Math.min(r+t,e.size),o=e.slice(r,i);n.push(o),r=i}return n},m=e=>new Promise(t=>{const n=new c.ArrayBuffer,r=new FileReader,i=2097152,o=h(e,i);let a=0;r.onload=e=>{var r;n.append(null===(r=e.target)||void 0===r?void 0:r.result),a++,a<o.length?s():t(n.end())},r.onerror=()=>{t("")};const s=()=>{const t=a*i,n=t+i>=e.size?e.size:t+i;r.readAsArrayBuffer(e.slice(t,n))};s()});class g{constructor(e){this.fileList=[],this.abortControllers=new Map,this.config=Object.assign({method:"POST",headers:{},timeout:3e4,maxRetries:3,retryDelay:1e3,chunkSize:5242880,chunkRetry:3,concurrency:3,autoUpload:!0,multiple:!1,withCredentials:!1},e),this.axiosInstance=t.create({timeout:this.config.timeout,headers:this.config.headers,withCredentials:this.config.withCredentials})}addFile(e){var t,n;const r={uid:d(e),file:e,name:e.name,size:e.size,type:e.type,status:"pending",percent:0,uploadedSize:0};return this.fileList.push(r),null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList),this.config.autoUpload&&this.upload(r),r}addFiles(e){return e.map(e=>this.addFile(e))}removeFile(e){var t,n;const r=this.fileList.findIndex(t=>t.uid===e);-1!==r&&(this.abortUpload(e),this.fileList.splice(r,1),null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList))}clearFiles(){var e,t;this.fileList.forEach(e=>{this.abortUpload(e.uid)}),this.fileList=[],null===(t=(e=this.config).onFileListChange)||void 0===t||t.call(e,this.fileList)}getFileList(){return[...this.fileList]}uploadAll(){return i(this,void 0,void 0,function*(){const e=this.fileList.filter(e=>"pending"===e.status);yield Promise.all(e.map(e=>this.upload(e)))})}abortUpload(e){var t,n,r,i;const o=this.abortControllers.get(e);if(o){o.abort(),this.abortControllers.delete(e);const a=this.fileList.find(t=>t.uid===e);a&&(a.status="canceled",a.percent=0,null===(n=(t=this.config).onCancel)||void 0===n||n.call(t,a),null===(i=(r=this.config).onFileListChange)||void 0===i||i.call(r,this.fileList))}}retryUpload(e){return i(this,void 0,void 0,function*(){var t,n;const r=this.fileList.find(t=>t.uid===e);!r||"error"!==r.status&&"canceled"!==r.status||(r.status="pending",r.percent=0,r.error=void 0,null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList),yield this.upload(r))})}checkFastUpload(e){return i(this,void 0,void 0,function*(){if(!this.config.url)return{shouldUpload:!0};try{return(yield this.axiosInstance.post(`${this.config.url}/check`,{fileName:e.name,fileSize:e.size,lastModified:e.file.lastModified})).data}catch(e){return console.warn("秒传检查失败,继续正常上传:",e),{shouldUpload:!0}}})}updateProgress(e,t,n){var r,i;if(e.uploadedSize=t,e.percent=n>0?Math.round(t/n*100):0,this.config.onProgress){const e=new ProgressEvent("progress",{loaded:t,total:n,lengthComputable:!0});this.config.onProgress(e)}null===(i=(r=this.config).onFileListChange)||void 0===i||i.call(r,this.fileList)}request(e){return i(this,arguments,void 0,function*(e,t=this.config.maxRetries){var n,r;let i;for(let o=0;o<t;o++)try{const t=new AbortController;(null===(n=e.data)||void 0===n?void 0:n.uid)&&this.abortControllers.set(e.data.uid,t);const i=yield this.axiosInstance(Object.assign(Object.assign({},e),{signal:t.signal}));return(null===(r=e.data)||void 0===r?void 0:r.uid)&&this.abortControllers.delete(e.data.uid),i.data}catch(e){if(i=e,"ERR_CANCELED"===e.code)throw e;o<t-1&&(yield new Promise(e=>setTimeout(e,this.config.retryDelay*Math.pow(2,o))))}throw i})}}class v{value;next;constructor(e){this.value=e}}class y{#e;#t;#n;constructor(){this.clear()}enqueue(e){const t=new v(e);this.#e?(this.#t.next=t,this.#t=t):(this.#e=t,this.#t=t),this.#n++}dequeue(){const e=this.#e;if(e)return this.#e=this.#e.next,this.#n--,this.#e||(this.#t=void 0),e.value}peek(){if(this.#e)return this.#e.value}clear(){this.#e=void 0,this.#t=void 0,this.#n=0}get size(){return this.#n}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}*drain(){for(;this.#e;)yield this.dequeue()}}function x(e){b(e);const t=new y;let n=0;const r=()=>{n<e&&t.size>0&&(n++,t.dequeue()())},i=async(e,t,i)=>{const o=(async()=>e(...i))();t(o);try{await o}catch{}n--,r()},o=(o,...a)=>new Promise(s=>{((o,a,s)=>{new Promise(e=>{t.enqueue(e)}).then(i.bind(void 0,o,a,s)),n<e&&r()})(o,s,a)});return Object.defineProperties(o,{activeCount:{get:()=>n},pendingCount:{get:()=>t.size},clearQueue:{value(){t.clear()}},concurrency:{get:()=>e,set(i){b(i),e=i,queueMicrotask(()=>{for(;n<e&&t.size>0;)r()})}},map:{async value(e,t){const n=Array.from(e,(e,n)=>this(t,e,n));return Promise.all(n)}}}),o}function b(e){if(!Number.isInteger(e)&&e!==Number.POSITIVE_INFINITY||!(e>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up")}class k extends g{constructor(e){super(e),this.chunkSize=e.chunkSize||5242880}upload(e){return i(this,void 0,void 0,function*(){try{if(!(yield this.validateFile(e)))return;const t=yield this.checkFastUpload(e);if(!0===(null==t?void 0:t.fileExists))return void(yield this.handleFastUpload(e,t));e.hash=yield m(e.file);const n=h(e.file,this.chunkSize);e.chunkList=n.map((t,n)=>({index:n,chunk:t,hash:`${e.hash}-${n}`,size:t.size,progress:0,status:"pending"})),yield this.uploadChunks(e,t.uploadedList||[]),yield this.mergeChunks(e)}catch(t){this.handleUploadError(e,t)}})}validateFile(e){return i(this,void 0,void 0,function*(){var t,n;if(this.config.beforeUpload){if(!(yield Promise.resolve(this.config.beforeUpload(e.file))))return this.removeFile(e.uid),!1}return e.status="uploading",null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList),!0})}handleFastUpload(e,t){return i(this,void 0,void 0,function*(){var t,n;e.status="success",e.percent=100,e.response={message:"秒传成功"},this.config.onSuccess&&this.config.onSuccess(e.response,e),null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList)})}uploadChunks(e,t){return i(this,void 0,void 0,function*(){const{chunkList:n}=e;if(!n)return;const r=x(this.config.concurrency||3),i=[];n.filter(e=>!t.includes(e.hash)).forEach(t=>{const n=r(()=>this.uploadChunk(e,t));i.push(n)}),yield Promise.all(i)})}uploadChunk(e,t){return i(this,void 0,void 0,function*(){t.status="uploading";const n=new FormData;n.append("file",t.chunk),n.append("chunkIndex",t.index.toString()),n.append("chunkHash",t.hash),n.append("fileHash",e.hash),n.append("fileName",e.name),n.append("totalChunks",e.chunkList.length.toString()),n.append("uid",e.uid);try{yield this.request({method:this.config.method,url:this.config.url,data:n,onUploadProgress:n=>{const r=n.loaded,i=n.total||t.size;t.progress=Math.round(r/i*100);const o=e.chunkList.reduce((e,n)=>e+(n.index===t.index?r:n.size*(n.progress/100)),0),a=e.size;this.updateProgress(e,o,a)}},this.config.chunkRetry),t.status="success",t.progress=100}catch(e){throw t.status="error",e}})}mergeChunks(e){return i(this,void 0,void 0,function*(){var t,n;const r=yield this.request({method:"POST",url:`${this.config.url}/merge`,data:{fileName:e.name,fileHash:e.hash,totalChunks:e.chunkList.length,uid:e.uid}});e.status="success",e.percent=100,e.response=r,this.config.onSuccess&&this.config.onSuccess(r,e),null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList)})}handleUploadError(e,t){var n,r;e.status="error",e.error=t,this.config.onError&&this.config.onError(t,e),null===(r=(n=this.config).onFileListChange)||void 0===r||r.call(n,this.fileList)}resumeUpload(e){return i(this,void 0,void 0,function*(){const t=this.fileList.find(t=>t.uid===e);if(t&&"error"===t.status)try{const e=(yield this.request({method:"GET",url:`${this.config.url}/uploaded`,params:{fileHash:t.hash,fileName:t.name}})).uploadedList||[];yield this.uploadChunks(t,e),yield this.mergeChunks(t)}catch(e){this.handleUploadError(t,e)}})}}class j extends g{constructor(e){super(e),this.concurrent=e.concurrent||3}upload(e){return i(this,void 0,void 0,function*(){var t,n,r,i;try{if(!(yield this.validateFile(e)))return;e.status="uploading",null===(n=(t=this.config).onFileListChange)||void 0===n||n.call(t,this.fileList);const r=new FormData;r.append("file",e.file),r.append("fileName",e.name),r.append("uid",e.uid);const i=yield this.request({method:this.config.method,url:this.config.url,data:r,onUploadProgress:t=>{this.updateProgress(e,t.loaded,t.total||e.size)}});e.status="success",e.percent=100,e.response=i,this.config.onSuccess&&this.config.onSuccess(i,e)}catch(t){this.handleUploadError(e,t)}null===(i=(r=this.config).onFileListChange)||void 0===i||i.call(r,this.fileList)})}uploadAll(){return i(this,void 0,void 0,function*(){const e=this.fileList.filter(e=>"pending"===e.status),t=x(this.concurrent),n=e.map(e=>t(()=>this.upload(e)));yield Promise.all(n)})}validateFile(e){return i(this,void 0,void 0,function*(){if(this.config.beforeUpload){if(!(yield Promise.resolve(this.config.beforeUpload(e.file))))return this.removeFile(e.uid),!1}return!0})}handleUploadError(e,t){e.status="error",e.error=t,this.config.onError&&this.config.onError(t,e)}}var C,N={exports:{}},w={};var S,L,F={};
|
|
2
2
|
/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.development.js
|
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/function _(){return N||(N=1,"production"!==process.env.NODE_ENV&&function(){function e(t){if(null==t)return null;if("function"==typeof t)return t.$$typeof===N?null:t.displayName||t.name||null;if("string"==typeof t)return t;switch(t){case f:return"Fragment";case g:return"Profiler";case m:return"StrictMode";case x:return"Suspense";case j:return"SuspenseList";case C:return"Activity"}if("object"==typeof t)switch("number"==typeof t.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case h:return"Portal";case v:return t.displayName||"Context";case y:return(t._context.displayName||"Context")+".Consumer";case b:var n=t.render;return(t=t.displayName)||(t=""!==(t=n.displayName||n.name||"")?"ForwardRef("+t+")":"ForwardRef"),t;case k:return null!==(n=t.displayName||null)?n:e(t.type)||"Memo";case w:n=t._payload,t=t._init;try{return e(t(n))}catch(e){}}return null}function t(e){return""+e}function i(e){try{t(e);var n=!1}catch(e){n=!0}if(n){var i=(n=console).error,r="function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return i.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",r),t(e)}}function r(t){if(t===f)return"<>";if("object"==typeof t&&null!==t&&t.$$typeof===w)return"<...>";try{var n=e(t);return n?"<"+n+">":"<...>"}catch(e){return"<...>"}}function s(){return Error("react-stack-top-frame")}function o(){var t=e(this.type);return z[t]||(z[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),void 0!==(t=this.props.ref)?t:null}function a(t,n,r,s,a,c){var d,h=n.children;if(void 0!==h)if(s)if(F(h)){for(s=0;s<h.length;s++)l(h[s]);Object.freeze&&Object.freeze(h)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else l(h);if(_.call(n,"key")){h=e(t);var f=Object.keys(n).filter(function(e){return"key"!==e});s=0<f.length?"{key: someKey, "+f.join(": ..., ")+": ...}":"{key: someKey}",R[h+s]||(f=0<f.length?"{"+f.join(": ..., ")+": ...}":"{}",console.error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',s,h,f,h),R[h+s]=!0)}if(h=null,void 0!==r&&(i(r),h=""+r),function(e){if(_.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(n)&&(i(n.key),h=""+n.key),"key"in n)for(var m in r={},n)"key"!==m&&(r[m]=n[m]);else r=n;return h&&function(e,t){function n(){u||(u=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}(r,"function"==typeof t?t.displayName||t.name||"Unknown":t),function(e,t,n,i,r,s){var a=n.ref;return e={$$typeof:p,type:e,key:t,props:n,_owner:i},null!==(void 0!==a?a:null)?Object.defineProperty(e,"ref",{enumerable:!1,get:o}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:r}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:s}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}(t,h,r,null===(d=S.A)?null:d.getOwner(),a,c)}function l(e){c(e)?e._store&&(e._store.validated=1):"object"==typeof e&&null!==e&&e.$$typeof===w&&("fulfilled"===e._payload.status?c(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function c(e){return"object"==typeof e&&null!==e&&e.$$typeof===p}var u,d=n,p=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),g=Symbol.for("react.profiler"),y=Symbol.for("react.consumer"),v=Symbol.for("react.context"),b=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),k=Symbol.for("react.memo"),w=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),N=Symbol.for("react.client.reference"),S=d.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_=Object.prototype.hasOwnProperty,F=Array.isArray,U=console.createTask?console.createTask:function(){return null},z={},A=(d={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(d,s)(),O=U(r(s)),R={};L.Fragment=f,L.jsx=function(e,t,n){var i=1e4>S.recentlyCreatedOwnerStacks++;return a(e,t,n,!1,i?Error("react-stack-top-frame"):A,i?U(r(e)):O)},L.jsxs=function(e,t,n){var i=1e4>S.recentlyCreatedOwnerStacks++;return a(e,t,n,!0,i?Error("react-stack-top-frame"):A,i?U(r(e)):O)}}()),L}var F=(S||(S=1,"production"===process.env.NODE_ENV?w.exports=function(){if(k)return C;k=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(t,n,i){var r=null;if(void 0!==i&&(r=""+i),void 0!==n.key&&(r=""+n.key),"key"in n)for(var s in i={},n)"key"!==s&&(i[s]=n[s]);else i=n;return n=i.ref,{$$typeof:e,type:t,key:r,ref:void 0!==n?n:null,props:i}}return C.Fragment=t,C.jsx=n,C.jsxs=n,C}():w.exports=_()),w.exports);const U=e=>{const[t,r]=n.useState([]),[s,o]=n.useState(!1),a=n.useRef(null),l=n.useCallback(()=>{e.chunkSize&&e.chunkSize>0?a.current=new x(Object.assign(Object.assign({},e),{onFileListChange:t=>{var n;r(t),null===(n=e.onFileListChange)||void 0===n||n.call(e,t)}})):a.current=new j(Object.assign(Object.assign({},e),{onFileListChange:t=>{var n;r(t),null===(n=e.onFileListChange)||void 0===n||n.call(e,t)}}))},[e]);return{fileList:t,uploading:s,handleFileSelect:n.useCallback(t=>{a.current||l();const n=Array.from(t).filter(t=>!(e.accept&&!d(t,e.accept))&&!!p(t,e.maxSize,e.minSize));n.length>0&&a.current.addFiles(n)},[e,l]),uploadAll:n.useCallback(()=>i(void 0,void 0,void 0,function*(){if(a.current){o(!0);try{yield a.current.uploadAll()}finally{o(!1)}}}),[]),cancelUpload:n.useCallback(e=>{var t;null===(t=a.current)||void 0===t||t.abortUpload(e)},[]),retryUpload:n.useCallback(e=>i(void 0,void 0,void 0,function*(){var t;yield null===(t=a.current)||void 0===t?void 0:t.retryUpload(e)}),[]),removeFile:n.useCallback(e=>{var t;null===(t=a.current)||void 0===t||t.removeFile(e)},[]),clearFiles:n.useCallback(()=>{var e;null===(e=a.current)||void 0===e||e.clearFiles()},[]),uploader:a.current}},z=({fileList:e,listType:t,onCancel:n,onRetry:i,onRemove:r})=>0===e.length?null:(()=>{switch(t){case"picture":return F.jsx("div",{className:"upload-list upload-list-picture",children:e.map(e=>F.jsxs("div",{className:"upload-list-item upload-list-item-picture",children:[F.jsx("div",{className:"upload-list-item-thumbnail",children:e.type.startsWith("image/")?F.jsx("img",{src:URL.createObjectURL(e.file),alt:e.name,onLoad:()=>URL.revokeObjectURL(URL.createObjectURL(e.file))}):F.jsx("div",{className:"upload-list-item-icon",children:e.type.split("/")[0]})}),F.jsxs("div",{className:"upload-list-item-info",children:[F.jsx("div",{className:"upload-list-item-name",children:e.name}),F.jsxs("div",{className:"upload-list-item-status",children:["uploading"===e.status&&F.jsxs(F.Fragment,{children:[F.jsxs("span",{className:"upload-list-item-progress",children:[e.percent,"%"]}),F.jsx("button",{className:"upload-list-item-action",onClick:()=>n(e.uid),children:"取消"})]}),"success"===e.status&&F.jsx("span",{className:"upload-list-item-success",children:"✓ 成功"}),"error"===e.status&&F.jsxs(F.Fragment,{children:[F.jsx("span",{className:"upload-list-item-error",children:"✗ 失败"}),F.jsx("button",{className:"upload-list-item-action",onClick:()=>i(e.uid),children:"重试"})]}),"canceled"===e.status&&F.jsxs(F.Fragment,{children:[F.jsx("span",{className:"upload-list-item-canceled",children:"已取消"}),F.jsx("button",{className:"upload-list-item-action",onClick:()=>i(e.uid),children:"重试"})]}),F.jsx("button",{className:"upload-list-item-action upload-list-item-remove",onClick:()=>r(e.uid),children:"删除"})]})]})]},e.uid))});case"picture-card":return F.jsx("div",{className:"upload-list upload-list-picture-card",children:e.map(e=>F.jsxs("div",{className:"upload-list-item upload-list-item-picture-card",children:[F.jsxs("div",{className:"upload-list-item-thumbnail",children:[e.type.startsWith("image/")?F.jsx("img",{src:URL.createObjectURL(e.file),alt:e.name,onLoad:()=>URL.revokeObjectURL(URL.createObjectURL(e.file))}):F.jsx("div",{className:"upload-list-item-icon",children:e.type.split("/")[0]}),F.jsx("div",{className:"upload-list-item-overlay",children:F.jsxs("div",{className:"upload-list-item-status",children:["uploading"===e.status&&F.jsxs(F.Fragment,{children:[F.jsxs("span",{className:"upload-list-item-progress",children:[e.percent,"%"]}),F.jsx("button",{className:"upload-list-item-action",onClick:()=>n(e.uid),children:"取消"})]}),"success"===e.status&&F.jsx("span",{className:"upload-list-item-success",children:"✓"}),"error"===e.status&&F.jsxs(F.Fragment,{children:[F.jsx("span",{className:"upload-list-item-error",children:"✗"}),F.jsx("button",{className:"upload-list-item-action",onClick:()=>i(e.uid),children:"重试"})]}),"canceled"===e.status&&F.jsxs(F.Fragment,{children:[F.jsx("span",{className:"upload-list-item-canceled",children:"已取消"}),F.jsx("button",{className:"upload-list-item-action",onClick:()=>i(e.uid),children:"重试"})]}),F.jsx("button",{className:"upload-list-item-action upload-list-item-remove",onClick:()=>r(e.uid),children:"删除"})]})})]}),F.jsx("div",{className:"upload-list-item-name",children:e.name})]},e.uid))});default:return F.jsx("div",{className:"upload-list upload-list-text",children:e.map(e=>{return F.jsxs("div",{className:"upload-list-item",children:[F.jsxs("div",{className:"upload-list-item-name",children:[F.jsx("span",{children:e.name}),F.jsxs("span",{className:"upload-list-item-size",children:["(",(t=e.size,t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(2)} KB`:`${(t/1048576).toFixed(2)} MB`),")"]})]}),F.jsxs("div",{className:"upload-list-item-status",children:["uploading"===e.status&&F.jsxs(F.Fragment,{children:[F.jsxs("span",{className:"upload-list-item-progress",children:[e.percent,"%"]}),F.jsx("button",{className:"upload-list-item-action",onClick:()=>n(e.uid),children:"取消"})]}),"success"===e.status&&F.jsx("span",{className:"upload-list-item-success",children:"✓ 成功"}),"error"===e.status&&F.jsxs(F.Fragment,{children:[F.jsx("span",{className:"upload-list-item-error",children:"✗ 失败"}),F.jsx("button",{className:"upload-list-item-action",onClick:()=>i(e.uid),children:"重试"})]}),"canceled"===e.status&&F.jsxs(F.Fragment,{children:[F.jsx("span",{className:"upload-list-item-canceled",children:"已取消"}),F.jsx("button",{className:"upload-list-item-action",onClick:()=>i(e.uid),children:"重试"})]}),F.jsx("button",{className:"upload-list-item-action upload-list-item-remove",onClick:()=>r(e.uid),children:"删除"})]})]},e.uid);var t})})}})(),A=({fileList:e,onUploadAll:t,onClear:n})=>{const i=(()=>{if(0===e.length)return 0;const t=e.reduce((e,t)=>e+t.size,0),n=e.reduce((e,t)=>e+(t.uploadedSize||0),0);return Math.round(n/t*100)})(),r=e.filter(e=>"uploading"===e.status).length,s=e.filter(e=>"success"===e.status).length,o=e.filter(e=>"error"===e.status).length;return 0===e.length?null:F.jsxs("div",{className:"upload-progress",children:[F.jsxs("div",{className:"upload-progress-header",children:[F.jsxs("div",{className:"upload-progress-status",children:[r>0&&F.jsxs("span",{className:"upload-progress-uploading",children:["正在上传 ",r," 个文件..."]}),0===r&&s>0&&F.jsxs("span",{className:"upload-progress-success",children:["已成功上传 ",s," 个文件"]}),o>0&&F.jsxs("span",{className:"upload-progress-error",children:["有 ",o," 个文件上传失败"]})]}),F.jsxs("div",{className:"upload-progress-actions",children:[F.jsx("button",{className:"upload-progress-action upload-progress-start",onClick:t,disabled:r>0,children:"开始上传"}),F.jsx("button",{className:"upload-progress-action upload-progress-clear",onClick:n,children:"清空"})]})]}),F.jsxs("div",{className:"upload-progress-bar-container",children:[F.jsx("div",{className:"upload-progress-bar",style:{width:`${i}%`}}),F.jsxs("div",{className:"upload-progress-text",children:[i,"%"]})]}),F.jsx("div",{className:"upload-progress-footer",children:F.jsxs("div",{className:"upload-progress-stats",children:[F.jsxs("span",{children:["总数: ",e.length]}),F.jsxs("span",{children:["成功: ",s]}),F.jsxs("span",{children:["失败: ",o]}),F.jsxs("span",{children:["等待: ",e.length-s-o-r]})]})})]})};!function(e,t){void 0===t&&(t={});var n=t.insertAt;if("undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&i.firstChild?i.insertBefore(r,i.firstChild):i.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}("/* 上传组件共享样式 */\n\n/* 基础样式 */\n.upload-container {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n}\n\n.upload-drag {\n border: 2px dashed #d9d9d9;\n border-radius: 6px;\n padding: 40px 20px;\n text-align: center;\n cursor: pointer;\n transition: border-color 0.3s;\n}\n\n.upload-drag:hover,\n.upload-dragover {\n border-color: #1890ff;\n}\n\n.upload-trigger {\n display: inline-block;\n cursor: pointer;\n}\n\n.upload-default {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n color: #666;\n}\n\n.upload-icon {\n font-size: 32px;\n color: #999;\n margin-bottom: 8px;\n}\n\n.upload-text {\n font-size: 14px;\n}\n\n/* UploadList 样式 */\n.upload-list {\n margin-top: 12px;\n}\n\n.upload-list-item {\n display: flex;\n align-items: center;\n padding: 8px 0;\n border-bottom: 1px solid #f0f0f0;\n}\n\n.upload-list-item-name {\n flex: 1;\n font-size: 14px;\n color: #333;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.upload-list-item-size {\n font-size: 12px;\n color: #999;\n margin-left: 8px;\n}\n\n.upload-list-item-status {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.upload-list-item-progress {\n font-size: 12px;\n color: #1890ff;\n}\n\n.upload-list-item-success {\n font-size: 12px;\n color: #52c41a;\n}\n\n.upload-list-item-error {\n font-size: 12px;\n color: #ff4d4f;\n}\n\n.upload-list-item-canceled {\n font-size: 12px;\n color: #999;\n}\n\n.upload-list-item-action {\n font-size: 12px;\n color: #1890ff;\n background: none;\n border: none;\n padding: 0;\n cursor: pointer;\n}\n\n.upload-list-item-action:hover {\n text-decoration: underline;\n}\n\n.upload-list-item-remove {\n color: #999;\n}\n\n/* 图片类型样式 */\n.upload-list-item-picture {\n flex-direction: column;\n align-items: flex-start;\n gap: 8px;\n}\n\n.upload-list-item-thumbnail {\n position: relative;\n width: 100px;\n height: 100px;\n border-radius: 4px;\n overflow: hidden;\n border: 1px solid #f0f0f0;\n}\n\n.upload-list-item-thumbnail img {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n\n.upload-list-item-icon {\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: #f5f5f5;\n font-size: 12px;\n color: #999;\n}\n\n.upload-list-item-info {\n width: 100%;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n/* 图片卡片类型样式 */\n.upload-list-picture-card {\n display: flex;\n gap: 12px;\n flex-wrap: wrap;\n}\n\n.upload-list-item-picture-card {\n width: 120px;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n border: none;\n padding: 0;\n}\n\n.upload-list-item-picture-card .upload-list-item-thumbnail {\n width: 120px;\n height: 120px;\n}\n\n.upload-list-item-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n}\n\n.upload-list-item-picture-card .upload-list-item-status {\n color: white;\n flex-direction: column;\n gap: 8px;\n}\n\n.upload-list-item-picture-card .upload-list-item-action {\n color: white;\n border: 1px solid white;\n padding: 2px 8px;\n border-radius: 4px;\n}\n\n.upload-list-item-picture-card .upload-list-item-action:hover {\n background-color: white;\n color: #1890ff;\n text-decoration: none;\n}\n\n.upload-list-item-picture-card .upload-list-item-name {\n font-size: 12px;\n text-align: center;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: 100%;\n}\n\n/* Progress 组件样式 */\n.upload-progress {\n margin-top: 12px;\n padding: 12px;\n background-color: #fafafa;\n border-radius: 6px;\n}\n\n.upload-progress-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 12px;\n}\n\n.upload-progress-status {\n font-size: 14px;\n color: #333;\n}\n\n.upload-progress-uploading {\n color: #1890ff;\n}\n\n.upload-progress-success {\n color: #52c41a;\n}\n\n.upload-progress-error {\n color: #ff4d4f;\n}\n\n.upload-progress-actions {\n display: flex;\n gap: 8px;\n}\n\n.upload-progress-action {\n font-size: 12px;\n padding: 4px 12px;\n border: 1px solid #d9d9d9;\n border-radius: 4px;\n background-color: white;\n cursor: pointer;\n transition: all 0.3s;\n}\n\n.upload-progress-action:hover {\n border-color: #1890ff;\n color: #1890ff;\n}\n\n.upload-progress-action:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.upload-progress-action:disabled:hover {\n border-color: #d9d9d9;\n color: #999;\n}\n\n.upload-progress-start {\n color: #1890ff;\n border-color: #1890ff;\n}\n\n.upload-progress-start:hover {\n background-color: #e6f7ff;\n}\n\n.upload-progress-clear {\n color: #666;\n}\n\n.upload-progress-bar-container {\n position: relative;\n height: 8px;\n background-color: #f0f0f0;\n border-radius: 4px;\n overflow: hidden;\n margin-bottom: 8px;\n}\n\n.upload-progress-bar {\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n background-color: #1890ff;\n transition: width 0.3s ease;\n}\n\n.upload-progress-text {\n position: absolute;\n top: 0;\n right: 8px;\n height: 100%;\n display: flex;\n align-items: center;\n font-size: 12px;\n color: #666;\n}\n\n.upload-progress-footer {\n margin-top: 8px;\n}\n\n.upload-progress-stats {\n display: flex;\n gap: 16px;\n font-size: 12px;\n color: #999;\n}");e.BaseUploader=m,e.ParallelUploader=j,e.ReactUpload=e=>{var{children:t,className:i="",style:r,drag:s=!1,showFileList:o=!0,listType:a="text"}=e,l=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["children","className","style","drag","showFileList","listType"]);const c=n.useRef(null),u=n.useRef(null),{fileList:d,uploading:p,handleFileSelect:h,uploadAll:f,cancelUpload:m,retryUpload:g,removeFile:y,clearFiles:v}=U(l),b=n.useCallback(()=>{var e;null===(e=c.current)||void 0===e||e.click()},[]),x=n.useCallback(e=>{e.target.files&&(h(e.target.files),e.target.value="")},[h]),j=n.useCallback(e=>{var t,n;e.preventDefault(),e.stopPropagation(),"dragenter"===e.type||"dragover"===e.type?null===(t=u.current)||void 0===t||t.classList.add("upload-dragover"):"dragleave"===e.type&&(null===(n=u.current)||void 0===n||n.classList.remove("upload-dragover"))},[]),k=n.useCallback(e=>{var t;e.preventDefault(),e.stopPropagation(),null===(t=u.current)||void 0===t||t.classList.remove("upload-dragover"),e.dataTransfer.files&&h(e.dataTransfer.files)},[h]),w=()=>t||F.jsxs("div",{className:"upload-default",children:[F.jsx("div",{className:"upload-icon",children:"+"}),F.jsx("div",{className:"upload-text",children:"点击或拖拽文件到此区域上传"})]});return F.jsxs("div",{className:`upload-container ${i}`,style:r,children:[F.jsx("input",{ref:c,type:"file",style:{display:"none"},multiple:l.multiple,accept:l.accept,onChange:x}),s?F.jsx("div",{ref:u,className:"upload-drag",onClick:b,onDragEnter:j,onDragOver:j,onDragLeave:j,onDrop:k,children:w()}):F.jsx("div",{className:"upload-trigger",onClick:b,children:w()}),o&&F.jsx(z,{fileList:d,listType:a,onCancel:m,onRetry:g,onRemove:y}),p&&F.jsx(A,{fileList:d,onUploadAll:f,onClear:v})]})},e.SliceUploader=x,e.calculateChunkSize=e=>e<=10485760?e:e<=104857600?5242880:e<=1073741824?10485760:20971520,e.calculateFileHash=f,e.createFileChunks=h,e.defaultConfig={url:"",method:"POST",timeout:3e4,maxRetries:3,retryDelay:1e3,chunkSize:5242880,chunkRetry:3,concurrent:3,autoUpload:!0,multiple:!1,withCredentials:!1},e.formatFileSize=e=>{if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["B","KB","MB","GB","TB"][t]},e.generateFileId=c,e.getFileExtension=u,e.useReactUpload=U,e.validateFileSize=p,e.validateFileType=d});
|
|
10
|
+
*/function B(){return S||(S=1,"production"!==process.env.NODE_ENV&&function(){function e(t){if(null==t)return null;if("function"==typeof t)return t.$$typeof===w?null:t.displayName||t.name||null;if("string"==typeof t)return t;switch(t){case h:return"Fragment";case g:return"Profiler";case m:return"StrictMode";case b:return"Suspense";case k:return"SuspenseList";case N:return"Activity"}if("object"==typeof t)switch("number"==typeof t.tag&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case f:return"Portal";case y:return t.displayName||"Context";case v:return(t._context.displayName||"Context")+".Consumer";case x:var n=t.render;return(t=t.displayName)||(t=""!==(t=n.displayName||n.name||"")?"ForwardRef("+t+")":"ForwardRef"),t;case j:return null!==(n=t.displayName||null)?n:e(t.type)||"Memo";case C:n=t._payload,t=t._init;try{return e(t(n))}catch(e){}}return null}function t(e){return""+e}function r(e){try{t(e);var n=!1}catch(e){n=!0}if(n){var r=(n=console).error,i="function"==typeof Symbol&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",i),t(e)}}function i(t){if(t===h)return"<>";if("object"==typeof t&&null!==t&&t.$$typeof===C)return"<...>";try{var n=e(t);return n?"<"+n+">":"<...>"}catch(e){return"<...>"}}function o(){return Error("react-stack-top-frame")}function a(){var t=e(this.type);return z[t]||(z[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),void 0!==(t=this.props.ref)?t:null}function s(t,n,i,o,s,c){var u,f=n.children;if(void 0!==f)if(o)if(B(f)){for(o=0;o<f.length;o++)l(f[o]);Object.freeze&&Object.freeze(f)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else l(f);if(L.call(n,"key")){f=e(t);var h=Object.keys(n).filter(function(e){return"key"!==e});o=0<h.length?"{key: someKey, "+h.join(": ..., ")+": ...}":"{key: someKey}",A[f+o]||(h=0<h.length?"{"+h.join(": ..., ")+": ...}":"{}",console.error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',o,f,h,f),A[f+o]=!0)}if(f=null,void 0!==i&&(r(i),f=""+i),function(e){if(L.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return void 0!==e.key}(n)&&(r(n.key),f=""+n.key),"key"in n)for(var m in i={},n)"key"!==m&&(i[m]=n[m]);else i=n;return f&&function(e,t){function n(){d||(d=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}(i,"function"==typeof t?t.displayName||t.name||"Unknown":t),function(e,t,n,r,i,o){var s=n.ref;return e={$$typeof:p,type:e,key:t,props:n,_owner:r},null!==(void 0!==s?s:null)?Object.defineProperty(e,"ref",{enumerable:!1,get:a}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:i}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:o}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}(t,f,i,null===(u=S.A)?null:u.getOwner(),s,c)}function l(e){c(e)?e._store&&(e._store.validated=1):"object"==typeof e&&null!==e&&e.$$typeof===C&&("fulfilled"===e._payload.status?c(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function c(e){return"object"==typeof e&&null!==e&&e.$$typeof===p}var d,u=n,p=Symbol.for("react.transitional.element"),f=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),g=Symbol.for("react.profiler"),v=Symbol.for("react.consumer"),y=Symbol.for("react.context"),x=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),j=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),w=Symbol.for("react.client.reference"),S=u.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=Object.prototype.hasOwnProperty,B=Array.isArray,_=console.createTask?console.createTask:function(){return null},z={},E=(u={react_stack_bottom_frame:function(e){return e()}}).react_stack_bottom_frame.bind(u,o)(),U=_(i(o)),A={};F.Fragment=h,F.jsx=function(e,t,n){var r=1e4>S.recentlyCreatedOwnerStacks++;return s(e,t,n,!1,r?Error("react-stack-top-frame"):E,r?_(i(e)):U)},F.jsxs=function(e,t,n){var r=1e4>S.recentlyCreatedOwnerStacks++;return s(e,t,n,!0,r?Error("react-stack-top-frame"):E,r?_(i(e)):U)}}()),F}var _=(L||(L=1,"production"===process.env.NODE_ENV?N.exports=function(){if(C)return w;C=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(t,n,r){var i=null;if(void 0!==r&&(i=""+r),void 0!==n.key&&(i=""+n.key),"key"in n)for(var o in r={},n)"key"!==o&&(r[o]=n[o]);else r=n;return n=r.ref,{$$typeof:e,type:t,key:i,ref:void 0!==n?n:null,props:r}}return w.Fragment=t,w.jsx=n,w.jsxs=n,w}():N.exports=B()),N.exports);const z=e=>{const[t,r]=n.useState([]),[o,a]=n.useState(!1),s=n.useRef(null),l=n.useCallback(()=>{e.chunkSize&&e.chunkSize>0?s.current=new k(Object.assign(Object.assign({},e),{onFileListChange:t=>{var n;r(t),null===(n=e.onFileListChange)||void 0===n||n.call(e,t)}})):s.current=new j(Object.assign(Object.assign({},e),{onFileListChange:t=>{var n;r(t),null===(n=e.onFileListChange)||void 0===n||n.call(e,t)}}))},[e]);return{fileList:t,uploading:o,handleFileSelect:n.useCallback(t=>{s.current||l();const n=Array.from(t).filter(t=>!(e.accept&&!p(t,e.accept))&&!!f(t,e.maxSize,e.minSize));n.length>0&&s.current.addFiles(n)},[e,l]),uploadAll:n.useCallback(()=>i(void 0,void 0,void 0,function*(){if(s.current){a(!0);try{yield s.current.uploadAll()}finally{a(!1)}}}),[]),cancelUpload:n.useCallback(e=>{var t;null===(t=s.current)||void 0===t||t.abortUpload(e)},[]),retryUpload:n.useCallback(e=>i(void 0,void 0,void 0,function*(){var t;yield null===(t=s.current)||void 0===t?void 0:t.retryUpload(e)}),[]),removeFile:n.useCallback(e=>{var t;null===(t=s.current)||void 0===t||t.removeFile(e)},[]),clearFiles:n.useCallback(()=>{var e;null===(e=s.current)||void 0===e||e.clearFiles()},[]),uploader:s.current}},E=({fileList:e,listType:t,onCancel:n,onRetry:r,onRemove:i})=>0===e.length?null:(()=>{switch(t){case"picture":return _.jsx("div",{className:"upload-list upload-list-picture",children:e.map(e=>_.jsxs("div",{className:"upload-list-item upload-list-item-picture",children:[_.jsx("div",{className:"upload-list-item-thumbnail",children:e.type.startsWith("image/")?_.jsx("img",{src:URL.createObjectURL(e.file),alt:e.name,onLoad:()=>URL.revokeObjectURL(URL.createObjectURL(e.file))}):_.jsx("div",{className:"upload-list-item-icon",children:e.type.split("/")[0]})}),_.jsxs("div",{className:"upload-list-item-info",children:[_.jsx("div",{className:"upload-list-item-name",children:e.name}),_.jsxs("div",{className:"upload-list-item-status",children:["uploading"===e.status&&_.jsxs(_.Fragment,{children:[_.jsxs("span",{className:"upload-list-item-progress",children:[e.percent,"%"]}),_.jsx("button",{className:"upload-list-item-action",onClick:()=>n(e.uid),children:"取消"})]}),"success"===e.status&&_.jsx("span",{className:"upload-list-item-success",children:"✓ 成功"}),"error"===e.status&&_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"upload-list-item-error",children:"✗ 失败"}),_.jsx("button",{className:"upload-list-item-action",onClick:()=>r(e.uid),children:"重试"})]}),"canceled"===e.status&&_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"upload-list-item-canceled",children:"已取消"}),_.jsx("button",{className:"upload-list-item-action",onClick:()=>r(e.uid),children:"重试"})]}),_.jsx("button",{className:"upload-list-item-action upload-list-item-remove",onClick:()=>i(e.uid),children:"删除"})]})]})]},e.uid))});case"picture-card":return _.jsx("div",{className:"upload-list upload-list-picture-card",children:e.map(e=>_.jsxs("div",{className:"upload-list-item upload-list-item-picture-card",children:[_.jsxs("div",{className:"upload-list-item-thumbnail",children:[e.type.startsWith("image/")?_.jsx("img",{src:URL.createObjectURL(e.file),alt:e.name,onLoad:()=>URL.revokeObjectURL(URL.createObjectURL(e.file))}):_.jsx("div",{className:"upload-list-item-icon",children:e.type.split("/")[0]}),_.jsx("div",{className:"upload-list-item-overlay",children:_.jsxs("div",{className:"upload-list-item-status",children:["uploading"===e.status&&_.jsxs(_.Fragment,{children:[_.jsxs("span",{className:"upload-list-item-progress",children:[e.percent,"%"]}),_.jsx("button",{className:"upload-list-item-action",onClick:()=>n(e.uid),children:"取消"})]}),"success"===e.status&&_.jsx("span",{className:"upload-list-item-success",children:"✓"}),"error"===e.status&&_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"upload-list-item-error",children:"✗"}),_.jsx("button",{className:"upload-list-item-action",onClick:()=>r(e.uid),children:"重试"})]}),"canceled"===e.status&&_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"upload-list-item-canceled",children:"已取消"}),_.jsx("button",{className:"upload-list-item-action",onClick:()=>r(e.uid),children:"重试"})]}),_.jsx("button",{className:"upload-list-item-action upload-list-item-remove",onClick:()=>i(e.uid),children:"删除"})]})})]}),_.jsx("div",{className:"upload-list-item-name",children:e.name})]},e.uid))});default:return _.jsx("div",{className:"upload-list upload-list-text",children:e.map(e=>{return _.jsxs("div",{className:"upload-list-item",children:[_.jsxs("div",{className:"upload-list-item-name",children:[_.jsx("span",{children:e.name}),_.jsxs("span",{className:"upload-list-item-size",children:["(",(t=e.size,t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(2)} KB`:`${(t/1048576).toFixed(2)} MB`),")"]})]}),_.jsxs("div",{className:"upload-list-item-status",children:["uploading"===e.status&&_.jsxs(_.Fragment,{children:[_.jsxs("span",{className:"upload-list-item-progress",children:[e.percent,"%"]}),_.jsx("button",{className:"upload-list-item-action",onClick:()=>n(e.uid),children:"取消"})]}),"success"===e.status&&_.jsx("span",{className:"upload-list-item-success",children:"✓ 成功"}),"error"===e.status&&_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"upload-list-item-error",children:"✗ 失败"}),_.jsx("button",{className:"upload-list-item-action",onClick:()=>r(e.uid),children:"重试"})]}),"canceled"===e.status&&_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"upload-list-item-canceled",children:"已取消"}),_.jsx("button",{className:"upload-list-item-action",onClick:()=>r(e.uid),children:"重试"})]}),_.jsx("button",{className:"upload-list-item-action upload-list-item-remove",onClick:()=>i(e.uid),children:"删除"})]})]},e.uid);var t})})}})(),U=({fileList:e,onUploadAll:t,onClear:n})=>{const r=(()=>{if(0===e.length)return 0;const t=e.reduce((e,t)=>e+t.size,0),n=e.reduce((e,t)=>e+(t.uploadedSize||0),0);return Math.round(n/t*100)})(),i=e.filter(e=>"uploading"===e.status).length,o=e.filter(e=>"success"===e.status).length,a=e.filter(e=>"error"===e.status).length;return 0===e.length?null:_.jsxs("div",{className:"upload-progress",children:[_.jsxs("div",{className:"upload-progress-header",children:[_.jsxs("div",{className:"upload-progress-status",children:[i>0&&_.jsxs("span",{className:"upload-progress-uploading",children:["正在上传 ",i," 个文件..."]}),0===i&&o>0&&_.jsxs("span",{className:"upload-progress-success",children:["已成功上传 ",o," 个文件"]}),a>0&&_.jsxs("span",{className:"upload-progress-error",children:["有 ",a," 个文件上传失败"]})]}),_.jsxs("div",{className:"upload-progress-actions",children:[_.jsx("button",{className:"upload-progress-action upload-progress-start",onClick:t,disabled:i>0,children:"开始上传"}),_.jsx("button",{className:"upload-progress-action upload-progress-clear",onClick:n,children:"清空"})]})]}),_.jsxs("div",{className:"upload-progress-bar-container",children:[_.jsx("div",{className:"upload-progress-bar",style:{width:`${r}%`}}),_.jsxs("div",{className:"upload-progress-text",children:[r,"%"]})]}),_.jsx("div",{className:"upload-progress-footer",children:_.jsxs("div",{className:"upload-progress-stats",children:[_.jsxs("span",{children:["总数: ",e.length]}),_.jsxs("span",{children:["成功: ",o]}),_.jsxs("span",{children:["失败: ",a]}),_.jsxs("span",{children:["等待: ",e.length-o-a-i]})]})})]})};function A(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===n&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}A("/* 上传组件共享样式 */\n\n/* 基础样式 */\n.upload-container {\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n}\n\n.upload-drag {\n border: 2px dashed #d9d9d9;\n border-radius: 6px;\n padding: 40px 20px;\n text-align: center;\n cursor: pointer;\n transition: border-color 0.3s;\n}\n\n.upload-drag:hover,\n.upload-dragover {\n border-color: #1890ff;\n}\n\n.upload-trigger {\n display: inline-block;\n cursor: pointer;\n}\n\n.upload-default {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n color: #666;\n}\n\n.upload-icon {\n font-size: 32px;\n color: #999;\n margin-bottom: 8px;\n}\n\n.upload-text {\n font-size: 14px;\n}\n\n/* UploadList 样式 */\n.upload-list {\n margin-top: 12px;\n}\n\n.upload-list-item {\n display: flex;\n align-items: center;\n padding: 8px 0;\n border-bottom: 1px solid #f0f0f0;\n}\n\n.upload-list-item-name {\n flex: 1;\n font-size: 14px;\n color: #333;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.upload-list-item-size {\n font-size: 12px;\n color: #999;\n margin-left: 8px;\n}\n\n.upload-list-item-status {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.upload-list-item-progress {\n font-size: 12px;\n color: #1890ff;\n}\n\n.upload-list-item-success {\n font-size: 12px;\n color: #52c41a;\n}\n\n.upload-list-item-error {\n font-size: 12px;\n color: #ff4d4f;\n}\n\n.upload-list-item-canceled {\n font-size: 12px;\n color: #999;\n}\n\n.upload-list-item-action {\n font-size: 12px;\n color: #1890ff;\n background: none;\n border: none;\n padding: 0;\n cursor: pointer;\n}\n\n.upload-list-item-action:hover {\n text-decoration: underline;\n}\n\n.upload-list-item-remove {\n color: #999;\n}\n\n/* 图片类型样式 */\n.upload-list-item-picture {\n flex-direction: column;\n align-items: flex-start;\n gap: 8px;\n}\n\n.upload-list-item-thumbnail {\n position: relative;\n width: 100px;\n height: 100px;\n border-radius: 4px;\n overflow: hidden;\n border: 1px solid #f0f0f0;\n}\n\n.upload-list-item-thumbnail img {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n\n.upload-list-item-icon {\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: #f5f5f5;\n font-size: 12px;\n color: #999;\n}\n\n.upload-list-item-info {\n width: 100%;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n/* 图片卡片类型样式 */\n.upload-list-picture-card {\n display: flex;\n gap: 12px;\n flex-wrap: wrap;\n}\n\n.upload-list-item-picture-card {\n width: 120px;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n border: none;\n padding: 0;\n}\n\n.upload-list-item-picture-card .upload-list-item-thumbnail {\n width: 120px;\n height: 120px;\n}\n\n.upload-list-item-overlay {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n}\n\n.upload-list-item-picture-card .upload-list-item-status {\n color: white;\n flex-direction: column;\n gap: 8px;\n}\n\n.upload-list-item-picture-card .upload-list-item-action {\n color: white;\n border: 1px solid white;\n padding: 2px 8px;\n border-radius: 4px;\n}\n\n.upload-list-item-picture-card .upload-list-item-action:hover {\n background-color: white;\n color: #1890ff;\n text-decoration: none;\n}\n\n.upload-list-item-picture-card .upload-list-item-name {\n font-size: 12px;\n text-align: center;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: 100%;\n}\n\n/* Progress 组件样式 */\n.upload-progress {\n margin-top: 12px;\n padding: 12px;\n background-color: #fafafa;\n border-radius: 6px;\n}\n\n.upload-progress-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 12px;\n}\n\n.upload-progress-status {\n font-size: 14px;\n color: #333;\n}\n\n.upload-progress-uploading {\n color: #1890ff;\n}\n\n.upload-progress-success {\n color: #52c41a;\n}\n\n.upload-progress-error {\n color: #ff4d4f;\n}\n\n.upload-progress-actions {\n display: flex;\n gap: 8px;\n}\n\n.upload-progress-action {\n font-size: 12px;\n padding: 4px 12px;\n border: 1px solid #d9d9d9;\n border-radius: 4px;\n background-color: white;\n cursor: pointer;\n transition: all 0.3s;\n}\n\n.upload-progress-action:hover {\n border-color: #1890ff;\n color: #1890ff;\n}\n\n.upload-progress-action:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.upload-progress-action:disabled:hover {\n border-color: #d9d9d9;\n color: #999;\n}\n\n.upload-progress-start {\n color: #1890ff;\n border-color: #1890ff;\n}\n\n.upload-progress-start:hover {\n background-color: #e6f7ff;\n}\n\n.upload-progress-clear {\n color: #666;\n}\n\n.upload-progress-bar-container {\n position: relative;\n height: 8px;\n background-color: #f0f0f0;\n border-radius: 4px;\n overflow: hidden;\n margin-bottom: 8px;\n}\n\n.upload-progress-bar {\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n background-color: #1890ff;\n transition: width 0.3s ease;\n}\n\n.upload-progress-text {\n position: absolute;\n top: 0;\n right: 8px;\n height: 100%;\n display: flex;\n align-items: center;\n font-size: 12px;\n color: #666;\n}\n\n.upload-progress-footer {\n margin-top: 8px;\n}\n\n.upload-progress-stats {\n display: flex;\n gap: 16px;\n font-size: 12px;\n color: #999;\n}");const O=e=>{const t=r.ref([]),n=r.ref(!1);let o=null;return{fileList:t,uploading:n,handleFileSelect:n=>{o||(o=e.chunkSize&&e.chunkSize>0?new k(Object.assign(Object.assign({},e),{onFileListChange:n=>{var r;t.value=n,null===(r=e.onFileListChange)||void 0===r||r.call(e,n)}})):new j(Object.assign(Object.assign({},e),{onFileListChange:n=>{var r;t.value=n,null===(r=e.onFileListChange)||void 0===r||r.call(e,n)}})));const r=Array.from(n).filter(t=>!(e.accept&&!p(t,e.accept))&&!!f(t,e.maxSize,e.minSize));r.length>0&&o.addFiles(r)},uploadAll:()=>i(void 0,void 0,void 0,function*(){if(o){n.value=!0;try{yield o.uploadAll()}finally{n.value=!1}}}),cancelUpload:e=>{null==o||o.abortUpload(e)},retryUpload:e=>i(void 0,void 0,void 0,function*(){yield null==o?void 0:o.retryUpload(e)}),removeFile:e=>{null==o||o.removeFile(e)},clearFiles:()=>{null==o||o.clearFiles()},uploader:o}},R={key:0,class:"upload-list-item-thumbnail"},T=["src","alt","onLoad"],V={key:1,class:"upload-list-item-icon"},P={key:2,class:"upload-list-item-overlay"},$={class:"upload-list-item-status"},q={key:0,class:"upload-list-item-progress"},D={key:1,class:"upload-list-item-success"},I={key:2,class:"upload-list-item-error"},M={key:3,class:"upload-list-item-canceled"},W=["onClick"],K=["onClick"],H=["onClick"],G={key:1,class:"upload-list-item-info"},J={class:"upload-list-item-name"},X={class:"upload-list-item-size"},Y={class:"upload-list-item-status"},Q={key:0,class:"upload-list-item-progress"},Z={key:1,class:"upload-list-item-success"},ee={key:2,class:"upload-list-item-error"},te={key:3,class:"upload-list-item-canceled"},ne=["onClick"],re=["onClick"],ie=["onClick"],oe={key:2,class:"upload-list-item-name"};var ae=r.defineComponent({__name:"UploadList",props:{fileList:{type:Array,required:!0},listType:{type:String,required:!0}},emits:["cancel","retry","remove"],setup(e,{emit:t}){const n=e=>URL.createObjectURL(e);return(t,i)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["upload-list",{"upload-list-text":"text"===e.listType,"upload-list-picture":"picture"===e.listType,"upload-list-picture-card":"picture-card"===e.listType}])},[(r.openBlock(!0),r.createElementBlock(r.Fragment,null,r.renderList(e.fileList,i=>{return r.openBlock(),r.createElementBlock("div",{key:i.uid,class:r.normalizeClass(["upload-list-item",{"upload-list-item-picture":"picture"===e.listType,"upload-list-item-picture-card":"picture-card"===e.listType}])},[r.createCommentVNode(" 图片类型显示缩略图 "),"picture"===e.listType||"picture-card"===e.listType?(r.openBlock(),r.createElementBlock("div",R,[i.type.startsWith("image/")?(r.openBlock(),r.createElementBlock("img",{key:0,src:n(i.file),alt:i.name,onLoad:e=>(e=>{setTimeout(()=>{URL.revokeObjectURL(URL.createObjectURL(e))},100)})(i.file)},null,40,T)):(r.openBlock(),r.createElementBlock("div",V,r.toDisplayString(i.type.split("/")[0]),1)),r.createCommentVNode(" 图片卡片类型显示覆盖层 "),"picture-card"===e.listType?(r.openBlock(),r.createElementBlock("div",P,[r.createElementVNode("div",$,["uploading"===i.status?(r.openBlock(),r.createElementBlock("span",q,r.toDisplayString(i.percent)+"% ",1)):"success"===i.status?(r.openBlock(),r.createElementBlock("span",D,"✓")):"error"===i.status?(r.openBlock(),r.createElementBlock("span",I,"✗")):"canceled"===i.status?(r.openBlock(),r.createElementBlock("span",M,"已取消")):r.createCommentVNode("v-if",!0),"uploading"===i.status?(r.openBlock(),r.createElementBlock("button",{key:4,class:"upload-list-item-action",onClick:e=>t.$emit("cancel",i.uid)}," 取消 ",8,W)):r.createCommentVNode("v-if",!0),"error"===i.status||"canceled"===i.status?(r.openBlock(),r.createElementBlock("button",{key:5,class:"upload-list-item-action",onClick:e=>t.$emit("retry",i.uid)}," 重试 ",8,K)):r.createCommentVNode("v-if",!0),r.createElementVNode("button",{class:"upload-list-item-action upload-list-item-remove",onClick:e=>t.$emit("remove",i.uid)}," 删除 ",8,H)])])):r.createCommentVNode("v-if",!0)])):r.createCommentVNode("v-if",!0),r.createCommentVNode(" 文件信息 "),"text"===e.listType||"picture"===e.listType?(r.openBlock(),r.createElementBlock("div",G,[r.createElementVNode("div",J,[r.createElementVNode("span",null,r.toDisplayString(i.name),1),r.createElementVNode("span",X,"("+r.toDisplayString((o=i.size,o<1024?`${o} B`:o<1048576?`${(o/1024).toFixed(2)} KB`:`${(o/1048576).toFixed(2)} MB`))+")",1)]),r.createElementVNode("div",Y,["uploading"===i.status?(r.openBlock(),r.createElementBlock("span",Q,r.toDisplayString(i.percent)+"% ",1)):"success"===i.status?(r.openBlock(),r.createElementBlock("span",Z,"✓ 成功")):"error"===i.status?(r.openBlock(),r.createElementBlock("span",ee,"✗ 失败")):"canceled"===i.status?(r.openBlock(),r.createElementBlock("span",te,"已取消")):r.createCommentVNode("v-if",!0),"uploading"===i.status?(r.openBlock(),r.createElementBlock("button",{key:4,class:"upload-list-item-action",onClick:e=>t.$emit("cancel",i.uid)}," 取消 ",8,ne)):r.createCommentVNode("v-if",!0),"error"===i.status||"canceled"===i.status?(r.openBlock(),r.createElementBlock("button",{key:5,class:"upload-list-item-action",onClick:e=>t.$emit("retry",i.uid)}," 重试 ",8,re)):r.createCommentVNode("v-if",!0),r.createElementVNode("button",{class:"upload-list-item-action upload-list-item-remove",onClick:e=>t.$emit("remove",i.uid)}," 删除 ",8,ie)])])):r.createCommentVNode("v-if",!0),r.createCommentVNode(" 图片卡片类型显示文件名 "),"picture-card"===e.listType?(r.openBlock(),r.createElementBlock("div",oe,r.toDisplayString(i.name),1)):r.createCommentVNode("v-if",!0)],2);var o}),128))],2))}});A("\n.upload-list[data-v-019ff626] {\n margin-top: 12px;\n}\n.upload-list-item[data-v-019ff626] {\n display: flex;\n align-items: center;\n padding: 8px 0;\n border-bottom: 1px solid #f0f0f0;\n}\n.upload-list-item-name[data-v-019ff626] {\n flex: 1;\n font-size: 14px;\n color: #333;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.upload-list-item-size[data-v-019ff626] {\n font-size: 12px;\n color: #999;\n margin-left: 8px;\n}\n.upload-list-item-status[data-v-019ff626] {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n.upload-list-item-progress[data-v-019ff626] {\n font-size: 12px;\n color: #1890ff;\n}\n.upload-list-item-success[data-v-019ff626] {\n font-size: 12px;\n color: #52c41a;\n}\n.upload-list-item-error[data-v-019ff626] {\n font-size: 12px;\n color: #ff4d4f;\n}\n.upload-list-item-canceled[data-v-019ff626] {\n font-size: 12px;\n color: #999;\n}\n.upload-list-item-action[data-v-019ff626] {\n font-size: 12px;\n color: #1890ff;\n background: none;\n border: none;\n padding: 0;\n cursor: pointer;\n}\n.upload-list-item-action[data-v-019ff626]:hover {\n text-decoration: underline;\n}\n.upload-list-item-remove[data-v-019ff626] {\n color: #999;\n}\n\n/* 图片类型样式 */\n.upload-list-item-picture[data-v-019ff626] {\n flex-direction: column;\n align-items: flex-start;\n gap: 8px;\n}\n.upload-list-item-thumbnail[data-v-019ff626] {\n position: relative;\n width: 100px;\n height: 100px;\n border-radius: 4px;\n overflow: hidden;\n border: 1px solid #f0f0f0;\n}\n.upload-list-item-thumbnail img[data-v-019ff626] {\n width: 100%;\n height: 100%;\n object-fit: cover;\n}\n.upload-list-item-icon[data-v-019ff626] {\n width: 100%;\n height: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n background-color: #f5f5f5;\n font-size: 12px;\n color: #999;\n}\n.upload-list-item-info[data-v-019ff626] {\n width: 100%;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n/* 图片卡片类型样式 */\n.upload-list-picture-card[data-v-019ff626] {\n display: flex;\n gap: 12px;\n flex-wrap: wrap;\n}\n.upload-list-item-picture-card[data-v-019ff626] {\n width: 120px;\n flex-direction: column;\n align-items: center;\n gap: 8px;\n border: none;\n padding: 0;\n}\n.upload-list-item-picture-card .upload-list-item-thumbnail[data-v-019ff626] {\n width: 120px;\n height: 120px;\n}\n.upload-list-item-overlay[data-v-019ff626] {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n background-color: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n color: white;\n}\n.upload-list-item-picture-card .upload-list-item-status[data-v-019ff626] {\n color: white;\n flex-direction: column;\n gap: 8px;\n}\n.upload-list-item-picture-card .upload-list-item-action[data-v-019ff626] {\n color: white;\n border: 1px solid white;\n padding: 2px 8px;\n border-radius: 4px;\n}\n.upload-list-item-picture-card .upload-list-item-action[data-v-019ff626]:hover {\n background-color: white;\n color: #1890ff;\n text-decoration: none;\n}\n.upload-list-item-picture-card .upload-list-item-name[data-v-019ff626] {\n font-size: 12px;\n text-align: center;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: 100%;\n}\n"),ae.__scopeId="data-v-019ff626",ae.__file="src/vue/components/UploadList.vue";const se={class:"upload-progress"},le={class:"upload-progress-header"},ce={class:"upload-progress-status"},de={key:0,class:"upload-progress-uploading"},ue={key:1,class:"upload-progress-success"},pe={key:2,class:"upload-progress-error"},fe={class:"upload-progress-actions"},he=["disabled"],me={class:"upload-progress-bar-container"},ge={class:"upload-progress-text"},ve={class:"upload-progress-footer"},ye={class:"upload-progress-stats"};var xe=r.defineComponent({__name:"Progress",props:{fileList:{type:Array,required:!0}},emits:["upload-all","clear"],setup(e,{emit:t}){const n=e,i=r.computed(()=>{if(0===n.fileList.length)return 0;const e=n.fileList.reduce((e,t)=>e+t.size,0),t=n.fileList.reduce((e,t)=>e+(t.uploadedSize||0),0);return Math.round(t/e*100)}),o=r.computed(()=>n.fileList.filter(e=>"uploading"===e.status).length),a=r.computed(()=>n.fileList.filter(e=>"success"===e.status).length),s=r.computed(()=>n.fileList.filter(e=>"error"===e.status).length),l=r.computed(()=>n.fileList.length-a.value-s.value-o.value);return(t,n)=>(r.openBlock(),r.createElementBlock("div",se,[r.createElementVNode("div",le,[r.createElementVNode("div",ce,[o.value>0?(r.openBlock(),r.createElementBlock("span",de," 正在上传 "+r.toDisplayString(o.value)+" 个文件... ",1)):a.value>0?(r.openBlock(),r.createElementBlock("span",ue," 已成功上传 "+r.toDisplayString(a.value)+" 个文件 ",1)):r.createCommentVNode("v-if",!0),s.value>0?(r.openBlock(),r.createElementBlock("span",pe," 有 "+r.toDisplayString(s.value)+" 个文件上传失败 ",1)):r.createCommentVNode("v-if",!0)]),r.createElementVNode("div",fe,[r.createElementVNode("button",{class:"upload-progress-action upload-progress-start",onClick:n[0]||(n[0]=e=>t.$emit("upload-all")),disabled:o.value>0}," 开始上传 ",8,he),r.createElementVNode("button",{class:"upload-progress-action upload-progress-clear",onClick:n[1]||(n[1]=e=>t.$emit("clear"))}," 清空 ")])]),r.createElementVNode("div",me,[r.createElementVNode("div",{class:"upload-progress-bar",style:r.normalizeStyle({width:`${i.value}%`})},null,4),r.createElementVNode("div",ge,r.toDisplayString(i.value)+"% ",1)]),r.createElementVNode("div",ve,[r.createElementVNode("div",ye,[r.createElementVNode("span",null,"总数: "+r.toDisplayString(e.fileList.length),1),r.createElementVNode("span",null,"成功: "+r.toDisplayString(a.value),1),r.createElementVNode("span",null,"失败: "+r.toDisplayString(s.value),1),r.createElementVNode("span",null,"等待: "+r.toDisplayString(l.value),1)])])]))}});A("\n.upload-progress[data-v-3a5faed4] {\n margin-top: 12px;\n padding: 12px;\n background-color: #fafafa;\n border-radius: 6px;\n}\n.upload-progress-header[data-v-3a5faed4] {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 12px;\n}\n.upload-progress-status[data-v-3a5faed4] {\n font-size: 14px;\n color: #333;\n}\n.upload-progress-uploading[data-v-3a5faed4] {\n color: #1890ff;\n}\n.upload-progress-success[data-v-3a5faed4] {\n color: #52c41a;\n}\n.upload-progress-error[data-v-3a5faed4] {\n color: #ff4d4f;\n}\n.upload-progress-actions[data-v-3a5faed4] {\n display: flex;\n gap: 8px;\n}\n.upload-progress-action[data-v-3a5faed4] {\n font-size: 12px;\n padding: 4px 12px;\n border: 1px solid #d9d9d9;\n border-radius: 4px;\n background-color: white;\n cursor: pointer;\n transition: all 0.3s;\n}\n.upload-progress-action[data-v-3a5faed4]:hover {\n border-color: #1890ff;\n color: #1890ff;\n}\n.upload-progress-action[data-v-3a5faed4]:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n.upload-progress-action[data-v-3a5faed4]:disabled:hover {\n border-color: #d9d9d9;\n color: #999;\n}\n.upload-progress-start[data-v-3a5faed4] {\n color: #1890ff;\n border-color: #1890ff;\n}\n.upload-progress-start[data-v-3a5faed4]:hover {\n background-color: #e6f7ff;\n}\n.upload-progress-clear[data-v-3a5faed4] {\n color: #666;\n}\n.upload-progress-bar-container[data-v-3a5faed4] {\n position: relative;\n height: 8px;\n background-color: #f0f0f0;\n border-radius: 4px;\n overflow: hidden;\n margin-bottom: 8px;\n}\n.upload-progress-bar[data-v-3a5faed4] {\n position: absolute;\n top: 0;\n left: 0;\n height: 100%;\n background-color: #1890ff;\n transition: width 0.3s ease;\n}\n.upload-progress-text[data-v-3a5faed4] {\n position: absolute;\n top: 0;\n right: 8px;\n height: 100%;\n display: flex;\n align-items: center;\n font-size: 12px;\n color: #666;\n}\n.upload-progress-footer[data-v-3a5faed4] {\n margin-top: 8px;\n}\n.upload-progress-stats[data-v-3a5faed4] {\n display: flex;\n gap: 16px;\n font-size: 12px;\n color: #999;\n}\n"),xe.__scopeId="data-v-3a5faed4",xe.__file="src/vue/components/Progress.vue";const be=["multiple","accept"];var ke=r.defineComponent({__name:"Upload",props:{className:{type:String,required:!1},style:{type:Object,required:!1},drag:{type:Boolean,required:!1,default:!1},showFileList:{type:Boolean,required:!1,default:!0},listType:{type:String,required:!1,default:"text"},url:{type:String,required:!0},method:{type:String,required:!1,default:"POST"},headers:{type:Object,required:!1},timeout:{type:Number,required:!1,default:3e4},withCredentials:{type:Boolean,required:!1,default:!1},chunkSize:{type:Number,required:!1,default:5242880},chunkRetry:{type:Number,required:!1,default:3},concurrent:{type:Number,required:!1,default:3},autoUpload:{type:Boolean,required:!1,default:!0},multiple:{type:Boolean,required:!1,default:!1},accept:{type:String,required:!1},maxSize:{type:Number,required:!1},minSize:{type:Number,required:!1},onProgress:{type:Function,required:!1},onSuccess:{type:Function,required:!1},onError:{type:Function,required:!1},onCancel:{type:Function,required:!1},beforeUpload:{type:Function,required:!1},onFileListChange:{type:Function,required:!1}},setup(e){const t=e,n=r.ref(),i=r.ref(),o=r.ref(!1),{fileList:a,uploading:s,handleFileSelect:l,uploadAll:c,cancelUpload:d,retryUpload:u,removeFile:p,clearFiles:f}=O(t),h=()=>{var e;null===(e=n.value)||void 0===e||e.click()},m=e=>{const t=e.target;t.files&&(l(t.files),t.value="")},g=e=>{const t=e;t.preventDefault(),"dragenter"===t.type||"dragover"===t.type?o.value=!0:"dragleave"===t.type&&(o.value=!1)},v=e=>{var t;const n=e;n.preventDefault(),o.value=!1,(null===(t=n.dataTransfer)||void 0===t?void 0:t.files)&&l(n.dataTransfer.files)};return(t,l)=>(r.openBlock(),r.createElementBlock("div",{class:r.normalizeClass(["upload-container",e.className]),style:r.normalizeStyle(e.style)},[r.createElementVNode("input",{ref_key:"fileInput",ref:n,type:"file",multiple:e.multiple,accept:e.accept,onChange:m,style:{display:"none"}},null,40,be),e.drag?(r.openBlock(),r.createElementBlock("div",{key:0,ref_key:"dragArea",ref:i,class:r.normalizeClass(["upload-drag",{"upload-dragover":o.value}]),onClick:h,onDragenter:r.withModifiers(g,["prevent"]),onDragover:r.withModifiers(g,["prevent"]),onDragleave:r.withModifiers(g,["prevent"]),onDrop:r.withModifiers(v,["prevent"])},[r.renderSlot(t.$slots,"default",{},()=>[l[0]||(l[0]=r.createElementVNode("div",{class:"upload-default"},[r.createElementVNode("div",{class:"upload-icon"},"+"),r.createElementVNode("div",{class:"upload-text"},"点击或拖拽文件到此区域上传")],-1))])],34)):(r.openBlock(),r.createElementBlock("div",{key:1,class:"upload-trigger",onClick:h},[r.renderSlot(t.$slots,"default",{},()=>[l[1]||(l[1]=r.createElementVNode("div",{class:"upload-default"},[r.createElementVNode("div",{class:"upload-icon"},"+"),r.createElementVNode("div",{class:"upload-text"},"点击上传文件")],-1))])])),e.showFileList?(r.openBlock(),r.createBlock(ae,{key:2,"file-list":r.unref(a),"list-type":e.listType,onCancel:r.unref(d),onRetry:r.unref(u),onRemove:r.unref(p)},null,8,["file-list","list-type","onCancel","onRetry","onRemove"])):r.createCommentVNode("v-if",!0),r.unref(s)?(r.openBlock(),r.createBlock(xe,{key:3,"file-list":r.unref(a),onUploadAll:r.unref(c),onClear:r.unref(f)},null,8,["file-list","onUploadAll","onClear"])):r.createCommentVNode("v-if",!0)],6))}});A("\n.upload-container[data-v-7a506f30] {\r\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n}\n.upload-drag[data-v-7a506f30] {\r\n border: 2px dashed #d9d9d9;\r\n border-radius: 6px;\r\n padding: 40px 20px;\r\n text-align: center;\r\n cursor: pointer;\r\n transition: border-color 0.3s;\n}\n.upload-drag[data-v-7a506f30]:hover,\r\n.upload-dragover[data-v-7a506f30] {\r\n border-color: #1890ff;\n}\n.upload-trigger[data-v-7a506f30] {\r\n display: inline-block;\r\n cursor: pointer;\n}\n.upload-default[data-v-7a506f30] {\r\n display: flex;\r\n flex-direction: column;\r\n align-items: center;\r\n justify-content: center;\r\n color: #666;\n}\n.upload-icon[data-v-7a506f30] {\r\n font-size: 32px;\r\n color: #999;\r\n margin-bottom: 8px;\n}\n.upload-text[data-v-7a506f30] {\r\n font-size: 14px;\n}\r\n"),ke.__scopeId="data-v-7a506f30",ke.__file="src/vue/components/Upload.vue";e.BaseUploader=g,e.ParallelUploader=j,e.Progress=xe,e.ReactUpload=e=>{var{children:t,className:r="",style:i,drag:o=!1,showFileList:a=!0,listType:s="text"}=e,l=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}(e,["children","className","style","drag","showFileList","listType"]);const c=n.useRef(null),d=n.useRef(null),{fileList:u,uploading:p,handleFileSelect:f,uploadAll:h,cancelUpload:m,retryUpload:g,removeFile:v,clearFiles:y}=z(l),x=n.useCallback(()=>{var e;null===(e=c.current)||void 0===e||e.click()},[]),b=n.useCallback(e=>{e.target.files&&(f(e.target.files),e.target.value="")},[f]),k=n.useCallback(e=>{var t,n;e.preventDefault(),e.stopPropagation(),"dragenter"===e.type||"dragover"===e.type?null===(t=d.current)||void 0===t||t.classList.add("upload-dragover"):"dragleave"===e.type&&(null===(n=d.current)||void 0===n||n.classList.remove("upload-dragover"))},[]),j=n.useCallback(e=>{var t;e.preventDefault(),e.stopPropagation(),null===(t=d.current)||void 0===t||t.classList.remove("upload-dragover"),e.dataTransfer.files&&f(e.dataTransfer.files)},[f]),C=()=>t||_.jsxs("div",{className:"upload-default",children:[_.jsx("div",{className:"upload-icon",children:"+"}),_.jsx("div",{className:"upload-text",children:"点击或拖拽文件到此区域上传"})]});return _.jsxs("div",{className:`upload-container ${r}`,style:i,children:[_.jsx("input",{ref:c,type:"file",style:{display:"none"},multiple:l.multiple,accept:l.accept,onChange:b}),o?_.jsx("div",{ref:d,className:"upload-drag",onClick:x,onDragEnter:k,onDragOver:k,onDragLeave:k,onDrop:j,children:C()}):_.jsx("div",{className:"upload-trigger",onClick:x,children:C()}),a&&_.jsx(E,{fileList:u,listType:s,onCancel:m,onRetry:g,onRemove:v}),p&&_.jsx(U,{fileList:u,onUploadAll:h,onClear:y})]})},e.SliceUploader=k,e.UploadList=ae,e.VueUpload=ke,e.calculateChunkSize=e=>e<=10485760?e:e<=104857600?5242880:e<=1073741824?10485760:20971520,e.calculateFileHash=m,e.createFileChunks=h,e.defaultConfig={url:"",method:"POST",timeout:3e4,maxRetries:3,retryDelay:1e3,chunkSize:5242880,chunkRetry:3,concurrent:3,autoUpload:!0,multiple:!1,withCredentials:!1},e.formatFileSize=e=>{if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,t)).toFixed(2))+" "+["B","KB","MB","GB","TB"][t]},e.generateFileId=d,e.getFileExtension=u,e.useReactUpload=z,e.useVueUpload=O,e.validateFileSize=f,e.validateFileType=p});
|
|
11
11
|
//# sourceMappingURL=index.umd.js.map
|