chutingting 1 год назад
Родитель
Сommit
e5d77ba566
2 измененных файлов: 23 добавлений и 3 удалений
  1. +7
    -3
      src/components/ueditor/index.vue
  2. +16
    -0
      src/components/uploadFile/index.vue

+ 7
- 3
src/components/ueditor/index.vue Просмотреть файл

@@ -11,7 +11,7 @@
<el-dialog v-if="uploadDiolagVisible" :visible.sync="uploadDiolagVisible" append-to-body title="图片上传"> <el-dialog v-if="uploadDiolagVisible" :visible.sync="uploadDiolagVisible" append-to-body title="图片上传">
<el-form> <el-form>
<el-form-item label="上传图片"> <el-form-item label="上传图片">
<uploadFile :url.sync="imgUrl" type="image" width="auto" height="auto"/>
<uploadFile :url.sync="imgUrl" :imgWidth.sync="imgWidth" type="image" width="auto" height="auto" />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" @click="saveImg()">保存</el-button> <el-button type="primary" @click="saveImg()">保存</el-button>
@@ -137,7 +137,8 @@ export default {
UEDITOR_HOME_URL: 'https://admin.meta-autotv.com/ueditor/' // UEditor资源文件的存放路径 UEDITOR_HOME_URL: 'https://admin.meta-autotv.com/ueditor/' // UEditor资源文件的存放路径
}, },
imgUrl: '', imgUrl: '',
uploadDiolagVisible: false
uploadDiolagVisible: false,
imgWidth: 0
} }
}, },
watch: { watch: {
@@ -162,7 +163,10 @@ export default {
if (this.isDisabled) this.editor.options.readonly = true if (this.isDisabled) this.editor.options.readonly = true
}, },
saveImg() { saveImg() {
let imageHtml = '<p><img width="100%" src=\"' + this.imgUrl + '\"/></p>'
let imageHtml = '<p><img src=\"' + this.imgUrl + '\"/></p>'
if (this.imgWidth > 800) {
imageHtml = '<p><img width="100%" src=\"' + this.imgUrl + '\"/></p>'
}
this.editor.execCommand('inserthtml', imageHtml) this.editor.execCommand('inserthtml', imageHtml)
this.uploadDiolagVisible = false this.uploadDiolagVisible = false
}, },


+ 16
- 0
src/components/uploadFile/index.vue Просмотреть файл

@@ -65,6 +65,22 @@ export default {
this.$message.error(txt) this.$message.error(txt)
return false return false
} }
this.asyncImgChecked(file)
},
asyncImgChecked(file) {
var reader = new FileReader()
let that = this
reader.onload = function(event) {
var txt = event.target.result
var img = document.createElement('img')
img.src = txt
img.onload = function() {
that.$emit('update:imgWidth', img.width)
// console.log(img.width);
// console.log(img.height);
}
}
reader.readAsDataURL(file)
}, },
getVideo(videoId) { getVideo(videoId) {
uploadProgress(videoId).then(d => { uploadProgress(videoId).then(d => {


Загрузка…
Отмена
Сохранить