@@ -19,7 +19,7 @@ import Cookies from 'js-cookie'
1919import Vue from 'vue'
2020import md5 from 'md5'
2121import { login , logout , api } from '@/api'
22- import { ACCESS_TOKEN , CURRENT_PROJECT , DEFAULT_THEME , ASYNC_JOB_IDS } from '@/store/mutation-types'
22+ import { ACCESS_TOKEN , CURRENT_PROJECT , DEFAULT_THEME , APIS , ASYNC_JOB_IDS } from '@/store/mutation-types'
2323
2424const user = {
2525 state : {
@@ -54,6 +54,7 @@ const user = {
5454 } ,
5555 SET_APIS : ( state , apis ) => {
5656 state . apis = apis
57+ Vue . ls . set ( APIS , apis )
5758 } ,
5859 SET_FEATURES : ( state , features ) => {
5960 state . features = features
@@ -114,22 +115,29 @@ const user = {
114115
115116 GetInfo ( { commit } ) {
116117 return new Promise ( ( resolve , reject ) => {
117- api ( 'listApis' ) . then ( response => {
118- const apis = { }
119- const apiList = response . listapisresponse . api
120- for ( var idx = 0 ; idx < apiList . length ; idx ++ ) {
121- const api = apiList [ idx ]
122- const apiName = api . name
123- apis [ apiName ] = {
124- params : api . params ,
125- response : api . response
118+ const cachedApis = Vue . ls . get ( APIS , { } )
119+ if ( Object . keys ( cachedApis ) . length > 0 ) {
120+ console . log ( 'Login detected, using cached APIs' )
121+ commit ( 'SET_APIS' , cachedApis )
122+ resolve ( cachedApis )
123+ } else {
124+ api ( 'listApis' ) . then ( response => {
125+ const apis = { }
126+ const apiList = response . listapisresponse . api
127+ for ( var idx = 0 ; idx < apiList . length ; idx ++ ) {
128+ const api = apiList [ idx ]
129+ const apiName = api . name
130+ apis [ apiName ] = {
131+ params : api . params ,
132+ response : api . response
133+ }
126134 }
127- }
128- commit ( 'SET_APIS' , apis )
129- resolve ( apis )
130- } ) . catch ( error => {
131- reject ( error )
132- } )
135+ commit ( 'SET_APIS' , apis )
136+ resolve ( apis )
137+ } ) . catch ( error => {
138+ reject ( error )
139+ } )
140+ }
133141
134142 api ( 'listUsers' ) . then ( response => {
135143 const result = response . listusersresponse . user [ 0 ]
0 commit comments