app.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. await refreshCase()
  49. if (caseProject.value) {
  50. await loadPack(initialSetting)
  51. prefix.value = caseProject.value!.caseTitle
  52. } else {
  53. await router.replace({name: RoutesName.error})
  54. }
  55. stopWatch()
  56. loaded.value = true
  57. console.log(loaded.value)
  58. }, { immediate: true })
  59. const layoutClassNames = computed(() => {
  60. return {
  61. [`sys-view-${custom.viewMode}`]: true,
  62. 'edit-mode': isEdit.value || custom.showToolbar,
  63. 'setting-mode': custom.showToolbar,
  64. 'hide-right-box-mode': !custom.showRightPano,
  65. 'hide-left-box-mode': !custom.showLeftPano,
  66. 'show-bottom-box-mode': custom.showBottomBar,
  67. 'hide-top-bar-mode': !custom.showHeadBar
  68. }
  69. })
  70. const layoutStyles = computed(() => {
  71. const styles: {[key in string]: string} = {}
  72. if (custom.showBottomBar) {
  73. styles['--editor-menu-bottom'] = custom.bottomBarHeight
  74. }
  75. return styles
  76. })
  77. </script>
  78. <style scoped lang="scss">
  79. .editor-layout {
  80. --editor-menu-bottom: 0px;
  81. --left-pano-left: calc(var(--editor-menu-left) + var(--editor-menu-width));
  82. }
  83. .sys-view-full {
  84. --header-top: var(--hide-header-top);
  85. --editor-menu-right: calc(-1 * var(--editor-toolbox-width)) !important;
  86. --editor-menu-left: calc(-1 * var(--editor-menu-width));
  87. --search-left: 52px;
  88. }
  89. .sys-view-auto {
  90. --header-top: var(--show-header-top);
  91. --search-left: 0px;
  92. }
  93. .hide-top-bar-mode {
  94. --header-top: var(--hide-header-top);
  95. }
  96. .hide-right-box-mode {
  97. --editor-menu-right: calc(-1 * var(--editor-toolbox-width)) !important;
  98. }
  99. .hide-left-box-mode {
  100. --left-pano-left: calc(var(--editor-menu-left) + var(--editor-menu-width) - var(--left-pano-width)) !important;
  101. }
  102. .edit-mode {
  103. --editor-menu-left: calc(-1 * var(--editor-menu-width));
  104. }
  105. .laser-layer {
  106. position: absolute;
  107. z-index: 1;
  108. inset: 0;
  109. .scene {
  110. width: 100%;
  111. height: 100%;
  112. background-color: #ccc;
  113. }
  114. }
  115. </style>