index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div class="layout-logo"
  3. v-if="$store.state.themeConfig.themeConfig.layout !== 'columns' && !$store.state.themeConfig.themeConfig.isCollapse"
  4. @click="onThemeConfigChange">
  5. <img v-if="maxLogo" class="layout-logo-medium-img" :src="maxLogo" />
  6. </div>
  7. <div class="layout-logo-size" v-else @click="onThemeConfigChange">
  8. <img v-if="minLogo" class="layout-logo-size-img" :src="minLogo" />
  9. </div>
  10. </template>
  11. <script>
  12. import {
  13. getLogo
  14. } from '@/api/common';
  15. export default {
  16. name: 'layoutLogo',
  17. data() {
  18. return {
  19. minLogo: '',
  20. maxLogo: '',
  21. };
  22. },
  23. computed: {
  24. // 获取布局配置信息
  25. getThemeConfig() {
  26. return this.$store.state.themeConfig.themeConfig;
  27. },
  28. // 设置 logo 是否显示
  29. setShowLogo() {
  30. let {
  31. isCollapse,
  32. layout
  33. } = this.$store.state.themeConfig.themeConfig;
  34. return !isCollapse || layout === 'classic' || document.body.clientWidth < 1000;
  35. },
  36. },
  37. mounted() {
  38. // this.getLogo();
  39. },
  40. methods: {
  41. // logo 点击实现菜单展开/收起
  42. onThemeConfigChange() {
  43. if (
  44. this.$store.state.themeConfig.themeConfig.layout == 'columns' &&
  45. !this.$store.state.menus.childMenuList.length &&
  46. this.$store.state.themeConfig.themeConfig.isCollapse
  47. )
  48. return;
  49. if (this.$store.state.themeConfig.themeConfig.layout === 'transverse') return false;
  50. this.$store.state.themeConfig.themeConfig.isCollapse = !this.$store.state.themeConfig.themeConfig
  51. .isCollapse;
  52. },
  53. getLogo() {
  54. getLogo().then((res) => {
  55. this.minLogo = res.data.logo_square;
  56. this.maxLogo = res.data.logo;
  57. });
  58. },
  59. },
  60. };
  61. </script>
  62. <style scoped lang="scss">
  63. .layout-logo {
  64. width: 180px;
  65. height: 50px;
  66. display: flex;
  67. align-items: center;
  68. justify-content: center;
  69. // box-shadow: 0px 1px 4px rgba(0, 21, 41, 2%);
  70. color: var(--prev-color-primary);
  71. font-size: 16px;
  72. cursor: pointer;
  73. animation: logoAnimation 0.3s ease-in-out;
  74. &:hover {
  75. span {
  76. opacity: 0.9;
  77. }
  78. }
  79. &-medium-img {
  80. width: 100%;
  81. height: 50px;
  82. margin-right: 5px;
  83. position: relative;
  84. top: 2px;
  85. }
  86. }
  87. .layout-logo-size {
  88. width: 50px;
  89. height: 50px;
  90. display: flex;
  91. cursor: pointer;
  92. margin: auto;
  93. &-img {
  94. width: 50px;
  95. height: 50px;
  96. margin: auto;
  97. animation: logoAnimation 0.3s ease-in-out;
  98. }
  99. }
  100. </style>