app.vue 3.1 KB

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