app.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 { 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 && !params.testMap) {
  61. sdk.switchMapType(isStandard.value ? "satellite" : "standard");
  62. }
  63. });
  64. const loaded = ref(false);
  65. const inputPwd = ref(false);
  66. const stopWatch = watch(
  67. currentLayout,
  68. async (layout) => {
  69. if (!layout) {
  70. return;
  71. } else if (layout === RoutesName.signModel || layout === RoutesName.error) {
  72. loaded.value = true;
  73. return;
  74. }
  75. // 单页面 非自己查看需要密码校验
  76. // if (currentLayout.value === RoutesName.show && !params.share) {
  77. // inputPwd.value = true;
  78. // await new Promise<void>((resolve) => {
  79. // const stopInputWatch = watchEffect(() => {
  80. // if (!inputPwd.value) {
  81. // stopInputWatch();
  82. // resolve();
  83. // }
  84. // });
  85. // });
  86. // }
  87. params.share = true;
  88. await refreshCase();
  89. if (caseProject.value) {
  90. await loadPack(initialSetting);
  91. prefix.value = caseProject.value!.caseTitle;
  92. } else {
  93. await router.replace({ name: RoutesName.error });
  94. }
  95. stopWatch();
  96. loaded.value = true;
  97. },
  98. { immediate: true }
  99. );
  100. const layoutClassNames = computed(() => {
  101. return {
  102. [`sys-view-${custom.viewMode}`]: true,
  103. "edit-mode": isEdit.value || custom.showToolbar,
  104. "setting-mode": custom.showToolbar,
  105. "hide-right-box-mode": !custom.showRightPano,
  106. "hide-left-box-mode": !custom.showLeftPano,
  107. "show-bottom-box-mode": custom.showBottomBar,
  108. "hide-top-bar-mode": !custom.showHeadBar,
  109. };
  110. });
  111. const layoutStyles = computed(() => {
  112. const styles: { [key in string]: string } = {};
  113. if (custom.showBottomBar) {
  114. styles["--editor-menu-bottom"] = custom.bottomBarHeight;
  115. }
  116. return styles;
  117. });
  118. </script>
  119. <style scoped lang="scss">
  120. .editor-layout {
  121. --editor-menu-bottom: 0px;
  122. background: #000;
  123. --left-pano-left: calc(var(--editor-menu-left) + var(--editor-menu-width));
  124. }
  125. .sys-view-full {
  126. --header-top: var(--hide-header-top);
  127. --editor-menu-right: calc(-1 * var(--editor-toolbox-width)) !important;
  128. --editor-menu-left: calc(-1 * var(--editor-menu-width));
  129. --search-left: 52px;
  130. }
  131. .sys-view-auto {
  132. --header-top: var(--show-header-top);
  133. --search-left: 0px;
  134. }
  135. .hide-top-bar-mode {
  136. --header-top: var(--hide-header-top);
  137. }
  138. .hide-right-box-mode {
  139. --editor-menu-right: calc(-1 * var(--editor-toolbox-width)) !important;
  140. }
  141. .hide-left-box-mode {
  142. --left-pano-left: calc(
  143. var(--editor-menu-left) + var(--editor-menu-width) - var(--left-pano-width)
  144. ) !important;
  145. }
  146. .edit-mode {
  147. --editor-menu-left: calc(-1 * var(--editor-menu-width));
  148. }
  149. .laser-layer {
  150. position: absolute;
  151. z-index: 1;
  152. inset: 0;
  153. .scene {
  154. width: 100%;
  155. height: 100%;
  156. background-color: #ccc;
  157. }
  158. }
  159. .taggle {
  160. position: absolute;
  161. font-size: 16px;
  162. color: #fff;
  163. background: rgba(0, 0, 0, 0.2);
  164. z-index: 9999999;
  165. width: 30px;
  166. height: 30px;
  167. display: flex;
  168. align-items: center;
  169. overflow: hidden;
  170. justify-content: center;
  171. border-radius: 3px;
  172. cursor: pointer;
  173. &.map-type {
  174. transition: all 0.3s ease;
  175. top: calc(var(--header-top) + var(--editor-head-height) + 10px);
  176. right: calc(var(--editor-toolbox-width) + var(--editor-menu-right) + 30px);
  177. width: 42px;
  178. height: 42px;
  179. img {
  180. width: 100%;
  181. height: 100%;
  182. object-fit: cover;
  183. }
  184. }
  185. }
  186. </style>