From 4b2206bfdf2cce57d0a0ac022ebd7355cdc32449 Mon Sep 17 00:00:00 2001 From: wkj <278599135@qq.com> Date: Tue, 13 Sep 2022 21:28:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=AF=91router=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E6=A0=B9=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/babel-plugin/router.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/config/babel-plugin/router.js b/config/babel-plugin/router.js index 5cd375e..2683684 100644 --- a/config/babel-plugin/router.js +++ b/config/babel-plugin/router.js @@ -148,6 +148,7 @@ module.exports = () => { (ele) => ele.value ); const disableAssemble = node2.elements[3] && node2.elements[3].value; + const isFirst = node2.elements[4] && node2.elements[4].value; if (namespaceArr && namespaceArr.length > 0) { for (let namespace of namespaceArr) { @@ -167,6 +168,7 @@ module.exports = () => { path, disableAssemble, namespace, + isFirst, }), ]; router.properties.push( @@ -182,6 +184,7 @@ module.exports = () => { path, disableAssemble, namespace, + isFirst, }); const properties = allRouters[fIndex].properties; @@ -210,6 +213,7 @@ module.exports = () => { projectOrPath, path, disableAssemble, + isFirst, }); allRouters.push(router); } @@ -240,7 +244,7 @@ module.exports = () => { }; }; -function getRouter({ projectOrPath, path, namespace, disableAssemble }) { +function getRouter({ projectOrPath, path, namespace, disableAssemble, isFirst }) { const filePath = disableAssemble ? projectOrPath : `${projectOrPath}/pages${ @@ -254,12 +258,12 @@ function getRouter({ projectOrPath, path, namespace, disableAssemble }) { let meta = []; if (jsonFileExists) { const { navigationBarTitleText } = require(`${relPath}.json`); - meta = [ + meta.push( t.objectProperty( t.identifier('title'), t.stringLiteral(navigationBarTitleText || '') - ), - ]; + ) + ); } const path2 = @@ -285,6 +289,11 @@ function getRouter({ projectOrPath, path, namespace, disableAssemble }) { ), t.objectProperty(t.identifier('meta'), t.objectExpression(meta)), ]; + if (isFirst) { + properties.push( + t.objectProperty(t.identifier('isFirst'), t.booleanLiteral(isFirst)) + ); + } if (namespace) { properties.push( t.objectProperty(