<template>
    <div class="sidebar-logo-container" :class="{ collapse: collapse }" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBg : variables.menuLightBg }">
        <transition name="sidebarLogoFade">
            <router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/">
                <div class="dddd">
                    <img v-if="logo" :src="logo" class="sidebar-logo" style="width: 22px; height: 22px" />
                    <h1 v-else class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.sidebarTitle : variables.sidebarLightTitle }">
                        {{ title }}
                    </h1>
                </div>
                
            </router-link>
            <router-link v-else key="expand" class="sidebar-logo-link" to="/">
                <div class="dddd">
                    <img v-if="logo" :src="logo" class="sidebar-logo" />
                    <h1 class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.sidebarTitle : variables.sidebarLightTitle }">
                        {{ title }}
                    </h1>
                </div>
                
            </router-link>
        </transition>
    </div>
</template>

<script>
import variables from '@/assets/styles/variables.scss'

export default {
    name: 'SidebarLogo',
    props: {
        collapse: {
            type: Boolean,
            required: true,
        },
    },
    computed: {
        variables() {
            return variables
        },
        sideTheme() {
            return this.$store.state.settings.sideTheme
        },
    },
    data() {
        return {
            title: this.$store.state.permission.siteConfig.site_title || '统一结算平台',
            logo: this.$store.state.permission.siteConfig.site_logo || require('@/assets/logo/logo.png'),
        }
    },
}
</script>

<style lang="scss" scoped>
.sidebarLogoFade-enter-active {
    transition: opacity 1.5s;
}

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

.sidebar-logo-container {
    position: relative;
    width: 100%;
      height: 60px;
      line-height: 60px;
    background: #2b2f3a;
    text-align: center;
    overflow: hidden;
    & .sidebar-logo-link {
        height: 100%;
        width: 100%;
      
        & .dddd{
            display: flex;
            justify-content: center;
            align-items: center;
            height: 60px;
        }
        & .sidebar-logo {
            width: 22px;
            height: 22px;
            //   vertical-align: middle;
            //   margin-right: 12px;
            // display: block;
            // margin: 20px auto;
        }

        & .sidebar-title {
            display: inline-block;
            margin: 0;
            color: #fff;
            font-weight: bold;
            font-size: 16px;
            font-family: Avenir, Helvetica Neue, Arial, Helvetica, sans-serif;
            vertical-align: middle;
            padding-left: 10px;
        }
    }

    &.collapse {
        .sidebar-logo {
            margin-right: 0px;
        }
    }
}
</style>
