app.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. <!-- <p class="botton-marker">
  44. <img src="/images/logo_police.png" /><span class="s1">&</span>
  45. <img src="/images/logo_4dage.png" /><span class="s2">|</span
  46. >公安部科技强警基础工作计划(2022JC13)
  47. </p> -->
  48. </template>
  49. <script lang="ts" setup>
  50. import {
  51. custom,
  52. params,
  53. showLeftPanoStack,
  54. showRightCtrlPanoStack,
  55. showRightPanoStack,
  56. } from "@/env";
  57. import { computed, ref, watch, watchEffect, nextTick } from "vue";
  58. import {
  59. isEdit,
  60. prefix,
  61. appEl,
  62. initialSetting,
  63. caseProject,
  64. refreshCase,
  65. fuseModels,
  66. scenes,
  67. } from "@/store";
  68. import router, { currentLayout, RoutesName } from "./router";
  69. import { asyncTimeout, encodePwd, loadPack, needMounts } from "@/utils";
  70. import { ConfigProvider } from "ant-design-vue";
  71. import PwdModel from "@/layout/pwd.vue";
  72. import { config } from "./config";
  73. import { sdk, sdkLoaded } from "./sdk";
  74. import GAxios from "axios";
  75. import { addReqErrorHandler, addResErrorHandler, ResCode, setToken } from "./api";
  76. import { mergeFuns } from "./components/drawing/hook";
  77. import Login from "./views/login.vue";
  78. // 获取URL参数中的app值
  79. function getAppParam() {
  80. const urlParams = new URLSearchParams(window.location.search);
  81. return {fromRoute: urlParams.get('fromRoute')};
  82. }
  83. const gotoLogin = () => {
  84. const params = getAppParam();
  85. let fromRoute = params.fromRoute == 'yunnan'?'criminal':params.fromRoute;
  86. // alert("请登录");/${params.fromRoute}/#/mix3dManager
  87. const loginHref = `/${fromRoute}/#/login`
  88. location.href = loginHref + '?redirect=' + escape(`/${fromRoute}/#/mix3dManager`)
  89. // showLogin.value = true;
  90. };
  91. addResErrorHandler((data: any) => {
  92. data = data.data;
  93. const params = getAppParam();
  94. console.log("addResErrorHandler", data, params);
  95. if (data.code === ResCode.TOKEN_INVALID) {
  96. gotoLogin();
  97. } else if (data.code === ResCode.UN_AUTH) {
  98. // console.log("--->");
  99. gotoLogin();
  100. } else if (data.code === ResCode.UN_EDIT_AUTH) {
  101. router.replace(RoutesName.show);
  102. }
  103. });
  104. addReqErrorHandler(gotoLogin);
  105. // https://192.168.0.13:7173/index.html?caseId=509&sign=vGxCu4X5321fkWpZN6HnqYBiE6iI71DDWzdgjEaUKIh7vDWo3o5yhqHdHhGr4Z3W#/show
  106. const isStandard = ref(true);
  107. watchEffect(() => {
  108. if (sdkLoaded.value && !params.testMap) {
  109. // sdk.switchMapType(isStandard.value ? "satellite" : "standard");
  110. }
  111. });
  112. const loaded = ref(false);
  113. const inputPwd = ref(false);
  114. const stopWatch = watch(
  115. currentLayout,
  116. async (layout) => {
  117. if (!layout) {
  118. return;
  119. } else if (layout === RoutesName.signModel || layout === RoutesName.error) {
  120. loaded.value = true;
  121. return;
  122. }
  123. // 单页面 非自己查看需要密码校验
  124. // if (currentLayout.value === RoutesName.show && !params.share) {
  125. // inputPwd.value = true;
  126. // await new Promise<void>((resolve) => {
  127. // const stopInputWatch = watchEffect(() => {
  128. // if (!inputPwd.value) {
  129. // stopInputWatch();
  130. // resolve();
  131. // }
  132. // });
  133. // });
  134. // }
  135. params.share = true;
  136. await asyncTimeout(100);
  137. await refreshCase();
  138. if (caseProject.value) {
  139. await loadPack(initialSetting);
  140. } else {
  141. await router.replace({ name: RoutesName.error });
  142. }
  143. stopWatch();
  144. loaded.value = true;
  145. },
  146. { immediate: true }
  147. );
  148. watchEffect(() => {
  149. prefix.value = caseProject.value?.fusionTitle || "多元融合";
  150. });
  151. const layoutClassNames = computed(() => {
  152. return {
  153. [`sys-view-${custom.viewMode}`]: true,
  154. "edit-mode": isEdit.value || custom.showToolbar,
  155. "setting-mode": custom.showToolbar,
  156. "hide-right-box-mode": !custom.showRightPano,
  157. "hide-left-box-mode": !custom.showLeftPano,
  158. "full-view": custom.full,
  159. "show-bottom-box-mode": custom.showBottomBar,
  160. "hide-top-bar-mode": !custom.showHeadBar,
  161. };
  162. });
  163. const layoutStyles = computed(() => {
  164. const styles: { [key in string]: string } = {};
  165. if (custom.showBottomBar) {
  166. styles["--editor-menu-bottom"] = custom.bottomBarHeight;
  167. }
  168. return styles;
  169. });
  170. const showLogin = ref(false);
  171. watch(
  172. () => custom.full,
  173. (full, _, onCleanup) => {
  174. if (full) {
  175. onCleanup(
  176. mergeFuns(
  177. showRightPanoStack.push(ref(false)),
  178. showLeftPanoStack.push(ref(false)),
  179. showRightCtrlPanoStack.push(ref(false)),
  180. showRightCtrlPanoStack.push(ref(false))
  181. )
  182. );
  183. }
  184. }
  185. );
  186. </script>
  187. <style scoped lang="scss">
  188. .editor-layout {
  189. --editor-menu-bottom: 0px;
  190. background: #000;
  191. --left-pano-left: calc(var(--editor-menu-left) + var(--editor-menu-width));
  192. }
  193. .sys-view-full {
  194. --header-top: var(--hide-header-top);
  195. --editor-menu-right: calc(-1 * var(--editor-toolbox-width)) !important;
  196. --editor-menu-left: calc(-1 * var(--editor-menu-width));
  197. --search-left: 52px;
  198. }
  199. .sys-view-auto {
  200. --header-top: var(--show-header-top);
  201. --search-left: 0px;
  202. }
  203. .hide-top-bar-mode {
  204. --header-top: var(--hide-header-top);
  205. }
  206. .hide-right-box-mode {
  207. --editor-menu-right: calc(-1 * var(--editor-toolbox-width)) !important;
  208. }
  209. .hide-left-box-mode {
  210. --left-pano-left: calc(
  211. var(--editor-menu-left) + var(--editor-menu-width) - var(--left-pano-width)
  212. ) !important;
  213. }
  214. .edit-mode {
  215. --editor-menu-left: calc(-1 * var(--editor-menu-width));
  216. }
  217. .laser-layer {
  218. position: absolute;
  219. z-index: 1;
  220. inset: 0;
  221. .scene {
  222. width: 100%;
  223. height: 100%;
  224. background-color: #ccc;
  225. }
  226. }
  227. .taggle {
  228. position: absolute;
  229. font-size: 16px;
  230. color: #fff;
  231. background: rgba(0, 0, 0, 0.2);
  232. z-index: 9999999;
  233. width: 30px;
  234. height: 30px;
  235. display: flex;
  236. align-items: center;
  237. overflow: hidden;
  238. justify-content: center;
  239. border-radius: 3px;
  240. cursor: pointer;
  241. &.map-type {
  242. transition: all 0.3s ease;
  243. top: calc(var(--header-top) + var(--editor-head-height) + 10px);
  244. right: calc(var(--editor-toolbox-width) + var(--editor-menu-right) + 30px);
  245. width: 42px;
  246. height: 42px;
  247. img {
  248. width: 100%;
  249. height: 100%;
  250. object-fit: cover;
  251. }
  252. }
  253. }
  254. </style>
  255. <style lang="scss">
  256. .full-view #global-search {
  257. left: 20px !important;
  258. }
  259. .botton-marker {
  260. display: flex;
  261. align-items: center;
  262. .s1 {
  263. margin: 0 6px;
  264. }
  265. .s2 {
  266. margin: 0 20px;
  267. }
  268. img {
  269. // height: 25px;
  270. margin: 0 4px;
  271. }
  272. position: absolute;
  273. z-index: 99999999;
  274. bottom: 20px;
  275. left: 50%;
  276. transform: translateX(-50%);
  277. font-size: 14px;
  278. pointer-events: none;
  279. color: #fff;
  280. letter-spacing: 2px;
  281. }
  282. </style>