|
|
@@ -5,6 +5,7 @@
|
|
|
<el-upload
|
|
|
:show-file-list="false"
|
|
|
:action="uploadURL"
|
|
|
+ :http-request="httpRequest"
|
|
|
:headers="{
|
|
|
Authorization: token,
|
|
|
...headers
|
|
|
@@ -124,13 +125,38 @@ export default {
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
+ httpRequest(params) {
|
|
|
+ const file = params.file
|
|
|
+ this.getBase64(file).then(res => {
|
|
|
+ this.$service.common.uploadImg({content: res}).then(subRes => {
|
|
|
+ params.onSuccess(subRes)
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getBase64(file) {
|
|
|
+ return new Promise(function (resolve, reject) {
|
|
|
+ let reader = new FileReader();
|
|
|
+ let imgResult = '';
|
|
|
+ reader.readAsDataURL(file);
|
|
|
+ reader.onload = function () {
|
|
|
+ imgResult = reader.result;
|
|
|
+ };
|
|
|
+ reader.onerror = function (error) {
|
|
|
+ reject(error);
|
|
|
+ };
|
|
|
+ reader.onloadend = function () {
|
|
|
+ resolve(imgResult);
|
|
|
+ };
|
|
|
+ });
|
|
|
+ },
|
|
|
uploadImageHandler() {
|
|
|
document.getElementById('quill-upload-btn').click();
|
|
|
},
|
|
|
|
|
|
upSuccess(res) {
|
|
|
+ console.log(res)
|
|
|
const { index } = this.quill.getSelection();
|
|
|
- this.quill.insertEmbed(index || 0, 'image', res.data, Quill.sources.USER);
|
|
|
+ this.quill.insertEmbed(index || 0, 'image', res.smallUrl, Quill.sources.USER);
|
|
|
},
|
|
|
|
|
|
setContent(val) {
|
|
|
@@ -225,5 +251,9 @@ export default {
|
|
|
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value='monospace']::before, .ql-snow .ql-picker.ql-font .ql-picker-item[data-value='monospace']::before {
|
|
|
content: '等宽字体';
|
|
|
}
|
|
|
+
|
|
|
+ .ql-snow .ql-editor img{
|
|
|
+ width: auto !important;
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|