AppMain.vue 2.1 KB

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