App.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <!-- <router-view /> -->
  3. <router-view v-slot="{ Component }">
  4. <transition
  5. name="fade-in-out"
  6. >
  7. <component
  8. :is="Component"
  9. />
  10. </transition>
  11. </router-view>
  12. <audio
  13. id="bg-music"
  14. src="./configMultiMedia/music/music1.mp3"
  15. />
  16. </template>
  17. <script setup>
  18. import { ref, computed, watch, onMounted } from "vue"
  19. import { useRoute, useRouter } from "vue-router"
  20. import { useStore } from "vuex"
  21. import {
  22. // checkLoginStatusAndProcess,
  23. // getUserFromStorageIfNeed
  24. } from '@/api.js'
  25. const route = useRoute()
  26. const router = useRouter()
  27. const store = useStore()
  28. // store.commit('getPageVisitRecordFromStorage')
  29. // checkLoginStatusAndProcess()
  30. // getUserFromStorageIfNeed()
  31. // if (store.state.loginStatus === store.getters.loginStatusEnum.notLogin && route.name !== 'LoginView') {
  32. // router.push({
  33. // name: 'LoginView',
  34. // query: {
  35. // redirect: encodeURI(route.fullPath)
  36. // }
  37. // })
  38. // }
  39. const time = ref(null)
  40. function isNotMobile() {
  41. const userAgent = navigator.userAgent || navigator.vendor || window.opera
  42. const mobileKeywords = [
  43. 'Android', 'webOS', 'iPhone', 'iPad', 'iPod', 'BlackBerry', 'Windows Phone',
  44. 'Opera Mini', 'IEMobile', 'Mobile', 'Android'
  45. ]
  46. // Check if any of the mobile keywords are present in the user agent string.
  47. return !mobileKeywords.some(keyword => userAgent.toLowerCase().includes(keyword.toLowerCase()))
  48. }
  49. onMounted(() => {
  50. const appDom = document.getElementById('#app')
  51. if (isNotMobile) {
  52. // appDom.style.maxWidth = '390px'
  53. // appDom.style.maxHeight = '844px'
  54. // appDom.clientHeight = '844px'
  55. // appDom.clientWidth = '390px'
  56. }
  57. window.addEventListener(
  58. "resize",
  59. () => {
  60. //@ts-ignore
  61. clearTimeout(time.value)
  62. //@ts-ignore
  63. time.value = window.setTimeout(() => {
  64. // 根元素
  65. const dom = document.querySelector("#app")
  66. if (dom && document.documentElement.clientWidth < 1000) {
  67. dom.style.height = document.documentElement.clientHeight + "px"
  68. dom.style.width = document.documentElement.clientWidth + "px"
  69. window.windowWidth = document.documentElement.clientWidth + "px"
  70. window.windowHeight = document.documentElement.clientHeight + "px"
  71. }
  72. }, 100)
  73. },
  74. true
  75. )
  76. })
  77. </script>
  78. <style lang="less">
  79. html, body {
  80. // overscroll-behavior: none;
  81. overflow: hidden;
  82. height: 100%;
  83. }
  84. * {
  85. user-select: none;
  86. -webkit-touch-callout: none;
  87. }
  88. // 360浏览器不支持not()
  89. input, textarea {
  90. user-select: initial;
  91. }
  92. #app {
  93. height: 100%;
  94. position: relative;
  95. max-width: 500px;
  96. left: 50%;
  97. transform: translateX(-50%);
  98. overflow: hidden;
  99. // background: green;
  100. // @media screen and (max-width: 400px) {
  101. // max-width: 390px;
  102. // max-height: 844px;
  103. // }
  104. }
  105. // 字体
  106. @font-face {
  107. font-family: 'KingHwa_OldSong';
  108. src: url('@/assets/style/KingHwa_OldSong.TTF');
  109. }
  110. @font-face {
  111. font-family: 'KaiTi';
  112. src: url('@/assets/style/SIMKAI.TTF');
  113. }
  114. // 滚动条,只设置某一项可能导致不生效。
  115. // ::-webkit-scrollbar { background: #dddecc; width: 6px; height: 6px; }
  116. // ::-webkit-scrollbar-thumb { background: #828a5b; border-radius: 3px; }
  117. // ::-webkit-scrollbar-corner { background: #dddecc; }
  118. // vue组件过渡效果
  119. .fade-out-leave-active {
  120. transition: opacity 2s;
  121. pointer-events: none;
  122. }
  123. .fade-out-leave-to {
  124. opacity: 0;
  125. }
  126. .fade-in-enter-active {
  127. transition: opacity 2s;
  128. }
  129. .fade-in-enter-from {
  130. opacity: 0;
  131. }
  132. .fade-in-out-enter-active {
  133. transition: opacity 1s;
  134. }
  135. .fade-in-out-leave-active {
  136. transition: opacity 1s;
  137. pointer-events: none;
  138. }
  139. .fade-in-out-enter-from {
  140. opacity: 0;
  141. }
  142. .fade-in-out-leave-to {
  143. opacity: 0;
  144. }
  145. // 不断渐变显隐 animation
  146. .animation-show-hide {
  147. animation: show-hide 1.5s infinite;
  148. }
  149. @keyframes show-hide {
  150. 0% {
  151. opacity: 0;
  152. }
  153. 50% {
  154. opacity: 1;
  155. }
  156. 100% {
  157. opacity: 0;
  158. }
  159. }
  160. // 不断渐变显隐,显示时间较长 animation
  161. .animation-show-long-hide {
  162. animation: show-long-hide 2.5s infinite;
  163. }
  164. @keyframes show-long-hide {
  165. 0% {
  166. opacity: 0;
  167. }
  168. 35% {
  169. opacity: 1;
  170. }
  171. 65% {
  172. opacity: 1;
  173. }
  174. 100% {
  175. opacity: 0;
  176. }
  177. }
  178. // // vue-viewer
  179. .viewer-backdrop {
  180. background-color: rgba(0, 0, 0, 90%) !important;
  181. }
  182. </style>