index.html 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <!DOCTYPE html>
  2. <html lang="ZH-cn">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <link rel="icon" href="/favicon.ico" />
  6. <title>管乐团云教练</title>
  7. <meta name="description" content="管乐团APP,器乐学习的不二选择" />
  8. <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
  9. <script src="/helpers/lottie.min.js"></script>
  10. <link href="/vant.css" rel="stylesheet">
  11. <script>
  12. if (window.navigator && navigator.serviceWorker) {
  13. navigator.serviceWorker.getRegistrations().then(function (registrations) {
  14. for (let registration of registrations) {
  15. registration.unregister()
  16. }
  17. })
  18. }
  19. // 获取token
  20. const instance = window.ORCHESTRA || window.webkit?.messageHandlers?.ORCHESTRA
  21. if (instance) {
  22. const sendData = { api: 'getToken', content: { uuid: '' + Date.now() + Math.floor(Math.random() * 1000000) } }
  23. function setToken(evt) {
  24. window.removeEventListener('message', setToken)
  25. try {
  26. const data = JSON.parse(evt.data)
  27. console.log("🚀 ~ data", data)
  28. if (data.api === 'getToken') {
  29. const token = `${data.content.tokenType} ${data.content.accessToken}`
  30. sessionStorage.setItem('Authorization', token)
  31. }
  32. } catch (error) { }
  33. }
  34. window.addEventListener('message', setToken)
  35. instance.postMessage(JSON.stringify(sendData))
  36. }
  37. </script>
  38. <style>
  39. #lottieWeb {
  40. position: fixed;
  41. z-index: 100;
  42. top: 50%;
  43. left: 50%;
  44. width: 100Px;
  45. height: 100Px;
  46. transform: translate(-50%, -50%);
  47. pointer-events: none;
  48. transition: opacity .3s;
  49. }
  50. </style>
  51. </head>
  52. <body>
  53. <div id="app"></div>
  54. <div id="lottieWeb"></div>
  55. <script>
  56. lottie.loadAnimation({
  57. container: document.getElementById('lottieWeb'),
  58. renderer: 'svg',
  59. width: '30px',
  60. height: '30px',
  61. loop: true,
  62. autoplay: true,
  63. path: '/orchestra-music-score/loading.json'
  64. });
  65. window.addEventListener('load', function () {
  66. const loadingEle = document.getElementById('lottieWeb')
  67. loadingEle.style.opacity = '0'
  68. setTimeout(() => {
  69. loadingEle.style.display = 'none'
  70. }, 1000)
  71. })
  72. </script>
  73. <script type="module" src="/src/subpages/colexiu/main.ts"></script>
  74. </body>
  75. </html>