<template>
    <div @mouseleave="handleHideSubMenus">
        <el-scrollbar>
            <lv1 :menuList="menuList" @change="handleShowSubMenus" />
        </el-scrollbar>
        <el-scrollbar class="sub-menu" v-if="displaySubMenus">
            <lv2 :menus="activedMenu" />
        </el-scrollbar>
    </div>
</template>

<script lang="ts" setup>
import lv1 from "./components/lv1.vue";
import lv2 from "./components/lv2.vue";
import { useRoute } from "vue-router";

defineProps<{ menuList: Menu.MenuOptions[] }>();

const $route = useRoute();

const activedMenu = ref<any>({});
const displaySubMenus = ref(false);
const handleShowSubMenus = (menu: any) => {
    activedMenu.value = menu;
    displaySubMenus.value = true;
};
const handleHideSubMenus = () => {
    activedMenu.value = {};
    displaySubMenus.value = false;
};
watch(
    () => $route,
    () => {
        displaySubMenus.value = false;
    }
);
</script>
<style lang="scss" scoped>
.sub-menu {
    position: fixed;
    top: 60px;
    left: 95px;
    z-index: 100;
    box-sizing: border-box;
    width: 210px;
    height: 100%;
    background-color: #ffffff;
    border-radius: 0 24px 24px 0;
    box-shadow: 24px 0 26px -23px rgb(223 228 237 / 60%);
}
</style>
