zhuf преди 4 месеца
родител
ревизия
d3ac6ce05e
променени са 2 файла, в които са добавени 22 реда и са изтрити 7 реда
  1. 15 6
      src/components/FileUploadProgress/index.vue
  2. 7 1
      vite.config.js

+ 15 - 6
src/components/FileUploadProgress/index.vue

@@ -92,8 +92,9 @@ function handleSuccess() {
     let part = [];
     let full = [];
     FILE_LIST.value.forEach(item => {
-
+      console.log('item : ', item)
       if (item.percentage === 100) {
+        console.log('percentage === 100 : ')
         const { url: part_url, file_name } = item.response.data
         part.push(part_url);
         full.push(`${part_url}|${file_name}`);
@@ -109,6 +110,8 @@ function handleSuccess() {
     List_full.value = full.join(';')
     List_part.value = part.join(';')
     List_time.value = (new Date().toLocaleString())
+
+    emitUpdate()
   }
 }
 
@@ -143,17 +146,22 @@ function renderSize(filesize) {
   return (filesize / 1024).toString()
 }
 
-watch(() => List_part.value, () => {
+
+function emitUpdate() {
   emit('update:part', List_part.value)
   emit('update:full', List_full.value)
   emit('update:size', renderSize(List_size.value))
   emit('update:time', List_time.value)
   emit('compile', FILE_LIST.value)
+}
+watch(() => List_part.value, () => {
+  console.log('watch : ', List_part)
+  emitUpdate()
   console.log('compile');
 })
 
 function handleRequest(args) {
-  // console.log('handleRequest', args)
+  console.log('handleRequest', args)
   REQUEST.upload({
     url: args.action,
     data: {
@@ -167,8 +175,10 @@ function handleRequest(args) {
     // },
   }).then((res) => {
     console.log('res', res)
-    if (res.code === '1')
+    if (res.code === '1') {
+      // args.file.percentage = 100
       args?.onSuccess(res, args.file, args.fileList)
+    }
 
     else
       args?.onError(res, args.file, args.fileList)
@@ -181,7 +191,7 @@ function handleRequest(args) {
   <!-- :on-preview="handlePictureCardPreview" -->
   <el-upload :action="action" :data="data" name="filedata" :on-success="handleSuccess" :on-remove="onRemove"
     :on-exceed="onExceed" :before-upload="beforeUpload" v-model:file-list="FILE_LIST"
-    :on-preview="handlePictureCardPreview" v-bind="attrs" class="w-full" :http-request="handleRequest" >
+    :on-preview="handlePictureCardPreview" v-bind="attrs" class="w-full" :http-request="handleRequest">
     <template #default>
       <slot>
         <el-button type="primary">点击上传</el-button>
@@ -199,4 +209,3 @@ function handleRequest(args) {
     <img w-full :src="dialogImageUrl" alt="Preview Image" />
   </el-dialog>
 </template>
-

+ 7 - 1
vite.config.js

@@ -89,5 +89,11 @@ export default defineConfig({
         }
       }
     }
-  }
+  },
+  terserOptions: {
+    compress: {
+      drop_console: true,
+      drop_debugger: true
+    }
+  },
 })