app.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <ConfigProvider v-bind="config" v-if="!showLogin">
  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. <Login v-else />
  43. </template>
  44. <script lang="ts" setup>
  45. import {
  46. custom,
  47. params,
  48. showLeftPanoStack,
  49. showRightCtrlPanoStack,
  50. showRightPanoStack,
  51. } from "@/env";
  52. import { computed, ref, watch, watchEffect, nextTick } from "vue";
  53. import {
  54. isEdit,
  55. prefix,
  56. appEl,
  57. initialSetting,
  58. caseProject,
  59. refreshCase,
  60. fuseModels,
  61. scenes,
  62. } from "@/store";
  63. import router, { currentLayout, RoutesName } from "./router";
  64. import { asyncTimeout, encodePwd, loadPack, needMounts } from "@/utils";
  65. import { ConfigProvider } from "ant-design-vue";
  66. import PwdModel from "@/layout/pwd.vue";
  67. import { config } from "./config";
  68. import { sdk, sdkLoaded } from "./sdk";
  69. import GAxios from "axios";
  70. import { addReqErrorHandler, addResErrorHandler, ResCode, setToken } from "./api";
  71. import { mergeFuns } from "./components/drawing/hook";
  72. import Login from "./views/login.vue";
  73. const gotoLogin = () => {
  74. showLogin.value = true;
  75. };
  76. addResErrorHandler((data: any) => {
  77. data = data.data;
  78. if (data.code === ResCode.TOKEN_INVALID) {
  79. gotoLogin();
  80. } else if (data.code === ResCode.UN_AUTH) {
  81. // console.log("--->");
  82. gotoLogin();
  83. } else if (data.code === ResCode.UN_EDIT_AUTH) {
  84. router.replace(RoutesName.show);
  85. }
  86. });
  87. addReqErrorHandler(gotoLogin);
  88. // https://192.168.0.13:7173/index.html?caseId=509&sign=vGxCu4X5321fkWpZN6HnqYBiE6iI71DDWzdgjEaUKIh7vDWo3o5yhqHdHhGr4Z3W#/show
  89. const isStandard = ref(true);
  90. watchEffect(() => {
  91. if (sdkLoaded.value && !params.testMap) {
  92. // sdk.switchMapType(isStandard.value ? "satellite" : "standard");
  93. }
  94. });
  95. const loaded = ref(false);
  96. const inputPwd = ref(false);
  97. const stopWatch = watch(
  98. currentLayout,
  99. async (layout) => {
  100. if (!layout) {
  101. return;
  102. } else if (layout === RoutesName.signModel || layout === RoutesName.error) {
  103. loaded.value = true;
  104. return;
  105. }
  106. // 单页面 非自己查看需要密码校验
  107. // if (currentLayout.value === RoutesName.show && !params.share) {
  108. // inputPwd.value = true;
  109. // await new Promise<void>((resolve) => {
  110. // const stopInputWatch = watchEffect(() => {
  111. // if (!inputPwd.value) {
  112. // stopInputWatch();
  113. // resolve();
  114. // }
  115. // });
  116. // });
  117. // }
  118. params.share = true;
  119. await asyncTimeout(100);
  120. await refreshCase();
  121. if (caseProject.value) {
  122. await loadPack(initialSetting);
  123. } else {
  124. await router.replace({ name: RoutesName.error });
  125. }
  126. stopWatch();
  127. loaded.value = true;
  128. },
  129. { immediate: true }
  130. );
  131. watchEffect(() => {
  132. prefix.value = caseProject.value?.fusionTitle || "多元融合";
  133. });
  134. const layoutClassNames = computed(() => {
  135. return {
  136. [`sys-view-${custom.viewMode}`]: true,
  137. "edit-mode": isEdit.value || custom.showToolbar,
  138. "setting-mode": custom.showToolbar,
  139. "hide-right-box-mode": !custom.showRightPano,
  140. "hide-left-box-mode": !custom.showLeftPano,
  141. "full-view": custom.full,
  142. "show-bottom-box-mode": custom.showBottomBar,
  143. "hide-top-bar-mode": !custom.showHeadBar,
  144. };
  145. });
  146. const layoutStyles = computed(() => {
  147. const styles: { [key in string]: string } = {};
  148. if (custom.showBottomBar) {
  149. styles["--editor-menu-bottom"] = custom.bottomBarHeight;
  150. }
  151. return styles;
  152. });
  153. const showLogin = ref(false);
  154. watch(
  155. () => custom.full,
  156. (full, _, onCleanup) => {
  157. if (full) {
  158. onCleanup(
  159. mergeFuns(
  160. showRightPanoStack.push(ref(false)),
  161. showLeftPanoStack.push(ref(false)),
  162. showRightCtrlPanoStack.push(ref(false)),
  163. showRightCtrlPanoStack.push(ref(false))
  164. )
  165. );
  166. }
  167. }
  168. );
  169. </script>
  170. <style scoped lang="scss">
  171. .editor-layout {
  172. --editor-menu-bottom: 0px;
  173. background: #000;
  174. --left-pano-left: calc(var(--editor-menu-left) + var(--editor-menu-width));
  175. }
  176. .sys-view-full {
  177. --header-top: var(--hide-header-top);
  178. --editor-menu-right: calc(-1 * var(--editor-toolbox-width)) !important;
  179. --editor-menu-left: calc(-1 * var(--editor-menu-width));
  180. --search-left: 52px;
  181. }
  182. .sys-view-auto {
  183. --header-top: var(--show-header-top);
  184. --search-left: 0px;
  185. }
  186. .hide-top-bar-mode {
  187. --header-top: var(--hide-header-top);
  188. }
  189. .hide-right-box-mode {
  190. --editor-menu-right: calc(-1 * var(--editor-toolbox-width)) !important;
  191. }
  192. .hide-left-box-mode {
  193. --left-pano-left: calc(
  194. var(--editor-menu-left) + var(--editor-menu-width) - var(--left-pano-width)
  195. ) !important;
  196. }
  197. .edit-mode {
  198. --editor-menu-left: calc(-1 * var(--editor-menu-width));
  199. }
  200. .laser-layer {
  201. position: absolute;
  202. z-index: 1;
  203. inset: 0;
  204. .scene {
  205. width: 100%;
  206. height: 100%;
  207. background-color: #ccc;
  208. }
  209. }
  210. .taggle {
  211. position: absolute;
  212. font-size: 16px;
  213. color: #fff;
  214. background: rgba(0, 0, 0, 0.2);
  215. z-index: 9999999;
  216. width: 30px;
  217. height: 30px;
  218. display: flex;
  219. align-items: center;
  220. overflow: hidden;
  221. justify-content: center;
  222. border-radius: 3px;
  223. cursor: pointer;
  224. &.map-type {
  225. transition: all 0.3s ease;
  226. top: calc(var(--header-top) + var(--editor-head-height) + 10px);
  227. right: calc(var(--editor-toolbox-width) + var(--editor-menu-right) + 30px);
  228. width: 42px;
  229. height: 42px;
  230. img {
  231. width: 100%;
  232. height: 100%;
  233. object-fit: cover;
  234. }
  235. }
  236. }
  237. </style>
  238. <style lang="scss">
  239. .full-view #global-search {
  240. left: 20px !important;
  241. }
  242. </style>