refactor:add keep-alive && component add name
This commit is contained in:
		@@ -1,6 +1,7 @@
 | 
			
		||||
const getters = {
 | 
			
		||||
  sidebar: state => state.app.sidebar,
 | 
			
		||||
  visitedViews: state => state.app.visitedViews,
 | 
			
		||||
  cachedViews: state => state.app.cachedViews,
 | 
			
		||||
  token: state => state.user.token,
 | 
			
		||||
  avatar: state => state.user.avatar,
 | 
			
		||||
  name: state => state.user.name,
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,8 @@ const app = {
 | 
			
		||||
    sidebar: {
 | 
			
		||||
      opened: !+Cookies.get('sidebarStatus')
 | 
			
		||||
    },
 | 
			
		||||
    visitedViews: []
 | 
			
		||||
    visitedViews: [],
 | 
			
		||||
    cachedViews: []
 | 
			
		||||
  },
 | 
			
		||||
  mutations: {
 | 
			
		||||
    TOGGLE_SIDEBAR: state => {
 | 
			
		||||
@@ -18,17 +19,28 @@ const app = {
 | 
			
		||||
    },
 | 
			
		||||
    ADD_VISITED_VIEWS: (state, view) => {
 | 
			
		||||
      if (state.visitedViews.some(v => v.path === view.path)) return
 | 
			
		||||
      state.visitedViews.push({ name: view.name, path: view.path })
 | 
			
		||||
      state.visitedViews.push({
 | 
			
		||||
        name: view.name,
 | 
			
		||||
        path: view.path
 | 
			
		||||
      })
 | 
			
		||||
      if (!view.meta.noCache) {
 | 
			
		||||
        state.cachedViews.push(view.name)
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    DEL_VISITED_VIEWS: (state, view) => {
 | 
			
		||||
      let index
 | 
			
		||||
      for (const [i, v] of state.visitedViews.entries()) {
 | 
			
		||||
        if (v.path === view.path) {
 | 
			
		||||
          index = i
 | 
			
		||||
          state.visitedViews.splice(i, 1)
 | 
			
		||||
          break
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      for (const i of state.cachedViews) {
 | 
			
		||||
        if (i === view.name) {
 | 
			
		||||
          const index = state.cachedViews.indexOf(i)
 | 
			
		||||
          state.cachedViews.splice(index, 1)
 | 
			
		||||
          break
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      state.visitedViews.splice(index, 1)
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  actions: {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user