Logo.vue 1.6 KB
Newer Older
陈文彬 已提交
1
<template>
N
nebv 已提交
2
  <div class="app-logo" @click="handleGoHome">
陈文彬 已提交
3
    <img :src="logo" />
4
    <div v-if="show" class="logo-title ml-1 ellipsis">{{ globSetting.title }}</div>
陈文彬 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
  </div>
</template>
<script lang="ts">
  import { defineComponent, PropType, ref, watch } from 'vue';
  // hooks
  import { useSetting } from '/@/hooks/core/useSetting';

  import { PageEnum } from '/@/enums/pageEnum';
  import logo from '/@/assets/images/logo.png';
  import { useTimeout } from '/@/hooks/core/useTimeout';
  import { useGo } from '/@/hooks/web/usePage';

  export default defineComponent({
    name: 'Logo',
    props: {
      showTitle: {
        type: Boolean as PropType<boolean>,
        default: true,
      },
    },
    setup(props) {
      const { globSetting } = useSetting();
      const go = useGo();
      function handleGoHome() {
        go(PageEnum.BASE_HOME);
      }
      const showRef = ref<boolean>(!!props.showTitle);
      watch(
        () => props.showTitle,
        (show: boolean) => {
          if (show) {
            useTimeout(() => {
              showRef.value = show;
            }, 280);
          } else {
            showRef.value = show;
          }
        }
      );
      return {
        handleGoHome,
        globSetting,
        show: showRef,
        logo,
      };
    },
  });
</script>
N
nebv 已提交
53 54 55 56 57 58 59 60 61 62 63 64
<style lang="less" scoped>
  @import (reference) '../design/index.less';

  .app-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;

    .logo-title {
      display: none;
      font-family: Georgia, serif;
65
      font-size: 16px;
N
nebv 已提交
66 67 68 69 70 71
      .respond-to(medium,{
       display: block;
     });
    }
  }
</style>