main.html 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Chenzhebei-ShanxiMuseum</title>
  8. <link rel="shortcut icon" href="TemplateData/favicon.ico">
  9. <style>
  10. * {
  11. margin: 0;
  12. padding: 0;
  13. box-sizing: border-box;
  14. }
  15. body {
  16. overflow: hidden;
  17. }
  18. .root {
  19. position: absolute;
  20. }
  21. iframe {
  22. width: 100%;
  23. height: 100%;
  24. }
  25. @media all and (orientation: landscape) {
  26. .landscape {
  27. transform: rotate(0deg);
  28. width: 100vw;
  29. width: 100dvw;
  30. height: 100vh;
  31. height: 100dvh;
  32. top: 0;
  33. left: 0;
  34. }
  35. .portrait {
  36. transform: rotate(90deg);
  37. transform-origin: left top;
  38. width: 100vh;
  39. width: 100dvh;
  40. height: 100vw;
  41. height: 100dvw;
  42. left: 100%;
  43. }
  44. }
  45. @media all and (orientation: portrait) {
  46. .landscape {
  47. transform: rotate(90deg);
  48. transform-origin: left top;
  49. width: 100vh;
  50. width: 100dvh;
  51. height: 100vw;
  52. height: 100dvw;
  53. left: 100%;
  54. }
  55. .portrait {
  56. transform: rotate(0deg);
  57. width: 100vw;
  58. width: 100dvw;
  59. height: 100vh;
  60. height: 100dvh;
  61. top: 0;
  62. left: 0;
  63. }
  64. }
  65. </style>
  66. </head>
  67. <body>
  68. <div class="root">
  69. <iframe
  70. id="main"
  71. frameborder="0">
  72. </iframe>
  73. </div>
  74. </body>
  75. <script>
  76. const rootDom = document.querySelector('.root')
  77. const iframe = document.querySelector('#main')
  78. let isPortrait = false;
  79. function internal_ChangeViewType(portrait){
  80. if(portrait){
  81. rootDom.classList.remove('landscape');
  82. rootDom.classList.add('portrait');
  83. }else{
  84. rootDom.classList.add('landscape');
  85. rootDom.classList.remove('portrait');
  86. }
  87. }
  88. window.changeViewType = function(landscape){
  89. if (isPortrait !== landscape){
  90. isPortrait = landscape;
  91. internal_ChangeViewType(landscape);
  92. }
  93. }
  94. internal_ChangeViewType(isPortrait);
  95. window.onUnityClickBack = function () {
  96. if (window.parent && window.parent !== window) {
  97. window.parent.onUnityClickBack();
  98. }
  99. }
  100. iframe.src = "./main.html"
  101. </script>
  102. </html>