loading.js 1.7 KB

1234567891011121314151617181920212223242526272829
  1. window.$owl = window.$owl || {}
  2. window.$owl.appLoader = () => {
  3. const value = localStorage.getItem(window.$adminApiPrefix.replace(/^\//, '') + '-settings')
  4. const settings = JSON.parse(value == 'undefined' ? '{}' : value)
  5. const color = settings?.system_theme_setting?.themeColor || '#1C1C1C'
  6. const bgColor = settings?.system_theme_setting?.darkTheme ? '#1f1f1f' : '#FFFFFF'
  7. const loader = `
  8. <div id="app-loader">
  9. <style>
  10. body{ margin: 0; padding: 0; }
  11. #app-loader { position: fixed; top: 0; left: 0; right: 0; bottom: 0; font-size: 20px; display: flex; align-items: center; justify-content: center; background-color: ${bgColor}; z-index: 9999; }
  12. .loader { position: relative; display: inline-block; font-size: 20px; width: 40px; height: 40px; transform: rotate(45deg); animation: antRotate 1.2s infinite linear;}
  13. .loader i { width: 16px; height: 16px; border-radius: 100%; background-color: ${color}; transform: scale(0.75); display: block; position: absolute; opacity: 0.3; animation: antSpinMove 1s infinite linear alternate; transform-origin: 50% 50%; }
  14. .loader i:nth-child(1) { left: 0; top: 0; } .loader i:nth-child(2) { right: 0; top: 0; animation-delay: 0.4s; }
  15. .loader i:nth-child(3) { right: 0; bottom: 0; animation-delay: 0.8s; } .loader i:nth-child(4) { left: 0; bottom: 0; animation-delay: 1.2s; }
  16. @keyframes antSpinMove { to { opacity: 1; } } @keyframes antRotate { to { transform: rotate(405deg); } }
  17. </style>
  18. <div>
  19. <span class="loader"><i></i> <i></i> <i></i> <i></i></span>
  20. </div>
  21. </div>
  22. `
  23. document.body.children.item(0).insertAdjacentHTML('afterend', loader)
  24. }
  25. window.$owl.appLoader()