app.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <ConfigProvider v-bind="config">
  3. <template v-for="needMount in needMounts">
  4. <Teleport :to="needMount[0]">
  5. <component
  6. :is="needMount[1]"
  7. v-bind="needMount[2]"
  8. :ref="(v: any) => needMount[3] && needMount[3](v)"
  9. />
  10. </Teleport>
  11. </template>
  12. <ui-editor-layout
  13. @click.stop
  14. id="layout-app"
  15. class="editor-layout"
  16. :style="layoutStyles"
  17. :class="layoutClassNames"
  18. >
  19. <div :ref="(el: any) => appEl = (el as HTMLDivElement)" v-if="loaded">
  20. <router-view v-slot="{ Component }">
  21. <!-- <keep-alive> -->
  22. <component :is="Component" />
  23. <!-- </keep-alive> -->
  24. </router-view>
  25. </div>
  26. <!-- <span
  27. v-if="fuseModels.length > 0 || scenes.length === 0"
  28. class="taggle map-type"
  29. @click="isStandard = !isStandard"
  30. @touchend="isStandard = !isStandard"
  31. >
  32. <img :src="isStandard ? 'images/satellite.jpg' : 'images/standard.jpg'" />
  33. </span> -->
  34. </ui-editor-layout>
  35. <PwdModel v-if="inputPwd" @close="inputPwd = false" />
  36. </ConfigProvider>
  37. </template>
  38. <script lang="ts" setup>
  39. import { custom, params } from "@/env";
  40. import { computed, ref, watch, watchEffect, nextTick } from "vue";
  41. import {
  42. isEdit,
  43. prefix,
  44. appEl,
  45. initialSetting,
  46. caseProject,
  47. refreshCase,
  48. fuseModels,
  49. scenes,
  50. } from "@/store";
  51. import router, { currentLayout, RoutesName } from "./router";
  52. import { asyncTimeout, loadPack, needMounts } from "@/utils";
  53. import { ConfigProvider } from "ant-design-vue";
  54. import PwdModel from "@/layout/pwd.vue";
  55. import { config } from "./config";
  56. import { sdk, sdkLoaded } from "./sdk";
  57. // https://192.168.0.13:7173/index.html?caseId=509&sign=vGxCu4X5321fkWpZN6HnqYBiE6iI71DDWzdgjEaUKIh7vDWo3o5yhqHdHhGr4Z3W#/show
  58. const isStandard = ref(true);
  59. watchEffect(() => {
  60. if (sdkLoaded.value) {
  61. const checkUrl = `https://www.google.com/maps/vt/pb=!1m5!1m4!1i11!2i3339!3i1787!4i128!2m2!1e1!3i998!3m9!2szh-CN!3s!5e1105!12m1!1e4!12m1!1e47!12m1!1e3!4e0!5m1!1e0!23i1368782!23i1368785!23i4861626!23i10211310!23i4897086!23i47054629!23i72385654!23i72458815!23i10211069!23i94243289!23i94255677!23i10210500!23i94222679!23i72860224!23i10211515!23i94260020`;
  62. Promise.race([
  63. new Promise((_, reject) => {
  64. if (params.ga === "true") {
  65. reject("ga版本");
  66. }
  67. }),
  68. fetch(checkUrl).then((res) => {
  69. if (res.status !== 200) {
  70. throw "谷歌访问不了";
  71. } else {
  72. return res.status;
  73. }
  74. }),
  75. new Promise((r, j) => setTimeout(j, 3000)),
  76. ])
  77. .then(() => {
  78. console.error("使用gmap");
  79. sdk.switchMapType(isStandard.value ? "satellite" : "standard", "gmap");
  80. })
  81. .catch(() => {
  82. console.error("使用amap");
  83. sdk.switchMapType(isStandard.value ? "satellite" : "standard", "amap");
  84. });
  85. }
  86. });
  87. const loaded = ref(false);
  88. const inputPwd = ref(false);
  89. const stopWatch = watch(
  90. currentLayout,
  91. async (layout) => {
  92. if (!layout) {
  93. return;
  94. } else if (layout === RoutesName.signModel || layout === RoutesName.error) {
  95. loaded.value = true;
  96. return;
  97. }
  98. // 单页面 非自己查看需要密码校验
  99. // if (currentLayout.value === RoutesName.show && !params.share) {
  100. // inputPwd.value = true;
  101. // await new Promise<void>((resolve) => {
  102. // const stopInputWatch = watchEffect(() => {
  103. // if (!inputPwd.value) {
  104. // stopInputWatch();
  105. // resolve();
  106. // }
  107. // });
  108. // });
  109. // }
  110. params.share = true;
  111. await refreshCase();
  112. if (caseProject.value) {
  113. await loadPack(initialSetting);
  114. prefix.value = caseProject.value!.caseTitle;
  115. } else {
  116. await router.replace({ name: RoutesName.error });
  117. }
  118. stopWatch();
  119. loaded.value = true;
  120. },
  121. { immediate: true }
  122. );
  123. const layoutClassNames = computed(() => {
  124. return {
  125. [`sys-view-${custom.viewMode}`]: true,
  126. "edit-mode": isEdit.value || custom.showToolbar,
  127. "setting-mode": custom.showToolbar,
  128. "hide-right-box-mode": !custom.showRightPano,
  129. "hide-left-box-mode": !custom.showLeftPano,
  130. "show-bottom-box-mode": custom.showBottomBar,
  131. "hide-top-bar-mode": !custom.showHeadBar,
  132. };
  133. });
  134. const layoutStyles = computed(() => {
  135. const styles: { [key in string]: string } = {};
  136. if (custom.showBottomBar) {
  137. styles["--editor-menu-bottom"] = custom.bottomBarHeight;
  138. }
  139. return styles;
  140. });
  141. </script>
  142. <style scoped lang="scss">
  143. .editor-layout {
  144. --editor-menu-bottom: 0px;
  145. background: #000;
  146. --left-pano-left: calc(var(--editor-menu-left) + var(--editor-menu-width));
  147. }
  148. .sys-view-full {
  149. --header-top: var(--hide-header-top);
  150. --editor-menu-right: calc(-1 * var(--editor-toolbox-width)) !important;
  151. --editor-menu-left: calc(-1 * var(--editor-menu-width));
  152. --search-left: 52px;
  153. }
  154. .sys-view-auto {
  155. --header-top: var(--show-header-top);
  156. --search-left: 0px;
  157. }
  158. .hide-top-bar-mode {
  159. --header-top: var(--hide-header-top);
  160. }
  161. .hide-right-box-mode {
  162. --editor-menu-right: calc(-1 * var(--editor-toolbox-width)) !important;
  163. }
  164. .hide-left-box-mode {
  165. --left-pano-left: calc(
  166. var(--editor-menu-left) + var(--editor-menu-width) - var(--left-pano-width)
  167. ) !important;
  168. }
  169. .edit-mode {
  170. --editor-menu-left: calc(-1 * var(--editor-menu-width));
  171. }
  172. .laser-layer {
  173. position: absolute;
  174. z-index: 1;
  175. inset: 0;
  176. .scene {
  177. width: 100%;
  178. height: 100%;
  179. background-color: #ccc;
  180. }
  181. }
  182. .taggle {
  183. position: absolute;
  184. font-size: 16px;
  185. color: #fff;
  186. background: rgba(0, 0, 0, 0.2);
  187. z-index: 9999999;
  188. width: 30px;
  189. height: 30px;
  190. display: flex;
  191. align-items: center;
  192. overflow: hidden;
  193. justify-content: center;
  194. border-radius: 3px;
  195. cursor: pointer;
  196. &.map-type {
  197. transition: all 0.3s ease;
  198. top: calc(var(--header-top) + var(--editor-head-height) + 10px);
  199. right: calc(var(--editor-toolbox-width) + var(--editor-menu-right) + 30px);
  200. width: 42px;
  201. height: 42px;
  202. img {
  203. width: 100%;
  204. height: 100%;
  205. object-fit: cover;
  206. }
  207. }
  208. }
  209. </style>