cwg-pc-header.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <uni-nav-bar
  3. :leftWidth="0"
  4. :rightWidth="0"
  5. :statusBar="true"
  6. :fixed="true"
  7. :height="55"
  8. :border="false"
  9. >
  10. <view class="cwg-pc-header bg-body">
  11. <!-- 左侧 -->
  12. <view class="left">
  13. <cwg-icon
  14. :name="!sidebarVisible ? 'crm-bars-staggered' : 'cwg-close'"
  15. color="#97A1C0"
  16. @click="openLeftDrawer"
  17. />
  18. </view>
  19. <!-- 中间 Logo -->
  20. <view class="center-logo" v-if="!isMobile">
  21. <image
  22. v-if="!isDark"
  23. class="logo-img"
  24. src="/static/images/vu/logo-full.svg"
  25. mode="widthFix"
  26. alt="logo"
  27. />
  28. <image
  29. v-else
  30. class="logo-img"
  31. src="/static/images/vu/logo-full-white.svg"
  32. mode="widthFix"
  33. alt="logo"
  34. />
  35. </view>
  36. <!-- 右侧 -->
  37. <view class="right">
  38. <cwg-download />
  39. <cwg-notice />
  40. <cwg-right-drawer />
  41. </view>
  42. </view>
  43. </uni-nav-bar>
  44. </template>
  45. <script setup lang="ts">
  46. import { computed } from 'vue'
  47. import useGlobalStore from '@/stores/use-global-store'
  48. import { useWindowWidth } from '@/composables/useWindowWidth'
  49. const windowWidth = useWindowWidth(300)
  50. const isMobile = computed(() => windowWidth.value <= 768)
  51. const globalStore = useGlobalStore()
  52. const isDark = computed(() => globalStore.theme === 'dark')
  53. defineProps({
  54. sidebarVisible: {
  55. type: Boolean,
  56. default: false
  57. }
  58. })
  59. const emit = defineEmits<{
  60. (e: 'open-right-drawer'): void
  61. (e: 'open-left-drawer'): void
  62. }>()
  63. function openLeftDrawer() {
  64. emit('open-left-drawer')
  65. }
  66. </script>
  67. <style scoped lang="scss">
  68. @import "@/uni.scss";
  69. .cwg-pc-header {
  70. position: relative;
  71. display: flex;
  72. align-items: center;
  73. justify-content: space-between;
  74. width: 100vw;
  75. height: px2rpx(55);
  76. padding: 0 px2rpx(16);
  77. box-sizing: border-box;
  78. background-color: rgba(255, 255, 255, 0.9);
  79. border-bottom: 1px solid var(--bs-border-color);
  80. }
  81. /* 左右区域 */
  82. .left,
  83. .right {
  84. display: flex;
  85. align-items: center;
  86. z-index: 2;
  87. }
  88. /* 中间 Logo 真正居中 */
  89. .center-logo {
  90. position: absolute;
  91. left: 50%;
  92. top: 50%;
  93. transform: translate(-50%, -50%);
  94. display: flex;
  95. align-items: center;
  96. justify-content: center;
  97. pointer-events: none;
  98. }
  99. /* Logo */
  100. .logo-img {
  101. width: px2rpx(120);
  102. display: block;
  103. }
  104. /* 通知红点 */
  105. .bell .dot {
  106. position: absolute;
  107. top: 0;
  108. right: -2px;
  109. width: 7px;
  110. height: 7px;
  111. background: #27ae60;
  112. border-radius: 50%;
  113. display: inline-block;
  114. }
  115. /* 头像 */
  116. .avatar .img {
  117. width: 32px;
  118. height: 32px;
  119. border-radius: 50%;
  120. background: #eee;
  121. }
  122. /* Logo占位 */
  123. .logo .img {
  124. width: 36px;
  125. height: 36px;
  126. border-radius: 50%;
  127. background: #fff;
  128. }
  129. </style>