Loading.svelte 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <script>
  2. import { isLoading } from '../control/loading';
  3. </script>
  4. {#if $isLoading}
  5. <div id="loading">
  6. <div class="loading-content">
  7. <div class="loading-spinner"></div>
  8. <br>
  9. <p>加载中...</p>
  10. </div>
  11. </div>
  12. {/if}
  13. <style>
  14. /* 全屏 loading 样式 */
  15. #loading {
  16. position: fixed;
  17. top: 0;
  18. left: 0;
  19. width: 100%;
  20. height: 100%;
  21. background: rgba(255, 255, 255, 0.9); /* 半透明背景 */
  22. z-index: 9999; /* 确保在最前面 */
  23. display: block; /* 默认隐藏 */
  24. }
  25. /* loading 内容区域 */
  26. .loading-content {
  27. position: absolute;
  28. top: 50%;
  29. left: 50%;
  30. transform: translate(-50%, -50%);
  31. text-align: center;
  32. }
  33. /* loading 动画 */
  34. .loading-spinner {
  35. width: 50px;
  36. height: 50px;
  37. border: 5px solid #f3f3f3;
  38. border-top: 5px solid #3498db;
  39. border-radius: 50%;
  40. animation: spin 1s linear infinite;
  41. }
  42. @keyframes spin {
  43. 0% { transform: rotate(0deg); }
  44. 100% { transform: rotate(360deg); }
  45. }
  46. </style>