admin-vben5/packages/business/layouts/src/authentication/widgets/layout-toggle.vue

62 lines
1.5 KiB
Vue
Raw Normal View History

2024-05-19 21:20:42 +08:00
<script setup lang="ts">
2024-06-09 13:31:43 +08:00
import type { AuthPageLayoutType } from '@vben-core/preferences';
2024-05-19 21:20:42 +08:00
import type { VbenDropdownMenuItem } from '@vben-core/shadcn-ui';
2024-06-08 19:49:06 +08:00
import { computed } from 'vue';
import { $t } from '@vben/locales';
2024-05-19 21:20:42 +08:00
import { MdiDockBottom, MdiDockLeft, MdiDockRight } from '@vben-core/iconify';
2024-06-09 12:53:38 +08:00
import {
preferences,
updatePreferences,
usePreferences,
} from '@vben-core/preferences';
2024-05-19 21:20:42 +08:00
import { VbenDropdownRadioMenu, VbenIconButton } from '@vben-core/shadcn-ui';
defineOptions({
name: 'AuthenticationLayoutToggle',
});
const menus = computed((): VbenDropdownMenuItem[] => [
{
icon: MdiDockLeft,
key: 'panel-left',
text: $t('layout.align-left'),
},
{
icon: MdiDockBottom,
key: 'panel-center',
text: $t('layout.center'),
},
{
icon: MdiDockRight,
key: 'panel-right',
text: $t('layout.align-right'),
},
]);
2024-06-01 23:15:29 +08:00
const { authPanelCenter, authPanelLeft, authPanelRight } = usePreferences();
2024-06-09 12:53:38 +08:00
function handleUpdate(value: string) {
updatePreferences({
app: {
authPageLayout: value as AuthPageLayoutType,
},
});
}
2024-05-19 21:20:42 +08:00
</script>
<template>
<VbenDropdownRadioMenu
:menus="menus"
2024-06-09 12:53:38 +08:00
:model-value="preferences.app.authPageLayout"
@update:model-value="handleUpdate"
2024-05-19 21:20:42 +08:00
>
<VbenIconButton>
<MdiDockRight v-if="authPanelRight" class="size-5" />
<MdiDockLeft v-if="authPanelLeft" class="size-5" />
<MdiDockBottom v-if="authPanelCenter" class="size-5" />
</VbenIconButton>
</VbenDropdownRadioMenu>
</template>