diff --git a/ruoyi-ui-vue3/src/components/Editor/index.vue b/ruoyi-ui-vue3/src/components/Editor/index.vue index c27635c3e..bf48cf163 100644 --- a/ruoyi-ui-vue3/src/components/Editor/index.vue +++ b/ruoyi-ui-vue3/src/components/Editor/index.vue @@ -9,14 +9,13 @@ name="file" :show-file-list="false" :headers="headers" - style="display: none" ref="uploadRef" v-if="type == 'url'" >
{ style.height = `${props.height}px`; } return style; -}) +}); const content = ref(""); watch(() => props.modelValue, (v) => { @@ -125,10 +124,10 @@ watch(() => props.modelValue, (v) => { // 图片上传成功返回图片地址 function handleUploadSuccess(res, file) { - // 获取富文本实例 - let quill = toRaw(myQuillEditor.value).getQuill(); // 如果上传成功 if (res.code == 200) { + // 获取富文本实例 + let quill = toRaw(myQuillEditor.value).getQuill(); // 获取光标位置 let length = quill.selection.savedRange.index; // 插入图片,res为服务器返回的图片链接地址 @@ -144,6 +143,13 @@ function handleUploadSuccess(res, file) { // 图片上传前拦截 function handleBeforeUpload(file) { + const type = ["image/jpeg", "image/jpg", "image/png", "image/svg"]; + const isJPG = type.includes(file.type); + //检验文件格式 + if (!isJPG) { + proxy.$modal.msgError(`图片格式错误!`); + return false; + } // 校检文件大小 if (props.fileSize) { const isLt = file.size / 1024 / 1024 < props.fileSize; @@ -164,6 +170,9 @@ function handleUploadError(err) {