index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <template v-if="loaded">
  3. <ui-icon
  4. class="screen-full"
  5. :class="{ fullScreen, pure: paramsRaw.pure }"
  6. v-if="paramsRaw.pure"
  7. style="margin-right: 10px"
  8. :type="fullScreen ? 'window_n' : 'window_m'"
  9. ctrl
  10. @click="fullHandler"
  11. />
  12. <div
  13. :class="{ hideLeft: !custom.showLeftPano }"
  14. :style="hasSingle ? { '--left-pano-left': '0px' } : ''"
  15. >
  16. <SlideMenu
  17. v-if="!hasSingle && !custom.full"
  18. :activeName="(router.currentRoute.value.name as RoutesName)"
  19. @change-item="(item) => router.push({ name: item.name })"
  20. />
  21. <router-view v-slot="{ Component }">
  22. <keep-alive>
  23. <component :is="Component" />
  24. </keep-alive>
  25. </router-view>
  26. <GlobalSearch />
  27. </div>
  28. <ViewSetting class="show-setting-layout" />
  29. </template>
  30. </template>
  31. <script lang="ts" setup>
  32. import GlobalSearch from "@/components/global-search/index.vue";
  33. import ViewSetting from "@/components/view-setting/index.vue";
  34. import { custom, params, paramsRaw, showRightPanoStack } from "@/env";
  35. import { ref, watchEffect } from "vue";
  36. import { router, RoutesName } from "@/router";
  37. import { loadModel, fuseModel } from "@/model";
  38. import { asyncTimeout } from "@/utils";
  39. import SlideMenu from "./slide-menu.vue";
  40. import {
  41. // initialFloders,
  42. // initialFloderTypes,
  43. initialFuseModels,
  44. initialRecords,
  45. initialScenes,
  46. // initialViews,
  47. defTitle,
  48. initialTaggingStyles,
  49. initialTaggings,
  50. initialMeasures,
  51. initialGuides,
  52. scenes,
  53. fuseModels,
  54. appEl,
  55. initialPaths,
  56. initMonitors,
  57. } from "@/store";
  58. import { initialAnimationModels } from "@/store/animation";
  59. import { fullView } from "@/utils/full";
  60. import { watch } from "fs";
  61. const hasSingle = new URLSearchParams(location.search).has("single");
  62. watchEffect((onCleanup) => {
  63. if (router.currentRoute.value.name === RoutesName.show) {
  64. onCleanup(showRightPanoStack.push(ref(false)));
  65. }
  66. });
  67. const fullScreen = ref(false);
  68. let quit: (() => void) | null = null;
  69. const fullHandler = async () => {
  70. if (quit) {
  71. quit();
  72. fullScreen.value = false;
  73. params.pure = true;
  74. quit = null;
  75. } else {
  76. quit = await fullView(() => {
  77. fullScreen.value = false;
  78. params.pure = true;
  79. quit = null;
  80. }, false);
  81. fullScreen.value = true;
  82. params.pure = false;
  83. }
  84. };
  85. const loaded = ref(false);
  86. const initialSys = async () => {
  87. await initialTaggingStyles();
  88. await Promise.all([
  89. initialFuseModels(),
  90. initialScenes(),
  91. // initialViews(),
  92. initialRecords(),
  93. // initialFloders(),
  94. // initialFloderTypes(),
  95. initialTaggings(),
  96. initialGuides(),
  97. initMonitors(),
  98. initialAnimationModels(),
  99. ]);
  100. await initialPaths();
  101. await initialMeasures();
  102. await loadModel(fuseModel);
  103. await asyncTimeout(1000);
  104. loaded.value = true;
  105. // custom.showLeftPano = true;
  106. };
  107. initialSys();
  108. defTitle.value = "";
  109. initialScenes();
  110. watchEffect((onCleanup) => {
  111. if (loaded.value && appEl.value && scenes.value.length && !fuseModels.value.length) {
  112. loadModel(scenes.value[0] as any);
  113. // custom.showLeftPano = true;
  114. }
  115. });
  116. </script>
  117. <style>
  118. :root {
  119. --editor-menu-width: 80px;
  120. --editor-head-height: 0px;
  121. }
  122. .hideLeft {
  123. --editor-menu-left: calc(-1 * var(--editor-menu-width));
  124. --left-pano-left: calc(
  125. var(--editor-menu-left) + var(--editor-menu-width) - var(--left-pano-width)
  126. ) !important;
  127. }
  128. </style>
  129. <style lang="scss" scoped>
  130. .show-setting-layout {
  131. position: absolute;
  132. bottom: 20px;
  133. z-index: 99;
  134. right: calc(var(--editor-menu-right) + var(--editor-toolbox-width) + 20px);
  135. }
  136. .screen-full {
  137. position: fixed;
  138. right: 20px;
  139. top: 20px;
  140. z-index: 999;
  141. text-shadow: 0 0 2px rgba(0, 0, 0, 0.6);
  142. font-size: 22px;
  143. color: #fff !important;
  144. &.fullScreen {
  145. right: calc(var(--editor-menu-right) + var(--editor-toolbox-width) + 20px);
  146. }
  147. }
  148. </style>