loading.js 5.4 KB

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