MainLayout.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <q-layout class="relative" view="hHh lpR fFf">
  3. <LeftMenuLayout v-if="!$q.screen.lt.sm" />
  4. <LeftMenuLayoutMobile v-else v-model="leftDrawerOpen" />
  5. <q-header v-if="$q.screen.lt.sm" class="bg-transparent q-pa-sm">
  6. <q-toolbar
  7. class="flex justify-between bg-surface"
  8. style="border-radius: 6px !important"
  9. >
  10. <q-btn dense flat @click="toggleLeftDrawer">
  11. <q-icon
  12. name="menu"
  13. color="black"
  14. style="font-size: 20px"
  15. />
  16. </q-btn>
  17. <div>
  18. <q-btn dense flat @click="logoutFn">
  19. <q-icon name="logout" color="negative" style="font-size: 20px" />
  20. </q-btn>
  21. </div>
  22. </q-toolbar>
  23. </q-header>
  24. <q-page-container>
  25. <q-page>
  26. <q-scroll-area
  27. ref="scrollAreaRef"
  28. :style="
  29. $q.screen.lt.sm
  30. ? 'height: calc(100dvh - 68px - env(safe-area-inset-top)) !important;'
  31. : 'height: calc(100dvh - env(safe-area-inset-top)) !important;'
  32. "
  33. >
  34. <router-view v-slot="{ Component }">
  35. <Transition mode="out-in">
  36. <component
  37. :is="Component"
  38. style="padding: 20px !important; padding-right: 10px !important"
  39. :style="$q.screen.lt.sm ? 'padding-left: 10px !important;' : ''"
  40. />
  41. </Transition>
  42. </router-view>
  43. </q-scroll-area>
  44. </q-page>
  45. </q-page-container>
  46. </q-layout>
  47. </template>
  48. <script setup>
  49. import { ref, useTemplateRef, watch } from "vue";
  50. import { useRoute, useRouter } from "vue-router";
  51. import { useAuth } from "src/composables/useAuth";
  52. import { useQuasar } from "quasar";
  53. import LeftMenuLayout from "src/components/layout/LeftMenuLayout.vue";
  54. import LeftMenuLayoutMobile from "src/components/layout/LeftMenuLayoutMobile.vue";
  55. const router = useRouter();
  56. const { logout } = useAuth();
  57. const route = useRoute();
  58. const $q = useQuasar();
  59. const leftDrawerOpen = ref(false);
  60. const scrollAreaRef = useTemplateRef("scrollAreaRef");
  61. let oldValue = route.path;
  62. const logoutFn = async () => {
  63. await logout();
  64. router.push({ name: "LoginPage" });
  65. };
  66. const toggleLeftDrawer = () => {
  67. leftDrawerOpen.value = !leftDrawerOpen.value;
  68. };
  69. watch(route, (value) => {
  70. if (oldValue.path != value.path) {
  71. scrollAreaRef.value.setScrollPosition("vertical", 0, 0);
  72. scrollAreaRef.value.setScrollPosition("horizontal", 0, 0);
  73. }
  74. oldValue = value.path;
  75. });
  76. </script>
  77. <style scoped>
  78. .v-enter-active {
  79. opacity: 1;
  80. transition: all 0.15s ease-in;
  81. }
  82. .v-leave-active {
  83. opacity: 1;
  84. transition: all 0.15s ease-out;
  85. }
  86. .v-enter-from,
  87. .v-leave-to {
  88. opacity: 0;
  89. transition: all 0.15s ease-in;
  90. }
  91. .v-leave-to {
  92. transition: all 0.15s ease-out;
  93. }
  94. </style>