loading.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /**
  2. * loading 占位
  3. * 解决首次加载时白屏的问题
  4. */
  5. (function () {
  6. const _root = document.querySelector('#root');
  7. if (_root && _root.innerHTML === '') {
  8. _root.innerHTML = `
  9. <style>
  10. html,
  11. body,
  12. #root {
  13. height: 100%;
  14. margin: 0;
  15. padding: 0;
  16. }
  17. #root {
  18. background-repeat: no-repeat;
  19. background-size: 100% auto;
  20. }
  21. .loading-title {
  22. font-size: 1.1rem;
  23. }
  24. .loading-sub-title {
  25. margin-top: 20px;
  26. font-size: 1rem;
  27. color: #888;
  28. }
  29. .page-loading-warp {
  30. display: flex;
  31. align-items: center;
  32. justify-content: center;
  33. padding: 26px;
  34. }
  35. .ant-spin {
  36. position: absolute;
  37. display: none;
  38. -webkit-box-sizing: border-box;
  39. box-sizing: border-box;
  40. margin: 0;
  41. padding: 0;
  42. color: rgba(0, 0, 0, 0.65);
  43. color: #1890ff;
  44. font-size: 14px;
  45. font-variant: tabular-nums;
  46. line-height: 1.5;
  47. text-align: center;
  48. list-style: none;
  49. opacity: 0;
  50. -webkit-transition: -webkit-transform 0.3s
  51. cubic-bezier(0.78, 0.14, 0.15, 0.86);
  52. transition: -webkit-transform 0.3s
  53. cubic-bezier(0.78, 0.14, 0.15, 0.86);
  54. transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
  55. transition: transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86),
  56. -webkit-transform 0.3s cubic-bezier(0.78, 0.14, 0.15, 0.86);
  57. -webkit-font-feature-settings: "tnum";
  58. font-feature-settings: "tnum";
  59. }
  60. .ant-spin-spinning {
  61. position: static;
  62. display: inline-block;
  63. opacity: 1;
  64. }
  65. .ant-spin-dot {
  66. position: relative;
  67. display: inline-block;
  68. width: 20px;
  69. height: 20px;
  70. font-size: 20px;
  71. }
  72. .ant-spin-dot-item {
  73. position: absolute;
  74. display: block;
  75. width: 9px;
  76. height: 9px;
  77. background-color: #1890ff;
  78. border-radius: 100%;
  79. -webkit-transform: scale(0.75);
  80. -ms-transform: scale(0.75);
  81. transform: scale(0.75);
  82. -webkit-transform-origin: 50% 50%;
  83. -ms-transform-origin: 50% 50%;
  84. transform-origin: 50% 50%;
  85. opacity: 0.3;
  86. -webkit-animation: antspinmove 1s infinite linear alternate;
  87. animation: antSpinMove 1s infinite linear alternate;
  88. }
  89. .ant-spin-dot-item:nth-child(1) {
  90. top: 0;
  91. left: 0;
  92. }
  93. .ant-spin-dot-item:nth-child(2) {
  94. top: 0;
  95. right: 0;
  96. -webkit-animation-delay: 0.4s;
  97. animation-delay: 0.4s;
  98. }
  99. .ant-spin-dot-item:nth-child(3) {
  100. right: 0;
  101. bottom: 0;
  102. -webkit-animation-delay: 0.8s;
  103. animation-delay: 0.8s;
  104. }
  105. .ant-spin-dot-item:nth-child(4) {
  106. bottom: 0;
  107. left: 0;
  108. -webkit-animation-delay: 1.2s;
  109. animation-delay: 1.2s;
  110. }
  111. .ant-spin-dot-spin {
  112. -webkit-transform: rotate(45deg);
  113. -ms-transform: rotate(45deg);
  114. transform: rotate(45deg);
  115. -webkit-animation: antrotate 1.2s infinite linear;
  116. animation: antRotate 1.2s infinite linear;
  117. }
  118. .ant-spin-lg .ant-spin-dot {
  119. width: 32px;
  120. height: 32px;
  121. font-size: 32px;
  122. }
  123. .ant-spin-lg .ant-spin-dot i {
  124. width: 14px;
  125. height: 14px;
  126. }
  127. @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
  128. .ant-spin-blur {
  129. background: #fff;
  130. opacity: 0.5;
  131. }
  132. }
  133. @-webkit-keyframes antSpinMove {
  134. to {
  135. opacity: 1;
  136. }
  137. }
  138. @keyframes antSpinMove {
  139. to {
  140. opacity: 1;
  141. }
  142. }
  143. @-webkit-keyframes antRotate {
  144. to {
  145. -webkit-transform: rotate(405deg);
  146. transform: rotate(405deg);
  147. }
  148. }
  149. @keyframes antRotate {
  150. to {
  151. -webkit-transform: rotate(405deg);
  152. transform: rotate(405deg);
  153. }
  154. }
  155. </style>
  156. <div style="
  157. display: flex;
  158. flex-direction: column;
  159. align-items: center;
  160. justify-content: center;
  161. height: 100%;
  162. min-height: 362px;
  163. ">
  164. <div class="page-loading-warp">
  165. <div class="ant-spin ant-spin-lg ant-spin-spinning">
  166. <span class="ant-spin-dot ant-spin-dot-spin">
  167. <i class="ant-spin-dot-item"></i>
  168. <i class="ant-spin-dot-item"></i>
  169. <i class="ant-spin-dot-item"></i>
  170. <i class="ant-spin-dot-item"></i>
  171. </span>
  172. </div>
  173. </div>
  174. </div>
  175. `;
  176. }
  177. })();