app.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <ui-editor-layout
  3. @click.stop
  4. id="layout-app"
  5. class="editor-layout"
  6. :style="layoutStyles"
  7. :class="layoutClassNames"
  8. >
  9. <div :ref="el => appEl = (el as HTMLDivElement)" v-if="loaded">
  10. <router-view v-slot="{ Component }">
  11. <keep-alive>
  12. <component :is="Component" />
  13. </keep-alive>
  14. </router-view>
  15. </div>
  16. </ui-editor-layout>
  17. <PwdModel v-if="inputPwd" @close="inputPwd = false" />
  18. </template>
  19. <script lang="ts" setup>
  20. import { custom, params } from '@/env'
  21. import { computed, ref, watch, watchEffect, nextTick } from 'vue'
  22. import { isEdit, prefix, appEl, initialSetting, caseProject, refreshCase } from '@/store'
  23. import router, { currentLayout, RoutesName } from './router';
  24. import { loadPack } from '@/utils'
  25. import PwdModel from '@/layout/pwd.vue'
  26. const loaded = ref(false)
  27. const inputPwd = ref(false)
  28. const stopWatch = watch(currentLayout, async (layout) => {
  29. if (!layout) {
  30. return;
  31. } else if (layout === RoutesName.signModel || layout === RoutesName.error) {
  32. loaded.value = true;
  33. return;
  34. }
  35. // 单页面 非自己查看需要密码校验
  36. if (currentLayout.value === RoutesName.show && !params.share) {
  37. inputPwd.value = true
  38. await new Promise<void>(resolve => {
  39. const stopInputWatch = watchEffect(() => {
  40. if (!inputPwd.value) {
  41. stopInputWatch()
  42. resolve()
  43. }
  44. })
  45. })
  46. }
  47. params.share = true
  48. try {
  49. await refreshCase()
  50. if (caseProject.value) {
  51. await loadPack(initialSetting)
  52. prefix.value = caseProject.value!.caseTitle
  53. } else {
  54. await router.replace({name: RoutesName.error})
  55. }
  56. } catch (error) {
  57. await router.replace({name: RoutesName.error})
  58. }
  59. stopWatch()
  60. loaded.value = true
  61. console.log(loaded.value)
  62. }, { immediate: true })
  63. const layoutClassNames = computed(() => {
  64. return {
  65. [`sys-view-${custom.viewMode}`]: true,
  66. 'edit-mode': isEdit.value || custom.showToolbar,
  67. 'setting-mode': custom.showToolbar,
  68. 'hide-right-box-mode': !custom.showRightPano,
  69. 'hide-left-box-mode': !custom.showLeftPano,
  70. 'show-bottom-box-mode': custom.showBottomBar,
  71. 'hide-top-bar-mode': !custom.showHeadBar
  72. }
  73. })
  74. const layoutStyles = computed(() => {
  75. const styles: {[key in string]: string} = {}
  76. if (custom.showBottomBar) {
  77. styles['--editor-menu-bottom'] = custom.bottomBarHeight
  78. }
  79. return styles
  80. })
  81. </script>
  82. <style scoped lang="scss">
  83. .editor-layout {
  84. --editor-menu-bottom: 0px;
  85. --left-pano-left: calc(var(--editor-menu-left) + var(--editor-menu-width));
  86. }
  87. .sys-view-full {
  88. --header-top: var(--hide-header-top);
  89. --editor-menu-right: calc(-1 * var(--editor-toolbox-width)) !important;
  90. --editor-menu-left: calc(-1 * var(--editor-menu-width));
  91. --search-left: 52px;
  92. }
  93. .sys-view-auto {
  94. --header-top: var(--show-header-top);
  95. --search-left: 0px;
  96. }
  97. .hide-top-bar-mode {
  98. --header-top: var(--hide-header-top);
  99. }
  100. .hide-right-box-mode {
  101. --editor-menu-right: calc(-1 * var(--editor-toolbox-width)) !important;
  102. }
  103. .hide-left-box-mode {
  104. --left-pano-left: calc(var(--editor-menu-left) + var(--editor-menu-width) - var(--left-pano-width)) !important;
  105. }
  106. .edit-mode {
  107. --editor-menu-left: calc(-1 * var(--editor-menu-width));
  108. }
  109. .laser-layer {
  110. position: absolute;
  111. z-index: 1;
  112. inset: 0;
  113. .scene {
  114. width: 100%;
  115. height: 100%;
  116. background-color: #ccc;
  117. }
  118. }
  119. </style>