<template>
  <div class="layer">
    <ly-top class="top" v-if="!isSystem" />
    <div class="content">
      <router-view v-slot="{ Component }" v-if="isSystem">
        <component :is="Component" />
      </router-view>
      <template v-else>
        <ly-slide class="slide" :names="menuRouteNames" v-if="!hiddenSlide" />
        <div class="view" :class="{ full: hiddenSlide }">
          <div class="main">
            <router-view v-slot="{ Component }">
              <component :is="Component" />
            </router-view>
          </div>
        </div>
      </template>
    </div>
  </div>
</template>

<script lang="ts" setup>
import lyTop from "./top/index.vue";
import lySlide from "./slide/index.vue";
import { routeIsSystem, router } from "@/router";
import { computed } from "vue";
import { menuRouteNames } from "@/app";

const isSystem = computed(() => routeIsSystem());

const hiddenSlide = computed(
  () => !menuRouteNames.includes(router.currentRoute.value.name as string)
);
</script>

<style lang="scss" scoped>
.layer {
  position: absolute;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;

  .top {
    flex: 0 0 auto;
  }

  .content {
    flex: 1 0;
    display: flex;
    overflow: hidden;

    .slide {
      width: 16.66rem;
      flex: 0 0 auto;
    }

    .view {
      flex: 0 0 auto;
      width: calc(100% - 16.66rem);
      background-color: var(--bgColor);
      flex-direction: column;
      display: flex;

      &.full {
        width: 100%;
      }

      .player {
        flex: 0 0 auto;
        height: 32px;
      }

      .main {
        margin: 0 16px 16px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        flex: 1;
      }
    }
  }
}
</style>
