From 90cbabb7a7a4b0dc5cf76f926b6cd63b989099f4 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: Thu, 04 Dec 2025 16:42:55 +0800
Subject: [PATCH] 优化代码

---
 ruoyi-ui/src/components/ImagePreview/index.vue |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/ruoyi-ui/src/components/ImagePreview/index.vue b/ruoyi-ui/src/components/ImagePreview/index.vue
index 14a245b..0cbb79d 100644
--- a/ruoyi-ui/src/components/ImagePreview/index.vue
+++ b/ruoyi-ui/src/components/ImagePreview/index.vue
@@ -17,7 +17,7 @@
   props: {
     src: {
       type: String,
-      required: true
+      default: ""
     },
     width: {
       type: [Number, String],
@@ -30,25 +30,31 @@
   },
   computed: {
     realSrc() {
-      let real_src = this.src.split(",")[0];
-      return real_src;
+      if (!this.src) {
+        return
+      }
+      let real_src = this.src.split(",")[0]
+      return real_src
     },
     realSrcList() {
-      let real_src_list = this.src.split(",");
-      let srcList = [];
+      if (!this.src) {
+        return
+      }
+      let real_src_list = this.src.split(",")
+      let srcList = []
       real_src_list.forEach(item => {
-        return srcList.push(item);
-      });
-      return srcList;
+        return srcList.push(item)
+      })
+      return srcList
     },
     realWidth() {
-      return typeof this.width == "string" ? this.width : `${this.width}px`;
+      return typeof this.width == "string" ? this.width : `${this.width}px`
     },
     realHeight() {
-      return typeof this.height == "string" ? this.height : `${this.height}px`;
+      return typeof this.height == "string" ? this.height : `${this.height}px`
     }
   },
-};
+}
 </script>
 
 <style lang="scss" scoped>

--
Gitblit v1.9.3