keepAlive.js 667 B

12345678910111213141516171819202122232425262728293031323334
  1. export default {
  2. state: {
  3. keepLiveRoute: [],
  4. routeKey: null,
  5. routeShow: true
  6. },
  7. mutations: {
  8. pushKeepLive(state, component) {
  9. if (!state.keepLiveRoute.includes(component)) {
  10. state.keepLiveRoute.push(component)
  11. }
  12. },
  13. removeKeepLive(state, component) {
  14. var index = state.keepLiveRoute.indexOf(component);
  15. if (index !== -1) {
  16. state.keepLiveRoute.splice(index, 1);
  17. }
  18. },
  19. clearKeepLive(state) {
  20. state.keepLiveRoute = []
  21. },
  22. setRouteKey(state, key) {
  23. state.routeKey = key
  24. },
  25. setRouteShow(state, key) {
  26. state.routeShow = key
  27. }
  28. },
  29. actions: {
  30. setRouteKey({ commit }, key) {
  31. commit('setRouteKey', key);
  32. }
  33. }
  34. }