AppMain.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template>
  2. <section class="app-main" :style="{'margin': appMargin}">
  3. <router-view :key="key" v-slot="{ Component }">
  4. <transition appear name="fade-transform" mode="out-in">
  5. <keep-alive>
  6. <component :is="Component" />
  7. </keep-alive>
  8. </transition>
  9. </router-view>
  10. </section>
  11. </template>
  12. <script>
  13. import { computed, defineComponent } from "vue";
  14. import { useRoute } from "vue-router";
  15. import { deviceDetection } from "../../utils/deviceDetection";
  16. export default defineComponent({
  17. name: "AppMain",
  18. setup() {
  19. const route = useRoute();
  20. const key = computed(() => route.path);
  21. const appMargin = computed(() => (deviceDetection() ? 0 : "10px"));
  22. return { key, appMargin };
  23. },
  24. });
  25. </script>
  26. <style scoped>
  27. .app-main {
  28. min-height: calc(100vh - 70px);
  29. width: 100%;
  30. position: relative;
  31. overflow-x: hidden;
  32. }
  33. .fixed-header + .app-main {
  34. padding-top: 50px;
  35. }
  36. </style>
  37. <style lang="scss">
  38. .el-popup-parent--hidden {
  39. .fixed-header {
  40. padding-right: 15px;
  41. }
  42. }
  43. </style>