app.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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. @contextmenu.prevent
  15. id="layout-app"
  16. class="editor-layout"
  17. :style="layoutStyles"
  18. :class="layoutClassNames"
  19. >
  20. <div
  21. :ref="(el: any) => appEl = (el as HTMLDivElement)"
  22. v-if="loaded"
  23. class="app-con"
  24. >
  25. <router-view v-slot="{ Component }">
  26. <!-- <keep-alive> -->
  27. <component :is="Component" />
  28. <!-- </keep-alive> -->
  29. </router-view>
  30. </div>
  31. <!-- <span
  32. v-if="fuseModels.length > 0 || scenes.length === 0"
  33. class="taggle map-type"
  34. @click="isStandard = !isStandard"
  35. @touchend="isStandard = !isStandard"
  36. >
  37. <img :src="isStandard ? 'images/satellite.jpg' : 'images/standard.jpg'" />
  38. </span> -->
  39. </ui-editor-layout>
  40. <PwdModel v-if="inputPwd" @close="inputPwd = false" />
  41. </ConfigProvider>
  42. </template>
  43. <script lang="ts" setup>
  44. import { custom, params } from "@/env";
  45. import { computed, ref, watch, watchEffect, nextTick } from "vue";
  46. import {
  47. isEdit,
  48. prefix,
  49. appEl,
  50. initialSetting,
  51. caseProject,
  52. refreshCase,
  53. fuseModels,
  54. scenes,
  55. } from "@/store";
  56. import router, { currentLayout, RoutesName } from "./router";
  57. import { loadPack, needMounts } from "@/utils";
  58. import { ConfigProvider } from "ant-design-vue";
  59. import PwdModel from "@/layout/pwd.vue";
  60. import { config } from "./config";
  61. import { sdk, sdkLoaded } from "./sdk";
  62. // https://192.168.0.13:7173/index.html?caseId=509&sign=vGxCu4X5321fkWpZN6HnqYBiE6iI71DDWzdgjEaUKIh7vDWo3o5yhqHdHhGr4Z3W#/show
  63. const isStandard = ref(true);
  64. watchEffect(() => {
  65. if (sdkLoaded.value && !params.testMap) {
  66. sdk.switchMapType(isStandard.value ? "satellite" : "standard");
  67. }
  68. });
  69. const loaded = ref(false);
  70. const inputPwd = ref(false);
  71. const stopWatch = watch(
  72. currentLayout,
  73. async (layout) => {
  74. if (!layout) {
  75. return;
  76. } else if (layout === RoutesName.signModel || layout === RoutesName.error) {
  77. loaded.value = true;
  78. return;
  79. }
  80. // 单页面 非自己查看需要密码校验
  81. // if (currentLayout.value === RoutesName.show && !params.share) {
  82. // inputPwd.value = true;
  83. // await new Promise<void>((resolve) => {
  84. // const stopInputWatch = watchEffect(() => {
  85. // if (!inputPwd.value) {
  86. // stopInputWatch();
  87. // resolve();
  88. // }
  89. // });
  90. // });
  91. // }
  92. params.share = true;
  93. await refreshCase();
  94. if (caseProject.value) {
  95. await loadPack(initialSetting);
  96. prefix.value = caseProject.value!.caseTitle;
  97. } else {
  98. await router.replace({ name: RoutesName.error });
  99. }
  100. stopWatch();
  101. loaded.value = true;
  102. },
  103. { immediate: true }
  104. );
  105. const layoutClassNames = computed(() => {
  106. return {
  107. [`sys-view-${custom.viewMode}`]: true,
  108. "edit-mode": isEdit.value || custom.showToolbar,
  109. "setting-mode": custom.showToolbar,
  110. "hide-right-box-mode": !custom.showRightPano,
  111. "hide-left-box-mode": !custom.showLeftPano,
  112. "show-bottom-box-mode": custom.showBottomBar,
  113. "hide-top-bar-mode": !custom.showHeadBar,
  114. };
  115. });
  116. const layoutStyles = computed(() => {
  117. const styles: { [key in string]: string } = {};
  118. if (custom.showBottomBar) {
  119. styles["--editor-menu-bottom"] = custom.bottomBarHeight;
  120. }
  121. return styles;
  122. });
  123. </script>
  124. <style scoped lang="scss">
  125. .editor-layout {
  126. --editor-menu-bottom: 0px;
  127. background: #000;
  128. --left-pano-left: calc(var(--editor-menu-left) + var(--editor-menu-width));
  129. }
  130. .sys-view-full {
  131. --header-top: var(--hide-header-top);
  132. --editor-menu-right: calc(-1 * var(--editor-toolbox-width)) !important;
  133. --editor-menu-left: calc(-1 * var(--editor-menu-width));
  134. --search-left: 52px;
  135. }
  136. .sys-view-auto {
  137. --header-top: var(--show-header-top);
  138. --search-left: 0px;
  139. }
  140. .hide-top-bar-mode {
  141. --header-top: var(--hide-header-top);
  142. }
  143. .hide-right-box-mode {
  144. --editor-menu-right: calc(-1 * var(--editor-toolbox-width)) !important;
  145. }
  146. .hide-left-box-mode {
  147. --left-pano-left: calc(
  148. var(--editor-menu-left) + var(--editor-menu-width) - var(--left-pano-width)
  149. ) !important;
  150. }
  151. .edit-mode {
  152. --editor-menu-left: calc(-1 * var(--editor-menu-width));
  153. }
  154. .laser-layer {
  155. position: absolute;
  156. z-index: 1;
  157. inset: 0;
  158. .scene {
  159. width: 100%;
  160. height: 100%;
  161. background-color: #ccc;
  162. }
  163. }
  164. .taggle {
  165. position: absolute;
  166. font-size: 16px;
  167. color: #fff;
  168. background: rgba(0, 0, 0, 0.2);
  169. z-index: 9999999;
  170. width: 30px;
  171. height: 30px;
  172. display: flex;
  173. align-items: center;
  174. overflow: hidden;
  175. justify-content: center;
  176. border-radius: 3px;
  177. cursor: pointer;
  178. &.map-type {
  179. transition: all 0.3s ease;
  180. top: calc(var(--header-top) + var(--editor-head-height) + 10px);
  181. right: calc(var(--editor-toolbox-width) + var(--editor-menu-right) + 30px);
  182. width: 42px;
  183. height: 42px;
  184. img {
  185. width: 100%;
  186. height: 100%;
  187. object-fit: cover;
  188. }
  189. }
  190. }
  191. </style>