Components.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <div class="components">
  3. <a-collapse :defaultActiveKey="componentKeys" :bordered="false" expandIconPosition="right">
  4. <a-collapse-panel v-for="group in data" :key="group.key" :header="group.name">
  5. <div class="module-list">
  6. <div
  7. v-for="(item, index) in group.data"
  8. :key="index"
  9. class="module-item"
  10. @click="handleClickItem(item.type)"
  11. >
  12. <a-icon class="module-icon" :component="item.icon" />
  13. <span class="module-title">{{ item.name }}</span>
  14. </div>
  15. </div>
  16. </a-collapse-panel>
  17. </a-collapse>
  18. </div>
  19. </template>
  20. <script>
  21. import { filterModules } from '@/core/app'
  22. import * as Icon from '@/assets/icons/page/components'
  23. const data = [
  24. {
  25. name: '媒体组件',
  26. key: 'media',
  27. data: [
  28. {
  29. name: '轮播图',
  30. type: 'banner',
  31. icon: Icon.banner
  32. },
  33. {
  34. name: '图片',
  35. type: 'image',
  36. icon: Icon.image
  37. },
  38. {
  39. name: '图片橱窗',
  40. type: 'window',
  41. icon: Icon.window
  42. },
  43. {
  44. name: '热区',
  45. type: 'hotZone',
  46. icon: Icon.window
  47. },
  48. {
  49. name: '文章',
  50. type: 'article',
  51. icon: Icon.article
  52. },
  53. {
  54. name: '视频',
  55. type: 'video',
  56. icon: Icon.video
  57. },
  58. {
  59. name: '头条快报',
  60. type: 'special',
  61. icon: Icon.special
  62. },
  63. {
  64. name: '标题文本',
  65. type: 'title',
  66. icon: Icon.title
  67. }
  68. ]
  69. },
  70. {
  71. name: '商城组件',
  72. key: 'store',
  73. data: [
  74. {
  75. name: '搜索框',
  76. type: 'search',
  77. icon: Icon.search
  78. },
  79. {
  80. name: '导航组',
  81. type: 'navBar',
  82. icon: Icon.navBar
  83. },
  84. {
  85. name: '店铺公告',
  86. type: 'notice',
  87. icon: Icon.notice
  88. },
  89. {
  90. name: '商品组',
  91. type: 'goods',
  92. icon: Icon.goods
  93. },
  94. {
  95. name: '优惠券',
  96. type: 'coupon',
  97. icon: Icon.coupon,
  98. moduleKey: 'market-coupon'
  99. },
  100. {
  101. name: '在线客服',
  102. type: 'service',
  103. icon: Icon.service
  104. }
  105. ]
  106. },
  107. {
  108. name: '其他组件',
  109. key: 'other',
  110. data: [
  111. {
  112. name: '富文本',
  113. type: 'richText',
  114. icon: Icon.richText
  115. },
  116. {
  117. name: '辅助空白',
  118. type: 'blank',
  119. icon: Icon.blank
  120. },
  121. {
  122. name: '辅助线',
  123. type: 'guide',
  124. icon: Icon.guide
  125. },
  126. {
  127. name: '备案号',
  128. type: 'ICPLicense',
  129. icon: Icon.ICPLicense
  130. },
  131. {
  132. name: '关注公众号',
  133. type: 'officialAccount',
  134. icon: Icon.officialAccount
  135. },
  136. ]
  137. }
  138. ]
  139. export default {
  140. data () {
  141. return { Icon, data }
  142. },
  143. computed: {
  144. componentKeys () {
  145. const { data } = this
  146. return data.map(item => item.key)
  147. }
  148. },
  149. methods: {
  150. handleClickItem (type) {
  151. this.$emit('handleClickItem', type)
  152. }
  153. }
  154. }
  155. </script>
  156. <style lang="less" scoped>
  157. ::-webkit-scrollbar {
  158. width: 0;
  159. height: 0;
  160. }
  161. // 组件库
  162. .components {
  163. width: 310px;
  164. background: #f8f9fa;
  165. height: 100%;
  166. overflow-y: auto;
  167. /deep/.ant-collapse-header {
  168. padding: 14px 16px;
  169. font-size: @font-size-base;
  170. font-weight: 700;
  171. color: #595961;
  172. }
  173. /deep/.ant-collapse-content-box {
  174. padding-top: 0 !important;
  175. }
  176. /deep/.ant-collapse > .ant-collapse-item {
  177. border-bottom: none;
  178. }
  179. .module-list {
  180. display: flex;
  181. flex-wrap: wrap;
  182. }
  183. .module-item {
  184. width: 90px;
  185. height: 90px;
  186. padding: 15px 0;
  187. text-align: center;
  188. font-size: 12px;
  189. color: #595961;
  190. line-height: 20px;
  191. position: relative;
  192. user-select: none;
  193. cursor: pointer;
  194. &:hover {
  195. background: #f7f7f7;
  196. border-radius: 4px;
  197. }
  198. .module-icon {
  199. display: block;
  200. width: 74px;
  201. height: 45px;
  202. line-height: 45px;
  203. margin: 0 auto;
  204. font-size: 26px;
  205. color: #9797a1;
  206. }
  207. }
  208. }
  209. </style>