提交 e11ce2a1 编写于 作者: Y yurj26

feat(mp-alipay、mp-baidu): 支持直达指定页面

上级 291c21f4
...@@ -44,6 +44,41 @@ function copyToJson (json, fromJson, options) { ...@@ -44,6 +44,41 @@ function copyToJson (json, fromJson, options) {
}) })
} }
function parseCondition (pagesJson) {
const condition = pagesJson.condition
const launchPagePath = process.env.UNI_CLI_LAUNCH_PAGE_PATH || ''
const launchPageQuery = process.env.UNI_CLI_LAUNCH_PAGE_QUERY || ''
const launchPageOptions = {
title: launchPagePath,
page: launchPagePath,
pageQuery: launchPageQuery
}
const compileModeJson = {
modes: []
}
if (condition && Array.isArray(condition.list) && condition.list.length) {
compileModeJson.modes = condition.list.map(item => {
return {
title: item.name,
page: item.path,
pageQuery: item.query
}
})
delete pagesJson.condition
}
if (launchPagePath) {
compileModeJson.modes = [launchPageOptions]
}
const miniIdeDir = path.join(process.env.UNI_OUTPUT_DIR, '.mini-ide')
if (!fs.existsSync(miniIdeDir)) {
fs.mkdirSync(miniIdeDir, { recursive: true })
fs.writeFileSync(
path.join(miniIdeDir, 'compileMode.json'),
JSON.stringify(compileModeJson, null, 2)
)
}
}
const projectKeys = ['component2', 'enableAppxNg'] const projectKeys = ['component2', 'enableAppxNg']
module.exports = function (pagesJson, manifestJson) { module.exports = function (pagesJson, manifestJson) {
...@@ -101,6 +136,8 @@ module.exports = function (pagesJson, manifestJson) { ...@@ -101,6 +136,8 @@ module.exports = function (pagesJson, manifestJson) {
project.enableAppxNg = hasOwn(platformJson, 'enableAppxNg') ? platformJson.enableAppxNg : true project.enableAppxNg = hasOwn(platformJson, 'enableAppxNg') ? platformJson.enableAppxNg : true
} }
parseCondition(pagesJson)
return [{ return [{
name: 'app', name: 'app',
content: app content: app
......
...@@ -6,9 +6,19 @@ module.exports = function (pagesJson, manifestJson) { ...@@ -6,9 +6,19 @@ module.exports = function (pagesJson, manifestJson) {
const content = project.content const content = project.content
if (content.condition && content.condition.miniprogram) { const miniprogram = content.condition && content.condition.miniprogram
content.condition.swan = content.condition.miniprogram if (miniprogram && Array.isArray(miniprogram.list) && miniprogram.list.length) {
delete content.condition.miniprogram content['compilation-args'].options = miniprogram.list.map((item) => {
return {
id: item.id,
text: item.name,
extra: {
index: item.pathName,
query: item.query
}
}
})
delete content.condition
} }
project.name = 'project.swan' project.name = 'project.swan'
...@@ -16,4 +26,4 @@ module.exports = function (pagesJson, manifestJson) { ...@@ -16,4 +26,4 @@ module.exports = function (pagesJson, manifestJson) {
app, app,
project project
] ]
} }
{ {
"appid": "", "appid": "",
"compilation-args": {
"selected": -3
},
"appInfo": {}, "appInfo": {},
"appkey": "", "appkey": "",
"condition": {}, "condition": {},
...@@ -7,4 +10,4 @@ ...@@ -7,4 +10,4 @@
"urlCheck": true "urlCheck": true
}, },
"libVersion": "" "libVersion": ""
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册