admin-vben/packages/effects/layouts/src/widgets/layout-toggle.vue

62 lines
1.5 KiB
Vue
Raw Normal View History

2024-05-19 13:20:42 +00:00
<script setup lang="ts">
import type { VbenDropdownMenuItem } from '@vben-core/shadcn-ui';
import type { AuthPageLayoutType } from '@vben-core/typings';
2024-05-19 13:20:42 +00:00
2024-06-08 11:49:06 +00:00
import { computed } from 'vue';
2024-05-19 13:20:42 +00:00
import { MdiDockBottom, MdiDockLeft, MdiDockRight } from '@vben-core/iconify';
import { $t } from '@vben-core/locales';
2024-06-09 04:53:38 +00:00
import {
preferences,
updatePreferences,
usePreferences,
} from '@vben-core/preferences';
2024-05-19 13:20:42 +00:00
import { VbenDropdownRadioMenu, VbenIconButton } from '@vben-core/shadcn-ui';
defineOptions({
name: 'AuthenticationLayoutToggle',
});
const menus = computed((): VbenDropdownMenuItem[] => [
{
icon: MdiDockLeft,
key: 'panel-left',
text: $t('authentication.layout.alignLeft'),
2024-05-19 13:20:42 +00:00
},
{
icon: MdiDockBottom,
key: 'panel-center',
2024-06-29 07:41:10 +00:00
text: $t('authentication.layout.center'),
2024-05-19 13:20:42 +00:00
},
{
icon: MdiDockRight,
key: 'panel-right',
text: $t('authentication.layout.alignRight'),
2024-05-19 13:20:42 +00:00
},
]);
2024-06-01 15:15:29 +00:00
const { authPanelCenter, authPanelLeft, authPanelRight } = usePreferences();
2024-06-09 04:53:38 +00:00
function handleUpdate(value: string) {
updatePreferences({
app: {
authPageLayout: value as AuthPageLayoutType,
},
});
}
2024-05-19 13:20:42 +00:00
</script>
<template>
<VbenDropdownRadioMenu
:menus="menus"
2024-06-09 04:53:38 +00:00
:model-value="preferences.app.authPageLayout"
@update:model-value="handleUpdate"
2024-05-19 13:20:42 +00: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>