Logo.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <div
  3. class="sidebar-logo-container"
  4. :class="{ collapse: collapse }"
  5. :style="{
  6. backgroundColor:
  7. sideTheme === 'theme-dark'
  8. ? variables.menuBackground
  9. : variables.menuLightBackground
  10. }"
  11. >
  12. <transition name="sidebarLogoFade">
  13. <router-link
  14. v-if="collapse"
  15. key="collapse"
  16. class="sidebar-logo-link"
  17. to="/"
  18. >
  19. <img v-if="logo" :src="logo" class="sidebar-logo" />
  20. <h1
  21. v-else
  22. class="sidebar-title"
  23. :style="{
  24. color:
  25. sideTheme === 'theme-dark'
  26. ? variables.logoTitleColor
  27. : variables.logoLightTitleColor
  28. }"
  29. >
  30. {{ title }}
  31. </h1>
  32. </router-link>
  33. <router-link v-else key="expand" class="sidebar-logo-link" to="/">
  34. <img v-if="logo" :src="logo" class="sidebar-logo" />
  35. <h1
  36. class="sidebar-title"
  37. :style="{
  38. color:
  39. sideTheme === 'theme-dark'
  40. ? variables.logoTitleColor
  41. : variables.logoLightTitleColor
  42. }"
  43. >
  44. {{ title }}
  45. </h1>
  46. </router-link>
  47. </transition>
  48. </div>
  49. </template>
  50. <script>
  51. import logoImg from '@/assets/images/logo.png';
  52. import variables from '@/assets/styles/variables.scss';
  53. export default {
  54. name: 'SidebarLogo',
  55. props: {
  56. collapse: {
  57. type: Boolean,
  58. required: true
  59. }
  60. },
  61. computed: {
  62. variables() {
  63. return variables;
  64. },
  65. sideTheme() {
  66. return this.$store.state.settings.sideTheme;
  67. }
  68. },
  69. data() {
  70. return {
  71. title: '水价改革管理系统',
  72. logo: logoImg
  73. };
  74. }
  75. };
  76. </script>
  77. <style lang="scss" scoped>
  78. .sidebarLogoFade-enter-active {
  79. transition: opacity 1.5s;
  80. }
  81. .sidebarLogoFade-enter,
  82. .sidebarLogoFade-leave-to {
  83. opacity: 0;
  84. }
  85. .sidebar-logo-container {
  86. position: relative;
  87. width: 100%;
  88. height: 50px;
  89. line-height: 50px;
  90. background: #2b2f3a;
  91. text-align: center;
  92. overflow: hidden;
  93. & .sidebar-logo-link {
  94. height: 100%;
  95. width: 100%;
  96. & .sidebar-logo {
  97. width: 32px;
  98. height: 32px;
  99. vertical-align: middle;
  100. margin-right: 12px;
  101. }
  102. & .sidebar-title {
  103. display: inline-block;
  104. margin: 0;
  105. color: #fff;
  106. font-weight: 600;
  107. line-height: 50px;
  108. font-size: 14px;
  109. vertical-align: middle;
  110. }
  111. }
  112. &.collapse {
  113. .sidebar-logo {
  114. margin-right: 0px;
  115. }
  116. }
  117. }
  118. </style>