<template>
  <div class="sidebar-logo-container" :class="{'collapse':collapse}" :style="{'background-color':theme}">
    <transition name="sidebarLogoFade">
      <router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/">
        <!-- <img :src="logo" class="sidebar-logo"> -->
        <h1 class="sidebar-title">{{ sysName }} </h1>
      </router-link>
      <router-link v-else key="expand" class="sidebar-logo-link" to="/">
        <!-- <img :src="logo" class="sidebar-logo"> -->
        <h1 class="sidebar-title">{{ sysName }} </h1>
      </router-link>
    </transition>
  </div>
</template>

<script>
  import logo from "@/assets/img/tuxiang.png"
  import {getconfig} from "@/api/login";
  export default {
    name: 'SidebarLogo',
    props: {
      collapse: {
        type: Boolean,
        required: true
      }
    },
    data() {
      return {
        title: '电子档案管理系统',
        logo: logo,
        sysName:'',
      }
    },
    computed:{
      theme() {
        return this.$store.state.settings.theme;
      },
      sysParams(){
        return this.$store.state.user.sysConfig;
      },
    },
    methods:{
      getconfig(){
        getconfig().then((res)=>{
          if(res.code == 100){
            let data = res.body.list || [];
            this.sysName = data[0].systemName;
          }
        })
      },
    },
    mounted(){
      this.getconfig();
    }
  }

</script>

<style lang="scss" scoped>
@import "~@/styles/element-variables.scss";
  .sidebarLogoFade-enter-active {
    transition: opacity 1.5s;
  }

  .sidebarLogoFade-enter,
  .sidebarLogoFade-leave-to {
    opacity: 0;
  }

  .sidebar-logo-container {
    position: relative;
    width: 100%;
    height: 50px;
    line-height: 50px;
    /* background: #2b2f3a; */
    background:$--color-common;
    text-align: center;
    // overflow: hidden;

    & .sidebar-logo-link {
      height: 100%;
      width: 100%;

      & .sidebar-logo {
        width: 40px;
        // height: 32px;
        vertical-align: middle;
        margin-right: 12px;
        border-radius: 50% 50%  0 0 ;
      }

      & .sidebar-title {
        // letter-spacing: 3px;
        display: inline-block;
        margin: 0;
        color: #fff;
        font-weight: 600;
        line-height: 50px;
        font-size: 18px;
        font-family: 'Open Sans', Arial, sans-serif;
        vertical-align: middle;
      }
    }

    &.collapse {
      .sidebar-logo {
        margin-right: 0px;
      }
    }
  }

</style>
