index.html 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <!DOCTYPE html>
  2. <html lang="">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <link rel="icon" href="/favicon.ico" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>镇水安澜</title>
  8. <style>
  9. * {
  10. margin: 0;
  11. padding: 0;
  12. box-sizing: border-box;
  13. }
  14. #app-container {
  15. width: 100vw;
  16. height: 100vh;
  17. overflow-y: auto;
  18. }
  19. #app {
  20. width: 100%;
  21. height: 100%;
  22. }
  23. @media (max-width: 768px) and (orientation: portrait) {
  24. body:not(.in-iframe) #app-container {
  25. position: fixed;
  26. top: 50%;
  27. left: 50%;
  28. width: 100vh;
  29. height: 100vw;
  30. transform: translate(-50%, -50%) rotate(90deg);
  31. transform-origin: center center;
  32. }
  33. body:not(.in-iframe) #app {
  34. display: none;
  35. }
  36. body:not(.in-iframe) #app-iframe {
  37. display: block;
  38. width: 100%;
  39. height: 100%;
  40. border: none;
  41. }
  42. }
  43. body.in-iframe #app-container {
  44. width: 100%;
  45. height: 100%;
  46. }
  47. body.in-iframe #app-iframe {
  48. display: none;
  49. }
  50. #app-iframe {
  51. display: none;
  52. }
  53. </style>
  54. </head>
  55. <body>
  56. <div id="app-container">
  57. <div id="app"></div>
  58. <iframe id="app-iframe"></iframe>
  59. </div>
  60. <script>
  61. if (window.self !== window.top) {
  62. document.body.classList.add("in-iframe");
  63. }
  64. if (window.self === window.top) {
  65. function handleOrientation() {
  66. const app = document.getElementById("app");
  67. const iframe = document.getElementById("app-iframe");
  68. if (
  69. window.innerWidth <= 768 &&
  70. window.innerHeight > window.innerWidth
  71. ) {
  72. app.style.display = "none";
  73. iframe.style.display = "block";
  74. if (!iframe.src) {
  75. const url = new URL(window.location.href);
  76. url.searchParams.set("iframe", "1");
  77. iframe.src = url.toString();
  78. }
  79. } else {
  80. app.style.display = "block";
  81. iframe.style.display = "none";
  82. }
  83. }
  84. handleOrientation();
  85. window.addEventListener("resize", handleOrientation);
  86. window.addEventListener("orientationchange", () => {
  87. setTimeout(handleOrientation, 100);
  88. });
  89. }
  90. </script>
  91. <script type="module" src="/src/main.js"></script>
  92. </body>
  93. </html>