<template>
    <div class="header-wrap ">
        <div class="header-logo">
            <img src="../assets/header-logo.png" alt="">
        </div>
        <div class="header-right flex" v-if="showRight">
            <!-- <div class="right-item">权限设置</div>
            <div class="right-item">岗位设置</div> -->
            <el-dropdown trigger="click">
                <div class="right-item flex el-dropdown-link">
                    <img class="right-item-icon" src="../assets/header-icon.png" alt="">
                    <span>{{user}}</span>
                    <img src="../assets/header-drop.svg" alt="">
                </div>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item><a href="/agent/domainList" target="_blank">我的域名</a></el-dropdown-item>
                    <el-dropdown-item><div @click="loginOut">退出</div></el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
        </div>
    </div>
</template>
<script>
import { logout } from '@/utils/logout';
export default {
    props:['showRight'],
    data() {
        return {
            user: ''
        }
    },
    mounted(){
        this.user = localStorage.getItem('user')
    },
    methods: {
        loginOut(){
            this.$http('POST', '/agentnew/login_out', {}).then(response => {
                if(response.status){
                    logout()
                }else{
                    this.$message.error(response.data.info)
                }
            }).catch(error => {
                console.error(error, 'error')
            })
        }
    }
}
</script>
<style lang="scss" scoped>
a {
    text-decoration: none;
    font-size: 14px;
    font-weight: normal;
    line-height: normal;
    letter-spacing: 0.08em;
    color: #1E2226;
}
a:hover {
    color: #006AFF;
}

.flex {
    display: flex;
}

.header-wrap {
    color: #1E2226;
    display: flex;
    justify-content: space-between;
    width: calc(100% - 64px);
    height: 100%;
    align-items: center;
    position: absolute;
    z-index: 9;
    .header-logo {
        img {
            height: 46px;
        }
    }

    .header-right {
        width: 362px;
        // justify-content: space-between;
        justify-content: flex-end;
        .el-dropdown-link {
            cursor: pointer;
        }
        .right-item{
            padding: 10px;
            transition: all .3s;
            cursor: pointer;
            &:hover{
                border-radius: 6px;
                background: rgba(255, 255, 255, 0.4);
                color: #006AFF;
                transition: all .3s;
            }
        }
        .el-dropdown .right-item{
            padding: 0 10px;
            cursor: pointer;
        }


        .right-item-icon {
            width: 36px;
            height: 36px;
        }

        .right-item-icon+span {
            display: inline-block;
            margin: 0 6px 0 12px;
        }
    }
}
</style>