Skip to content

Commit

Permalink
chore: optimize the code of caching tabs;
Browse files Browse the repository at this point in the history
  • Loading branch information
iczer committed Sep 26, 2020
1 parent bad4456 commit 435b2ff
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/layouts/tabs/TabsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,17 @@ export default {
* 加载缓存的 tabs
*/
loadCachedTabs() {
const cachedTabs = sessionStorage.getItem(process.env.VUE_APP_TBAS_KEY)
if (cachedTabs) {
const cachedTabsStr = sessionStorage.getItem(process.env.VUE_APP_TBAS_KEY)
if (cachedTabsStr) {
try {
const tabs = JSON.parse(cachedTabs)
if (tabs.length > 0) {
this.pageList = tabs
const cachedTabs = JSON.parse(cachedTabsStr)
if (cachedTabs.length > 0) {
this.pageList = cachedTabs
}
sessionStorage.removeItem(process.env.VUE_APP_TBAS_KEY)
} catch (e) {
console.warn('failed to load cached tabs, got exception:', e)
} finally {
sessionStorage.removeItem(process.env.VUE_APP_TBAS_KEY)
}
}
},
Expand Down

0 comments on commit 435b2ff

Please sign in to comment.