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,