<template>
  <div id="loyout">
    <el-container>
      <layoutAside></layoutAside>
      <el-container>
        <layoutHeader></layoutHeader>
        <el-main id="elmain">
          <transition name="main" mode="out-in">
            <keep-alive key="keepAlive">
              <router-view v-if="$route.meta.keepAlive" ></router-view>
            </keep-alive>
          </transition>
          <transition name="main" mode="out-in">
            <router-view v-if="!$route.meta.keepAlive" key="not-keepAlive"></router-view>
          </transition>
        </el-main>
        <el-footer height="28px">
          <Bottom></Bottom>
        </el-footer>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import layoutAside from "./aside/aside";
import layoutHeader from "./header/header";
import Bottom from "./Footer/bottom";
import langSelect from "../../components/lang/langSelect";
import { getURLParams } from "@/utils";

export default {
  name: "layout",
  components: {
    layoutHeader,
    Bottom,
    langSelect,
    layoutAside,
  },
  data() {
    return {
      code: "",
    };
  },
  methods: {
    initRouter() {
      this.code = getURLParams("code") || this.$store.getters.code;
      if (this.code) {
        this.$store.commit("setCode", this.code);
        this._LoginCheck();
      }
    },
    async _LoginCheck() {
      let params = {};
      if (this.code) {
        params = {
          code: this.code,
        };
      }
      this.$store.dispatch("CSLogin", this.code);
    },
  },
};
</script>

<style>
.main-enter,
.main-leave-to {
  opacity: 0;
  transform: translateY(30px);
}
.main-enter-active {
  transition: all 0.2s;
}
.main-leave-active {
  position: absolute;
  transition: all 0.3s;
}
</style>
<style lang="scss" scoped>
$top: top;
$bottom: bottom;
$left: left;
$right: right;
$leftright: ($left, $right);
%w100 {
  width: 100%;
}

%h100 {
  height: 100%;
}

%cursor {
  cursor: pointer;
}

#loyout,
.el-container,
#asideNav,
ul.el-menu {
  @extend %h100;
}

@mixin set-value($side, $value) {
  @each $prop in $leftright {
    #{$side}-#{$prop}: $value;
  }
}

#elmain {
  background-color: #fff;
  padding: 0;
  min-height: calc(100% - 78px);
}

.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9 !important;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409eff;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>
