App.vue 4.2 KB

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