index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <div id="dashboard-container" ref="containerRef" class="dashboard-container">
  3. <div class="bg">
  4. <HeaderSection />
  5. <div class="dashboard-content">
  6. <LeftSection v-show="showLeftSection" />
  7. <MiddleSection>
  8. <i :class="showLeftSection ? 'arrow-icon left-icon' : 'arrow-icon right-icon'" @click="handleTelescoping('left')" />
  9. <i :class="showRightSection ? 'arrow-icon2 right-icon' : 'arrow-icon2 left-icon'" @click="handleTelescoping('right')" />
  10. </MiddleSection>
  11. <RightSection v-show="showRightSection" />
  12. </div>
  13. <FooterSection style="position: absolute; bottom: 0; left: 0" />
  14. </div>
  15. </div>
  16. </template>
  17. <script lang="ts" setup>
  18. import LeftSection from './LeftSection/index.vue';
  19. import RightSection from './RightSection/index.vue';
  20. import MiddleSection from './MiddleSection.vue';
  21. import autofit from 'autofit.js';
  22. import { getTransformScale } from '@/utils';
  23. import useAppStore from '@/store/modules/app';
  24. const appStore = useAppStore();
  25. const containerRef = ref();
  26. let scale = ref({ scaleX: 1, scaleY: 1 });
  27. let showLeftSection = computed(() => {
  28. return appStore.showLeftSection;
  29. });
  30. let showRightSection = computed(() => {
  31. return appStore.showRightSection;
  32. });
  33. const handleTelescoping = (type: string) => {
  34. if (type === 'left') {
  35. appStore.toggleLeftSection();
  36. } else if (type === 'right') {
  37. appStore.toggleRightSection();
  38. }
  39. };
  40. provide('containerScale', () => scale.value);
  41. onMounted(() => {
  42. autofit.init(
  43. {
  44. dw: 8960,
  45. dh: 2520,
  46. el: '#dashboard-container',
  47. resize: process.env.NODE_ENV === 'production',
  48. ignore: ['#aMap', '#YztMap']
  49. },
  50. false
  51. );
  52. scale.value = getTransformScale(containerRef.value);
  53. });
  54. onUnmounted(() => {
  55. if (location.hostname === 'localhost___') {
  56. autofit.off();
  57. }
  58. });
  59. </script>
  60. <style lang="scss" scoped>
  61. .dashboard-container {
  62. width: 8960px;
  63. height: 2520px;
  64. font-size: 36px;
  65. font-family: 'PingFang SC', sans-serif;
  66. display: flex;
  67. justify-content: center;
  68. align-items: center;
  69. .bg {
  70. width: 100%;
  71. background: url('@/assets/images/bg.jpg') no-repeat;
  72. background-size: 100% 100%;
  73. position: relative;
  74. }
  75. .dashboard-content {
  76. padding: 0 81px;
  77. display: flex;
  78. height: calc(2520px - 228px);
  79. overflow: hidden;
  80. }
  81. }
  82. .left-icon {
  83. background: url('@/assets/images/left.png') no-repeat;
  84. background-size: 100% 100%;
  85. }
  86. .right-icon {
  87. background: url('@/assets/images/right.png') no-repeat;
  88. background-size: 100% 100%;
  89. }
  90. .arrow-icon {
  91. position: absolute;
  92. bottom: 180px;
  93. left: 0;
  94. z-index: 9;
  95. width: 152px;
  96. height: 158px;
  97. cursor: pointer;
  98. }
  99. .arrow-icon2 {
  100. position: absolute;
  101. bottom: 180px;
  102. right: 0;
  103. z-index: 9;
  104. width: 152px;
  105. height: 158px;
  106. cursor: pointer;
  107. }
  108. </style>