rightSettingImport.js 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * @description: 批量导入所有右侧配置组件
  3. * @Date: 2023-03-13 10:04:58
  4. * @Author: xing.heng
  5. * @LastEditors: xing.heng
  6. * @LastEditTime: 2023-05-17 13:18:36
  7. */
  8. const modules = {}
  9. const replaceName = {}
  10. // 排除的组件
  11. const excludeCommponents = [] // 有的话就添加进去
  12. function importComponentSetting (files) {
  13. files.keys().filter(key => {
  14. return key.match(/setting/)
  15. }).forEach(key => {
  16. // 正则,取到./和/之间的字符串
  17. const reg = new RegExp('(.\\/)(.*)(\\/)')
  18. let moduleName = key.match(reg)[0].replace(/(\.\/)|(\/)/g, '')
  19. // 替换组件名称
  20. if (replaceName[moduleName]) {
  21. moduleName = replaceName[moduleName]
  22. }
  23. // 去掉排除的组件
  24. if (!excludeCommponents.includes(moduleName)) {
  25. modules[moduleName] = files(key).default
  26. }
  27. })
  28. }
  29. importComponentSetting(require.context('packages/BasicComponents', true, /\.vue$/))
  30. importComponentSetting(require.context('packages/Borders', true, /\.vue$/))
  31. importComponentSetting(require.context('packages/Decorations', true, /\.vue$/))
  32. export default modules