index.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <section 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. xxx-项目 {{ fullYear }}
  12. </footer>
  13. </section>
  14. </template>
  15. <script>
  16. import { VabKeel, VabKeelHeading, VabKeelText } from "@/plugins/vabKeel";
  17. import { mapActions, mapGetters } from "vuex";
  18. import {
  19. copyright,
  20. footerCopyright,
  21. keepAliveMaxNum,
  22. title,
  23. } from "@/config/settings";
  24. export default {
  25. name: "AppMain",
  26. data() {
  27. return {
  28. show: false,
  29. fullYear: new Date().getFullYear(),
  30. copyright,
  31. title,
  32. keepAliveMaxNum,
  33. routerView: true,
  34. footerCopyright,
  35. };
  36. },
  37. computed: {
  38. ...mapGetters({
  39. visitedRoutes: "tabsBar/visitedRoutes",
  40. device: "settings/device",
  41. }),
  42. cachedRoutes() {
  43. const cachedRoutesArr = [];
  44. this.visitedRoutes.forEach((item) => {
  45. if (!item.meta.noKeepAlive) {
  46. cachedRoutesArr.push(item.name);
  47. }
  48. });
  49. return cachedRoutesArr;
  50. },
  51. key() {
  52. return this.$route.path;
  53. },
  54. },
  55. watch: {
  56. $route: {
  57. handler(route) {
  58. if ("mobile" === this.device) this.foldSideBar();
  59. },
  60. immediate: true,
  61. },
  62. },
  63. created() {
  64. //重载所有路由
  65. this.$baseEventBus.$on("reload-routerview", () => {
  66. this.routerView = false;
  67. this.$nextTick(() => {
  68. this.routerView = true;
  69. });
  70. });
  71. },
  72. mounted() {},
  73. methods: {
  74. ...mapActions({
  75. foldSideBar: "settings/foldSideBar",
  76. }),
  77. },
  78. };
  79. </script>
  80. <style lang="scss" scoped>
  81. .app-main-container {
  82. position: relative;
  83. width: 100%;
  84. overflow: hidden;
  85. .vab-keel {
  86. margin: $base-padding;
  87. }
  88. .app-main-height {
  89. min-height: $base-app-main-height;
  90. }
  91. .footer-copyright {
  92. min-height: 55px;
  93. line-height: 55px;
  94. color: rgba(0, 0, 0, 0.45);
  95. text-align: center;
  96. border-top: 1px dashed $base-border-color;
  97. }
  98. }
  99. </style>