line.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <!--
  2. * @Author: NMTuan
  3. * @Email: NMTuan@qq.com
  4. * @Date: 2024-02-18 22:03:42
  5. * @LastEditTime: 2024-02-20 18:48:40
  6. * @LastEditors: NMTuan
  7. * @Description:
  8. * @FilePath: \timeNow\components\time\line.vue
  9. -->
  10. <template>
  11. <div class="flex items-end justify-between w-full relative select-none">
  12. <template v-for="hour in 25">
  13. <div class="flex flex-col items-center relative">
  14. <div class="font-digital-dismay text-zinc-700 bg-black absolute -top-6 z-10">
  15. {{ hour - 1 }}
  16. </div>
  17. <div class="w-[1px] h-[32px] bg-zinc-800"></div>
  18. </div>
  19. <template v-if="hour !== 25" v-for="m in 3">
  20. <div class="w-[1px] h-[18px] bg-zinc-800"></div>
  21. </template>
  22. </template>
  23. <div class="absolute bottom-0 w-[1px] h-[52px] bg-orange-500 z-1" :style="progressStyle"></div>
  24. </div>
  25. </template>
  26. <script setup>
  27. const dateStore = useDateStore()
  28. const progressStyle = computed(() => {
  29. const second =
  30. dateStore.hour * 3600 + dateStore.minute * 60 + dateStore.second
  31. const oneDaySecond = 24 * 3600
  32. // round会导致时间线的秒针位置不准确
  33. // const left = Math.round(second / oneDaySecond).toFixed(2)
  34. const left = second / oneDaySecond
  35. return {
  36. left: left + '%'
  37. }
  38. })
  39. </script>