layout-toggle.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <script setup lang="ts">
  2. import type { VbenDropdownMenuItem } from '@vben-core/shadcn-ui';
  3. import { MdiDockBottom, MdiDockLeft, MdiDockRight } from '@vben-core/iconify';
  4. import { preferences, usePreferences } from '@vben-core/preferences';
  5. import { VbenDropdownRadioMenu, VbenIconButton } from '@vben-core/shadcn-ui';
  6. import { $t } from '@vben/locales';
  7. import { computed } from 'vue';
  8. defineOptions({
  9. name: 'AuthenticationLayoutToggle',
  10. });
  11. const menus = computed((): VbenDropdownMenuItem[] => [
  12. {
  13. icon: MdiDockLeft,
  14. key: 'panel-left',
  15. text: $t('layout.align-left'),
  16. },
  17. {
  18. icon: MdiDockBottom,
  19. key: 'panel-center',
  20. text: $t('layout.center'),
  21. },
  22. {
  23. icon: MdiDockRight,
  24. key: 'panel-right',
  25. text: $t('layout.align-right'),
  26. },
  27. ]);
  28. const { authPanelCenter, authPanelLeft, authPanelRight } = usePreferences();
  29. </script>
  30. <template>
  31. <VbenDropdownRadioMenu
  32. v-model="preferences.app.authPageLayout"
  33. :menus="menus"
  34. >
  35. <VbenIconButton>
  36. <MdiDockRight v-if="authPanelRight" class="size-5" />
  37. <MdiDockLeft v-if="authPanelLeft" class="size-5" />
  38. <MdiDockBottom v-if="authPanelCenter" class="size-5" />
  39. </VbenIconButton>
  40. </VbenDropdownRadioMenu>
  41. </template>