feat: 在大屏保存数据时和设计业务组件时,出现保存封面失败时,添加提示语,告诉使用者图片资源跨域,需要先将资源上传到资源库再使用

main
wu.jian2 1 year ago
parent f83314a55b
commit abe2531245

@ -439,12 +439,32 @@ export default {
} else {
pageInfo.isPreview = false
this.saveLoading = true
pageInfo.coverPicture = this.initialCoverPicture
const node = document.querySelector('.render-theme-wrap')
let dataUrl = ''
let res = null
try {
dataUrl = await toJpeg(node, { quality: 0.2 })
} catch (error) {
console.info(error)
if (error.type === 'error') {
// error.currentTargetimg
if (error.currentTarget.tagName.toLowerCase() === 'img') {
//
this.$confirm('保存封面失败我们将使用上次保存的封面它不会影响其他数据的保存。由于图片资源跨域问题导致使用toDataURL API生成图片失败我们需要将图片上传到资源库。然后在组件中使用资源库中的图片资源以确保没有跨域问题。', '提示', {
confirmButtonText: '确定',
type: 'warning',
customClass: 'bs-el-message-box'
}).then(async () => {
res = await saveScreen(pageInfo)
this.$message.success('数据保存成功')
}).catch(async () => {
res = await saveScreen(pageInfo)
this.$message.success('数据保存成功')
})
}
} else {
this.$message.warning('出现未知错误,请重试')
}
}
if (dataUrl) {
if (showSize(dataUrl) > 200) {
@ -464,12 +484,9 @@ export default {
} else {
pageInfo.coverPicture = dataUrl
}
} else {
this.$message.warning('保存封面失败,将使用上次保存的封面')
pageInfo.coverPicture = this.initialCoverPicture
res = await saveScreen(pageInfo)
this.$message.success('数据保存成功')
}
const res = await saveScreen(pageInfo)
this.$message.success('保存成功')
return res
}
} catch (error) {
@ -554,10 +571,22 @@ export default {
this.saveAndPreviewLoading = false
//
EventBus.$emit('startMarquee')
})
.catch(() => {
this.$message.warning('出现未知错误,请重试')
}).catch((error) => {
this.saveAndPreviewLoading = false
if (error.type === 'error') {
// error.currentTargetimg
if (error.currentTarget.tagName.toLowerCase() === 'img') {
//
this.$confirm('图片资源跨域导致使用toDataURL API生成图片失败请将图片上传到资源库然后在组件中使用资源库中的图片资源确保没有跨域问题。', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
customClass: 'bs-el-message-box'
}).then(() => { }).catch(() => { })
}
} else {
this.$message.warning('出现未知错误,请重试')
}
})
}
}

@ -415,9 +415,21 @@ export default {
this.loading = false
})
.catch((error) => {
console.info(error)
this.$message.warning('出现未知错误,请重试')
this.loading = false
if (error.type === 'error') {
// error.currentTargetimg
if (error.currentTarget.tagName.toLowerCase() === 'img') {
//
this.$confirm('图片资源跨域导致使用toDataURL API生成图片失败请将图片上传到资源库然后在组件中使用资源库中的图片资源确保没有跨域问题。', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
customClass: 'bs-el-message-box'
}).then(() => { }).catch(() => { })
}
} else {
this.$message.warning('出现未知错误,请重试')
}
})
},
pageJump () {

Loading…
Cancel
Save