<template>
  <div id="app">
    <el-container>
      <el-header style="height: 62px;" v-if="showHeader">
        <Header></Header>
        <video class="top_viedo" width="100%" src="./assets/headerBg1.mp4" autoplay loop muted
        ></video>
        <div class="bg"></div>
      </el-header>
      <el-container :class="(showHeader ? 'short-container' : '')">
        <SliderMenu v-if="showSidebar" :menuData="slidermenu" :customize="customize"></SliderMenu>
        <!-- <SliderMenu v-if="showSidebar" :menuData="menuData"></SliderMenu> -->
        <el-container class="main-right-content">
          <!-- 面包屑导航 -->
          <Breadcrumb />
          <el-main class="app-content">
              <global-loading>
                <router-view />
              </global-loading>
            </el-main>
          <!-- <el-footer v-if="showFooter"> -->
            <Footer v-if="showFooter"></Footer>
          <!-- </el-footer> -->

        </el-container>
      </el-container>
    </el-container>
  </div>
</template>
<script>
import SliderMenu from '@/components/SliderMenu.vue';
// import Footer from '@/components/Footer.vue';
import { mapState } from 'vuex';
import Header from './components/Header.vue';
import Breadcrumb from './components/Breadcrumb.vue';
// import loadingAnimation from '@/assets/loadingAni.json' // 导入JSON文件
import GlobalLoading from '@/components/GlobalLoading1.vue'
// import ContentWithLoading from '@/components/ContentWithLoading'
export default {
  data() {
    return {
      isCollapse: true,
    //   menuData: [
    //     {
    //       index: '1',
    //       title: '父级菜单1',
    //       icon: 'el-icon-location',
    //       children: [
    //         { index: '1-1', title: '子级菜单1-1', path: '/' },
    //         { index: '1-2', title: 'ui页面', path: '/ui' }
    //       ]
    //     },
    //     {
    //       index: '2',
    //       title: '父级菜单2',
    //       icon: 'el-icon-menu',
    //       children: [
    //         { index: '2-1', title: '子级菜单2-1', path: '/about' },
    //         { index: '2-2', title: '加盟耶main', path: '/franchise' }
    //       ]
    //     }
    //   ]
    };
  },
  components: {
    GlobalLoading,
    // ContentWithLoading,
    SliderMenu,
    // Footer,
    Header,
    Breadcrumb
  },
  computed: {
    ...mapState(['showSidebar', 'showFooter', 'showHeader','slidermenu','customize']) // 从Vuex映射showSidebar状态到组件的计算属性中
  },
  mounted() {
    window.addEventListener('beforeunload', this.clearStorage);
  },
  beforeUnmount() {
    window.removeEventListener('beforeunload', this.clearStorage);
  },
  methods: {
    clearStorage() {
      // 或按需清除特定项：
      localStorage.removeItem('date');
    },
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    }
  }
}
</script>
<style lang="scss" scoped>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  font-family: Microsoft YaHei UI;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  height: 100%;
  background: #F5F7FA;
}
.app-content {
  position: relative;
  isolation: isolate;
}
.short-container {
  height: calc(100vh - 62px);
}
.main-right-content{
  display: flex;
  flex-direction: column;
}


::v-deep .el-container .el-main {
  // padding: 12px;
}

.bg {
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
  background: rgba(255, 255, 255, 0.61);
  z-index: 2;
}

::v-deep .el-header {
  height: 62px;
  overflow: hidden;
  position: relative;
  box-sizing: border-box;
  background: linear-gradient(270deg, #4EA4F3 0%, #3D85EA 100%);
}

.top_viedo {
  width: 100%;
  height: 100%;
  position: absolute;
  object-fit: cover;
  left: 0;
  top: 0;
}

nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
