将uniapp项目打包成WGT资源后,集成到鸿蒙原生next项目里面;点击桌面icon冷启动App时,会有一个空白页面的启动页,如何处理此空白页面?
o***@aihuayan.com
- 发布:2025-12-13 15:58
- 更新:2025-12-22 11:56
- 阅读:273
4 个回复
Ask小助手
在鸿蒙平台上集成uni-app打包的WGT后出现冷启动空白页面,通常是由于启动图配置不正确导致的。根据uni-app官方文档,需要检查manifest.json中的启动图配置项。
解决方案:
示例配置:
详细配置说明可参考启动图资源规范。注意鸿蒙平台与App平台配置方式不同,不要使用app-plus相关API。
o***@aihuayan.com (作者)
以上配置对于鸿蒙next系统无效,是否还有其他的方案?
o***@aihuayan.com (作者)
是否有人工客服或者真人可以回复?
DCloud_UNI_OttoJi - 日常回复 uni-app/x 问题,如果艾特我没看到,请主动私信
重新描述你的问题,描述操作步骤, unimpsdk 怎么配置的,通过手动按钮触发启动小程序是否正常,页面空白自查原生鸿蒙工程配置的是否有问题
o***@aihuayan.com (作者)
操作步骤:
1、桌面点击App
2、index页面加载后,点击图片
3、加载unimp小程序资源
此场景下,会出现空白页面,然后显示unimp主页面
index.ets逻辑:
@Builder
getBackGround() {
Image($r("app.media.startIcon"))
.width('100%')
.width('100%')
}
build() {
Stack({ alignContent: Alignment.Center }) {
Image($r("app.media.startIcon"))
.height('100%')
.width('90%')
.objectFit(ImageFit.Cover)
.onClick(() => {
this.launchUniMP()
})
}
.height('100%')
.width('100%')
}
unimpSDK 设置
async launchUniMP(): Promise<void> {
const mpId = "UNIEC57CCB"
try {
// 判断应用是否已释放到运行目录
let isExists = isExistsUniMP(mpId)
console.log("UniMP isExists:" + isExists)
// 拼接wgt包路径
let path = getContext().resourceDir + "/" + mpId + ".wgt"
console.log("UniMP path:" + path)
// 释放 wgt 包到运行目录
await new Promise<void>((resolve, reject) => {
releaseWgtToRunPath(mpId, path, (code: number, data: object) => {
console.log('UniMP result: ' + JSON.stringify({ code, data }))
resolve()
})
})
// 启动小程序
const config: IOpenUniMPConfig = {
showCapsuleButton: false,
launcher: this.getBackGround,
animationType: 'none',
showSplashScreen: true // 显示splash界面
}
const mp = openUniMP(mpId, config)
this.mp = mp
setTimeout(() => {
let data: Record<string, string | boolean> = {}
data['isShowPiP'] = true
mp.sendUniMPEvent('ShowPiPEvent', data)
}, 1000)
mp.on('uniMPEvent', (data: ESObject) => {
console.log('UniMP-event监听unimp发送的数据:' + JSON.stringify(data))
if (data === "clearBadge") {
//清除角标
notificationManager.setBadgeNumber(0);
}
})
console.log('UniMP-open:' + JSON.stringify(mp))
mp.on('close', () => {
console.log('UniMP-close')
})
mp.on('show', () => {
console.log('UniMP-show')
})
mp.on('hide', () => {
console.log('UniMP-hide')
})
} catch (err) {
console.error('启动UniMP失败:', err)
}
}
2025-12-22 12:29
o***@aihuayan.com (作者)
手动触发也存在空白页面
2025-12-22 12:30
DCloud_UNI_OttoJi
回复 o***@aihuayan.com: 提供复现工程
2025-12-22 14:03
DCloud_UNI_OttoJi
你反馈的问题,是无法接受启动一瞬间加载导致的白屏,还是反馈点击按钮启动小程序但是白屏失败了?
2025-12-22 14:09
o***@aihuayan.com (作者)
回复 DCloud_UNI_OttoJi: 无法接收启动一瞬间有大概一两秒左右的白屏
2025-12-22 15:21
DCloud_UNI_OttoJi
回复 o***@aihuayan.com: 目前沟通下来,有几个优化点,白屏时间减少、加载 laoding 可以展示、希望页面加载完成后 移除 slpahsscreen ,这个部分会分步骤来优化,目前白屏时间可以进一步降低
2025-12-23 14:50
DCloud_UNI_OttoJi
回复 DCloud_UNI_OttoJi: 这个问题后续在 https://issues.dcloud.net.cn/pages/issues/detail?id=24904 沟通,目前 js 资源并行加载配合 loading 展示,有一定加速效果,具体见是昨天演示的效果
2025-12-23 17:12
要回复问题请先登录或注册
公告
更多>相关问题