use-layout.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import type { LayoutType } from '@vben-core/typings';
  2. import type { VbenLayoutProps } from '../vben-layout';
  3. import { computed } from 'vue';
  4. export function useLayout(props: VbenLayoutProps) {
  5. const currentLayout = computed(() =>
  6. props.isMobile ? 'sidebar-nav' : (props.layout as LayoutType),
  7. );
  8. /**
  9. * 是否全屏显示content,不需要侧边、底部、顶部、tab区域
  10. */
  11. const isFullContent = computed(() => currentLayout.value === 'full-content');
  12. /**
  13. * 是否侧边混合模式
  14. */
  15. const isSidebarMixedNav = computed(
  16. () => currentLayout.value === 'sidebar-mixed-nav',
  17. );
  18. /**
  19. * 是否为头部导航模式
  20. */
  21. const isHeaderNav = computed(() => currentLayout.value === 'header-nav');
  22. /**
  23. * 是否为混合导航模式
  24. */
  25. const isMixedNav = computed(
  26. () =>
  27. currentLayout.value === 'mixed-nav' ||
  28. currentLayout.value === 'header-sidebar-nav',
  29. );
  30. /**
  31. * 是否为头部混合模式
  32. */
  33. const isHeaderMixedNav = computed(
  34. () => currentLayout.value === 'header-mixed-nav',
  35. );
  36. return {
  37. currentLayout,
  38. isFullContent,
  39. isHeaderMixedNav,
  40. isHeaderNav,
  41. isMixedNav,
  42. isSidebarMixedNav,
  43. };
  44. }