You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.0 KiB
74 lines
2.0 KiB
2 years ago
|
<template>
|
||
2 years ago
|
<el-menu :default-active="active" router class="menu-tree" :text-color="state.style.menuColor"
|
||
|
:background-color="state.style.menuBg" :active-text-color="state.style.menuActiveColor" :size="state.size.size">
|
||
2 years ago
|
<template v-for="menu in data">
|
||
|
<template v-if="menu.children && menu.children.length > 0">
|
||
|
<el-sub-menu :index="menu.path" :key="menu.path">
|
||
|
<template #title>
|
||
|
<span>{{ menu.title ? menu.title : defTitle }}</span>
|
||
|
</template>
|
||
2 years ago
|
<el-menu-item v-for="child in menu.children" :index="child.path" :router="router">{{ child.title
|
||
|
}}</el-menu-item>
|
||
2 years ago
|
</el-sub-menu>
|
||
|
</template>
|
||
|
<template v-else>
|
||
2 years ago
|
<el-menu-item :index="menu.path" :key="menu.path" :router="router">
|
||
2 years ago
|
<span>{{ menu.title ? menu.title : defTitle }}</span>
|
||
|
</el-menu-item>
|
||
|
</template>
|
||
|
</template>
|
||
|
</el-menu>
|
||
|
</template>
|
||
|
<script setup lang="ts">
|
||
|
import { useStore } from "vuex";
|
||
|
import { useRouter } from "vue-router";
|
||
|
import { ref, onMounted } from "vue"
|
||
|
|
||
2 years ago
|
const { state } = useStore()
|
||
2 years ago
|
const props = defineProps({
|
||
|
data: {
|
||
|
type: Array<any>(),
|
||
|
default: null
|
||
|
},
|
||
|
type: {
|
||
|
type: String,
|
||
|
default: 'def',
|
||
|
},
|
||
2 years ago
|
active: {
|
||
|
type: String,
|
||
|
default: 'home',
|
||
|
}
|
||
2 years ago
|
});
|
||
|
|
||
|
const router = useRouter();
|
||
|
const clickMenu = (menu) => {
|
||
|
router.push(menu.path);
|
||
|
};
|
||
|
const active = ref("");
|
||
|
|
||
|
const defTitle = "";
|
||
|
|
||
|
onMounted(() => {
|
||
2 years ago
|
active.value = props.active;
|
||
|
router.push(active.value);
|
||
2 years ago
|
})
|
||
|
|
||
|
</script>
|
||
|
|
||
|
<style scoped lang="scss">
|
||
2 years ago
|
.menu-tree {
|
||
|
padding-top: 1px;
|
||
|
height: 100%;
|
||
|
border: none;
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
.el-menu-item.is-active {
|
||
|
background-color: v-bind('state.style.menuActiveBg');
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
.el-sub-menu .el-menu-item {
|
||
|
min-width: v-bind('state.size.asideWidth') !important;
|
||
|
font-size: v-bind('state.size.fontSize') !important;
|
||
2 years ago
|
}
|
||
|
</style>
|