From 239b24cb95bb109b83aa567188229ecab707c39e Mon Sep 17 00:00:00 2001
From: liaoanqi <1776106376@qq.com>
Date: Mon, 27 Feb 2023 10:13:57 +0800
Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85=E7=BC=96?=
=?UTF-8?q?=E8=BE=91=E5=8F=AF=E4=B8=8A=E4=BC=A0=E5=9B=BE=E7=89=87?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/components/tiny-mce/index.vue | 41 +++++++++++++++++++++++++------
1 file changed, 34 insertions(+), 7 deletions(-)
diff --git a/src/components/tiny-mce/index.vue b/src/components/tiny-mce/index.vue
index d33ce64..33f740c 100644
--- a/src/components/tiny-mce/index.vue
+++ b/src/components/tiny-mce/index.vue
@@ -1,6 +1,18 @@
@@ -9,17 +21,19 @@
* docs:
* https://panjiachen.github.io/vue-element-admin-site/feature/component/rich-editor.html#tinymce
*/
+import mulPicUpload from '@/components/mul-pic-upload'
import plugins from './plugins'
import toolbar from './toolbar'
import load from './dynamicLoadScript'
// why use this cdn, detail see https://github.com/PanJiaChen/tinymce-all-in-one
-const resourceCdn2 = 'https://cdn.jsdelivr.net/npm/tinymce-all-in-one@4.9.3/tinymce.min.js'
-const resourceCdn3 = 'https://unpkg.zhimg.com/tinymce-all-in-one@4.9.3/tinymce.min.js'
-const resourceCdn1 = 'https://unpkg.com/tinymce-all-in-one@4.9.3/tinymce.min.js'
+const resourceCdn1 = 'https://cdn.jsdelivr.net/npm/tinymce-all-in-one@4.9.3/tinymce.min.js'
+const resourceCdn2 = 'https://unpkg.zhimg.com/tinymce-all-in-one@4.9.3/tinymce.min.js'
+const resourceCdn3 = 'https://unpkg.com/tinymce-all-in-one@4.9.3/tinymce.min.js'
export default {
name: 'Tinymce',
+ components: { mulPicUpload },
props: {
id: {
type: String,
@@ -58,7 +72,8 @@ export default {
hasChange: false,
hasInit: false,
tinymceId: this.id,
- fullscreen: false
+ fullscreen: false,
+ resourcesUrl: process.env.VUE_APP_RESOURCES_URL
}
},
computed: {
@@ -215,10 +230,22 @@ export default {
getContent () {
window.tinymce.get(this.tinymceId).getContent()
},
- imageSuccessCBK (arr) {
+ // 限制图片上传大小
+ beforeAvatarUpload (file) {
+ const isJPG = file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/gif' || file.type === 'image/jpg'
+ if (!isJPG) {
+ this.$message.error('上传图片只能是jpeg/jpg/png/gif 格式!')
+ }
+ const isLt2M = file.size / 1024 / 1024 < 2
+ if (!isLt2M) {
+ this.$message.error('上传图片大小不能超过 2MB!')
+ }
+ return isLt2M && isJPG
+ },
+ imageSuccessCBK (response, file, fileList) {
const _this = this
- arr.forEach(v => {
- window.tinymce.get(_this.tinymceId).insertContent(`
`)
+ fileList.forEach(v => {
+ window.tinymce.get(_this.tinymceId).insertContent(`
`)
})
}
}