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

main
wu.jian2
parent f83314a55b
commit abe2531245

@ -439,12 +439,32 @@ export default {
} else { } else {
pageInfo.isPreview = false pageInfo.isPreview = false
this.saveLoading = true this.saveLoading = true
pageInfo.coverPicture = this.initialCoverPicture
const node = document.querySelector('.render-theme-wrap') const node = document.querySelector('.render-theme-wrap')
let dataUrl = '' let dataUrl = ''
let res = null
try { try {
dataUrl = await toJpeg(node, { quality: 0.2 }) dataUrl = await toJpeg(node, { quality: 0.2 })
} catch (error) { } 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 (dataUrl) {
if (showSize(dataUrl) > 200) { if (showSize(dataUrl) > 200) {
@ -464,12 +484,9 @@ export default {
} else { } else {
pageInfo.coverPicture = dataUrl pageInfo.coverPicture = dataUrl
} }
} else { res = await saveScreen(pageInfo)
this.$message.warning('保存封面失败,将使用上次保存的封面') this.$message.success('数据保存成功')
pageInfo.coverPicture = this.initialCoverPicture
} }
const res = await saveScreen(pageInfo)
this.$message.success('保存成功')
return res return res
} }
} catch (error) { } catch (error) {
@ -554,10 +571,22 @@ export default {
this.saveAndPreviewLoading = false this.saveAndPreviewLoading = false
// //
EventBus.$emit('startMarquee') EventBus.$emit('startMarquee')
}) }).catch((error) => {
.catch(() => {
this.$message.warning('出现未知错误,请重试')
this.saveAndPreviewLoading = false 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 this.loading = false
}) })
.catch((error) => { .catch((error) => {
console.info(error)
this.$message.warning('出现未知错误,请重试')
this.loading = false 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 () { pageJump () {

Loading…
Cancel
Save