UsageProgressLine.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <script setup lang="ts">
  2. import {computed} from 'vue'
  3. const props = withDefaults(defineProps<{
  4. percent: number
  5. }>(), {
  6. percent: 0
  7. })
  8. const color = computed(() => {
  9. if (props.percent < 80) {
  10. return '#1890ff'
  11. } else if (props.percent >= 80 && props.percent < 90) {
  12. return '#faad14'
  13. } else {
  14. return '#ff6385'
  15. }
  16. })
  17. const fixed_percent = computed(() => {
  18. return parseFloat(props.percent.toFixed(2))
  19. })
  20. </script>
  21. <template>
  22. <div>
  23. <div>
  24. <span class="slot-icon"><slot name="icon"></slot></span>
  25. <span class="slot">
  26. <slot></slot>
  27. </span>
  28. <span class="dot"> ·</span> {{ fixed_percent + '%' }}
  29. </div>
  30. <a-progress :percent="fixed_percent" :stroke-color="color" :show-info="false"/>
  31. </div>
  32. </template>
  33. <style scoped lang="less">
  34. .slot-icon {
  35. margin-right: 5px;
  36. }
  37. @media (max-width: 1000px) and (min-width: 600px) {
  38. .dot {
  39. display: none;
  40. }
  41. .slot {
  42. display: none;
  43. }
  44. }
  45. </style>