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