app.vue 5.1 KB

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