moduleLeft.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <Transition class="module-left">
  3. <!-- 正常展示模块时 -->
  4. <div v-if="moduleShown" class="module-content">
  5. <div class="module-content__title__expand">
  6. <span class="action-btn close-btn" @click="closeModel"></span>
  7. {{ title }}
  8. </div>
  9. <div class="module-slot">
  10. <slot></slot>
  11. </div>
  12. </div>
  13. <!-- 隐藏模块时 -->
  14. <div v-else class="w-100%">
  15. <div class="module-content__title">
  16. <span class="action-btn show-btn" @click="showModel"></span>
  17. {{ title }}
  18. </div>
  19. </div>
  20. </Transition>
  21. </template>
  22. <script lang="ts" setup>
  23. import { ref } from 'vue';
  24. defineProps<{ title: string }>();
  25. const moduleShown = ref(true);
  26. function closeModel() {
  27. moduleShown.value = false;
  28. }
  29. function showModel() {
  30. moduleShown.value = true;
  31. }
  32. </script>
  33. <style lang="less" scoped>
  34. .module-left {
  35. --bg-height: 33px;
  36. color: #fff;
  37. box-sizing: border-box;
  38. .module-content {
  39. width: 100%;
  40. height: 100%;
  41. }
  42. .module-content__title__expand {
  43. width: 100%;
  44. height: var(--bg-height);
  45. background: url('@/assets/images/home-container/configurable/model_left_title_bg_expand.png') no-repeat;
  46. background-size: 100% 100%;
  47. position: relative;
  48. text-align: right;
  49. padding: 4px 10% 0 0;
  50. }
  51. .module-content__title {
  52. width: 50%;
  53. height: var(--bg-height);
  54. background: url('@/assets/images/home-container/configurable/model_left_title_bg.png') no-repeat;
  55. background-size: 100% 100%;
  56. position: relative;
  57. text-align: right;
  58. padding: 4px 10% 0 0;
  59. }
  60. // 固定在父容器右上角的按钮图标
  61. .action-btn {
  62. width: 18px;
  63. height: 18px;
  64. background: url('@/assets/images/home-container/configurable/expand.svg') no-repeat center;
  65. position: absolute;
  66. right: 0;
  67. top: 0;
  68. }
  69. .close-btn {
  70. transform: rotate(-90deg);
  71. }
  72. .module-slot {
  73. height: calc(100% - 33px);
  74. width: 100%;
  75. background-color: #259ccf22;
  76. }
  77. }
  78. // Transition动画相关
  79. .v-enter-active,
  80. .v-leave-active {
  81. transition: all 0.3s ease;
  82. }
  83. .v-enter-from,
  84. .v-leave-to {
  85. // opacity: 1;
  86. transform: translateX(-100%);
  87. // transform: scaleY(0);
  88. // transform-origin: center top;
  89. }
  90. </style>