index2.vue 3.1 KB

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