|
1 |
| -// 路由输入 |
| 1 | +export enum NavigationType { |
| 2 | + push = 'push', |
| 3 | + replace = 'replace', |
| 4 | + go = 'go', |
| 5 | + forward = 'forward', |
| 6 | + back = 'back', |
| 7 | + pushLayer = 'pushLayer', |
| 8 | + openWindow = 'openWindow', |
| 9 | + reload = 'reload', |
| 10 | + forceReload = 'forceReload', |
| 11 | + // 导航结果类型 |
| 12 | + aborted = 'aborted', |
| 13 | + redirect = 'redirect', |
| 14 | + external = 'external', |
| 15 | + notFound = 'notFound' |
| 16 | +} |
2 | 17 |
|
3 |
| -export interface RouteInputPush { |
4 |
| - type: 'push'; |
| 18 | +export interface NavigationPush { |
| 19 | + type: NavigationType.push; |
5 | 20 | location: RouterRawLocation;
|
6 | 21 | }
|
7 |
| -export interface RouteInputReplace { |
8 |
| - type: 'replace'; |
| 22 | +export interface NavigationReplace { |
| 23 | + type: NavigationType.replace; |
9 | 24 | location: RouterRawLocation;
|
10 | 25 | }
|
11 |
| -export interface RouteInputGo { |
12 |
| - type: 'go'; |
| 26 | +export interface NavigationGo { |
| 27 | + type: NavigationType.go; |
13 | 28 | index: number;
|
14 | 29 | }
|
15 | 30 |
|
16 |
| -export interface RouteInputForward { |
17 |
| - type: 'forward'; |
| 31 | +export interface NavigationForward { |
| 32 | + type: NavigationType.forward; |
18 | 33 | }
|
19 |
| -export interface RouteInputBack { |
20 |
| - type: 'back'; |
| 34 | +export interface NavigationBack { |
| 35 | + type: NavigationType.back; |
21 | 36 | }
|
22 | 37 |
|
23 |
| -export interface RouteInputPushLayer { |
24 |
| - type: 'pushLayer'; |
| 38 | +export interface NavigationPushLayer { |
| 39 | + type: NavigationType.pushLayer; |
25 | 40 | }
|
26 |
| -export interface RouteInputOpenWindow { |
27 |
| - type: 'openWindow'; |
| 41 | +export interface NavigationOpenWindow { |
| 42 | + type: NavigationType.openWindow; |
28 | 43 | name?: string;
|
29 | 44 | windowFeatures?: string;
|
30 | 45 | }
|
31 | 46 |
|
32 |
| -export interface RouteInputReload { |
33 |
| - type: 'reload'; |
| 47 | +export interface NavigationReload { |
| 48 | + type: NavigationType.reload; |
34 | 49 | location?: RouterRawLocation;
|
35 | 50 | }
|
36 | 51 |
|
37 |
| -export interface RouteInputForceReload { |
38 |
| - type: 'forceReload'; |
| 52 | +export interface NavigationForceReload { |
| 53 | + type: NavigationType.forceReload; |
39 | 54 | url?: string;
|
40 | 55 | }
|
41 | 56 |
|
42 |
| -export type RouteInput = |
43 |
| - | RouteInputPush |
44 |
| - | RouteInputReplace |
45 |
| - | RouteInputGo |
46 |
| - | RouteInputForward |
47 |
| - | RouteInputBack |
48 |
| - | RouteInputPushLayer |
49 |
| - | RouteInputOpenWindow |
50 |
| - | RouteInputReload |
51 |
| - | RouteInputForceReload; |
52 |
| - |
53 |
| -// 路由输出 |
54 |
| - |
55 |
| -export interface RouteResultPush { |
56 |
| - type: 'push'; |
| 57 | +export type Navigation = |
| 58 | + | NavigationPush |
| 59 | + | NavigationReplace |
| 60 | + | NavigationGo |
| 61 | + | NavigationForward |
| 62 | + | NavigationBack |
| 63 | + | NavigationPushLayer |
| 64 | + | NavigationOpenWindow |
| 65 | + | NavigationReload |
| 66 | + | NavigationForceReload; |
| 67 | + |
| 68 | +export interface NavigationResultPush { |
| 69 | + type: NavigationType.push; |
57 | 70 | }
|
58 |
| -export interface RouteResultReplace { |
59 |
| - type: 'replace'; |
| 71 | +export interface NavigationResultReplace { |
| 72 | + type: NavigationType.replace; |
60 | 73 | }
|
61 |
| -export interface RouteResultAborted { |
62 |
| - type: 'aborted'; |
| 74 | +export interface NavigationResultAborted { |
| 75 | + type: NavigationType.aborted; |
63 | 76 | }
|
64 |
| -export interface RouteResultRedirect { |
65 |
| - type: 'redirect'; |
| 77 | +export interface NavigationResultRedirect { |
| 78 | + type: NavigationType.redirect; |
66 | 79 | }
|
67 |
| -export interface RouteResultUpdateIndex { |
68 |
| - type: 'redirect'; |
| 80 | +export interface NavigationResultUpdateIndex { |
| 81 | + type: NavigationType.redirect; |
69 | 82 | }
|
70 |
| -export interface RouteResultExternal { |
71 |
| - type: 'external'; |
| 83 | +export interface NavigationResultExternal { |
| 84 | + type: NavigationType.external; |
72 | 85 | }
|
73 |
| -export interface RouteResultNotFound { |
74 |
| - type: 'notFound'; |
| 86 | +export interface NavigationResultNotFound { |
| 87 | + type: NavigationType.notFound; |
75 | 88 | }
|
76 | 89 |
|
77 |
| -export type RouteResult = |
78 |
| - | RouteResultPush |
79 |
| - | RouteResultReplace |
80 |
| - | RouteResultAborted |
81 |
| - | RouteResultRedirect |
82 |
| - | RouteResultExternal |
83 |
| - | RouteResultNotFound; |
| 90 | +export type NavigationResult = |
| 91 | + | NavigationResultPush |
| 92 | + | NavigationResultReplace |
| 93 | + | NavigationResultAborted |
| 94 | + | NavigationResultRedirect |
| 95 | + | NavigationResultExternal |
| 96 | + | NavigationResultNotFound; |
84 | 97 |
|
85 | 98 | // 构造实例选项
|
86 | 99 | export interface RouterOptions {
|
|
0 commit comments