line.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <!--
  2. * @Author: NMTuan
  3. * @Email: NMTuan@qq.com
  4. * @Date: 2024-02-18 22:03:42
  5. * @LastEditTime: 2024-02-19 23:18:32
  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 absolute -top-6">
  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
  24. class="absolute bottom-0 w-[1px] h-[52px] bg-red-500"
  25. :style="progressStyle"
  26. ></div>
  27. </div>
  28. </template>
  29. <script setup>
  30. const dateStore = useDateStore()
  31. const progressStyle = computed(() => {
  32. const second =
  33. dateStore.hour * 3600 + dateStore.minute * 60 + dateStore.second
  34. const oneDaySecond = 24 * 3600
  35. // round会导致时间线的秒针位置不准确
  36. // const left = Math.round(second / oneDaySecond).toFixed(2)
  37. const left = second / oneDaySecond
  38. return {
  39. left: left + '%'
  40. }
  41. })
  42. </script>