feat: 添加解析类型的方法,优化微应用配置逻辑

This commit is contained in:
kuaifan 2025-12-18 08:26:42 +00:00
parent 52913abb4f
commit d94ebfe04c
2 changed files with 23 additions and 16 deletions

View File

@ -404,6 +404,9 @@ export default {
}
}
// type
config.type = this.resolveType(config.type)
// blank
if (/_blank$/i.test(config.type)) {
await this.inlineBlank(config)
@ -769,6 +772,25 @@ export default {
this.closeMicroApp(app.name, true)
}
})
},
/**
* 解析类型
* @param type
*/
resolveType(type) {
if (typeof type === 'string') {
return type
}
if ($A.isJson(type)) {
const defaultType = typeof type.default === 'string' ? type.default : 'iframe'
const mobileType = typeof type.mobile === 'string'
? type.mobile
: (typeof type.app === 'string' ? type.app : defaultType)
const desktopType = typeof type.desktop === 'string' ? type.desktop : defaultType
return $A.platformType() === 'desktop' ? desktopType : mobileType
}
return 'inline'
}
}
}

View File

@ -5095,26 +5095,11 @@ export default {
})
.replace(/\{system_base_url}/g, serverLocation.origin)
const resolveType = () => {
if (typeof data.type === 'string') {
return data.type
}
if ($A.isJson(data.type)) {
const defaultType = typeof data.type.default === 'string' ? data.type.default : 'iframe'
const mobileType = typeof data.type.mobile === 'string'
? data.type.mobile
: (typeof data.type.app === 'string' ? data.type.app : defaultType)
const desktopType = typeof data.type.desktop === 'string' ? data.type.desktop : defaultType
return $A.platformType() === 'desktop' ? desktopType : mobileType
}
return 'inline'
}
const config = {
id: data.id,
name: data.name,
url: $A.mainUrl(data.url),
type: resolveType(),
type: data.type || data.url_type,
background: data.background || null,
capsule: $A.isJson(data.capsule) ? data.capsule : {},
transparent: typeof data.transparent == 'boolean' ? data.transparent : false,