@ray-js/router-mp
Version:
Ray Core
57 lines (56 loc) • 1.68 kB
TypeScript
import { RouterScheduler as IRouterScheduler, type Routes, type SubPackages, type TabBar } from '@ray-js/types';
export type Route = Routes[number] & {
isTabBar: boolean;
};
export type SubPackageRoute = {
root: string;
route: string;
path: string;
};
export declare function currentPage(): any;
/**
* 小程序路由别名机制,将标准化的 web pathname 转化为小程序的 path
*/
export declare class RouterScheduler extends IRouterScheduler<Route> {
$entityMap: Route[];
$subPackageRoute: Record<string, SubPackageRoute[]>;
private $pathMap;
constructor();
getCurrentRoute(): Route | undefined;
/**
* 将小程序地址栏转化为 web 地址
* @param opts
*/
getHrefByPath(opts: {
path: string;
query: Record<string, unknown>;
hash: string;
}): string;
registryPages(params: {
routes: Routes;
tabBar: TabBar;
subpackages?: SubPackages;
}): void;
getMatchedPage(pathname: string): import("@ray-js/types").RootRouteItem & {
isTabBar: boolean;
} & {
params: object;
pathname: string;
};
getRouteByPath(pagePath: string): Route | undefined;
addPage(route: Route): void;
addSubPackagePage(subPackageRoute: SubPackageRoute): void;
getMatchedSubPackagePage(pathname: string, subPackage: string): {
pathname: string;
route: string;
params: any;
subPackage: string;
path: string;
} | undefined;
/**
* 以小程序地址进行匹配页面
* @param path - 小程序页面地址 /pages/home/index
* @returns
*/
private matchPageByPath;
}