- 封装组件
<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