From c38e6d39bc93100e50c3e776efa22711614326e2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?=
 <3277200+sentsim@users.noreply.github.com>
Date: Tue, 21 Mar 2023 23:29:03 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E5=A4=9A=E4=B8=8A?=
 =?UTF-8?q?=E4=BC=A0=E8=AE=BE=E7=BD=AE=E6=96=87=E4=BB=B6=E5=A4=A7=E5=B0=8F?=
 =?UTF-8?q?=E9=99=90=E5=88=B6=E6=97=B6=EF=BC=8C=E5=88=A0=E9=99=A4=E8=B6=85?=
 =?UTF-8?q?=E5=87=BA=E5=A4=A7=E5=B0=8F=E7=9A=84=E6=96=87=E4=BB=B6=E4=BB=8D?=
 =?UTF-8?q?=E7=84=B6=E6=A0=A1=E9=AA=8C=E4=B8=8D=E9=80=9A=E8=BF=87=E7=9A=84?=
 =?UTF-8?q?=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/modules/upload.js | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/modules/upload.js b/src/modules/upload.js
index 0bbe7efc..150356ab 100644
--- a/src/modules/upload.js
+++ b/src/modules/upload.js
@@ -171,17 +171,23 @@ layui.define(['lay','layer'], function(exports){
     }
   };
   
-  //执行上传
+  // 执行上传
   Class.prototype.upload = function(files, type){
-    var that = this
-    ,options = that.config
-    ,elemFile = that.elemFile[0]
+    var that = this;
+    var options = that.config;
+    var elemFile = that.elemFile[0];
+
+    // 获取文件队列
+    var getFiles = function(){
+      return files || that.files || that.chooseFiles || elemFile.files;
+    };
     
     //高级浏览器处理方式,支持跨域
-    ,ajaxSend = function(){
-      var successful = 0, failed = 0
-      ,items = files || that.files || that.chooseFiles || elemFile.files
-      ,allDone = function(){ //多文件全部上传完毕的回调
+    var ajaxSend = function(){
+      var successful = 0;
+      var failed = 0
+      var items = getFiles();
+      var allDone = function(){ // 多文件全部上传完毕的回调
         if(options.multiple && successful + failed === that.fileLength){
           typeof options.allDone === 'function' && options.allDone({
             total: that.fileLength
@@ -412,8 +418,8 @@ layui.define(['lay','layer'], function(exports){
     
     //检验文件数量
     that.fileLength = function(){
-      var length = 0
-      ,items = files || that.files || that.chooseFiles || elemFile.files;
+      var length = 0;
+      var items = getFiles();
       layui.each(items, function(){
         length++;
       });
@@ -427,11 +433,11 @@ layui.define(['lay','layer'], function(exports){
       );
     }
     
-    //检验文件大小
+    // 检验文件大小
     if(options.size > 0 && !(device.ie && device.ie < 10)){
       var limitSize;
       
-      layui.each(that.chooseFiles, function(index, file){
+      layui.each(getFiles(), function(index, file){
         if(file.size > 1024*options.size){
           var size = options.size/1024;
           size = size >= 1 ? (size.toFixed(2) + 'MB') : options.size + 'KB'