index.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <template v-if="loaded">
  3. <div
  4. :class="{ hideLeft: !custom.showLeftPano }"
  5. :style="hasSingle ? { '--left-pano-left': '0px' } : ''"
  6. >
  7. <SlideMenu
  8. v-if="!hasSingle"
  9. :activeName="(router.currentRoute.value.name as RoutesName)"
  10. @change-item="(item) => router.push({ name: item.name })"
  11. />
  12. <router-view v-slot="{ Component }">
  13. <keep-alive>
  14. <component :is="Component" />
  15. </keep-alive>
  16. </router-view>
  17. </div>
  18. </template>
  19. </template>
  20. <script lang="ts" setup>
  21. import { custom, params } from "@/env";
  22. import { computed, nextTick, ref, watch, watchEffect } from "vue";
  23. import { router, RoutesName } from "@/router";
  24. import { loadModel, fuseModel } from "@/model";
  25. import SlideMenu from "./slide-menu.vue";
  26. import { sdk } from "@/sdk";
  27. import {
  28. initialFloders,
  29. initialFloderTypes,
  30. initialFuseModels,
  31. initialRecords,
  32. initialScenes,
  33. initialViews,
  34. defTitle,
  35. initialTaggingStyles,
  36. initialTaggings,
  37. initialMeasures,
  38. initialGuides,
  39. scenes,
  40. fuseModels,
  41. appEl,
  42. } from "@/store";
  43. const hasSingle = new URLSearchParams(location.search).has("single");
  44. const loaded = ref(false);
  45. const initialSys = async () => {
  46. await Promise.all([
  47. initialFuseModels(),
  48. initialScenes(),
  49. initialViews(),
  50. initialRecords(),
  51. initialFloders(),
  52. initialFloderTypes(),
  53. initialTaggingStyles(),
  54. initialTaggings(),
  55. initialGuides(),
  56. ]);
  57. await initialMeasures();
  58. loaded.value = true;
  59. await loadModel(fuseModel);
  60. sdk.hideGrid();
  61. custom.showLeftPano = true;
  62. };
  63. initialSys();
  64. defTitle.value = "";
  65. initialScenes();
  66. watchEffect((onCleanup) => {
  67. if (loaded.value && appEl.value && scenes.value.length && !fuseModels.value.length) {
  68. loadModel(scenes.value[0] as any);
  69. custom.showLeftPano = true;
  70. }
  71. });
  72. </script>
  73. <style>
  74. :root {
  75. --editor-menu-width: 80px;
  76. --editor-head-height: 0px;
  77. }
  78. .hideLeft {
  79. --editor-menu-left: calc(-1 * var(--editor-menu-width));
  80. --left-pano-left: calc(
  81. var(--editor-menu-left) + var(--editor-menu-width) - var(--left-pano-width)
  82. ) !important;
  83. }
  84. </style>