2021-09-26 22:09:33 +00:00
|
|
|
<template>
|
2021-10-24 09:23:39 +00:00
|
|
|
<section :class="classes">
|
2021-10-12 03:30:07 +00:00
|
|
|
<slot />
|
2021-10-24 09:23:39 +00:00
|
|
|
</section>
|
2021-09-26 22:09:33 +00:00
|
|
|
</template>
|
2021-10-24 09:23:39 +00:00
|
|
|
<script lang="ts">
|
|
|
|
export default {
|
|
|
|
name: 'LayLayout',
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { Component, computed, useSlots } from 'vue'
|
|
|
|
import Header from '../header/index.vue'
|
2021-09-26 22:09:33 +00:00
|
|
|
|
2021-10-24 09:23:39 +00:00
|
|
|
const props = withDefaults(
|
|
|
|
defineProps<{
|
|
|
|
isVertical?: boolean
|
|
|
|
}>(),
|
|
|
|
{
|
|
|
|
isVertical: false,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
const slots = useSlots()
|
|
|
|
|
|
|
|
const isVertical = computed(() => {
|
|
|
|
if (!slots.default) return false
|
|
|
|
const vNodes = slots.default()
|
|
|
|
return vNodes.some((vNode) => {
|
|
|
|
const componentName = (vNode.type as Component).name
|
|
|
|
if (!componentName) return false
|
|
|
|
return [Header.name].includes(componentName)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
const classes = computed(() => {
|
|
|
|
return ['layui-layout', { 'layui-layout-vertical': isVertical.value }]
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.layui-layout {
|
|
|
|
display: flex;
|
|
|
|
flex: 1;
|
|
|
|
flex-basis: auto;
|
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
|
|
|
box-sizing: border-box;
|
|
|
|
}
|
|
|
|
|
|
|
|
.layui-layout-vertical {
|
|
|
|
flex-direction: column;
|
|
|
|
}
|
|
|
|
</style>
|