AppLogo.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <!--
  2. * @Author: Vben
  3. * @Description: logo component
  4. -->
  5. <template>
  6. <div class="anticon" :class="getAppLogoClass" @click="goHome">
  7. <img :src="isEn?logoEn:logo" />
  8. <!-- <div class="ml-2 truncate md:opacity-100" :class="getTitleClass" v-show="showTitle">
  9. {{ title }}
  10. </div> -->
  11. </div>
  12. </template>
  13. <script lang="ts" setup>
  14. import { computed, unref } from 'vue';
  15. import { useGlobSetting } from '/@/hooks/setting';
  16. import { useGo } from '/@/hooks/web/usePage';
  17. import { useMenuSetting } from '/@/hooks/setting/useMenuSetting';
  18. import { useDesign } from '/@/hooks/web/useDesign';
  19. import { PageEnum } from '/@/enums/pageEnum';
  20. import { useUserStore } from '/@/store/modules/user';
  21. import { useLocaleStore } from '/@/store/modules/locale';
  22. import logo from '/@/assets/images/grey-logo.png';
  23. import logoEn from '/@/assets/images/grey-logo-en.png';
  24. const props = defineProps({
  25. /**
  26. * The theme of the current parent component
  27. */
  28. theme: { type: String, validator: (v: string) => ['light', 'dark'].includes(v) },
  29. /**
  30. * Whether to show title
  31. */
  32. showTitle: { type: Boolean, default: true },
  33. /**
  34. * The title is also displayed when the menu is collapsed
  35. */
  36. alwaysShowTitle: { type: Boolean },
  37. });
  38. const localeStore = useLocaleStore();
  39. const isEn = computed(() => localeStore.getLocale === 'en');
  40. const { prefixCls } = useDesign('app-logo');
  41. const { getCollapsedShowTitle } = useMenuSetting();
  42. const userStore = useUserStore();
  43. const { title } = useGlobSetting();
  44. const go = useGo();
  45. const getAppLogoClass = computed(() => [
  46. prefixCls,
  47. props.theme,
  48. { 'collapsed-show-title': unref(getCollapsedShowTitle) },
  49. ]);
  50. const getTitleClass = computed(() => [
  51. `${prefixCls}__title`,
  52. {
  53. 'xs:opacity-0': !props.alwaysShowTitle,
  54. },
  55. ]);
  56. function goHome() {
  57. go(userStore.getUserInfo.homePath || PageEnum.BASE_HOME);
  58. }
  59. </script>
  60. <style lang="less" scoped>
  61. @prefix-cls: ~'@{namespace}-app-logo';
  62. .@{prefix-cls} {
  63. display: flex;
  64. align-items: center;
  65. padding-left: 7px;
  66. cursor: pointer;
  67. transition: all 0.2s ease;
  68. &.light {
  69. border-bottom: 1px solid @border-color-base;
  70. }
  71. &.collapsed-show-title {
  72. padding-left: 20px;
  73. }
  74. &.light &__title {
  75. color: @primary-color;
  76. }
  77. &.dark &__title {
  78. color: @white;
  79. }
  80. &__title {
  81. font-size: 16px;
  82. font-weight: 700;
  83. transition: all 0.5s;
  84. line-height: normal;
  85. }
  86. }
  87. </style>