提交 1fb17aa0 编写于 作者: fxy060608's avatar fxy060608

fix(cli): refactor nvue pages

上级 adcfdfd2
......@@ -82,9 +82,9 @@ function processPagesJson (pagesJson, loader = {
})
}
if (Object.keys(uniNVuePages).length) { // 直接挂在 pagesJson 上
if (uniNVuePages.length) { // 直接挂在 pagesJson 上
pagesJson.nvue = {
pages: uniNVuePages
pages: uniNVuePages.reverse()
}
if (uniNVueEntryPagePath) {
pagesJson.nvue.entryPagePath = uniNVueEntryPagePath
......@@ -152,9 +152,10 @@ function isValidPage (page, root = '') {
// process.UNI_NVUE_ENTRY[pagePath] = path.resolve(process.env.UNI_INPUT_DIR, pagePath + '.nvue') + '?entry'
// }
uniNVuePages[pagePath + '.html'] = {
'window': page.style || {}
}
uniNVuePages.push({
'path': pagePath + '.html',
'style': page.style || {}
})
return false
}
......@@ -176,7 +177,7 @@ function getNVueMainJsPath (page) {
process.UNI_ENTRY = {}
process.UNI_NVUE_ENTRY = {}
let uniNVuePages = {}
const uniNVuePages = []
function parsePages (pagesJson, pageCallback, subPageCallback) {
if (!pagesJson) {
......@@ -215,7 +216,7 @@ function parseEntry (pagesJson) {
process.UNI_NVUE_ENTRY['app-service'] = path.resolve(process.env.UNI_INPUT_DIR, getMainEntry())
}
uniNVuePages = {}
uniNVuePages.length = 0
if (!pagesJson) {
pagesJson = getPagesJson() // 会检测修改 nvue entry
......
......@@ -128,12 +128,14 @@ module.exports = function (pagesJson, userManifestJson) {
const nvuePages = pagesJson.nvue && pagesJson.nvue.pages
const nvuePagePaths = Object.keys(nvuePages || {})
if (nvuePagePaths.length) {
if (nvuePages.length) {
const pages = {}
nvuePagePaths.forEach(nvuePagePath => {
pages[nvuePagePath] = {
'window': parseStyle(pagesJson.nvue.pages[nvuePagePath]['window'] || {}),
nvuePages.forEach(({
path,
style
}) => {
pages[path] = {
'window': parseStyle(style),
'nvue': true
}
})
......@@ -319,7 +321,7 @@ module.exports = function (pagesJson, userManifestJson) {
// networkTimeout
normalizeNetworkTimeout(appJson)
appJson.page = Object.create(null)
appJson.pages = Object.keys(appJson.nvue.pages).reverse().map(pagePath => {
appJson.pages = Object.keys(appJson.nvue.pages).map(pagePath => {
const newPagePath = pagePath.replace('.html', '')
appJson.page[newPagePath] = {
window: appJson.nvue.pages[pagePath].window,
......
......@@ -44,7 +44,9 @@ const pagesJson2AppJson = {
fromJson &&
fromJson.nvue &&
fromJson.nvue.pages &&
fromJson.nvue.pages[page.pagePath + '.html']
fromJson.nvue.pages.find(({
path
}) => path === (page.pagePath + '.html'))
)
) {
console.error(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册