<script setup lang="ts">
import { getTopMenu } from "@/router/utils";
import { useNav } from "@/layout/hooks/useNav";
import logoImg from "@/assets/logo.png";
import logoImg2x from "@/assets/logo@2x.png";
import { useRoute } from "vue-router";
import { onMounted } from "vue";
const $route = useRoute();
const props = defineProps({
  collapse: Boolean
});
onMounted(() => {});
const { title, getLogo } = useNav();
</script>

<template>
  <div class="sidebar-logo-container" :class="{ collapses: props.collapse }">
    <transition name="sidebarLogoFade">
      <router-link
        v-if="props.collapse"
        key="props.collapse"
        :title="title"
        class="sidebar-logo-link"
        :to="getTopMenu()?.path ?? '/'"
      >
        <!-- <img :src="logoImg" alt="logo"/>  -->
        <img
          :src="getLogo()"
          alt="logo"
          style="height: 30px; margin-left: 5px"
        />
        <span class="sidebar-title">{{ title }}</span>
      </router-link>
      <router-link
        v-else
        key="expand"
        :title="title"
        class="sidebar-logo-link"
        :to="getTopMenu()?.path ?? '/'"
      >
        <!-- <img :src="getLogo()" alt="logo" /> -->
        <img :src="logoImg2x" alt="logo" class="imgbg" />
        <!-- <img :src:"logoImg" alt="logo"/> -->
        <!-- <span class="sidebar-title">医院运营管理系统</span> -->
      </router-link>
    </transition>
  </div>
</template>

<style lang="scss" scoped>
.sidebar-logo-container {
  position: relative;
  width: 100%;
  height: 48px;
  // border: 1px solid red;
  overflow: hidden;

  .sidebar-logo-link {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    height: 100%;
    padding-left: 10px;

    img {
      display: inline-block;
      // height: 32px;
    }

    .sidebar-title {
      display: inline-block;
      height: 32px;
      margin: 2px 0 0 12px;
      overflow: hidden;
      font-size: 13px;
      // font-weight: 600;
      line-height: 32px;
      // color: $subMenuActiveText;
      color: black;
      // color: #fff;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
}
</style>
