Blame view

src/layout/components/Sidebar/Logo.vue 1.86 KB
赵千 committed
1
<template>
任超 committed
2
  <div class="sidebar-logo-container" :class="{ 'collapse': collapse }">
赵千 committed
3
    <transition name="sidebarLogoFade">
任超 committed
4 5 6
      <router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/">
        <img v-if="logo" :src="logo" class="sidebar-logo">
        <h1 v-else class="sidebar-title">
赵千 committed
7 8 9
          {{ title }}
        </h1>
      </router-link>
任超 committed
10 11
      <router-link v-else key="expand" class="sidebar-logo-link" to="/">
        <img v-if="logo" :src="logo" class="sidebar-logo">
赵千 committed
12
        <h1 class="sidebar-title">
任超 committed
13
          {{ title }}
赵千 committed
14 15 16 17 18 19 20
        </h1>
      </router-link>
    </transition>
  </div>
</template>

<script>
任超 committed
21 22
import defaultSettings from '@/settings'
const { title } = defaultSettings
任超 committed
23
import logonImg from '@/image/logo.png'
赵千 committed
24 25 26 27 28 29 30 31
export default {
  name: 'SidebarLogo',
  props: {
    collapse: {
      type: Boolean,
      required: true
    }
  },
任超 committed
32
  data () {
赵千 committed
33
    return {
任超 committed
34
      title: title,
赵千 committed
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
      logo: logonImg
    }
  }
}
</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%;
  text-align: center;
  overflow: hidden;
任超 committed
56
  height: 100px;
赵千 committed
57 58 59 60

  & .sidebar-logo-link {
    height: 100%;
    width: 100%;
任超 committed
61

赵千 committed
62 63 64 65
    & .sidebar-logo {
      width: 41px;
      height: 39px;
      vertical-align: middle;
任超 committed
66 67
      //   margin-left: 47px;
      //   margin-right: 48px;
赵千 committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
      margin-top: 22px;
    }

    & .sidebar-title {
      margin: 0;
      margin-top: 10px;
      margin-bottom: 20px;
      color: #fff;
      font-weight: 600;
      line-height: 25px;
      font-size: 16px;
      font-family: Avenir, Helvetica Neue, Arial, Helvetica, sans-serif;
      vertical-align: middle;
    }
  }

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