chunk.ARRH633M.js 781 B

1234567891011121314151617181920212223242526272829303132
  1. // src/components/icon/request.ts
  2. var iconFiles = new Map();
  3. var requestIcon = (url) => {
  4. if (iconFiles.has(url)) {
  5. return iconFiles.get(url);
  6. } else {
  7. const request = fetch(url).then(async (response) => {
  8. if (response.ok) {
  9. const div = document.createElement("div");
  10. div.innerHTML = await response.text();
  11. const svg = div.firstElementChild;
  12. return {
  13. ok: response.ok,
  14. status: response.status,
  15. svg: svg && svg.tagName.toLowerCase() === "svg" ? svg.outerHTML : ""
  16. };
  17. } else {
  18. return {
  19. ok: response.ok,
  20. status: response.status,
  21. svg: null
  22. };
  23. }
  24. });
  25. iconFiles.set(url, request);
  26. return request;
  27. }
  28. };
  29. export {
  30. requestIcon
  31. };