logo.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <div class="logo" :style="{ width: width }">
  3. <router-link :to="homeRoute || '/'">
  4. <img src="@/assets/logo1.svg" alt="logo" style="height:32px;width:32px;" />
  5. </router-link>
  6. <h1>{{ shortName }}</h1>
  7. <el-tooltip effect="dark" :content="switchTip" placement="bottom" v-if="switchable && !collapse">
  8. <el-switch :value="navMode" active-color="#13ce66" active-value="nested" inactive-value="lite" @change="switchMode"> </el-switch>
  9. </el-tooltip>
  10. </div>
  11. </template>
  12. <script>
  13. import { createNamespacedHelpers } from 'vuex';
  14. const { mapState } = createNamespacedHelpers('naf/menu');
  15. export default {
  16. props: {
  17. shortName: String,
  18. width: {
  19. type: String,
  20. default: '256px',
  21. },
  22. navMode: String,
  23. homeRoute: String,
  24. },
  25. methods: {
  26. switchMode(payload) {
  27. this.$emit('switch-mode', payload);
  28. },
  29. },
  30. computed: {
  31. ...mapState(['collapse', 'switchable']),
  32. switchTip() {
  33. return this.navMode == 'nested' ? '切换到简单导航模式' : '切换到经典导航模式';
  34. },
  35. },
  36. };
  37. </script>
  38. <style lang="less" scoped>
  39. .logo {
  40. display: table;
  41. border-right: solid 1px #e6e6e6;
  42. padding: 0 16px;
  43. overflow: hidden;
  44. img,
  45. h1 {
  46. vertical-align: middle;
  47. }
  48. h1 {
  49. display: inline-block;
  50. margin: 0 0 0 12px;
  51. }
  52. .el-switch {
  53. vertical-align: middle;
  54. text-align: right;
  55. display: table-cell;
  56. }
  57. }
  58. </style>