GlobalAside.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <script lang="ts" setup>
  2. import { useMenuStore } from '@/stores/menu'
  3. import { useThemeStore } from '@/stores/theme'
  4. import config from '@/config/defaultSetting'
  5. import router from '@/router'
  6. const handleLogoClick = () => {
  7. router.push({ name: config.homeRouteName })
  8. }
  9. const menuStore = useMenuStore()
  10. const collapse = computed(() => menuStore.collapse)
  11. const themeStore = useThemeStore()
  12. const themeStyle = computed(() => themeStore.themeStyle)
  13. const logoStyle = computed(() => {
  14. if (themeStyle.value.name === 'nav-light') {
  15. return {
  16. color: themeStyle.value.textColor,
  17. backgroundColor: themeStyle.value.bgColor
  18. }
  19. }
  20. return {
  21. color: '#fff',
  22. backgroundColor: themeStyle.value.bgColor
  23. }
  24. })
  25. </script>
  26. <template>
  27. <div
  28. class="logo flex items-center justify-center cursor-pointer px-10px"
  29. :class="{ collapse: collapse }"
  30. :style="logoStyle"
  31. @click="handleLogoClick"
  32. >
  33. <img src="/logo.png" class="h-36px" />
  34. <div class="ml-2 line2" :class="{ hidden: collapse }">{{ config.title }}</div>
  35. </div>
  36. <global-menu />
  37. </template>
  38. <style lang="scss" scoped>
  39. .logo {
  40. width: var(--menu-width);
  41. height: var(--el-header-height);
  42. }
  43. .collapse {
  44. width: calc(var(--el-menu-icon-width) + var(--el-menu-base-level-padding) * 2);
  45. }
  46. </style>