修复 src 结构
This commit is contained in:
10
src/component/layout/index.less
Normal file
10
src/component/layout/index.less
Normal file
@@ -0,0 +1,10 @@
|
||||
.layui-layout {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-basis: auto;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.layui-layout-vertical {
|
||||
flex-direction: column;
|
||||
}
|
||||
9
src/component/layout/index.ts
Normal file
9
src/component/layout/index.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { App } from "vue";
|
||||
import Component from "./index.vue";
|
||||
import type { IDefineComponent } from "../type/index";
|
||||
|
||||
Component.install = (app: App) => {
|
||||
app.component(Component.name || "LayLayout", Component);
|
||||
};
|
||||
|
||||
export default Component as IDefineComponent;
|
||||
41
src/component/layout/index.vue
Normal file
41
src/component/layout/index.vue
Normal file
@@ -0,0 +1,41 @@
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: "LayLayout",
|
||||
};
|
||||
</script>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Component, computed, useSlots } from "vue";
|
||||
import Header from "../header/index.vue";
|
||||
import "./index.less";
|
||||
|
||||
export interface LayLayoutProps {
|
||||
isVertical?: boolean;
|
||||
}
|
||||
|
||||
const slots = useSlots();
|
||||
|
||||
const props = withDefaults(defineProps<LayLayoutProps>(), {
|
||||
isVertical: false,
|
||||
});
|
||||
|
||||
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>
|
||||
|
||||
<template>
|
||||
<section :class="classes">
|
||||
<slot></slot>
|
||||
</section>
|
||||
</template>
|
||||
Reference in New Issue
Block a user