Logo.vue 2.5 KB

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