AppMain.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <section class="app-main">
  3. <router-view v-slot="{ Component, route }">
  4. <transition v-if="!route.meta.noCache" :enter-active-class="animante" mode="out-in">
  5. <keep-alive v-if="!route.meta.noCache" :include="tagsViewStore.cachedViews">
  6. <component :is="Component" v-if="!route.meta.link" :key="route.path" />
  7. </keep-alive>
  8. </transition>
  9. <transition v-if="route.meta.noCache" :enter-active-class="animante" mode="out-in">
  10. <component :is="Component" v-if="!route.meta.link && route.meta.noCache" :key="route.path" />
  11. </transition>
  12. </router-view>
  13. <iframe-toggle />
  14. </section>
  15. </template>
  16. <script setup name="AppMain" lang="ts">
  17. import useSettingsStore from '@/store/modules/settings';
  18. import useTagsViewStore from '@/store/modules/tagsView';
  19. import IframeToggle from './IframeToggle/index.vue';
  20. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  21. const route = useRoute();
  22. const tagsViewStore = useTagsViewStore();
  23. // 随机动画集合
  24. const animante = ref<string>('');
  25. const animationEnable = ref(useSettingsStore().animationEnable);
  26. watch(
  27. () => useSettingsStore().animationEnable,
  28. (val: boolean) => {
  29. animationEnable.value = val;
  30. if (val) {
  31. animante.value = proxy?.animate.animateList[Math.round(Math.random() * proxy?.animate.animateList.length)] as string;
  32. } else {
  33. animante.value = proxy?.animate.defaultAnimate as string;
  34. }
  35. },
  36. { immediate: true }
  37. );
  38. onMounted(() => {
  39. addIframe()
  40. })
  41. watchEffect((route) => {
  42. addIframe()
  43. })
  44. function addIframe() {
  45. if (route.meta.link) {
  46. useTagsViewStore().addIframeView(route)
  47. }
  48. }
  49. </script>
  50. <style lang="scss" scoped>
  51. .app-main {
  52. /* 50= navbar 50 */
  53. min-height: calc(100vh - 50px);
  54. width: 100%;
  55. position: relative;
  56. overflow: hidden;
  57. }
  58. .fixed-header + .app-main {
  59. padding-top: 50px;
  60. }
  61. .hasTagsView {
  62. .app-main {
  63. /* 84 = navbar + tags-view = 50 + 34 */
  64. min-height: calc(100vh - 84px);
  65. }
  66. .fixed-header + .app-main {
  67. padding-top: 84px;
  68. }
  69. }
  70. </style>
  71. <style lang="scss">
  72. // fix css style bug in open el-dialog
  73. .el-popup-parent--hidden {
  74. .fixed-header {
  75. padding-right: 6px;
  76. }
  77. }
  78. ::-webkit-scrollbar {
  79. width: 6px;
  80. height: 6px;
  81. }
  82. ::-webkit-scrollbar-track {
  83. background-color: #f1f1f1;
  84. }
  85. ::-webkit-scrollbar-thumb {
  86. background-color: #c0c0c0;
  87. border-radius: 3px;
  88. }
  89. </style>