svg-icons-lib.tpl.js 570 B

12345678910111213141516171819202122232425262728
  1. // == collection start
  2. const collections = {
  3. default: __default__,
  4. }
  5. // == collection end
  6. const svglib = {}
  7. svglib.registerCollection = (key, lib) => {
  8. if (collections[key]) {
  9. return
  10. }
  11. if (typeof lib.registerCollection === 'function') {
  12. collections[key] = lib.getCollection('default')
  13. } else {
  14. collections[key] = lib
  15. }
  16. }
  17. svglib.getCollection = (key = 'default') => {
  18. if (!collections[key]) throw new Error(`没有找到名为 ${key} 的图标库。`)
  19. return collections[key]
  20. }
  21. export const SvgIconLib = svglib
  22. export default SvgIconLib