chore: optimize the code of caching tabs;

master
chenghongxing 4 years ago
parent bad44562e7
commit 435b2ff585
  1. 13
      src/layouts/tabs/TabsView.vue

@ -228,16 +228,17 @@ export default {
* 加载缓存的 tabs * 加载缓存的 tabs
*/ */
loadCachedTabs() { loadCachedTabs() {
const cachedTabs = sessionStorage.getItem(process.env.VUE_APP_TBAS_KEY) const cachedTabsStr = sessionStorage.getItem(process.env.VUE_APP_TBAS_KEY)
if (cachedTabs) { if (cachedTabsStr) {
try { try {
const tabs = JSON.parse(cachedTabs) const cachedTabs = JSON.parse(cachedTabsStr)
if (tabs.length > 0) { if (cachedTabs.length > 0) {
this.pageList = tabs this.pageList = cachedTabs
} }
sessionStorage.removeItem(process.env.VUE_APP_TBAS_KEY)
} catch (e) { } catch (e) {
console.warn('failed to load cached tabs, got exception:', e) console.warn('failed to load cached tabs, got exception:', e)
} finally {
sessionStorage.removeItem(process.env.VUE_APP_TBAS_KEY)
} }
} }
}, },

Loading…
Cancel
Save