<template>
  <div
    style="width: 100vw; height: 100vh"
    v-loading="globalStateStore.globalLodingShow"
    :element-loading-text="globalStateStore.globalLodingShowText">
    <headMenuVue
      @expand-change="expandChange"
      class="header-menue"
      :class="{ 'expand-control': expand }"></headMenuVue>
    <leftMenuVue
      class="left-menue"
      :menue-data="realMenue"
      :class="{ 'expand-close': expand }"></leftMenuVue>
    <div
      class="main"
      :class="{ 'expand-control': expand }"
      v-loading="globalStateStore.loadingShow"
      :element-loading-text="globalStateStore.loadingText">
      <router-view v-slot="{ Component }">
        <transition name="transition" mode="out-in">
          <component :is="Component"></component>
        </transition>
      </router-view>
    </div>
  </div>
</template>

<script lang="ts" setup>
import headMenuVue from "./headMenu.vue";
import leftMenuVue from "./leftMenu.vue";
import router from "@/routers/index";
import { globalState } from "@/store";
import { RouteRecordRaw } from "vue-router";
import { ref, onBeforeMount, onMounted, reactive } from "vue";
let filterRoute = ["首页"];
let leftMenue: Array<RouteRecordRaw> = router.options.routes.find(
  (item: RouteRecordRaw) => item?.name === "主页"
)?.children as Array<RouteRecordRaw>;
let globalStateStore = globalState();
let realMenue = leftMenue.filter(
  (item: RouteRecordRaw) => !filterRoute.includes(item.name as string)
);
let expand = ref(false);

onBeforeMount(() => {});
onMounted(() => {});

function expandChange(newVal: boolean) {
  expand.value = newVal;
}
</script>
<style lang="scss" scoped>
.main {
  width: calc(100vw - 200px);
  height: calc(100vh - 50px);
  position: absolute;
  top: 50px;
  margin-left: 200px;
  overflow-y: auto;
  background-color: #f1f3f4;
  padding: 12px;
}
.left-menue {
  transition: all 0.3s;
  color: #fff;
  user-select: none;
  background-color: #fff;
  :deep(.el-menu) {
    .el-menu-item {
      &:hover {
        background-color: #f1f3f4;
        color: #15559a;
      }
    }
    .is-active {
      background-color: #f1f3f4;
    }
    .el-sub-menu .is-active {
      ::after {
        content: "";
        width: 5px;
        position: absolute;
        left: -8px;
        top: 50%;
        transform: translateY(-50%);
        background-color: #15559a;
        border-radius: 8px;
        animation: menueLeftLine 0.45s ease;
        animation-fill-mode: forwards;
      }
    }
  }
}
.expand {
  left: 0;
  opacity: 0;
}
.main,
.header-menue {
  transition: all 0.3s;
}
.expand-control {
  width: 100vw;
  margin-left: 0;
}
.expand-close {
  width: 0;
  overflow: hidden;
}

.transition-enter-to {
  opacity: 1;
  transition: all 0.3s ease;
}
.transition-enter-from {
  transform: translateY(5%);
  opacity: 0;
}

@keyframes menueLeftLine {
  0% {
    height: 0%;
  }
  100% {
    height: 120%;
  }
}
</style>
