App.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <div
  3. class="app-view"
  4. :class="{
  5. higher: !isShowNavBar,
  6. }"
  7. >
  8. <div
  9. v-show="$route.meta.isShowUnityModel"
  10. id="unity-container"
  11. >
  12. <canvas
  13. id="unity-canvas"
  14. width="960"
  15. height="600"
  16. tabindex="-1"
  17. />
  18. </div>
  19. <router-view />
  20. <nav
  21. v-show="!$route.meta.hideNavBar"
  22. :style="{
  23. bottom: isShowNavBar ? '0' : `-${navBarHeight}`,
  24. }"
  25. >
  26. <button
  27. class="tab-item"
  28. :class="{
  29. active: $route.meta.belongNavGroup === 0
  30. }"
  31. @click="$router.push({name: 'GeneralView'})"
  32. >
  33. 概述总览
  34. <img
  35. class="decorator"
  36. src="@/assets/images/nav-item-active-decorator.png"
  37. alt=""
  38. draggable="false"
  39. >
  40. </button>
  41. <button
  42. class="tab-item"
  43. :class="{
  44. active: $route.meta.belongNavGroup === 1
  45. }"
  46. @click="$router.push({name: 'HistoryView'})"
  47. >
  48. 历史回顾
  49. <img
  50. class="decorator"
  51. src="@/assets/images/nav-item-active-decorator.png"
  52. alt=""
  53. draggable="false"
  54. >
  55. </button>
  56. <button
  57. class="tab-item"
  58. :class="{
  59. active: $route.meta.belongNavGroup === 2
  60. }"
  61. @click="$router.push({name: 'TreasureView'})"
  62. >
  63. 国之重器
  64. <img
  65. class="decorator"
  66. src="@/assets/images/nav-item-active-decorator.png"
  67. alt=""
  68. draggable="false"
  69. >
  70. </button>
  71. <button
  72. class="tab-item"
  73. :class="{
  74. active: $route.meta.belongNavGroup === 3
  75. }"
  76. @click="$router.push({name: 'MetaverseView'})"
  77. >
  78. 工业元宇宙
  79. <img
  80. class="decorator"
  81. src="@/assets/images/nav-item-active-decorator.png"
  82. alt=""
  83. draggable="false"
  84. >
  85. </button>
  86. </nav>
  87. <button
  88. v-show="!$route.meta.hideNavBar"
  89. class="show-hide"
  90. :style="{
  91. backgroundImage: isShowNavBar ? `url(${require(`@/assets/images/arrow-down.png`)})` : `url(${require(`@/assets/images/arrow-up.png`)})`,
  92. }"
  93. @click="isShowNavBar = !isShowNavBar"
  94. />
  95. <Teleport to="body">
  96. <transition name="fade-out">
  97. <HomeFadeIn
  98. v-if="isShowFadeInMask"
  99. class="fade-in-mask"
  100. :progress="progress"
  101. />
  102. </transition>
  103. </Teleport>>
  104. <Teleport to="body">
  105. <div class="screen-rotate-tip">
  106. <div class="inner-wrapper">
  107. <img
  108. class=""
  109. src="@/assets/images/tip-screen-rotate.png"
  110. alt=""
  111. draggable="false"
  112. >
  113. <span>请横屏浏览</span>
  114. </div>
  115. </div>
  116. </Teleport>
  117. </div>
  118. </template>
  119. <script>
  120. import HomeFadeIn from "@/components/HomeFadeIn.vue"
  121. import {
  122. computed,
  123. onMounted,
  124. reactive,
  125. ref,
  126. } from 'vue'
  127. export default {
  128. components: {
  129. HomeFadeIn,
  130. },
  131. setup () {
  132. const isShowFadeInMask = ref(true)
  133. const progress = ref(0)
  134. onMounted(() => {
  135. /**
  136. * 加载unity
  137. */
  138. window.addEventListener("load", function () {
  139. if ("serviceWorker" in navigator) {
  140. navigator.serviceWorker.register("ServiceWorker.js")
  141. }
  142. })
  143. var canvas = document.querySelector("#unity-canvas")
  144. var buildUrl = "unity/Build"
  145. var loaderUrl = buildUrl + "/SHIndustryMuseum_2.6.loader.js"
  146. var config = {
  147. dataUrl: buildUrl + "/SHIndustryMuseum_2.6.data.unityweb",
  148. frameworkUrl: buildUrl + "/SHIndustryMuseum_2.6.framework.js.unityweb",
  149. codeUrl: buildUrl + "/SHIndustryMuseum_2.6.wasm.unityweb",
  150. streamingAssetsUrl: "StreamingAssets",
  151. companyName: "DefaultCompany",
  152. productName: "SHIndustryMuseum",
  153. productVersion: "0.1",
  154. }
  155. // By default Unity keeps WebGL canvas render target size matched with
  156. // the DOM size of the canvas element (scaled by window.devicePixelRatio)
  157. // Set this to false if you want to decouple this synchronization from
  158. // happening inside the engine, and you would instead like to size up
  159. // the canvas DOM size and WebGL render target sizes yourself.
  160. // config.matchWebGLToCanvasSize = false;
  161. if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
  162. // Mobile device style: fill the whole browser client area with the game canvas:
  163. var meta = document.createElement('meta')
  164. meta.name = 'viewport'
  165. meta.content = 'width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, shrink-to-fit=yes'
  166. document.getElementsByTagName('head')[0].appendChild(meta)
  167. }
  168. var script = document.createElement("script")
  169. script.src = loaderUrl
  170. script.onload = () => {
  171. createUnityInstance(canvas, config, (paramProgress) => {
  172. progress.value = Math.round(paramProgress * 100)
  173. if (paramProgress > 0.95) {
  174. setTimeout(() => {
  175. isShowFadeInMask.value = false
  176. }, 1000)
  177. }
  178. }).then((unityInstance) => {
  179. window.gUnityInst = unityInstance
  180. utils.loadUnitySceneGeneral()
  181. }).catch((message) => {
  182. alert(message)
  183. })
  184. }
  185. window.onClickEnterprise = function (id) {
  186. if (window.handleClickEnterprise) {
  187. window.handleClickEnterprise(id)
  188. }
  189. }
  190. window.onClickPlanet = function (id) {
  191. if (window.handleClickPlanet) {
  192. window.handleClickPlanet(id)
  193. }
  194. }
  195. window.onMovedPlanet = function (id) {
  196. if (window.handleMovedPlanet) {
  197. window.handleMovedPlanet(id)
  198. }
  199. }
  200. document.body.appendChild(script)
  201. /**
  202. * end of unity
  203. */
  204. })
  205. const isShowNavBar = ref(true)
  206. const activeNavItemIdx = ref(0)
  207. const navBarHeight = '90px'
  208. return {
  209. isShowFadeInMask,
  210. progress,
  211. isShowNavBar,
  212. activeNavItemIdx,
  213. navBarHeight,
  214. }
  215. },
  216. }
  217. </script>
  218. <style lang="less">
  219. html, body {
  220. // overscroll-behavior: none;
  221. // overflow: hidden;
  222. height: 100%;
  223. }
  224. #app {
  225. height: 100%;
  226. width: 100%;
  227. background-image: url(@/assets/images/main-bg.jpg);
  228. background-size: cover;
  229. background-repeat: no-repeat;
  230. background-position: center center;
  231. }
  232. // * {
  233. // user-select: none;
  234. // -webkit-touch-callout: none;
  235. // }
  236. // // 360浏览器不支持not()
  237. // input, textarea {
  238. // user-select: initial;
  239. // }
  240. // 字体
  241. @font-face {
  242. font-family: 'Source Han Sans CN-Light';
  243. src: url('@/assets/style/SOURCEHANSANSCN-LIGHT.OTF');
  244. }
  245. @font-face {
  246. font-family: 'Source Han Sans CN-Regular';
  247. src: url('@/assets/style/SOURCEHANSANSCN-REGULAR.OTF');
  248. }
  249. @font-face {
  250. font-family: 'Source Han Sans CN';
  251. src: url('@/assets/style/SOURCEHANSANSCN-REGULAR.OTF');
  252. }
  253. @font-face {
  254. font-family: 'Source Han Sans CN-Bold';
  255. src: url('@/assets/style/SOURCEHANSANSCN-BOLD.OTF');
  256. }
  257. // i {
  258. // font-style: italic;
  259. // }
  260. // 滚动条
  261. // ::-webkit-scrollbar { background: #dddecc; width: 0.3rem; height: 0.3rem; } /*宽度是对垂直滚动条而言,高度是对水平滚动条而言*/
  262. // ::-webkit-scrollbar-thumb { background: #828a5b; border-radius: 0.15rem; }
  263. // ::-webkit-scrollbar-corner { background: #dddecc; }
  264. // vue组件过渡效果
  265. .fade-out-leave-active {
  266. transition: opacity 1s;
  267. }
  268. .fade-out-leave-to {
  269. opacity: 0;
  270. }
  271. // // 不断渐变显隐 animation
  272. // .animation-show-hide {
  273. // animation: show-hide 1.8s infinite;
  274. // }
  275. // @keyframes show-hide {
  276. // 0% {
  277. // opacity: 0;
  278. // }
  279. // 50% {
  280. // opacity: 1;
  281. // }
  282. // 100% {
  283. // opacity: 0;
  284. // }
  285. // }
  286. // // vue-viewer
  287. // .viewer-container {
  288. // background-color: rgba(0, 0, 0, 80%) !important;
  289. // }
  290. // 或者
  291. // .viewer-backdrop {
  292. // background-color: rgba(0, 0, 0, 90%) !important;
  293. // }
  294. .screen-rotate-tip {
  295. position: fixed;
  296. left: 0;
  297. top: 0;
  298. width: 100%;
  299. height: 100%;
  300. background: rgba(0, 0, 0, 0.8);
  301. display: none;
  302. @media (max-aspect-ratio: 1/1) {
  303. display: initial;
  304. }
  305. >.inner-wrapper {
  306. position: absolute;
  307. left: 50%;
  308. top: 50%;
  309. transform: translate(-50%, -50%);
  310. width: 126px;
  311. height: 126px;
  312. >img {
  313. width: 100%;
  314. height: 100%;
  315. }
  316. >span {
  317. position: absolute;
  318. left: 50%;
  319. bottom: -8px;
  320. transform: translate(-50%, 100%);
  321. font-size: 16px;
  322. font-family: Source Han Sans-Regular, Source Han Sans;
  323. font-weight: 400;
  324. color: #FFFFFF;
  325. white-space: pre;
  326. }
  327. }
  328. }
  329. </style>
  330. <style scoped lang="less">
  331. .app-view {
  332. width: 100%;
  333. height: calc(100% - v-bind('navBarHeight'));
  334. position: relative;
  335. &.higher {
  336. height: 100%;
  337. }
  338. >.fade-in-mask {
  339. z-index: 2005;
  340. }
  341. >#unity-container {
  342. position: absolute;
  343. width: 100%;
  344. height: 100%;
  345. >#unity-canvas {
  346. height: 100%;
  347. width: 100%;
  348. background: #231F20;
  349. }
  350. }
  351. >nav {
  352. position: fixed;
  353. left: 0;
  354. width: 100%;
  355. height: rgba(210, 189, 132, 0.7);
  356. height: v-bind('navBarHeight');
  357. border-radius: 5px 5px 0 0;
  358. border-top: solid 1px #D2BD84;
  359. box-shadow: inset 0px 2px 2px 0px rgba(210,189,132,0.45), 0px -9px 24px 0px rgba(183,162,109,0.25);
  360. display: flex;
  361. justify-content: center;
  362. align-items: center;
  363. transition: all 0.5s;
  364. // backdrop-filter: blur(10px);
  365. background-image: url(@/assets/images/bg-bottom-bar.jpg);
  366. background-size: cover;
  367. background-repeat: no-repeat;
  368. background-position: center center;
  369. // background-color: #0c0d12;
  370. >button.tab-item {
  371. font-size: 30px;
  372. font-family: Source Han Sans CN-Regular, Source Han Sans CN;
  373. font-weight: 400;
  374. color: #FFFFFF;
  375. margin-left: 200px;
  376. opacity: 0.5;
  377. position: relative;
  378. user-select: none;
  379. >img.decorator {
  380. display: none;
  381. }
  382. &:first-of-type {
  383. margin-left: initial;
  384. }
  385. &.active {
  386. opacity: initial;
  387. font-weight: bold;
  388. >img.decorator {
  389. display: initial;
  390. position: absolute;
  391. left: 50%;
  392. bottom: -15px;
  393. transform: translateX(-50%);
  394. width: 150%;
  395. }
  396. }
  397. }
  398. @media only screen and (max-width: 1400px) {
  399. >button.tab-item {
  400. margin-left: 100px;
  401. }
  402. }
  403. }
  404. >button.show-hide {
  405. position: fixed;
  406. right: 82px;
  407. bottom: 34px;
  408. width: 36px;
  409. height: 36px;
  410. background-size: cover;
  411. background-repeat: no-repeat;
  412. background-position: center center;
  413. }
  414. @media only screen and (max-width: 1400px) {
  415. >button.show-hide {
  416. right: 10px;
  417. }
  418. }
  419. }
  420. </style>