options.d.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import Vue, { ComponentOptions,PluginFunction, AsyncComponent } from "vue";
  2. type Component = ComponentOptions<Vue> | typeof Vue | AsyncComponent;
  3. type Dictionary<T> = { [key: string]: T };
  4. type Position = { x: number; y: number };
  5. type PositionResult = Position | { selector: string; offset?: Position } | void;
  6. type NAVTYPE= 'push' | 'replace' | 'replaceAll' | 'pushTab'
  7. interface Location {
  8. name?: string;
  9. path?: string;
  10. query?: Dictionary<string | (string | null)[] | null | undefined>;
  11. params?: Dictionary<string>;
  12. NAVTYPE?: NAVTYPE;
  13. }
  14. interface Route {
  15. path: string;
  16. name?: string;
  17. params?: any;
  18. query?: any;
  19. beforeEnter?:(to:Route, from:Route, next:Function) => void;
  20. meta?: any; //其他格外参数
  21. }
  22. interface Animation{
  23. animationType?:string;
  24. animationDuration?:number;
  25. }
  26. interface H5{
  27. rewriteFun?:boolean; //是否对uni-app reLaunch/navigateBack 两个方法重写 处理uni刷新直接返回到首页和触发路由守卫
  28. paramsToQuery?: boolean; //h5端上通过params传参时规则是vue-router 刷新会丢失 开启此开关将变成?连接的方式
  29. loading?: boolean; //是否显示加载动画
  30. hinderTab?: boolean; //是否拦截uni-app自带底部菜单 TODO
  31. vueRouterDev?: boolean; //完全使用采用vue-router的开发模式
  32. useUniConfig?: boolean; //是否采用在pages.json下的所有页面配置信息,false时需开发者自行设置页面
  33. keepUniIntercept?: boolean; //保留uni-app使用vue-router的拦截器
  34. vueNext?: boolean; //在next管道函数中是否获取vueRouter next的原本参数
  35. replaceStyle?: boolean; //是否对resetStyle函数中返回的style节点进行全部替换,否则为追加
  36. resetStyle?: () => Object; //自定义加载样式函数 可返回一个包涵 html、style、script 的对象来重置Router内置的加载动画
  37. mode?: string;
  38. base?: string;
  39. linkActiveClass?: string;
  40. linkExactActiveClass?: string;
  41. scrollBehavior?: (to:Route, from:Route, savedPostion:Position|void) => PositionResult | Promise<PositionResult>,
  42. fallback?: boolean,
  43. }
  44. interface APP{
  45. holdTabbar?:boolean; //是否开启底部菜单拦截
  46. rewriteFun?:boolean; //是否对uni-app 下的chooseLocation/openLocation 两个方法重写 目的是隐藏和显示拦截tabbar
  47. loddingPageStyle?:()=>Object; //当前等待页面的样式 必须返回一个json
  48. loddingPageHook?:()=>void; //刚刚打开页面处于等待状态,会触发此事件
  49. holdTabbarStyle?:()=>Object;
  50. animation?:Animation; //页面切换动画
  51. switchPageOutTime?:number, //最高能忍耐的页面切换时间 达到此时间 不管切换有没有完成都会显示页面出来 这对启动页帮助很大
  52. }
  53. interface RouteConfig {
  54. path: string; //pages.json中的path 必须加上 '/' 开头
  55. component?: Component; //H5端可用
  56. name?: string; // 命名路由
  57. components?: { [name: string]: Component }; // 命名视图组件,H5端可用
  58. redirect?: string | Location | Function; //H5端可用
  59. props?: boolean | Object | Function; //H5端可用
  60. aliasPath?:string; //h5端 设置一个别名路径来替换 uni-app的默认路径
  61. alias?: string | Array<string>; //H5端可用
  62. children?: Array<RouteConfig>; // 嵌套路由,H5端可用
  63. beforeEnter?: (to: Route, from: Route, next: Function) => void; //路由元守卫
  64. meta?: any; //其他格外参数
  65. }
  66. interface RouterOptions{
  67. h5?:H5;
  68. APP?:APP;
  69. debugger?: boolean; //是否处于开发阶段 设置为true则打印日志
  70. encodeURI?: boolean; //是否对url传递的参数进行编码
  71. routerBeforeEach?: () => Object; //router 前置路由函数 每次触发跳转前先会触发此函数
  72. routerAfterEach?: () => Object; //router 后置路由函数 每次触发跳转后会触发此函数
  73. routes?: RouteConfig[];
  74. }
  75. export {
  76. PluginFunction,
  77. Component,
  78. Location,
  79. Route,
  80. Animation,
  81. H5,
  82. APP,
  83. RouteConfig,
  84. RouterOptions
  85. }