MainLayout.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <q-layout class="relative" view="hHh lpR fFf">
  3. <LeftMenuLayout v-model="leftDrawerOpen" />
  4. <q-page-container>
  5. <q-page
  6. >
  7. <q-scroll-area
  8. ref="scrollAreaRef"
  9. style="
  10. padding-top: 20px !important;
  11. margin-left: 20px !important;
  12. margin-right: 10px !important;
  13. height: calc(100dvh - 50px - env(safe-area-inset-top)) !important;
  14. "
  15. >
  16. <router-view v-slot="{ Component }">
  17. <Transition mode="out-in">
  18. <component :is="Component" />
  19. </Transition>
  20. </router-view>
  21. </q-scroll-area>
  22. </q-page>
  23. </q-page-container>
  24. </q-layout>
  25. </template>
  26. <script setup>
  27. import { ref, useTemplateRef, watch } from "vue";
  28. import { useRoute } from "vue-router";
  29. import LeftMenuLayout from "src/components/geral/LeftMenuLayout.vue";
  30. defineOptions({
  31. name: "MainLayout",
  32. });
  33. const leftDrawerOpen = ref(true);
  34. const scrollAreaRef = useTemplateRef("scrollAreaRef");
  35. const route = useRoute();
  36. let oldValue = route.path;
  37. watch(route, (value) => {
  38. if (oldValue.path != value.path) {
  39. scrollAreaRef.value.setScrollPosition("vertical", 0, 0);
  40. scrollAreaRef.value.setScrollPosition("horizontal", 0, 0);
  41. }
  42. oldValue = value.path;
  43. });
  44. </script>
  45. <style scoped>
  46. .v-enter-active {
  47. opacity: 1;
  48. transition: all 0.15s ease-in;
  49. }
  50. .v-leave-active {
  51. opacity: 1;
  52. transition: all 0.15s ease-out;
  53. }
  54. .v-enter-from,
  55. .v-leave-to {
  56. opacity: 0;
  57. transition: all 0.15s ease-in;
  58. }
  59. .v-leave-to {
  60. transition: all 0.15s ease-out;
  61. }
  62. </style>