@@ -18,7 +18,7 @@ import { OUTPUT_NAME } from './constant'
1818import { writeDeclaration } from './declaration'
1919import { checkPagesJsonFileSync , getPathSets , writeFileWithLock } from './files'
2020import { resolveOptions } from './options'
21- import { PAGE_TYPE_KEY , PageFile } from './pageFile'
21+ import { PAGE_TYPE_KEY , PageFile , TABBAR_INDEX_KEY } from './pageFile'
2222import {
2323 debug ,
2424 invalidatePagesModule ,
@@ -278,7 +278,7 @@ export class Context {
278278 }
279279
280280 private async getTabBarMerged ( ) : Promise < TabBar | undefined > {
281- const tabBarItems : ( TabBarItem & { index : number } ) [ ] = [ ]
281+ const tabBarItems : ( TabBarItem ) [ ] = [ ]
282282 for ( const [ _ , pf ] of this . pageFiles ) {
283283 const tabbar = await pf . getTabBar ( )
284284 if ( tabbar ) {
@@ -300,12 +300,15 @@ export class Context {
300300 pagePaths . set ( item . pagePath , true )
301301 }
302302
303- tabBarItems . sort ( ( a , b ) => a . index - b . index )
303+ tabBarItems . sort ( ( a , b ) => {
304+ const aIdx = ( a as any ) [ TABBAR_INDEX_KEY ] || 0
305+ const bIdx = ( b as any ) [ TABBAR_INDEX_KEY ] || 0
306+ return aIdx - bIdx
307+ } )
304308
305309 for ( const item of tabBarItems ) {
306310 if ( ! pagePaths . has ( item . pagePath ) ) {
307- const { index : _ , ...tabbar } = item
308- tabBar . list . push ( tabbar )
311+ tabBar . list . push ( item )
309312 }
310313 }
311314
0 commit comments