<template>
  <el-container :class="'el-container-style-' + curTheme">
    <Navbar />
    <el-aside :width="appStore.nav.isCollapse ? '60px' : '240px'">
      <el-scrollbar style="height: calc(100% + 17px)">
        <Sidebar :is-collapse="appStore.nav.isCollapse" />
      </el-scrollbar>
    </el-aside>
    <el-main class="right-container">
      <div class="pageTitle">{{ route.matched[route.matched.length - 1]?.meta?.name || '' }}</div>
      <div class="main-box">
        <router-view v-if="route.meta?.keepAlive" />
        <router-view v-if="!route.meta?.keepAlive" />
      </div>
    </el-main>
  </el-container>
</template>

<script setup lang="ts">
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import Sidebar from './layout/Sidebar.vue'
import Navbar from './layout/Navbar.vue'
import { useAppStore } from '@/stores/app'
import { useUserStore } from '@/stores/user'

const route = useRoute()
const appStore = useAppStore()
const userStore = useUserStore()

const curTheme = computed(() => userStore.curTheme)
</script>

<style scoped lang="less">
.el-aside {
  margin-top: 90px;
  margin-right: 20px;
  height: calc(100vh - 90px);
  background: #fff;
  border-top-right-radius: 20px;
  overflow: hidden !important;

  :deep(.el-scrollbar__wrap) {
    overflow-x: hidden;
  }
}

.right-container {
  margin-top: 90px;
  margin-right: 20px;
  background-color: #fff;
  border-radius: 20px 20px 0 0;
  height: calc(100vh - 90px);
}

.el-main {
  background-color: #fff;
  overflow-y: auto;
}

.pageTitle {
  font-size: 16px;
  font-weight: bold;
  color: #000;
  padding: @mainPadding;
  display: flex;
  align-items: center;
  position: relative;
  z-index: 1;
  background: #fff;

  &::before {
    content: '';
    display: block;
    width: 6px;
    height: 14px;
    background: @theme-color;
    margin-right: 8px;
    border-radius: 88px;
  }
}
</style>
