Skip to content

Commit

Permalink
feat: add entryPagePath support
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchuzhang authored and Chen-jj committed Dec 9, 2021
1 parent ae60b2c commit 10c9648
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/taro-router/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export function createRouter (
}

if (history.location.pathname === '/') {
history.replace(prependBasename(routes[0].path as string + history.location.search))
history.replace(prependBasename((config.entryPagePath || routes[0].path) as string + history.location.search))
}

render({ location: history.location, action: LocationAction.Push })
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-router/src/tabbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function initTabbar (config: AppConfig) {

// TODO: 找到 tabbar 的类型
const tabbar = document.createElement('taro-tabbar') as any
const homePage = config.pages ? config.pages[0] : ''
const homePage = config.entryPagePath || (config.pages ? config.pages[0] : '')
tabbar.conf = config.tabBar
tabbar.conf.homePage = history.location.pathname === '/' ? homePage : history.location.pathname
const routerConfig = (config as any).router
Expand Down
4 changes: 4 additions & 0 deletions packages/taro/types/taro.config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,10 @@ declare module './index' {
}

interface AppConfig {
/**
* 小程序默认启动首页,未指定 entryPagePath 时,数组的第一项代表小程序的初始页面(首页)。
*/
entryPagePath?: string
/**
* 接受一个数组,每一项都是字符串,来指定小程序由哪些页面组成,数组的第一项代表小程序的初始页面
*/
Expand Down

0 comments on commit 10c9648

Please sign in to comment.