DownloadProgress.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div class="c-progress-list">
  3. <div
  4. v-for="file in files"
  5. :key="file.id"
  6. class="l-flex--row c-progress-list__item"
  7. >
  8. <div class="l-flex__none c-progress-list__type" />
  9. <div class="l-flex__auto l-flex--col">
  10. <div class="c-progress-list__info">
  11. <div class="l-flex__auto c-progress-list__name u-ellipsis">{{ file.name }}</div>
  12. <div class="l-flex__none c-progress-list__tip">{{ file.tip }}</div>
  13. <div class="l-flex__none c-progress-list__icon">
  14. <template v-if="file.complete">
  15. <i
  16. v-if="file.success"
  17. class="el-icon-success u-color--success"
  18. />
  19. <i
  20. v-else
  21. class="el-icon-error u-color--error"
  22. />
  23. </template>
  24. </div>
  25. </div>
  26. <el-progress
  27. :class="[file.status]"
  28. :percentage="file.percentage"
  29. :stroke-width="2"
  30. :show-text="false"
  31. />
  32. </div>
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. import {
  38. addListener,
  39. removeListener
  40. } from '../monitor'
  41. export default {
  42. name: 'DownloadProgress',
  43. data () {
  44. return {
  45. files: []
  46. }
  47. },
  48. created () {
  49. addListener('download', this.onUpdate)
  50. },
  51. beforeDestroy () {
  52. removeListener('download', this.onUpdate)
  53. },
  54. methods: {
  55. onUpdate (files) {
  56. this.files = files
  57. }
  58. }
  59. }
  60. </script>
  61. <style lang="scss" scoped>
  62. .c-progress-list {
  63. display: flex;
  64. flex-direction: column;
  65. overflow: auto;
  66. &__item {
  67. padding: 6px 16px 6px 0;
  68. color: $gray--dark;
  69. border-bottom: 1px solid $gray--light;
  70. &:first-child {
  71. border-top: 1px solid $gray--light;
  72. }
  73. }
  74. &__type {
  75. margin-right: $spacing;
  76. }
  77. &__info {
  78. display: flex;
  79. align-items: flex-end;
  80. padding-bottom: 6px;
  81. line-height: 1;
  82. }
  83. &__name {
  84. min-width: 0;
  85. color: $gray--dark;
  86. font-size: 16px;
  87. }
  88. &__tip {
  89. min-width: 90px;
  90. padding-left: 10px;
  91. font-size: 12px;
  92. text-align: right;
  93. }
  94. &__icon {
  95. width: 50px;
  96. text-align: right;
  97. }
  98. .is-processing {
  99. ::v-deep {
  100. .el-progress-bar__outer::before {
  101. content: "";
  102. position: absolute;
  103. top: 0;
  104. left: 0;
  105. height: 100%;
  106. width: 100%;
  107. background-size: 3em 3em;
  108. background-image: linear-gradient(
  109. 90deg,
  110. transparent 0em,
  111. transparent 1em,
  112. $blue 1em,
  113. $blue 2em,
  114. transparent 2em,
  115. transparent 3em,
  116. $blue 3em
  117. );
  118. animation: move 0.3s linear infinite;
  119. }
  120. .el-progress-bar__inner {
  121. background-color: $blue;
  122. }
  123. }
  124. }
  125. }
  126. @keyframes move {
  127. from {
  128. background-position: 0 0;
  129. }
  130. to {
  131. background-position: 3em 0;
  132. }
  133. }
  134. </style>