welcomeBar.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <script setup lang="ts">
  2. import {useUserStore} from "@/store/modules/user";
  3. import { ref } from "vue"
  4. const { t } = useI18n()
  5. const userStore = useUserStore()
  6. const avatar = userStore.getUser.avatar
  7. const username = userStore.getUser.nickname
  8. // 星期映射
  9. const weekDays = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"]
  10. // 获取当前日期
  11. const getToday = () => {
  12. const now = new Date()
  13. const year = now.getFullYear()
  14. const month = now.getMonth() + 1
  15. const day = now.getDate()
  16. const week = weekDays[now.getDay()]
  17. return `${year}年${month}月${day}日,${week}`
  18. }
  19. const todayStr = ref(getToday())
  20. </script>
  21. <template>
  22. <div class="flex items-center">
  23. <el-avatar :src="avatar" :size="70" class="mr-16px">
  24. <img src="../../assets/imgs/avatar.gif" alt="" />
  25. </el-avatar>
  26. <div>
  27. <div class="text-20px">
  28. {{ t('workplace.welcome') }} {{ username }} {{ t('workplace.happyDay') }}
  29. </div>
  30. <div class="mt-10px text-14px text-gray-500">
  31. {{ todayStr }}
  32. </div>
  33. </div>
  34. </div>
  35. </template>
  36. <style scoped lang="scss">
  37. .items-center{
  38. background: #fff;
  39. padding: 20px;
  40. }
  41. </style>