LayoutPage.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { storeToRefs } from 'pinia'
  4. import { ref } from 'vue'
  5. import { useApplicationStore } from '#shared/stores/application.ts'
  6. import { useSessionStore } from '#shared/stores/session.ts'
  7. import LeftSidebarFooterMenu from '#desktop/components/layout/LayoutSidebar/LeftSidebar/LeftSidebarFooterMenu.vue'
  8. import LeftSidebarHeader from '#desktop/components/layout/LayoutSidebar/LeftSidebar/LeftSidebarHeader.vue'
  9. import LayoutSidebar from '#desktop/components/layout/LayoutSidebar.vue'
  10. import { numberOfPermanentItems } from '#desktop/components/PageNavigation/firstLevelRoutes.ts'
  11. import PageNavigation from '#desktop/components/PageNavigation/PageNavigation.vue'
  12. import UserTaskbarTabs from '#desktop/components/UserTaskbarTabs/UserTaskbarTabs.vue'
  13. import { useResizeGridColumns } from '#desktop/composables/useResizeGridColumns.ts'
  14. const { config } = storeToRefs(useApplicationStore())
  15. const noTransition = ref(false)
  16. const { userId } = useSessionStore()
  17. const storageKeyId = `${userId}-left`
  18. const {
  19. currentSidebarWidth,
  20. maxSidebarWidth,
  21. minSidebarWidth,
  22. gridColumns,
  23. collapseSidebar,
  24. resizeSidebar,
  25. expandSidebar,
  26. resetSidebarWidth,
  27. } = useResizeGridColumns(storageKeyId)
  28. </script>
  29. <template>
  30. <div
  31. class="grid h-full max-h-full overflow-y-clip duration-100"
  32. :class="{ 'transition-none': noTransition }"
  33. :style="gridColumns"
  34. >
  35. <LayoutSidebar
  36. id="main-sidebar"
  37. :name="storageKeyId"
  38. :aria-label="$t('Main sidebar')"
  39. :current-width="currentSidebarWidth"
  40. :max-width="maxSidebarWidth"
  41. :min-width="minSidebarWidth"
  42. :classes="{
  43. collapseButton: 'z-60',
  44. resizeLine: 'z-60',
  45. }"
  46. collapsible
  47. resizable
  48. no-scroll
  49. remember-collapse
  50. @collapse="collapseSidebar"
  51. @expand="expandSidebar"
  52. @resize-horizontal="resizeSidebar"
  53. @resize-horizontal-start="noTransition = true"
  54. @resize-horizontal-end="noTransition = false"
  55. @reset-width="resetSidebarWidth"
  56. >
  57. <template #default="{ isCollapsed }">
  58. <!-- TODO: Switch to `scheme-dark` utility once we upgrade to TW 4. -->
  59. <div
  60. class="flex h-full flex-col"
  61. data-theme="dark"
  62. style="color-scheme: dark"
  63. >
  64. <LeftSidebarHeader class="mb-2" :collapsed="isCollapsed" />
  65. <PageNavigation :collapsed="isCollapsed" />
  66. <UserTaskbarTabs :collapsed="isCollapsed" />
  67. <LeftSidebarFooterMenu :collapsed="isCollapsed" class="mt-auto" />
  68. </div>
  69. </template>
  70. </LayoutSidebar>
  71. <div id="main-content" class="relative">
  72. <RouterView #default="{ Component, route: currentRoute }">
  73. <KeepAlive
  74. :exclude="['ErrorTab']"
  75. :max="config.ui_task_mananger_max_task_count"
  76. >
  77. <component
  78. :is="Component"
  79. v-if="!currentRoute.meta.permanentItem"
  80. :key="currentRoute.path"
  81. />
  82. </KeepAlive>
  83. <KeepAlive :max="numberOfPermanentItems">
  84. <component
  85. :is="Component"
  86. v-if="currentRoute.meta.permanentItem"
  87. :key="currentRoute.meta.pageKey || currentRoute.path"
  88. />
  89. </KeepAlive>
  90. </RouterView>
  91. </div>
  92. </div>
  93. </template>