ruoyi-plus-vben5/packages/effects/layouts/src/widgets/preferences/blocks/layout/layout.vue

103 lines
2.5 KiB
Vue
Raw Normal View History

2024-05-19 21:20:42 +08:00
<script setup lang="ts">
import type { LayoutType } from '@vben/types';
2024-05-19 21:20:42 +08:00
2024-06-08 19:49:06 +08:00
import { type Component, computed } from 'vue';
2024-05-19 21:20:42 +08:00
import { CircleHelp } from '@vben/icons';
import { $t } from '@vben/locales';
2024-06-08 19:49:06 +08:00
import { VbenTooltip } from '@vben-core/shadcn-ui';
2024-05-19 21:20:42 +08:00
import {
FullContent,
HeaderMixedNav,
2024-05-19 21:20:42 +08:00
HeaderNav,
MixedNav,
2024-06-09 15:39:11 +08:00
SidebarMixedNav,
SidebarNav,
2024-05-19 21:20:42 +08:00
} from '../../icons';
interface PresetItem {
name: string;
tip: string;
type: LayoutType;
}
defineOptions({
name: 'PreferenceLayout',
});
2024-06-09 15:39:11 +08:00
const modelValue = defineModel<LayoutType>({ default: 'sidebar-nav' });
2024-05-19 21:20:42 +08:00
const components: Record<LayoutType, Component> = {
'full-content': FullContent,
'header-nav': HeaderNav,
'mixed-nav': MixedNav,
2024-06-09 15:39:11 +08:00
'sidebar-mixed-nav': SidebarMixedNav,
'sidebar-nav': SidebarNav,
'header-mixed-nav': HeaderMixedNav,
2024-05-19 21:20:42 +08:00
};
const PRESET = computed((): PresetItem[] => [
{
2024-06-16 13:43:33 +08:00
name: $t('preferences.vertical'),
tip: $t('preferences.verticalTip'),
2024-06-09 15:39:11 +08:00
type: 'sidebar-nav',
2024-05-19 21:20:42 +08:00
},
{
name: $t('preferences.twoColumn'),
tip: $t('preferences.twoColumnTip'),
2024-06-09 15:39:11 +08:00
type: 'sidebar-mixed-nav',
2024-05-19 21:20:42 +08:00
},
{
2024-06-16 13:43:33 +08:00
name: $t('preferences.horizontal'),
tip: $t('preferences.horizontalTip'),
2024-05-19 21:20:42 +08:00
type: 'header-nav',
},
{
name: $t('preferences.mixedMenu'),
tip: $t('preferences.mixedMenuTip'),
2024-05-19 21:20:42 +08:00
type: 'mixed-nav',
},
{
name: $t('preferences.headerTwoColumn'),
tip: $t('preferences.headerTwoColumnTip'),
type: 'header-mixed-nav',
},
2024-05-19 21:20:42 +08:00
{
name: $t('preferences.fullContent'),
tip: $t('preferences.fullContentTip'),
2024-05-19 21:20:42 +08:00
type: 'full-content',
},
]);
function activeClass(theme: string): string[] {
return theme === modelValue.value ? ['outline-box-active'] : [];
}
</script>
<template>
<div class="flex w-full flex-wrap gap-5">
<template v-for="theme in PRESET" :key="theme.name">
<div
class="flex w-[100px] cursor-pointer flex-col"
@click="modelValue = theme.type"
>
<div :class="activeClass(theme.type)" class="outline-box flex-center">
<component :is="components[theme.type]" />
</div>
<div
class="text-muted-foreground flex-center hover:text-foreground mt-2 text-center text-xs"
>
{{ theme.name }}
<VbenTooltip v-if="theme.tip" side="bottom">
<template #trigger>
<CircleHelp class="ml-1 size-3 cursor-help" />
2024-05-19 21:20:42 +08:00
</template>
{{ theme.tip }}
</VbenTooltip>
</div>
</div>
</template>
</div>
</template>