From 80354e0377248cffc8c4404d3943f51251b68b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=80=81=E5=8F=B6?= Date: Thu, 20 Oct 2022 19:45:22 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=9B=BE=E7=89=87=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/TinymceEditor/util.js | 27 ++++++++++++++++--- .../activity/components/activity-item.vue | 2 +- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/components/TinymceEditor/util.js b/src/components/TinymceEditor/util.js index e4874b4..cc144b0 100644 --- a/src/components/TinymceEditor/util.js +++ b/src/components/TinymceEditor/util.js @@ -1,4 +1,5 @@ const BASE_URL = process.env.BASE_URL; +import request from '@/utils/request'; // 默认加载插件 const PLUGINS = [ @@ -89,11 +90,31 @@ export const DEFAULT_CONFIG = { toolbar_mode: 'sliding', quickbars_insert_toolbar: '', images_upload_handler: (blobInfo, success, error) => { - if (blobInfo.blob().size / 1024 > 400) { - error('大小不能超过 400KB'); + if (blobInfo.blob().size / 1024 > 10000) { + error('大小不能超过 10M'); return; } - success('data:image/jpeg;base64,' + blobInfo.base64()); + const formData = new FormData(); + formData.append('file', blobInfo.blob()); + request({ + url: '/upload', + method: 'post', + data: formData + }) + .then((res) => { + if (res.data.code === 0) { + success(res.data.data.full_url); + } + }) + .catch(() => { + error('上传失败!'); + }); + + // if (blobInfo.blob().size / 1024 > 400) { + // error('大小不能超过 400KB'); + // return; + // } + // success('data:image/jpeg;base64,' + blobInfo.base64()); }, file_picker_types: 'media', file_picker_callback: () => {} diff --git a/src/views/sylive/activity/components/activity-item.vue b/src/views/sylive/activity/components/activity-item.vue index 146c1aa..e1d2eb5 100644 --- a/src/views/sylive/activity/components/activity-item.vue +++ b/src/views/sylive/activity/components/activity-item.vue @@ -110,7 +110,7 @@ height: 300, toolbar: [ 'code | forecolor backcolor bold italic underline strikethrough link anchor | alignleft aligncenter alignright alignjustify outdent indent | fontsizeselect | bullist numlist | \ - table emoticons hr preview | fullscreen | bdmap indent2em lineheight formatpainter axupimgs' + table emoticons hr preview | fullscreen | bdmap indent2em lineheight formatpainter axupimgs| image emoticons hr ' ] }, defaultForm,