UNPKG

cione-comp-lib

Version:

`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`

41 lines (40 loc) 1.34 kB
let CORSUrlList = []; const getCORSWhiteList = async () => { let result = await fetch(window.env.VITE_MAIN_URL + "/cors/redirect_address/list", { method: "GET", headers: { "Content-Type": "application/json" } }).then((response) => response.json()); CORSUrlList = result.data.data; }; const getStaticUrl = async (url) => { if (!CORSUrlList.length) await getCORSWhiteList(); for (let item of CORSUrlList) { let newUrl = url.replaceAll(item, window.env.VITE_BASE_URL + "/thirdPart"); if (newUrl != url) return newUrl; } return url; }; const handleComponetEvent = (key, evt, data) => { window.handleComponetEvents && window.handleComponetEvents(key, evt, data); }; const handlePushEvent = (evt) => { if (window.EventPublisher && window.EventPublisher.name === "EventPublisher") { window.EventPublisher.publish(evt.key, evt); } }; const handleEventCallback = (dataSource, event, data) => { if ((dataSource == null ? void 0 : dataSource.events[event]) && typeof dataSource.events[event] === "function") { const EventPublisher = { packageCode: dataSource.packageCode, elementId: dataSource.elementId, event, data }; dataSource.events[event](EventPublisher); } }; export { getStaticUrl, handleComponetEvent, handleEventCallback, handlePushEvent };