App.vue 4.3 KB

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