preloading.js 1.1 KB

1234567891011121314151617181920212223242526
  1. window.onload = function () {
  2. if(this.sessionStorage.getItem("preloading")) return
  3. let pre = document.getElementById('pre')
  4. if (!pre) {
  5. let pre = document.createElement("div")
  6. pre.setAttribute('id', 'pre')
  7. pre.setAttribute('style', 'position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 100000; ')
  8. let cover = document.createElement('div')
  9. cover.setAttribute('style', 'background-color: rgba(0, 0, 0, .8); width: 100%; height: 100%;')
  10. let loading = document.createElement('div')
  11. loading.setAttribute('style', 'position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);')
  12. let img = document.createElement('img')
  13. img.setAttribute('src', '/img/loding.jpg')
  14. loading.appendChild(img)
  15. cover.appendChild(loading)
  16. pre.appendChild(cover)
  17. document.body.appendChild(pre)
  18. }
  19. let app = document.createElement("script")
  20. app.setAttribute("src", "/js/app.8bf2d5f0.js") // 与生成app同步
  21. document.body.appendChild(app)
  22. let chunk = document.createElement("script")
  23. chunk.setAttribute("src", "/js/chunk-vendors.89f16f72.js") // 同步
  24. document.body.appendChild(chunk)
  25. }