1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- type libRouterHandlesKeys = '$live' | '$map';
- type libRouterHandles = {
- [key in libRouterHandlesKeys]:(this:LibRouterApi,data:LibRouter)=>LibRouter
- }
- interface LibRouter extends WechatMiniprogram.NavigateToOption{
- url?:string,
- // 名称
- name?:libRouterHandlesKeys | string,
- // 路径
- path?:string,
- // 参数
- params?: Record<string, any> | string,
- // 内存数据
- memoryParams?:Record<string, any>,
- // 分包名称
- subcontract?:string,
- // 房间id
- roomId?:number | string
- }
- type LibRouterFunctionKeys = 'navigateTo' | 'switchTab' | 'navigateBack' | 'reLaunch' | 'redirectTo';
- type LibRouterParamsApi = {
- [key in Exclude<LibRouterFunctionKeys, 'navigateBack'>]:(data:LibRouter | string) => Promise<any>
- }
- interface LibRouterOtherParams {
- // 返回上一页
- navigateBack:(data?:number) => Promise<any>,
- // 获取 直播路径
- getLivePath:(roomId:number | string,params:Record<string, any> | string)=> string,
- getMapPath:(params:Record<string, any> | string) => string,
- // 执行跳转辅助
- router:(name:string,data:LibRouter | string | libRouterHandlesKeys,params?:boolean) => Promise<any>
- // 将params 转为 string
- getParamsString: (params:Record<string, any> | string) => string;
- // 内存缓存数据
- memoryData: Record<string, Record<string, any>>;
- // 向内存数据获取
- memoryGet:(name:string) => Record<string, any> | undefined;
- // 向内存数据写入
- memorySet:(name:string,params:Record<string, any>) => void;
- // 获取路由名称
- getRouterName:(path:string) => string;
- // 推断分包
- inferSubPages:(url:string)=>string | undefined,
- autoRouter:(data:LibRouter | string,defaultMode?:LibRouterFunctionKeys)=> Promise<any>
- // 辅助对象
- routerParams:{
- // 是否可以继续执行
- next:boolean,
- // 延迟执行时间
- delay:number
- }
- }
- type LibRouterApi = LibRouterOtherParams & LibRouterParamsApi;
|