loadBeautifier.js 644 B

12345678910111213141516171819202122232425262728
  1. import loadScript from './loadScript'
  2. import ELEMENT from 'element-ui'
  3. import pluginsConfig from './pluginsConfig'
  4. let beautifierObj
  5. export default function loadBeautifier(cb) {
  6. const { beautifierUrl } = pluginsConfig
  7. if (beautifierObj) {
  8. cb(beautifierObj)
  9. return
  10. }
  11. const loading = ELEMENT.Loading.service({
  12. fullscreen: true,
  13. lock: true,
  14. text: '格式化资源加载中...',
  15. spinner: 'el-icon-loading',
  16. background: 'rgba(255, 255, 255, 0.5)'
  17. })
  18. loadScript(beautifierUrl, () => {
  19. loading.close()
  20. // eslint-disable-next-line no-undef
  21. beautifierObj = beautifier
  22. cb(beautifierObj)
  23. })
  24. }