From 522aa174419e641a39ed5762a6b1f39141dd3198 Mon Sep 17 00:00:00 2001 From: icssoa <615206459@qq.com> Date: Wed, 21 Feb 2024 16:43:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=20cl-upload=20=E5=9C=A8=20fo?= =?UTF-8?q?rm=20=E5=88=86=E7=BB=84=E4=B8=8B=E5=90=8C=E4=B8=AA=20prop=20?= =?UTF-8?q?=E9=A2=84=E8=A7=88=E4=B8=8D=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../upload/components/upload-item/index.vue | 1 - src/plugins/upload/components/upload.vue | 17 +++++++++++------ src/plugins/upload/config.ts | 4 ++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/plugins/upload/components/upload-item/index.vue b/src/plugins/upload/components/upload-item/index.vue index 5b305be..8961dde 100644 --- a/src/plugins/upload/components/upload-item/index.vue +++ b/src/plugins/upload/components/upload-item/index.vue @@ -16,7 +16,6 @@ class="cl-upload-item__image-cover" fit="contain" :src="item.preload || url" - lazy @error="item.error = '加载失败'" /> diff --git a/src/plugins/upload/components/upload.vue b/src/plugins/upload/components/upload.vue index a0fe7c0..215aeb4 100644 --- a/src/plugins/upload/components/upload.vue +++ b/src/plugins/upload/components/upload.vue @@ -355,17 +355,17 @@ async function httpRequest(req: any, item?: Upload.Item) { toUpload(req.file, { prefixPath: props.prefixPath, onProgress(progress) { - item.progress = progress; + item!.progress = progress; emit("progress", item); } }) .then((res) => { - Object.assign(item, res); + Object.assign(item!, res); emit("success", item); update(); }) .catch((err) => { - item.error = err.message; + item!.error = err.message; emit("error", item); }); } @@ -418,14 +418,19 @@ watch( list.value = urls .map((url, index) => { + const old = list.value[index] || {}; + return Object.assign( { type: getType(url), progress: 100, - uid: uuid(), - url + uid: uuid() }, - list.value[index] + old, + { + url, + preload: old.url == url ? old.preload : url // 防止重复预览 + } ); }) .filter((_, i) => { diff --git a/src/plugins/upload/config.ts b/src/plugins/upload/config.ts index fc1ecf5..6df4a80 100644 --- a/src/plugins/upload/config.ts +++ b/src/plugins/upload/config.ts @@ -3,8 +3,8 @@ export default () => { label: "文件上传", description: "基于 el-upload 封装的文件上传组件", author: "COOL", - version: "1.1.1", - updateTime: "2024-02-19", + version: "1.1.2", + updateTime: "2024-02-21", demo: [ { name: "基础用法",