From 0d17bf2c78965fe1bbf5b70827fe6c6a0e0a7565 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期一, 14 七月 2025 08:58:23 +0800
Subject: [PATCH] 富文本编辑视频插入问题

---
 manager/src/views/activity/index.vue |   18 +++++++++++++++---
 manager/src/views/activity/video.js  |   20 ++++++++++----------
 2 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/manager/src/views/activity/index.vue b/manager/src/views/activity/index.vue
index b19956a..ad53333 100644
--- a/manager/src/views/activity/index.vue
+++ b/manager/src/views/activity/index.vue
@@ -528,6 +528,7 @@
                 <div
                   class="activity-content"
                   v-html="activityInfo.activityContent || '鏃犲唴瀹�'"
+                  ref="鈥渁ctivityHTMLContent"
                 ></div>
               </div>
             </Col>
@@ -1100,7 +1101,6 @@
 
 
         if (fileType === 'video') {
-          console.log("鎻掑叆")
           this.Quill.insertEmbed(index, 'video', {
             url:url,
             controls:'controls',
@@ -1114,8 +1114,8 @@
           this.$Message.warning('涓嶆敮鎸佺殑鏂囦欢绫诲瀷');
           return;
         }
+        console.log(this.activityFrom.activityContent)
         this.Quill.setSelection(index + 1);
-        console.log(this.content)
         this.$Message.success('涓婁紶鎴愬姛')
       }
     }).catch(() => {
@@ -1217,7 +1217,19 @@
     this.infoModelShow = true
     this.activityInfo = row
     this.activityInfo.activityContent = this.escapeStringHTML(this.activityInfo.activityContent);
+    this.$nextTick(() => {
+      this.processVideos();
+    });
 
+  },
+    processVideos() {
+      const videos = this.$el.querySelectorAll('video');
+      videos.forEach(video => {
+        // 纭繚瑙嗛鍏冪礌鏈夊繀瑕佺殑灞炴��
+        video.setAttribute('controls', '');
+        video.setAttribute('playsinline', ''); // 閽堝绉诲姩绔�
+        video.load();
+      });
   },
   // 鑾峰彇瀵屾枃鏈紪杈戝櫒鐨勫唴瀹�
   // 鍒濆鍖栨暟鎹�
@@ -1347,7 +1359,7 @@
     this.activityFrom.coverType = this.coverType === '杈撳叆鏂囧瓧灏侀潰' ? 'text' :
       this.file ? this.getFileCategory(this.file.type) :
         this.activityFrom.coverType
-    //鍒ゆ柇鏂囧瓧绫诲瀷鏈夌偣闂
+
     this.$refs.form.validate(valid => {
       if (valid) {
         this.submitLoading = true
diff --git a/manager/src/views/activity/video.js b/manager/src/views/activity/video.js
index a5993ce..166112f 100644
--- a/manager/src/views/activity/video.js
+++ b/manager/src/views/activity/video.js
@@ -3,23 +3,17 @@
 const BlockEmbed = Quill.import('blots/block/embed');
 const Link = Quill.import('formats/link');
 
-const ATTRIBUTES = ['height', 'width', 'controls', 'src', 'poster'];
+const ATTRIBUTES = ['height', 'width', 'controls', 'src', ];
 
 class VideoBlot extends BlockEmbed {
   static create(value) {
     const node = super.create();
 
-    // 璁剧疆鍩烘湰灞炴��
-    node.setAttribute('controls', 'controls');
-    node.setAttribute('controlsList', 'nodownload');
-    node.setAttribute('preload', 'metadata');
-
-    // 鏀寔瀵硅薄褰㈠紡鐨剉alue
     if (typeof value === 'object') {
       node.setAttribute('src', this.sanitize(value.url));
-      node.setAttribute('poster', value.poster || '');
       node.setAttribute('width', value.width || '100%');
       node.setAttribute('height', value.height || 'auto');
+      node.setAttribute('controls', value.controls || 'controls');
     } else {
       node.setAttribute('src', this.sanitize(value));
     }
@@ -43,9 +37,9 @@
   static value(node) {
     return {
       url: node.getAttribute('src'),
-      poster: node.getAttribute('poster'),
       width: node.getAttribute('width'),
-      height: node.getAttribute('height')
+      height: node.getAttribute('height'),
+      controls: node.getAttribute('controls'),
     };
   }
 
@@ -66,4 +60,10 @@
 VideoBlot.className = 'ql-video';
 VideoBlot.tagName = 'video';
 
+// 娣诲姞涓嶄細琚� sanitize 鐨勬爣璁�
+VideoBlot.sanitize = function(url) {
+  const sanitized = Link.sanitize(url);
+  return sanitized === Link.PROTOCOL_WHITELIST[0] ? 'about:blank' : sanitized;
+};
+
 export default VideoBlot;

--
Gitblit v1.8.0