Browse Source

2022-12-06 update

1. 调整tinymce上传时, 增加对img的判断.
moccus 2 years ago
parent
commit
5e981ea542
1 changed files with 12 additions and 8 deletions
  1. 12 8
      exam-06173-vue/src/components/Tinymce/index.vue

+ 12 - 8
exam-06173-vue/src/components/Tinymce/index.vue

@@ -157,21 +157,25 @@ export default {
     imageSuccessCBK(arr) {
       const that = this
       arr.forEach(v => {
+        const isImg = v.url.indexOf('jpg') !== -1 || v.url.indexOf('png') !== -1
         const isPdf = v.url.indexOf('pdf') !== -1
         const isDocx = v.url.indexOf('docx') !== -1
         let isDownload = false
         const fileName = v.url.substring(v.url.lastIndexOf('/') + 1)
         let href = ''
-        if (isPdf) {
-          href = `/pdf/web/viewer.html?file=${encodeURIComponent(v.url)}`
-        } else if (isDocx) {
-          href = `/#/docxPreview?file=${encodeURIComponent(v.url)}`
+        if (!isImg) {
+          if (isPdf) {
+            href = `/pdf/web/viewer.html?file=${encodeURIComponent(v.url)}`
+          } else if (isDocx) {
+            href = `/#/docxPreview?file=${encodeURIComponent(v.url)}`
+          } else {
+            href = v.url
+            isDownload = true
+          }
+          window.tinymce.get(that.tinymceId).insertContent(`<a class="wscnph" target="_blank" ${isDownload ? 'download' : ''} href="${href}" >${fileName}</a>`)
         } else {
-          href = v.url
-          isDownload = true
+          window.tinymce.get(that.tinymceId).insertContent(`<img class="wscnph" src="${v.url}" >`)
         }
-        // window.tinymce.get(that.tinymceId).insertContent(`<img class="wscnph" src="${v.url}" >`)
-        window.tinymce.get(that.tinymceId).insertContent(`<a class="wscnph" target="_blank" ${isDownload ? 'download' : ''} href="${href}" >${fileName}</a>`)
       })
     }
   }