64b3b19eb4c370e80cfc37d4a6c2e9d3b937bcc2.svn-base 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <div class="main">
  3. <keep-alive :include="includedComponents">
  4. <router-view v-if="keepAlive" />
  5. </keep-alive>
  6. <router-view v-if="!keepAlive" />
  7. </div>
  8. </template>
  9. <script>
  10. import Vue from 'vue'
  11. import { CACHE_INCLUDED_ROUTES } from "@/store/mutation-types"
  12. export default {
  13. name: "RouteView",
  14. computed: {
  15. //update-begin--Author:scott Date:20201015 for:路由缓存问题,关闭了tab页时再打开就不刷新 #842
  16. includedComponents() {
  17. const includedRouters = Vue.ls.get(CACHE_INCLUDED_ROUTES)
  18. console.log("includedRouters:" + includedRouters)
  19. //如果是缓存路由,则加入到 cache_included_routes
  20. if (this.$route.meta.keepAlive && this.$route.meta.componentName) {
  21. let cacheRouterArray = Vue.ls.get(CACHE_INCLUDED_ROUTES) || []
  22. if(!cacheRouterArray.includes(this.$route.meta.componentName)){
  23. cacheRouterArray.push(this.$route.meta.componentName)
  24. // cacheRouterArray.push("OnlCgformHeadList")
  25. console.log("Vue ls set componentName :" + this.$route.meta.componentName)
  26. Vue.ls.set(CACHE_INCLUDED_ROUTES, cacheRouterArray)
  27. console.log("Vue ls includedRouterArrays :" + Vue.ls.get(CACHE_INCLUDED_ROUTES))
  28. return cacheRouterArray;
  29. }
  30. }
  31. return includedRouters;
  32. },
  33. //update-end--Author:scott Date:20201015 for:路由缓存问题,关闭了tab页时再打开就不刷新 #842
  34. keepAlive () {
  35. return this.$route.meta.keepAlive
  36. }
  37. },
  38. }
  39. </script>