cwg-pc-header.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <header class="cwg-pc-header">
  3. <div class="left">
  4. <cwg-icon :name="!props.sidebarVisible ? 'crm-bars-staggered' : 'crm-angle-left'" :size="24" color="#e32326"
  5. @click="$emit('toggle-sidebar')" />
  6. </div>
  7. <div class="center"></div>
  8. <div class="right">
  9. <div class="lang-select">
  10. <image class="img flag" src="/static/flag-en.png" alt="en" />
  11. <text>English</text>
  12. <text class="arrow">▼</text>
  13. </div>
  14. <text class="icon sun" @click="toggleTheme">🌞</text>
  15. <text class="icon bell">🔔<text class="dot"></text></text>
  16. <text class="icon avatar">
  17. <image class="img" src="/static/avatar.png" alt="avatar" />
  18. </text>
  19. <text class="icon logo" @click="openRightDrawer">
  20. <image class="img" src="/static/logo.png" alt="logo" />
  21. </text>
  22. </div>
  23. </header>
  24. </template>
  25. <script setup lang="ts">
  26. import useGlobalStore from '@/stores/use-global-store'
  27. const globalStore = useGlobalStore()
  28. import useRouter from "@/hooks/useRouter";
  29. const router = useRouter();
  30. const props = defineProps({
  31. sidebarVisible: {
  32. type: Boolean,
  33. default: false
  34. },
  35. })
  36. const emit = defineEmits<{
  37. (e: 'open-right-drawer'): void
  38. }>()
  39. function toggleTheme() {
  40. globalStore.setGlobalTheme(globalStore.theme === 'light' ? 'dark' : 'light');
  41. }
  42. function openRightDrawer() {
  43. emit('open-right-drawer');
  44. }
  45. </script>
  46. <style scoped lang="scss">
  47. .cwg-pc-header {
  48. display: flex;
  49. align-items: center;
  50. justify-content: space-between;
  51. height: 56px;
  52. background: #fff;
  53. border-bottom: 1px solid #f0f0f0;
  54. padding: 0 32px;
  55. position: relative;
  56. z-index: 10;
  57. }
  58. .left {
  59. display: flex;
  60. align-items: center;
  61. }
  62. .back-arrow {
  63. color: #e74c3c;
  64. font-size: 22px;
  65. cursor: pointer;
  66. margin-right: 16px;
  67. }
  68. .center {
  69. flex: 1;
  70. }
  71. .right {
  72. display: flex;
  73. align-items: center;
  74. gap: 18px;
  75. }
  76. .lang-select {
  77. display: flex;
  78. align-items: center;
  79. background: #f5f7fa;
  80. border-radius: 18px;
  81. padding: 4px 12px;
  82. font-size: 14px;
  83. cursor: pointer;
  84. }
  85. .flag {
  86. width: 22px;
  87. height: 16px;
  88. margin-right: 6px;
  89. }
  90. .arrow {
  91. margin-left: 4px;
  92. font-size: 12px;
  93. }
  94. .icon {
  95. font-size: 20px;
  96. position: relative;
  97. cursor: pointer;
  98. }
  99. .bell .dot {
  100. position: absolute;
  101. top: 0;
  102. right: -2px;
  103. width: 7px;
  104. height: 7px;
  105. background: #27ae60;
  106. border-radius: 50%;
  107. display: inline-block;
  108. }
  109. .avatar .img {
  110. width: 32px;
  111. height: 32px;
  112. border-radius: 50%;
  113. background: #eee;
  114. }
  115. .logo .img {
  116. width: 36px;
  117. height: 36px;
  118. border-radius: 50%;
  119. background: #fff;
  120. }
  121. </style>