const ROUTES = Object.freeze({ tabs: { home: '/pages/home/index', library: '/pages/library/index', ai: '/pages/ai/index', profile: '/pages/profile/index', login: '/pages/login/index' }, tcm: { aiHistory: '/packages/tcm/pages/ai-history/index', assets: '/packages/tcm/pages/assets/index', bianzheng: '/packages/tcm/pages/bianzheng/index', bookDetail: '/packages/tcm/pages/book-detail/index', searchBooks: '/packages/tcm/pages/search-books/index', section: '/packages/tcm/pages/section/index', placeholder: '/packages/tcm/pages/placeholder/index' }, mingli: { hall: '/packages/mingli/pages/hall/index', bazi: '/packages/mingli/pages/bazi/index', bookDetail: '/packages/mingli/pages/book-detail/index', searchBooks: '/packages/mingli/pages/search-books/index', section: '/packages/mingli/pages/section/index', interpret: '/packages/mingli/pages/interpret/index' }, learning: { center: '/packages/learning/pages/center/index' } }) const TAB_PAGE_ROUTES = Object.freeze([ ROUTES.tabs.home, ROUTES.tabs.library, ROUTES.tabs.ai, ROUTES.tabs.profile ]) function normalizeRoute(route) { if (typeof route !== 'string') { return '' } return route.split('?')[0] } function isTabRoute(route) { return TAB_PAGE_ROUTES.includes(normalizeRoute(route)) } function openStaticRoute(route, wxApi) { if (!route || !wxApi) { return false } if (isTabRoute(route)) { if (typeof wxApi.switchTab !== 'function') { return false } wxApi.switchTab({ url: normalizeRoute(route) }) return true } if (typeof wxApi.navigateTo !== 'function') { return false } wxApi.navigateTo({ url: route }) return true } module.exports = { ROUTES, TAB_PAGE_ROUTES, isTabRoute, openStaticRoute }