import type * as React from 'react'; import type { Target } from './platform'; import type { TabBar } from './tabbar'; /** * Web 注册后的页面对象 */ export type Page = { route: string; originalRoute?: string; path: string; config: PageConfig; isTabBar?: boolean; component: () => Promise; }; export type RootRouteItem = { route?: string; path: string; targets?: Array; name?: string; }; /** * 小程序注册后的页面对象 */ export type Route = RootRouteItem; export interface Router { push(to: string): void; replace(to: string): void; reload(url?: string): void; go(delta: number): void; back(): void; } export type RouteOptions = { subpackage: string; }; export type Routes = Route[]; export type RoutesWithConfig = Array; export type Pages = Array; /** * 根据路由匹配的页面对象 */ export type MatchedPage = Page & { params: object; pathname: string; }; export type MatchedRoute = Route & { params: object; pathname: string; }; export type UrlQuery = Record; export type PageComponent = typeof React.Component | React.FC; /** * 页面配置 * @see https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/page.html */ export type PageConfig = { navigationBarTitleText?: string; backgroundColor?: string; enablePullDownRefresh?: boolean; onReachBottomDistance?: number; }; /** * 抽象实现路由调度、路由注册、 */ export interface RouterSchedulerA { $entityMap: Record; registryPages(params: { routes: Routes; tabBar: TabBar; }): void; registryPages(params: { routes: Routes; tabBar: TabBar; pages: Pages; }): void; getMatchedPage(pathname: string): P; matchPage(pathname: string, entities: T[]): P; matchPageByPathname(pathname: string): P; addPage(entity: T): void; } export declare abstract class RouterScheduler { abstract $entityMap: T[]; abstract registryPages(params: { routes: Routes; tabBar: TabBar; }): void; abstract registryPages(params: { routes: Routes; tabBar: TabBar; pages: Pages; }): void; abstract getMatchedPage(pathname: string): P; abstract addPage(entity: T): void; matchPage(pathname: string, entities: T[]): P; matchPageByPathname(pathname: string): P; }