From 79c885decb7941ab3b39cb97f9e8e473802343aa Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: Fri, 25 Apr 2025 15:11:17 +0800
Subject: [PATCH] 使用Gateway CacheRequestBody代替CacheRequestFilter

---
 ruoyi-ui/src/components/Editor/index.vue |   31 +++++++++++++++++++++++++++----
 1 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/ruoyi-ui/src/components/Editor/index.vue b/ruoyi-ui/src/components/Editor/index.vue
index 0cb489a..66209ff 100644
--- a/ruoyi-ui/src/components/Editor/index.vue
+++ b/ruoyi-ui/src/components/Editor/index.vue
@@ -18,6 +18,7 @@
 </template>
 
 <script>
+import axios from "axios";
 import Quill from "quill";
 import "quill/dist/quill.core.css";
 import "quill/dist/quill.snow.css";
@@ -108,7 +109,7 @@
         if (val !== this.currentValue) {
           this.currentValue = val === null ? "" : val;
           if (this.Quill) {
-            this.Quill.pasteHTML(this.currentValue);
+            this.Quill.clipboard.dangerouslyPasteHTML(this.currentValue);
           }
         }
       },
@@ -135,8 +136,9 @@
             this.quill.format("image", false);
           }
         });
+        this.Quill.root.addEventListener('paste', this.handlePasteCapture, true);
       }
-      this.Quill.pasteHTML(this.currentValue);
+      this.Quill.clipboard.dangerouslyPasteHTML(this.currentValue);
       this.Quill.on("text-change", (delta, oldDelta, source) => {
         const html = this.$refs.editor.children[0].innerHTML;
         const text = this.Quill.getText();
@@ -192,8 +194,29 @@
     handleUploadError() {
       this.$message.error("图片插入失败");
     },
-  },
-};
+    // 复制粘贴图片处理
+    handlePasteCapture(e) {
+      const clipboard = e.clipboardData || window.clipboardData;
+      if (clipboard && clipboard.items) {
+        for (let i = 0; i < clipboard.items.length; i++) {
+          const item = clipboard.items[i];
+          if (item.type.indexOf('image') !== -1) {
+            e.preventDefault();
+            const file = item.getAsFile();
+            this.insertImage(file);
+          }
+        }
+      }
+    },
+    insertImage(file) {
+      const formData = new FormData();
+      formData.append("file", file);
+      axios.post(this.uploadUrl, formData, { headers: { "Content-Type": "multipart/form-data", Authorization: this.headers.Authorization } }).then(res => {
+        this.handleUploadSuccess(res.data);
+      })
+    }
+  }
+}
 </script>
 
 <style>

--
Gitblit v1.9.3