1
1
import Routes from './routes'
2
- import { getKey } from './utils'
2
+ import { getKey } from './utils'
3
3
4
4
export default ( bus , store , moduleName , keyName ) => {
5
5
if ( store ) {
@@ -8,16 +8,16 @@ export default (bus, store, moduleName, keyName) => {
8
8
routes : Routes
9
9
} ,
10
10
mutations : {
11
- 'navigation/FORWARD' : ( state , { to, from, name} ) => {
11
+ 'navigation/FORWARD' : ( state , { to, from, name } ) => {
12
12
state . routes . push ( name )
13
13
} ,
14
- 'navigation/BACK' : ( state , { to, from, count} ) => {
14
+ 'navigation/BACK' : ( state , { to, from, count } ) => {
15
15
state . routes . splice ( state . routes . length - count , count )
16
16
} ,
17
- 'navigation/REPLACE' : ( state , { to, from, name} ) => {
17
+ 'navigation/REPLACE' : ( state , { to, from, name } ) => {
18
18
state . routes . splice ( Routes . length - 1 , 1 , name )
19
19
} ,
20
- 'navigation/REFRESH' : ( state , { to, from} ) => {
20
+ 'navigation/REFRESH' : ( state , { to, from } ) => {
21
21
} ,
22
22
'navigation/RESET' : ( state ) => {
23
23
state . routes . splice ( 0 , state . routes . length )
@@ -27,43 +27,43 @@ export default (bus, store, moduleName, keyName) => {
27
27
}
28
28
29
29
const forward = ( name , toRoute , fromRoute ) => {
30
- const to = { route : toRoute }
31
- const from = { route : fromRoute }
30
+ const to = { route : toRoute }
31
+ const from = { route : fromRoute }
32
32
const routes = store ? store . state [ moduleName ] . routes : Routes
33
33
// if from does not exist, it will be set null
34
34
from . name = routes [ routes . length - 1 ] || null
35
35
to . name = name
36
- store ? store . commit ( 'navigation/FORWARD' , { to, from, name} ) : routes . push ( name )
36
+ store ? store . commit ( 'navigation/FORWARD' , { to, from, name } ) : routes . push ( name )
37
37
window . sessionStorage . VUE_NAVIGATION = JSON . stringify ( routes )
38
38
bus . $emit ( 'forward' , to , from )
39
39
}
40
40
const back = ( count , toRoute , fromRoute ) => {
41
- const to = { route : toRoute }
42
- const from = { route : fromRoute }
41
+ const to = { route : toRoute }
42
+ const from = { route : fromRoute }
43
43
const routes = store ? store . state [ moduleName ] . routes : Routes
44
44
from . name = routes [ routes . length - 1 ]
45
45
to . name = routes [ routes . length - 1 - count ]
46
- store ? store . commit ( 'navigation/BACK' , { to, from, count} ) : routes . splice ( Routes . length - count , count )
46
+ store ? store . commit ( 'navigation/BACK' , { to, from, count } ) : routes . splice ( Routes . length - count , count )
47
47
window . sessionStorage . VUE_NAVIGATION = JSON . stringify ( routes )
48
48
bus . $emit ( 'back' , to , from )
49
49
}
50
50
const replace = ( name , toRoute , fromRoute ) => {
51
- const to = { route : toRoute }
52
- const from = { route : fromRoute }
51
+ const to = { route : toRoute }
52
+ const from = { route : fromRoute }
53
53
const routes = store ? store . state [ moduleName ] . routes : Routes
54
54
// if from does not exist, it will be set null
55
55
from . name = routes [ routes . length - 1 ] || null
56
56
to . name = name
57
- store ? store . commit ( 'navigation/REPLACE' , { to, from, name} ) : routes . splice ( Routes . length - 1 , 1 , name )
57
+ store ? store . commit ( 'navigation/REPLACE' , { to, from, name } ) : routes . splice ( Routes . length - 1 , 1 , name )
58
58
window . sessionStorage . VUE_NAVIGATION = JSON . stringify ( routes )
59
59
bus . $emit ( 'replace' , to , from )
60
60
}
61
61
const refresh = ( toRoute , fromRoute ) => {
62
- const to = { route : toRoute }
63
- const from = { route : fromRoute }
62
+ const to = { route : toRoute }
63
+ const from = { route : fromRoute }
64
64
const routes = store ? store . state [ moduleName ] . routes : Routes
65
65
to . name = from . name = routes [ routes . length - 1 ]
66
- store ? store . commit ( 'navigation/REFRESH' , { to, from} ) : null
66
+ store ? store . commit ( 'navigation/REFRESH' , { to, from } ) : null
67
67
bus . $emit ( 'refresh' , to , from )
68
68
}
69
69
const reset = ( ) => {
0 commit comments