index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <script setup lang="ts">
  2. import { ref } from "vue";
  3. import { onClickOutside } from "@vueuse/core";
  4. import { emitter } from "/@/utils/mitt";
  5. let show = ref<Boolean>(false);
  6. const target = ref(null);
  7. onClickOutside(target, (event: any) => {
  8. if (event.clientX > target.value.offsetLeft) return;
  9. show.value = false;
  10. });
  11. emitter.on("openPanel", () => {
  12. show.value = true;
  13. });
  14. </script>
  15. <template>
  16. <div :class="{ show: show }" class="right-panel-container">
  17. <div class="right-panel-background" />
  18. <div ref="target" class="right-panel bg-bg_color">
  19. <div class="right-panel-items">
  20. <div class="project-configuration">
  21. <h3 class="dark:text-white">项目配置</h3>
  22. <span title="关闭配置">
  23. <IconifyIconOffline
  24. class="dark:text-white"
  25. icon="close"
  26. @click="show = !show"
  27. />
  28. </span>
  29. </div>
  30. <div
  31. class="border-b-[1px] border-solid border-[#dcdfe6] dark:border-[#303030]"
  32. />
  33. <slot />
  34. </div>
  35. </div>
  36. </div>
  37. </template>
  38. <style>
  39. .showright-panel {
  40. overflow: hidden;
  41. position: relative;
  42. width: calc(100% - 15px);
  43. }
  44. </style>
  45. <style lang="scss" scoped>
  46. .right-panel-background {
  47. position: fixed;
  48. top: 0;
  49. left: 0;
  50. opacity: 0;
  51. transition: opacity 0.3s cubic-bezier(0.7, 0.3, 0.1, 1);
  52. background: rgba(0, 0, 0, 0.2);
  53. z-index: -1;
  54. }
  55. .right-panel {
  56. width: 100%;
  57. max-width: 315px;
  58. height: 100vh;
  59. position: fixed;
  60. top: 0;
  61. right: 0;
  62. box-shadow: 0 0 15px 0 rgba(0, 0, 0, 0.05);
  63. transition: all 0.25s cubic-bezier(0.7, 0.3, 0.1, 1);
  64. transform: translate(100%);
  65. // background: #fff;
  66. z-index: 40000;
  67. }
  68. .show {
  69. transition: all 0.3s cubic-bezier(0.7, 0.3, 0.1, 1);
  70. .right-panel-background {
  71. z-index: 20000;
  72. opacity: 1;
  73. width: 100%;
  74. height: 100%;
  75. }
  76. .right-panel {
  77. transform: translate(0);
  78. }
  79. }
  80. .handle-button {
  81. width: 48px;
  82. height: 48px;
  83. position: absolute;
  84. left: -48px;
  85. text-align: center;
  86. font-size: 24px;
  87. border-radius: 6px 0 0 6px !important;
  88. z-index: 0;
  89. pointer-events: auto;
  90. cursor: pointer;
  91. color: #fff;
  92. line-height: 48px;
  93. top: 45%;
  94. background: rgb(24, 144, 255);
  95. i {
  96. font-size: 24px;
  97. line-height: 48px;
  98. }
  99. }
  100. .right-panel-items {
  101. margin-top: 60px;
  102. height: calc(100vh - 60px);
  103. overflow-y: auto;
  104. }
  105. .project-configuration {
  106. display: flex;
  107. width: 100%;
  108. height: 30px;
  109. position: fixed;
  110. justify-content: space-between;
  111. align-items: center;
  112. top: 15px;
  113. margin-left: 10px;
  114. svg {
  115. font-size: 20px;
  116. margin-right: 20px;
  117. &:hover {
  118. cursor: pointer;
  119. color: var(--el-color-primary);
  120. }
  121. }
  122. }
  123. :deep(.el-divider--horizontal) {
  124. width: 90%;
  125. margin: 20px auto 0 auto;
  126. }
  127. </style>