1- import { appRouters , otherRouters } from '../../router/router'
1+ import { appRouters , otherRouters } from '../../router/router'
22import Util from '../../lib/util' ;
33import Vue from 'vue' ;
4- import { Store , Module , ActionContext } from 'vuex'
4+ import { Store , Module , ActionContext } from 'vuex'
55import Vuex from 'vuex' ;
6- import ajax from '../../lib/ajax'
6+ import ajax from '../../lib/ajax'
77import appconst from '../../lib/appconst'
88Vue . use ( Vuex ) ;
9- interface AppState {
10- cachePage :Array < any > ;
11- lang :string ;
9+ interface AppState {
10+ cachePage : Array < any > ;
11+ lang : string ;
1212 isFullScreen : boolean ;
1313 openedSubmenuArr : Array < any > ;
1414 menuTheme : string ;
1515 themeColor : string ,
16- pageOpenedList :Array < any > ;
16+ pageOpenedList : Array < any > ;
1717 currentPageName : string ;
18- currentPath :Array < any > ;
18+ currentPath : Array < any > ;
1919 menuList : Array < any > ;
20- routers :Array < any > ;
20+ routers : Array < any > ;
2121 tagsList : Array < any > ;
2222 messageCount : number ;
23- dontCache :Array < any > ;
24- noticeList :Array < any > ;
23+ dontCache : Array < any > ;
24+ noticeList : Array < any > ;
2525}
26- class AppModule implements Module < AppState , any > {
27- namespaced = true ;
28- state = {
26+ class AppModule implements Module < AppState , any > {
27+ namespaced = true ;
28+ state = {
2929 cachePage : [ ] ,
3030 lang : '' ,
3131 isFullScreen : false ,
32- openedSubmenuArr : [ ] ,
32+ openedSubmenuArr : [ ] ,
3333 menuTheme : 'dark' ,
3434 themeColor : '' ,
3535 pageOpenedList : [ {
36- meta :{ title : 'HomePage' } ,
36+ meta : { title : 'HomePage' } ,
3737 path : '' ,
3838 name : 'home'
3939 } ] ,
4040 currentPageName : '' ,
4141 currentPath : [
4242 {
43- meta :{ title : 'HomePage' } ,
43+ meta : { title : 'HomePage' } ,
4444 path : '' ,
4545 name : 'home'
4646 }
@@ -53,43 +53,41 @@ class AppModule implements Module<AppState,any>{
5353 tagsList : [ ...otherRouters . children ] ,
5454 messageCount : 0 ,
5555 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' } ]
5757 } ;
58- mutations = {
59- logout ( state :AppState ) {
58+ mutations = {
59+ logout ( state : AppState ) {
6060 localStorage . clear ( ) ;
6161 sessionStorage . clear ( ) ;
6262 } ,
63- setTagsList ( state :AppState , list :Array < any > ) {
63+ setTagsList ( state : AppState , list : Array < any > ) {
6464 state . tagsList . push ( ...list ) ;
6565 } ,
66- updateMenulist ( state :AppState ) {
67- let menuList :Array < any > = [ ] ;
66+ updateMenulist ( state : AppState ) {
67+ let menuList : Array < Router > = [ ] ;
6868 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 ) ) {
7674 return child ;
77- }
75+ }
7876 } else {
7977 return child ;
8078 }
8179 } ) ;
82- if ( childrenArr . length > 0 ) {
83- item . children = childrenArr ;
80+ if ( hasPermissionMenuArr . length > 0 ) {
81+ item . children = hasPermissionMenuArr ;
8482 menuList . push ( item ) ;
85- }
83+ }
8684 } else {
87- if ( itemAny . children . length === 1 ) {
85+ if ( item . children . length === 1 ) {
8886 menuList . push ( item ) ;
8987 } else {
9088 let len = menuList . push ( item ) ;
9189 let childrenArr = [ ] ;
92- childrenArr = itemAny . children . filter ( child => {
90+ childrenArr = item . children . filter ( child => {
9391 return child ;
9492 } ) ;
9593 let handledItem = JSON . parse ( JSON . stringify ( menuList [ len - 1 ] ) ) ;
@@ -100,13 +98,13 @@ class AppModule implements Module<AppState,any>{
10098 } ) ;
10199 state . menuList = menuList ;
102100 } ,
103- changeMenuTheme ( state :AppState , theme :string ) {
101+ changeMenuTheme ( state : AppState , theme : string ) {
104102 state . menuTheme = theme ;
105103 } ,
106- changeMainTheme ( state :AppState , mainTheme :string ) {
104+ changeMainTheme ( state : AppState , mainTheme : string ) {
107105 state . themeColor = mainTheme ;
108106 } ,
109- addOpenSubmenu ( state :AppState , name :any ) {
107+ addOpenSubmenu ( state : AppState , name : any ) {
110108 let hasThisName = false ;
111109 let isEmpty = false ;
112110 if ( name . length === 0 ) {
@@ -119,26 +117,26 @@ class AppModule implements Module<AppState,any>{
119117 state . openedSubmenuArr . push ( name ) ;
120118 }
121119 } ,
122- closePage ( state :AppState , name :any ) {
120+ closePage ( state : AppState , name : any ) {
123121 state . cachePage . forEach ( ( item , index ) => {
124122 if ( item === name ) {
125123 state . cachePage . splice ( index , 1 ) ;
126124 }
127125 } ) ;
128126 } ,
129- initCachepage ( state :AppState ) {
127+ initCachepage ( state : AppState ) {
130128 if ( localStorage . cachePage ) {
131129 state . cachePage = JSON . parse ( localStorage . cachePage ) ;
132130 }
133131 } ,
134- removeTag ( state :AppState , name :string ) {
132+ removeTag ( state : AppState , name : string ) {
135133 state . pageOpenedList . map ( ( item , index ) => {
136134 if ( item . name === name ) {
137135 state . pageOpenedList . splice ( index , 1 ) ;
138136 }
139137 } ) ;
140138 } ,
141- pageOpenedList ( state :AppState , get :any ) {
139+ pageOpenedList ( state : AppState , get : any ) {
142140 let openedPage = state . pageOpenedList [ get . index ] ;
143141 if ( get . argu ) {
144142 openedPage . argu = get . argu ;
@@ -149,12 +147,12 @@ class AppModule implements Module<AppState,any>{
149147 state . pageOpenedList . splice ( get . index , 1 , openedPage ) ;
150148 localStorage . pageOpenedList = JSON . stringify ( state . pageOpenedList ) ;
151149 } ,
152- clearAllTags ( state :AppState ) {
150+ clearAllTags ( state : AppState ) {
153151 state . pageOpenedList . splice ( 1 ) ;
154152 state . cachePage . length = 0 ;
155153 localStorage . pageOpenedList = JSON . stringify ( state . pageOpenedList ) ;
156154 } ,
157- clearOtherTags ( state :AppState , vm :Vue ) {
155+ clearOtherTags ( state : AppState , vm : Vue ) {
158156 let currentName = vm . $route . name ;
159157 let currentIndex = 0 ;
160158 state . pageOpenedList . forEach ( ( item , index ) => {
@@ -174,34 +172,34 @@ class AppModule implements Module<AppState,any>{
174172 state . cachePage = newCachepage ;
175173 localStorage . pageOpenedList = JSON . stringify ( state . pageOpenedList ) ;
176174 } ,
177- setOpenedList ( state :AppState ) {
175+ setOpenedList ( state : AppState ) {
178176 state . pageOpenedList = localStorage . pageOpenedList ? JSON . parse ( localStorage . pageOpenedList ) : [ otherRouters . children [ 0 ] ] ;
179177 } ,
180- setCurrentPath ( state :AppState , pathArr :Array < any > ) {
178+ setCurrentPath ( state : AppState , pathArr : Array < any > ) {
181179 state . currentPath = pathArr ;
182180 } ,
183- setCurrentPageName ( state :AppState , name :string ) {
181+ setCurrentPageName ( state : AppState , name : string ) {
184182 state . currentPageName = name ;
185183 } ,
186- clearOpenedSubmenu ( state :AppState ) {
184+ clearOpenedSubmenu ( state : AppState ) {
187185 state . openedSubmenuArr . length = 0 ;
188186 } ,
189- increateTag ( state :AppState , tagObj :any ) {
187+ increateTag ( state : AppState , tagObj : any ) {
190188 if ( ! Util . oneOf ( tagObj . name , state . dontCache ) ) {
191189 state . cachePage . push ( tagObj . name ) ;
192190 localStorage . cachePage = JSON . stringify ( state . cachePage ) ;
193191 }
194192 state . pageOpenedList . push ( tagObj ) ;
195193 }
196194 }
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 ) ;
200198 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 )
203201 } ,
204202 }
205203}
206- const appModule = new AppModule ( ) ;
204+ const appModule = new AppModule ( ) ;
207205export default appModule ;
0 commit comments