ivy-head.vue 3.93 KB
<template>
	<div class="head-box" :class="{'blue-bg':skinPeeler=='def','bb-bg':skinPeeler=='bb','orange-bg':skinPeeler=='orange',}">
      <img class="logo" src="@/assets/images/user-logo.svg" alt="">
      
      <div class="user-box flex flex-pack-justify flex-align-center">
        <img class="screen-img" @click="screen" src="@/assets/images/full-screen.svg">
        <!-- <img class="theme-img" @click="showPop" src="@/assets/images/theme.svg"> -->
        <img class="infos-img" src="@/assets/images/infos.svg">
        <span>admin</span>
        <img class="user-img" src="@/assets/images/user.svg" alt="">
        <img class="sign-out" src="@/assets/images/sign-out.svg" alt="">
        <div class="popper-box" v-show="shouPop">
          <p class="pop-tit">切换主题</p>
          <div class="col-box flex flex-align-center flex-pack-justify" @click="handleColorChange('def')">
            <div class="color-spr color-def"></div>
            <span>默认</span>
          </div>
          <div class="col-box flex flex-align-center flex-pack-justify" @click="handleColorChange('bb')">
            <div class="color-spr"></div>
            <span>青蓝</span>
          </div>
          <div class="col-box flex flex-align-center flex-pack-justify" @click="handleColorChange('orange')">
            <div class="color-spr color-one"></div>
            <span>橙黄</span>
          </div>
        </div>
      </div>
  </div>
</template>
<script>
import screenfull from 'screenfull'
export default {
  data() {
    return {
      shouPop:false,
      skinPeeler:'def',
    };
  },
  watch: {},
  mounted() {
    this.initpage()
  },
  methods: {
    initpage(){
      let color='def';
      if(sessionStorage.getItem('skinPeeler')){
        color=sessionStorage.getItem('skinPeeler');
      }
      this.skinPeeler=color;
      // this.$store.commit('changeSkinPeeler', color);
    },
    showPop(){
      this.shouPop=!this.shouPop;
    },
    handleColorChange (color) {
      this.skinPeeler=color;
      // this.$store.commit('changeSkinPeeler', color);
      this.shouPop=!this.shouPop;
      sessionStorage.setItem('skinPeeler',color)
    },
    screen(){
      // 如果不允许进入全屏,发出不允许提示
      // if (!screenfull.enabled) {
      //   this.$message('您的浏览器不能全屏');
      //   return false
      // }
      screenfull.toggle();
    }
  }
};
</script>
<style lang="less" scoped>
  /* 默认 */
  .blue-bg{
    background: #0C71FB !important;
  }
  /* 青蓝 */
  .bb-bg{
    background: #1AE1C5 !important;
  }
  /* 橙黄 */
  .orange-bg{
    background: #FFB701 !important;
  }
.head-box {
  width: 100%;
  height: 52px;
  .logo {
    height: 22px;
    width: auto;
    margin-top: 15px;
    margin-left: 26px;
    float: left;
  }
  .user-box {
    float: right;
    margin-right: 18px;
    height: 52px;
    font-size: 12px;
    color: #fff;
    position: relative;
  }
  .popper-box{
    position: absolute;
    width: 66px;
    top: 52px;
    right: 134px;
    background:rgba(255,255,255,1);
    box-shadow:0px 1px 6px 0px rgba(0,0,0,0.24);
    border-radius:2px;
    border:1px solid rgba(222,222,222,1);
    box-sizing: border-box;
    padding: 10px 8px;
    z-index: 1;
  }
  .pop-tit{
    color: #6D7278;
    font-size: 12p;
  }
  .col-box{
    height: 12px;
    margin-top: 10px;
    font-size: 12px;
    line-height: 12px;
    color: #6D7278;
    cursor: pointer;
  }
  .color-spr{
    width: 10px;
    height: 10px;
    background:#1AE1C5;
    border-radius:2px;
  }
  .color-def{
    background: #0C71FB;
  }
  .color-one{
    background: #FFB701;
  }
  .screen-img {
    width: 17px;
    height: 17px;
    margin-right: 20px;
  }
  .theme-img {
    width: 20px;
    height: 20px;
    margin-right: 20px;
  }
  .infos-img {
    width: 20px;
    height: 16px;
    margin-right: 30px;
  }
  .user-img {
    width: 18px;
    height: 18px;
    margin-left: 3px;
  }
  .sign-out {
    width: 18px;
    height: 18px;
    margin-left: 12px;
  }
}
</style>