Merge pull request #12910 from dataease/pr@dev-v2@fix_img

fix(数据大屏、仪表板): 修复含有分组、tab的资源导出模板再导入时出现图片列开问题
This commit is contained in:
王嘉豪 2024-10-25 14:01:41 +08:00 committed by GitHub
commit 8aa0379aec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -158,17 +158,8 @@ export function dataURLToBlob(dataUrl) {
return new Blob([u8arr], { type: mime }) return new Blob([u8arr], { type: mime })
} }
// 解析静态文件 function findStaticSourceInner(componentDataInfo, staticResource) {
export function findStaticSource(callBack) { componentDataInfo.forEach(item => {
const staticResource = []
// 系统背景文件
if (
typeof canvasStyleData.value.background === 'string' &&
canvasStyleData.value.background.indexOf('static-resource') > -1
) {
staticResource.push(canvasStyleData.value.background)
}
componentData.value.forEach(item => {
if ( if (
typeof item.commonBackground.outerImage === 'string' && typeof item.commonBackground.outerImage === 'string' &&
item.commonBackground.outerImage.indexOf('static-resource') > -1 item.commonBackground.outerImage.indexOf('static-resource') > -1
@ -182,8 +173,37 @@ export function findStaticSource(callBack) {
item.propValue['url'].indexOf('static-resource') > -1 item.propValue['url'].indexOf('static-resource') > -1
) { ) {
staticResource.push(item.propValue['url']) staticResource.push(item.propValue['url'])
} else if (
item.component === 'picture-group' &&
item.propValue['urlList'] &&
item.propValue['urlList'].length > 0
) {
item.propValue['urlList'].forEach(urlInfo => {
if (urlInfo.url.indexOf('static-resource') > -1) {
staticResource.push(urlInfo.url)
}
})
} else if (item.component === 'Group') {
findStaticSourceInner(item.propValue, staticResource)
} else if (item.component === 'DeTabs') {
item.propValue.forEach(tabItem => {
findStaticSourceInner(tabItem.componentData, staticResource)
})
} }
}) })
}
// 解析静态文件
export function findStaticSource(callBack) {
const staticResource = []
// 系统背景文件
if (
typeof canvasStyleData.value.background === 'string' &&
canvasStyleData.value.background.indexOf('static-resource') > -1
) {
staticResource.push(canvasStyleData.value.background)
}
findStaticSourceInner(componentData.value, staticResource)
if (staticResource.length > 0) { if (staticResource.length > 0) {
try { try {
findResourceAsBase64({ resourcePathList: staticResource }).then(rsp => { findResourceAsBase64({ resourcePathList: staticResource }).then(rsp => {