- 封装组件
<template>
<div>
<script id="editor" type="text/plain" style="height:300px;" />
</div>
</template>
<script>
import '../../static/ueditor/ueditor.config.js'
import '../../static/ueditor/ueditor.all.js'
import '../../static/ueditor/lang/zh-cn/zh-cn.js'
import '../../static/ueditor/ueditor.parse.min.js'
import constants from '@/utils/constants'
import { getToken } from '@/utils/auth'
export default {
name: 'UE',
props: {
catalog: {
type: String,
required: true
},
// 默认的初始内容
defaultMsg: {
type: String,
default: ''
},
// 配置项,工具栏
config: {
type: Object,
default: () => {
return {}
}
}
},
data() {
return {
editor: null
}
},
mounted() {
const _this = this
this.config.chishipConfig = {
headers: {
'App-Key': this.constants.APP_KEY,
'App-Id': this.constants.APP_ID,
'Access-Token': getToken()
},
fileViewServer: this.global.getFileView('{UUID}')
}
this.config.serverUrl = process.env.BASE_API + this.constants.UPMS + 'ue'
// eslint-disable-next-line no-undef
this.editor = UE.getEditor('editor', this.config)
this.editor.addListener('ready', function() {
_this.editor.setContent(_this.defaultMsg)
})
// eslint-disable-next-line no-undef
if (!UE.Editor.prototype._bkGetActionUrl) {
// eslint-disable-next-line no-undef
UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl
// eslint-disable-next-line no-undef
UE.Editor.prototype.getActionUrl = function(action) {
console.log(action)
if (action === 'uploadimage') {
return (
process.env.BASE_API + constants.DOCS + 'file/ueUpload?catalogId=' + _this.catalog
)
} else if

本文详细介绍了如何封装和配置富文本编辑器UEditor,包括设置appid、appkey、token和文件预览地址,以及针对图片、附件、视频和涂鸦上传的接口修改,确保与项目统一并支持文件上传验证。此外,还提供了编辑器内容的设置和获取方法。
最低0.47元/天 解锁文章
3427

被折叠的 条评论
为什么被折叠?



