@alicd/micro-stark
Version:
cone微应用
31 lines (30 loc) • 1.18 kB
JavaScript
// 在进入子应用前对已存在的弹窗进行标识
export function attachmentStaticWrapper() {
let targetEles = document.querySelectorAll('div[data-tag="gateway-wrapper"]');
if (targetEles?.length) {
targetEles.forEach((item) => {
const wrapperType = item.getAttribute('data-cone-micro');
if (wrapperType !== 'dynamic') item.setAttribute('data-cone-micro', 'static');
});
}
}
// 进入子应用后的弹窗进行标识
export function attachmentDynamicWrapper() {
let targetEles = document.querySelectorAll('div[data-tag="gateway-wrapper"]');
if (targetEles?.length) {
targetEles.forEach((item) => {
const wrapperType = item.getAttribute('data-cone-micro');
if (wrapperType !== 'static') item.setAttribute('data-cone-micro', 'dynamic');
});
}
}
// 移除子应用的弹窗
export function delRemaindToastEle() {
let targetEles = document.querySelectorAll('div[data-tag="gateway-wrapper"]');
if (targetEles && targetEles.length > 0) {
targetEles.forEach((item) => {
const wrapperType = item.getAttribute('data-cone-micro');
if (wrapperType !== 'static') document.body.removeChild(item);
});
}
}