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,43 +53,41 @@ 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
- let itemAny = item as any ;
70
- if ( itemAny . permission !== undefined ) {
71
- let childrenArr = [ ] ;
72
- childrenArr = itemAny . children . filter ( child => {
73
- let childany = child as any ;
74
- if ( childany . permission !== undefined ) {
75
- if ( Util . abp . auth . hasPermission ( childany . permission ) ) {
69
+ if ( item . permission !== undefined ) {
70
+ let hasPermissionMenuArr : Array < Router > = [ ] ;
71
+ hasPermissionMenuArr = item . children . filter ( child => {
72
+ if ( child . permission !== undefined ) {
73
+ if ( Util . abp . auth . hasPermission ( child . permission ) ) {
76
74
return child ;
77
- }
75
+ }
78
76
} else {
79
77
return child ;
80
78
}
81
79
} ) ;
82
- if ( childrenArr . length > 0 ) {
83
- item . children = childrenArr ;
80
+ if ( hasPermissionMenuArr . length > 0 ) {
81
+ item . children = hasPermissionMenuArr ;
84
82
menuList . push ( item ) ;
85
- }
83
+ }
86
84
} else {
87
- if ( itemAny . children . length === 1 ) {
85
+ if ( item . children . length === 1 ) {
88
86
menuList . push ( item ) ;
89
87
} else {
90
88
let len = menuList . push ( item ) ;
91
89
let childrenArr = [ ] ;
92
- childrenArr = itemAny . children . filter ( child => {
90
+ childrenArr = item . children . filter ( child => {
93
91
return child ;
94
92
} ) ;
95
93
let handledItem = JSON . parse ( JSON . stringify ( menuList [ len - 1 ] ) ) ;
@@ -100,13 +98,13 @@ class AppModule implements Module<AppState,any>{
100
98
} ) ;
101
99
state . menuList = menuList ;
102
100
} ,
103
- changeMenuTheme ( state :AppState , theme :string ) {
101
+ changeMenuTheme ( state : AppState , theme : string ) {
104
102
state . menuTheme = theme ;
105
103
} ,
106
- changeMainTheme ( state :AppState , mainTheme :string ) {
104
+ changeMainTheme ( state : AppState , mainTheme : string ) {
107
105
state . themeColor = mainTheme ;
108
106
} ,
109
- addOpenSubmenu ( state :AppState , name :any ) {
107
+ addOpenSubmenu ( state : AppState , name : any ) {
110
108
let hasThisName = false ;
111
109
let isEmpty = false ;
112
110
if ( name . length === 0 ) {
@@ -119,26 +117,26 @@ class AppModule implements Module<AppState,any>{
119
117
state . openedSubmenuArr . push ( name ) ;
120
118
}
121
119
} ,
122
- closePage ( state :AppState , name :any ) {
120
+ closePage ( state : AppState , name : any ) {
123
121
state . cachePage . forEach ( ( item , index ) => {
124
122
if ( item === name ) {
125
123
state . cachePage . splice ( index , 1 ) ;
126
124
}
127
125
} ) ;
128
126
} ,
129
- initCachepage ( state :AppState ) {
127
+ initCachepage ( state : AppState ) {
130
128
if ( localStorage . cachePage ) {
131
129
state . cachePage = JSON . parse ( localStorage . cachePage ) ;
132
130
}
133
131
} ,
134
- removeTag ( state :AppState , name :string ) {
132
+ removeTag ( state : AppState , name : string ) {
135
133
state . pageOpenedList . map ( ( item , index ) => {
136
134
if ( item . name === name ) {
137
135
state . pageOpenedList . splice ( index , 1 ) ;
138
136
}
139
137
} ) ;
140
138
} ,
141
- pageOpenedList ( state :AppState , get :any ) {
139
+ pageOpenedList ( state : AppState , get : any ) {
142
140
let openedPage = state . pageOpenedList [ get . index ] ;
143
141
if ( get . argu ) {
144
142
openedPage . argu = get . argu ;
@@ -149,12 +147,12 @@ class AppModule implements Module<AppState,any>{
149
147
state . pageOpenedList . splice ( get . index , 1 , openedPage ) ;
150
148
localStorage . pageOpenedList = JSON . stringify ( state . pageOpenedList ) ;
151
149
} ,
152
- clearAllTags ( state :AppState ) {
150
+ clearAllTags ( state : AppState ) {
153
151
state . pageOpenedList . splice ( 1 ) ;
154
152
state . cachePage . length = 0 ;
155
153
localStorage . pageOpenedList = JSON . stringify ( state . pageOpenedList ) ;
156
154
} ,
157
- clearOtherTags ( state :AppState , vm :Vue ) {
155
+ clearOtherTags ( state : AppState , vm : Vue ) {
158
156
let currentName = vm . $route . name ;
159
157
let currentIndex = 0 ;
160
158
state . pageOpenedList . forEach ( ( item , index ) => {
@@ -174,34 +172,34 @@ class AppModule implements Module<AppState,any>{
174
172
state . cachePage = newCachepage ;
175
173
localStorage . pageOpenedList = JSON . stringify ( state . pageOpenedList ) ;
176
174
} ,
177
- setOpenedList ( state :AppState ) {
175
+ setOpenedList ( state : AppState ) {
178
176
state . pageOpenedList = localStorage . pageOpenedList ? JSON . parse ( localStorage . pageOpenedList ) : [ otherRouters . children [ 0 ] ] ;
179
177
} ,
180
- setCurrentPath ( state :AppState , pathArr :Array < any > ) {
178
+ setCurrentPath ( state : AppState , pathArr : Array < any > ) {
181
179
state . currentPath = pathArr ;
182
180
} ,
183
- setCurrentPageName ( state :AppState , name :string ) {
181
+ setCurrentPageName ( state : AppState , name : string ) {
184
182
state . currentPageName = name ;
185
183
} ,
186
- clearOpenedSubmenu ( state :AppState ) {
184
+ clearOpenedSubmenu ( state : AppState ) {
187
185
state . openedSubmenuArr . length = 0 ;
188
186
} ,
189
- increateTag ( state :AppState , tagObj :any ) {
187
+ increateTag ( state : AppState , tagObj : any ) {
190
188
if ( ! Util . oneOf ( tagObj . name , state . dontCache ) ) {
191
189
state . cachePage . push ( tagObj . name ) ;
192
190
localStorage . cachePage = JSON . stringify ( state . cachePage ) ;
193
191
}
194
192
state . pageOpenedList . push ( tagObj ) ;
195
193
}
196
194
}
197
- actions = {
198
- async login ( content :ActionContext < AppState , any > , payload :any ) {
199
- 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 ) ;
200
198
var tokenExpireDate = payload . data . rememberMe ? ( new Date ( new Date ( ) . getTime ( ) + 1000 * rep . data . result . expireInSeconds ) ) : undefined ;
201
- Util . abp . auth . setToken ( rep . data . result . accessToken , tokenExpireDate ) ;
202
- 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 )
203
201
} ,
204
202
}
205
203
}
206
- const appModule = new AppModule ( ) ;
204
+ const appModule = new AppModule ( ) ;
207
205
export default appModule ;
0 commit comments