app.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. </ui-editor-layout>
  27. <PwdModel v-if="inputPwd" @close="inputPwd = false" />
  28. </ConfigProvider>
  29. </template>
  30. <script lang="ts" setup>
  31. import { custom, params } from "@/env";
  32. import { computed, ref, watch, watchEffect, nextTick } from "vue";
  33. import { isEdit, prefix, appEl, initialSetting, caseProject, refreshCase } from "@/store";
  34. import router, { currentLayout, RoutesName } from "./router";
  35. import { loadPack, needMounts } from "@/utils";
  36. import { ConfigProvider } from "ant-design-vue";
  37. import PwdModel from "@/layout/pwd.vue";
  38. import { config } from "./config";
  39. const loaded = ref(false);
  40. const inputPwd = ref(false);
  41. const stopWatch = watch(
  42. currentLayout,
  43. async (layout) => {
  44. if (!layout) {
  45. return;
  46. } else if (layout === RoutesName.signModel || layout === RoutesName.error) {
  47. loaded.value = true;
  48. return;
  49. }
  50. // 单页面 非自己查看需要密码校验
  51. // if (currentLayout.value === RoutesName.show && !params.share) {
  52. // inputPwd.value = true;
  53. // await new Promise<void>((resolve) => {
  54. // const stopInputWatch = watchEffect(() => {
  55. // if (!inputPwd.value) {
  56. // stopInputWatch();
  57. // resolve();
  58. // }
  59. // });
  60. // });
  61. // }
  62. params.share = true;
  63. await refreshCase();
  64. if (caseProject.value) {
  65. await loadPack(initialSetting);
  66. prefix.value = caseProject.value!.caseTitle;
  67. } else {
  68. await router.replace({ name: RoutesName.error });
  69. }
  70. stopWatch();
  71. loaded.value = true;
  72. },
  73. { immediate: true }
  74. );
  75. const layoutClassNames = computed(() => {
  76. return {
  77. [`sys-view-${custom.viewMode}`]: true,
  78. "edit-mode": isEdit.value || custom.showToolbar,
  79. "setting-mode": custom.showToolbar,
  80. "hide-right-box-mode": !custom.showRightPano,
  81. "hide-left-box-mode": !custom.showLeftPano,
  82. "show-bottom-box-mode": custom.showBottomBar,
  83. "hide-top-bar-mode": !custom.showHeadBar,
  84. };
  85. });
  86. const layoutStyles = computed(() => {
  87. const styles: { [key in string]: string } = {};
  88. if (custom.showBottomBar) {
  89. styles["--editor-menu-bottom"] = custom.bottomBarHeight;
  90. }
  91. return styles;
  92. });
  93. </script>
  94. <style scoped lang="scss">
  95. .editor-layout {
  96. --editor-menu-bottom: 0px;
  97. --left-pano-left: calc(var(--editor-menu-left) + var(--editor-menu-width));
  98. }
  99. .sys-view-full {
  100. --header-top: var(--hide-header-top);
  101. --editor-menu-right: calc(-1 * var(--editor-toolbox-width)) !important;
  102. --editor-menu-left: calc(-1 * var(--editor-menu-width));
  103. --search-left: 52px;
  104. }
  105. .sys-view-auto {
  106. --header-top: var(--show-header-top);
  107. --search-left: 0px;
  108. }
  109. .hide-top-bar-mode {
  110. --header-top: var(--hide-header-top);
  111. }
  112. .hide-right-box-mode {
  113. --editor-menu-right: calc(-1 * var(--editor-toolbox-width)) !important;
  114. }
  115. .hide-left-box-mode {
  116. --left-pano-left: calc(
  117. var(--editor-menu-left) + var(--editor-menu-width) - var(--left-pano-width)
  118. ) !important;
  119. }
  120. .edit-mode {
  121. --editor-menu-left: calc(-1 * var(--editor-menu-width));
  122. }
  123. .laser-layer {
  124. position: absolute;
  125. z-index: 1;
  126. inset: 0;
  127. .scene {
  128. width: 100%;
  129. height: 100%;
  130. background-color: #ccc;
  131. }
  132. }
  133. </style>