Rap 原分销系统代码Web
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

c5f8a4f28d44c0e463d5c4a71ecb8c04254c8b6f.svn-base 2.9KB

5 个月前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <div ref="rightPanel" :class="{show:show}" class="rightPanel-container">
  3. <div class="rightPanel-background" />
  4. <div class="rightPanel">
  5. <div class="rightPanel-items">
  6. <slot />
  7. </div>
  8. </div>
  9. </div>
  10. </template>
  11. <script>
  12. import { addClass, removeClass } from '@/utils'
  13. export default {
  14. name: 'RightPanel',
  15. props: {
  16. clickNotClose: {
  17. default: false,
  18. type: Boolean
  19. },
  20. buttonTop: {
  21. default: 250,
  22. type: Number
  23. }
  24. },
  25. computed: {
  26. show: {
  27. get() {
  28. return this.$store.state.settings.showSettings
  29. },
  30. set(val) {
  31. this.$store.dispatch('settings/changeSetting', {
  32. key: 'showSettings',
  33. value: val
  34. })
  35. }
  36. },
  37. theme() {
  38. return this.$store.state.settings.theme
  39. }
  40. },
  41. watch: {
  42. show(value) {
  43. if (value && !this.clickNotClose) {
  44. this.addEventClick()
  45. }
  46. if (value) {
  47. addClass(document.body, 'showRightPanel')
  48. } else {
  49. removeClass(document.body, 'showRightPanel')
  50. }
  51. }
  52. },
  53. mounted() {
  54. this.insertToBody()
  55. this.addEventClick()
  56. },
  57. beforeDestroy() {
  58. const elx = this.$refs.rightPanel
  59. elx.remove()
  60. },
  61. methods: {
  62. addEventClick() {
  63. window.addEventListener('click', this.closeSidebar)
  64. },
  65. closeSidebar(evt) {
  66. const parent = evt.target.closest('.rightPanel')
  67. if (!parent) {
  68. this.show = false
  69. window.removeEventListener('click', this.closeSidebar)
  70. }
  71. },
  72. insertToBody() {
  73. const elx = this.$refs.rightPanel
  74. const body = document.querySelector('body')
  75. body.insertBefore(elx, body.firstChild)
  76. }
  77. }
  78. }
  79. </script>
  80. <style>
  81. .showRightPanel {
  82. overflow: hidden;
  83. position: relative;
  84. width: calc(100% - 15px);
  85. }
  86. </style>
  87. <style lang="scss" scoped>
  88. .rightPanel-background {
  89. position: fixed;
  90. top: 0;
  91. left: 0;
  92. opacity: 0;
  93. transition: opacity .3s cubic-bezier(.7, .3, .1, 1);
  94. background: rgba(0, 0, 0, .2);
  95. z-index: -1;
  96. }
  97. .rightPanel {
  98. width: 100%;
  99. max-width: 260px;
  100. height: 100vh;
  101. position: fixed;
  102. top: 0;
  103. right: 0;
  104. box-shadow: 0px 0px 15px 0px rgba(0, 0, 0, .05);
  105. transition: all .25s cubic-bezier(.7, .3, .1, 1);
  106. transform: translate(100%);
  107. background: #fff;
  108. z-index: 40000;
  109. }
  110. .show {
  111. transition: all .3s cubic-bezier(.7, .3, .1, 1);
  112. .rightPanel-background {
  113. z-index: 20000;
  114. opacity: 1;
  115. width: 100%;
  116. height: 100%;
  117. }
  118. .rightPanel {
  119. transform: translate(0);
  120. }
  121. }
  122. .handle-button {
  123. width: 48px;
  124. height: 48px;
  125. position: absolute;
  126. left: -48px;
  127. text-align: center;
  128. font-size: 24px;
  129. border-radius: 6px 0 0 6px !important;
  130. z-index: 0;
  131. pointer-events: auto;
  132. cursor: pointer;
  133. color: #fff;
  134. line-height: 48px;
  135. i {
  136. font-size: 24px;
  137. line-height: 48px;
  138. }
  139. }
  140. </style>