使用jsplumb框架画图
使用html2canvas + svgToCanvas 将svg图片以及canvas生成缩略图并用于用户在界面下载和上传后台
// 导入utils.js文件,导入html2canvas包
import utils from '../../utils/util'
import html2canvas from 'html2canvas'
…………
downloadPicture () {
// 用户生成图片用于本地下载
this.designLoading = true
if (!this.checkJpg()) {
this.designLoading = false
return
}
this.$refs.designCanvas.unselectCurrent() // 取消所有节点的选中关闭右侧编辑框
this.createJpg().then((response) => {
this.$Message.success('缩略图生成成功')
this.designLoading = false
this.pictureVisible = true
}).catch(() => {
this.designLoading = false
this.$Message.error('缩略图生成失败请重试')
})
},
downLoadFlowPicture () {
// 用户下载缩略图
utils.downLoadFlowPicture(this.graphId, this.htmlUrl, this.graphName)
},
cancelDownLoadFlowPicture () {
this.pictureVisible = false
},
async createJpg () {
// 生成缩略图
this.designLoading = true
const create = this