index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <transition name="fade" v-if="styleLoadingIsOpen">
  3. <view
  4. class="mask"
  5. v-show="isActive"
  6. :class="{ 'full-screen': isFullScreen }"
  7. :style="{ backgroundColor }"
  8. >
  9. <view
  10. class="spinner"
  11. :style="{ transform: `translate(-50%, -${translateY}%)` }"
  12. >
  13. <slot>
  14. <loop v-if="styleLoadingType === 'loop'" :color="themeColor.color" :size="size" />
  15. <shrinkRect v-if="styleLoadingType === 'shrinkRect'" :color="themeColor.color" :size="size" />
  16. <bounce v-if="styleLoadingType === 'bounce'" :color="themeColor.color" :size="size" />
  17. <doubleBounce v-if="styleLoadingType === 'doubleBounce'" :color="themeColor.color" :size="size" />
  18. <doubleCube v-if="styleLoadingType === 'doubleCube'" :color="themeColor.color" :size="size" />
  19. <doubleDot v-if="styleLoadingType === 'doubleDot'" :color="themeColor.color" :size="size" />
  20. <rotatePlane v-if="styleLoadingType === 'rotatePlane'" :color="themeColor.color" :size="size" />
  21. <scaleOut v-if="styleLoadingType === 'scaleOut'" :color="themeColor.color" :size="size" />
  22. </slot>
  23. <view v-if="text.length" :style="{ color: textColor }">
  24. {{ text }}
  25. </view>
  26. </view>
  27. </view>
  28. </transition>
  29. </template>
  30. <script>
  31. // ==========在这里选一个您要的其他去掉也行==========
  32. import loop from './loaders/loop.vue';
  33. import bounce from './loaders/bounce.vue';
  34. import doubleBounce from './loaders/double-bounce.vue';
  35. import doubleCube from './loaders/double-cube.vue';
  36. import doubleDot from './loaders/double-dot.vue';
  37. import rotatePlane from './loaders/rotate-plane.vue';
  38. import scaleOut from './loaders/scale-out.vue';
  39. import shrinkRect from './loaders/shrink-rect.vue';
  40. // ==========在这里选一个您要的其他去掉也行==========
  41. export default {
  42. name: 'rfLoading',
  43. components: {
  44. loop,
  45. bounce,
  46. doubleBounce,
  47. doubleCube,
  48. doubleDot,
  49. rotatePlane,
  50. scaleOut,
  51. shrinkRect
  52. },
  53. props: {
  54. active: Boolean,
  55. translateY: {
  56. type: Number,
  57. default: 150
  58. },
  59. text: {
  60. type: String,
  61. default: ''
  62. },
  63. color: {
  64. type: String,
  65. default: '#333'
  66. },
  67. textColor: {
  68. type: String,
  69. default: '#333'
  70. },
  71. isFullScreen: {
  72. type: Boolean,
  73. default: false
  74. },
  75. backgroundColor: {
  76. type: String,
  77. default: 'rgba(255, 255, 255, .9)'
  78. },
  79. size: {
  80. type: Number,
  81. default: 40
  82. }
  83. },
  84. data() {
  85. return {
  86. isActive: this.active || false,
  87. styleLoadingIsOpen: this.$mSettingConfig.styleLoadingIsOpen,
  88. styleLoadingType: this.$mSettingConfig.styleLoadingType
  89. };
  90. },
  91. watch: {
  92. active(value) {
  93. this.isActive = value;
  94. }
  95. }
  96. };
  97. </script>
  98. <style scoped>
  99. .mask {
  100. position: absolute;
  101. left: 0;
  102. right: 0;
  103. top: 0;
  104. bottom: 0;
  105. z-index: 3000;
  106. transition: opacity 0.3s linear;
  107. }
  108. .full-screen {
  109. position: fixed;
  110. top: 0;
  111. right: 0;
  112. bottom: 0;
  113. left: 0;
  114. }
  115. .spinner {
  116. position: absolute;
  117. top: 50%;
  118. left: 50%;
  119. text-align: center;
  120. }
  121. .fade-enter-active,
  122. .fade-leave-active {
  123. transition: opacity 0.3s;
  124. }
  125. .fade-enter,
  126. .fade-leave-to {
  127. opacity: 0;
  128. }
  129. </style>