1
- import { appRouters , otherRouters } from '../../router/router'
1
+ import { appRouters , otherRouters } from '../../router/router'
2
2
import Util from '../../lib/util' ;
3
3
import Vue from 'vue' ;
4
- import { Store , Module , ActionContext } from 'vuex'
4
+ import { Store , Module , ActionContext } from 'vuex'
5
5
import Vuex from 'vuex' ;
6
- import ajax from '../../lib/ajax'
6
+ import ajax from '../../lib/ajax'
7
7
import appconst from '../../lib/appconst'
8
8
Vue . use ( Vuex ) ;
9
- interface AppState {
10
- cachePage :Array < any > ;
11
- lang :string ;
9
+ interface AppState {
10
+ cachePage : Array < any > ;
11
+ lang : string ;
12
12
isFullScreen : boolean ;
13
13
openedSubmenuArr : Array < any > ;
14
14
menuTheme : string ;
15
15
themeColor : string ,
16
- pageOpenedList :Array < any > ;
16
+ pageOpenedList : Array < any > ;
17
17
currentPageName : string ;
18
- currentPath :Array < any > ;
18
+ currentPath : Array < any > ;
19
19
menuList : Array < any > ;
20
- routers :Array < any > ;
20
+ routers : Array < any > ;
21
21
tagsList : Array < any > ;
22
22
messageCount : number ;
23
- dontCache :Array < any > ;
24
- noticeList :Array < any > ;
23
+ dontCache : Array < any > ;
24
+ noticeList : Array < any > ;
25
25
}
26
- class AppModule implements Module < AppState , any > {
27
- namespaced = true ;
28
- state = {
26
+ class AppModule implements Module < AppState , any > {
27
+ namespaced = true ;
28
+ state = {
29
29
cachePage : [ ] ,
30
30
lang : '' ,
31
31
isFullScreen : false ,
32
- openedSubmenuArr : [ ] ,
32
+ openedSubmenuArr : [ ] ,
33
33
menuTheme : 'dark' ,
34
34
themeColor : '' ,
35
35
pageOpenedList : [ {
36
- meta :{ title : 'HomePage' } ,
36
+ meta : { title : 'HomePage' } ,
37
37
path : '' ,
38
38
name : 'home'
39
39
} ] ,
40
40
currentPageName : '' ,
41
41
currentPath : [
42
42
{
43
- meta :{ title : 'HomePage' } ,
43
+ meta : { title : 'HomePage' } ,
44
44
path : '' ,
45
45
name : 'home'
46
46
}
@@ -53,35 +53,34 @@ class AppModule implements Module<AppState,any>{
53
53
tagsList : [ ...otherRouters . children ] ,
54
54
messageCount : 0 ,
55
55
dontCache : [ ] ,
56
- noticeList :[ { read :false , type :0 , title :'First notice' , description :'One day ago' } , { read :false , type :1 } , { read :false , type :0 , title :'Second notice' , description :'One month ago' } ]
56
+ noticeList : [ { read : false , type : 0 , title : 'First notice' , description : 'One day ago' } , { read : false , type : 1 } , { read : false , type : 0 , title : 'Second notice' , description : 'One month ago' } ]
57
57
} ;
58
- mutations = {
59
- logout ( state :AppState ) {
58
+ mutations = {
59
+ logout ( state : AppState ) {
60
60
localStorage . clear ( ) ;
61
61
sessionStorage . clear ( ) ;
62
62
} ,
63
- setTagsList ( state :AppState , list :Array < any > ) {
63
+ setTagsList ( state : AppState , list : Array < any > ) {
64
64
state . tagsList . push ( ...list ) ;
65
65
} ,
66
- updateMenulist ( state :AppState ) {
67
- let menuList :Array < any > = [ ] ;
66
+ updateMenulist ( state : AppState ) {
67
+ let menuList : Array < Router > = [ ] ;
68
68
appRouters . forEach ( ( item , index ) => {
69
69
if ( item . permission !== undefined ) {
70
- let childrenArr = [ ] ;
71
- childrenArr = item . children . filter ( child => {
72
- let childany = child as any ;
73
- if ( childany . permission !== undefined ) {
74
- if ( Util . abp . auth . hasPermission ( childany . permission ) ) {
70
+ let hasPermissionMenuArr : Array < Router > = [ ] ;
71
+ hasPermissionMenuArr = item . children . filter ( child => {
72
+ if ( child . permission !== undefined ) {
73
+ if ( Util . abp . auth . hasPermission ( child . permission ) ) {
75
74
return child ;
76
- }
75
+ }
77
76
} else {
78
77
return child ;
79
78
}
80
79
} ) ;
81
- if ( childrenArr . length > 0 ) {
82
- item . children = childrenArr ;
80
+ if ( hasPermissionMenuArr . length > 0 ) {
81
+ item . children = hasPermissionMenuArr ;
83
82
menuList . push ( item ) ;
84
- }
83
+ }
85
84
} else {
86
85
if ( item . children . length === 1 ) {
87
86
menuList . push ( item ) ;
@@ -99,13 +98,13 @@ class AppModule implements Module<AppState,any>{
99
98
} ) ;
100
99
state . menuList = menuList ;
101
100
} ,
102
- changeMenuTheme ( state :AppState , theme :string ) {
101
+ changeMenuTheme ( state : AppState , theme : string ) {
103
102
state . menuTheme = theme ;
104
103
} ,
105
- changeMainTheme ( state :AppState , mainTheme :string ) {
104
+ changeMainTheme ( state : AppState , mainTheme : string ) {
106
105
state . themeColor = mainTheme ;
107
106
} ,
108
- addOpenSubmenu ( state :AppState , name :any ) {
107
+ addOpenSubmenu ( state : AppState , name : any ) {
109
108
let hasThisName = false ;
110
109
let isEmpty = false ;
111
110
if ( name . length === 0 ) {
@@ -118,26 +117,26 @@ class AppModule implements Module<AppState,any>{
118
117
state . openedSubmenuArr . push ( name ) ;
119
118
}
120
119
} ,
121
- closePage ( state :AppState , name :any ) {
120
+ closePage ( state : AppState , name : any ) {
122
121
state . cachePage . forEach ( ( item , index ) => {
123
122
if ( item === name ) {
124
123
state . cachePage . splice ( index , 1 ) ;
125
124
}
126
125
} ) ;
127
126
} ,
128
- initCachepage ( state :AppState ) {
127
+ initCachepage ( state : AppState ) {
129
128
if ( localStorage . cachePage ) {
130
129
state . cachePage = JSON . parse ( localStorage . cachePage ) ;
131
130
}
132
131
} ,
133
- removeTag ( state :AppState , name :string ) {
132
+ removeTag ( state : AppState , name : string ) {
134
133
state . pageOpenedList . map ( ( item , index ) => {
135
134
if ( item . name === name ) {
136
135
state . pageOpenedList . splice ( index , 1 ) ;
137
136
}
138
137
} ) ;
139
138
} ,
140
- pageOpenedList ( state :AppState , get :any ) {
139
+ pageOpenedList ( state : AppState , get : any ) {
141
140
let openedPage = state . pageOpenedList [ get . index ] ;
142
141
if ( get . argu ) {
143
142
openedPage . argu = get . argu ;
@@ -148,12 +147,12 @@ class AppModule implements Module<AppState,any>{
148
147
state . pageOpenedList . splice ( get . index , 1 , openedPage ) ;
149
148
localStorage . pageOpenedList = JSON . stringify ( state . pageOpenedList ) ;
150
149
} ,
151
- clearAllTags ( state :AppState ) {
150
+ clearAllTags ( state : AppState ) {
152
151
state . pageOpenedList . splice ( 1 ) ;
153
152
state . cachePage . length = 0 ;
154
153
localStorage . pageOpenedList = JSON . stringify ( state . pageOpenedList ) ;
155
154
} ,
156
- clearOtherTags ( state :AppState , vm :Vue ) {
155
+ clearOtherTags ( state : AppState , vm : Vue ) {
157
156
let currentName = vm . $route . name ;
158
157
let currentIndex = 0 ;
159
158
state . pageOpenedList . forEach ( ( item , index ) => {
@@ -173,34 +172,34 @@ class AppModule implements Module<AppState,any>{
173
172
state . cachePage = newCachepage ;
174
173
localStorage . pageOpenedList = JSON . stringify ( state . pageOpenedList ) ;
175
174
} ,
176
- setOpenedList ( state :AppState ) {
175
+ setOpenedList ( state : AppState ) {
177
176
state . pageOpenedList = localStorage . pageOpenedList ? JSON . parse ( localStorage . pageOpenedList ) : [ otherRouters . children [ 0 ] ] ;
178
177
} ,
179
- setCurrentPath ( state :AppState , pathArr :Array < any > ) {
178
+ setCurrentPath ( state : AppState , pathArr : Array < any > ) {
180
179
state . currentPath = pathArr ;
181
180
} ,
182
- setCurrentPageName ( state :AppState , name :string ) {
181
+ setCurrentPageName ( state : AppState , name : string ) {
183
182
state . currentPageName = name ;
184
183
} ,
185
- clearOpenedSubmenu ( state :AppState ) {
184
+ clearOpenedSubmenu ( state : AppState ) {
186
185
state . openedSubmenuArr . length = 0 ;
187
186
} ,
188
- increateTag ( state :AppState , tagObj :any ) {
187
+ increateTag ( state : AppState , tagObj : any ) {
189
188
if ( ! Util . oneOf ( tagObj . name , state . dontCache ) ) {
190
189
state . cachePage . push ( tagObj . name ) ;
191
190
localStorage . cachePage = JSON . stringify ( state . cachePage ) ;
192
191
}
193
192
state . pageOpenedList . push ( tagObj ) ;
194
193
}
195
194
}
196
- actions = {
197
- async login ( content :ActionContext < AppState , any > , payload :any ) {
198
- let rep = await ajax . post ( "/api/TokenAuth/Authenticate" , payload . data ) ;
195
+ actions = {
196
+ async login ( content : ActionContext < AppState , any > , payload : any ) {
197
+ let rep = await ajax . post ( "/api/TokenAuth/Authenticate" , payload . data ) ;
199
198
var tokenExpireDate = payload . data . rememberMe ? ( new Date ( new Date ( ) . getTime ( ) + 1000 * rep . data . result . expireInSeconds ) ) : undefined ;
200
- Util . abp . auth . setToken ( rep . data . result . accessToken , tokenExpireDate ) ;
201
- Util . abp . utils . setCookieValue ( appconst . authorization . encrptedAuthTokenName , rep . data . result . encryptedAccessToken , tokenExpireDate , Util . abp . appPath )
199
+ Util . abp . auth . setToken ( rep . data . result . accessToken , tokenExpireDate ) ;
200
+ Util . abp . utils . setCookieValue ( appconst . authorization . encrptedAuthTokenName , rep . data . result . encryptedAccessToken , tokenExpireDate , Util . abp . appPath )
202
201
} ,
203
202
}
204
203
}
205
- const appModule = new AppModule ( ) ;
204
+ const appModule = new AppModule ( ) ;
206
205
export default appModule ;
0 commit comments