index.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div v-if="routerView" class="app-main-container">
  3. <transition mode="out-in" name="fade-transform">
  4. <keep-alive :include="cachedRoutes" :max="keepAliveMaxNum">
  5. <router-view :key="key" class="app-main-height" />
  6. </keep-alive>
  7. </transition>
  8. <footer v-show="footerCopyright" class="footer-copyright">
  9. Copyright
  10. <vab-icon :icon="['fas', 'copyright']"></vab-icon>
  11. syjy-in-cloud
  12. </footer>
  13. </div>
  14. </template>
  15. <script>
  16. import { mapActions, mapGetters } from 'vuex'
  17. import { copyright, footerCopyright, keepAliveMaxNum, title } from '@/config'
  18. export default {
  19. name: 'VabAppMain',
  20. data() {
  21. return {
  22. show: false,
  23. fullYear: new Date().getFullYear(),
  24. copyright,
  25. title,
  26. keepAliveMaxNum,
  27. routerView: true,
  28. footerCopyright,
  29. }
  30. },
  31. computed: {
  32. ...mapGetters({
  33. visitedRoutes: 'tabsBar/visitedRoutes',
  34. device: 'settings/device',
  35. }),
  36. cachedRoutes() {
  37. const cachedRoutesArr = []
  38. this.visitedRoutes.forEach((item) => {
  39. if (!item.meta.noKeepAlive) {
  40. cachedRoutesArr.push(item.name)
  41. }
  42. })
  43. return cachedRoutesArr
  44. },
  45. key() {
  46. return this.$route.path
  47. },
  48. },
  49. watch: {
  50. $route: {
  51. handler(route) {
  52. if ('mobile' === this.device) this.foldSideBar()
  53. },
  54. immediate: true,
  55. },
  56. },
  57. created() {
  58. //重载所有路由
  59. this.$baseEventBus.$on('reload-router-view', () => {
  60. this.routerView = false
  61. this.$nextTick(() => {
  62. this.routerView = true
  63. })
  64. })
  65. },
  66. mounted() {},
  67. methods: {
  68. ...mapActions({
  69. foldSideBar: 'settings/foldSideBar',
  70. }),
  71. },
  72. }
  73. </script>
  74. <style lang="scss" scoped>
  75. .app-main-container {
  76. position: relative;
  77. width: 100%;
  78. overflow: hidden;
  79. .vab-keel {
  80. margin: $base-padding;
  81. }
  82. .app-main-height {
  83. min-height: $base-app-main-height;
  84. }
  85. .footer-copyright {
  86. min-height: 55px;
  87. line-height: 55px;
  88. color: rgba(0, 0, 0, 0.45);
  89. text-align: center;
  90. border-top: 1px dashed $base-border-color;
  91. }
  92. }
  93. </style>