ProgressPage.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <div v-show="visible" class="main">
  3. <div class="center">
  4. <el-progress type="circle" :width="100" :stroke-width="5" color="#0F9900" :percentage="percentage"></el-progress>
  5. <p class="text">{{ text }}</p>
  6. </div>
  7. </div>
  8. </template>
  9. <script>
  10. //-----------------------------------------------------------------------------
  11. import Vue from 'vue';
  12. import Component from 'vue-class-component';
  13. const ruMessage = {
  14. 'start': ' ',
  15. 'finish': ' ',
  16. 'error': ' ',
  17. 'download': 'скачивание',
  18. 'decompress': 'распаковка',
  19. 'convert': 'конвертирование',
  20. 'loading': 'загрузка',
  21. 'parse': 'обработка',
  22. };
  23. export default @Component({
  24. })
  25. class ProgressPage extends Vue {
  26. text = '';
  27. totalSteps = 1;
  28. step = 1;
  29. progress = 0;
  30. visible = false;
  31. show() {
  32. this.$el.style.width = this.$parent.$el.offsetWidth + 'px';
  33. this.$el.style.height = this.$parent.$el.offsetHeight + 'px';
  34. this.text = '';
  35. this.totalSteps = 1;
  36. this.step = 1;
  37. this.progress = 0;
  38. this.visible = true;
  39. }
  40. async hide() {
  41. this.visible = false;
  42. }
  43. setState(state) {
  44. if (state.state)
  45. this.text = (ruMessage[state.state] ? ruMessage[state.state] : state.state);
  46. this.step = (state.step ? state.step : this.step);
  47. this.totalSteps = (state.totalSteps > this.totalSteps ? state.totalSteps : this.totalSteps);
  48. this.progress = state.progress || 0;
  49. }
  50. get percentage() {
  51. let circle = document.querySelector('path[class="el-progress-circle__path"]');
  52. if (circle)
  53. circle.style.transition = '';
  54. return Math.round(((this.step - 1)/this.totalSteps + this.progress/(100*this.totalSteps))*100);
  55. }
  56. }
  57. //-----------------------------------------------------------------------------
  58. </script>
  59. <style scoped>
  60. .main {
  61. display: flex;
  62. flex-direction: column;
  63. justify-content: center;
  64. align-items: center;
  65. z-index: 100;
  66. background-color: rgba(0, 0, 0, 0.8);
  67. position: absolute;
  68. }
  69. .center {
  70. display: flex;
  71. flex-direction: column;
  72. justify-content: flex-start;
  73. align-items: center;
  74. color: white;
  75. height: 300px;
  76. }
  77. .text {
  78. color: yellow;
  79. }
  80. </style>
  81. <style>
  82. .el-progress__text {
  83. color: lightgreen;
  84. }
  85. </style>