Skip to content

Commit a08613c

Browse files
huayuanroadqufangtao
andauthored
修复应用模式下不支持最新应用&卡片rpks包安装的问题 (#112)
Signed-off-by: qufangtao <qufangtao@xiaomi.com> Co-authored-by: qufangtao <qufangtao@xiaomi.com>
1 parent 256430b commit a08613c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

packages/hap-packager/src/router/routes.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import moment from 'moment'
1010

1111
import {
1212
colorconsole,
13+
readJson,
1314
relateCwd,
1415
globalConfig,
1516
recordClient,
@@ -63,7 +64,26 @@ async function bundle(context, next) {
6364
const projectName = projectInfo.projectName
6465
const projectVersion = projectInfo.projectVersion
6566
const platformVersion = context.request.query.platformVersion
66-
if (platformVersion && platformVersion >= RPKS_SUPPORT_VERSION_FROM) {
67+
let useAppRpk = false
68+
// 应用模式下
69+
if (parseInt(context.request.query.mode || 0) === 0) {
70+
// 读取 manifest
71+
let manifest
72+
try {
73+
manifest = readJson(path.join(projectPath, './src/manifest.json'))
74+
} catch (err) {
75+
manifest = null
76+
}
77+
// 不存在分包
78+
if (manifest && manifest.router && (!manifest.subpackages || manifest.subpackages.length === 0)) {
79+
// 存在卡片
80+
if (manifest.router.widgets && Object.keys(manifest.router.widgets).length > 0) {
81+
useAppRpk = true
82+
}
83+
}
84+
}
85+
86+
if (platformVersion && platformVersion >= RPKS_SUPPORT_VERSION_FROM && !useAppRpk) {
6787
distFile = getDistFilePath(projectDist, projectName, projectVersion, 'rpks')
6888
}
6989
if (!distFile) {

0 commit comments

Comments
 (0)