♻️(component): 清除layer.notifiy工具函数中的ts-ignore

This commit is contained in:
0o张不歪o0 2022-07-09 19:38:53 +08:00
parent 04dd4ab102
commit c8cadea60a
2 changed files with 12 additions and 29 deletions

View File

@ -450,6 +450,7 @@ const closeHandle = () => {
//Notify //Notify
if (type === 6) { if (type === 6) {
//@ts-ignore
removeNotifiyFromQueen(props.id); removeNotifiyFromQueen(props.id);
} }
}; };

View File

@ -314,10 +314,8 @@ export function calculateNotifOffset(offset: any, area: any, layerId: string) {
// 间隙 // 间隙
let transOffsetLeft = 15; let transOffsetLeft = 15;
let transOffsetTop = 15; let transOffsetTop = 15;
// @ts-ignore (window as any).NotifiyQueen = (window as any).NotifiyQueen || [];
window.NotifiyQueen = window.NotifiyQueen || []; let notifiyQueen = (window as any).NotifiyQueen;
// @ts-ignore
let notifiyQueen = window.NotifiyQueen;
if (typeof offset != "string" || arr.indexOf(offset) === -1) { if (typeof offset != "string" || arr.indexOf(offset) === -1) {
offset = "rt"; offset = "rt";
} }
@ -369,19 +367,14 @@ export function calculateNotifOffset(offset: any, area: any, layerId: string) {
} }
//移除Notify队列中某项并且重新计算其他Notify位置 //移除Notify队列中某项并且重新计算其他Notify位置
export function removeNotifiyFromQueen(layerId: string | undefined) { export function removeNotifiyFromQueen(layerId: string) {
// 间隙 // 间隙
let transOffsetTop = 15; let transOffsetTop = 15;
// @ts-ignore 删除项的高度 // 删除项的高度
let offsetHeight = let notifiyDom = document.getElementById(layerId)?.firstElementChild?.firstElementChild as HTMLElement;
// @ts-ignore let offsetHeight = notifiyDom.offsetHeight;
// @ts-ignore (window as any).NotifiyQueen = (window as any).NotifiyQueen || [];
document.getElementById(layerId)?.firstElementChild?.firstElementChild let notifiyQueen = (window as any).NotifiyQueen;
?.offsetHeight;
// @ts-ignore
window.NotifiyQueen = window.NotifiyQueen || [];
// @ts-ignore
let notifiyQueen = window.NotifiyQueen;
let index = notifiyQueen.findIndex((e: { id: string }) => e.id === layerId); let index = notifiyQueen.findIndex((e: { id: string }) => e.id === layerId);
let offsetType = notifiyQueen[index].offset; let offsetType = notifiyQueen[index].offset;
let list = notifiyQueen.filter((e: { offset: any }) => { let list = notifiyQueen.filter((e: { offset: any }) => {
@ -393,22 +386,11 @@ export function removeNotifiyFromQueen(layerId: string | undefined) {
// //得到需要修改的定位的Notifiy集合 // //得到需要修改的定位的Notifiy集合
let needCalculatelist = list.slice(findIndex + 1); let needCalculatelist = list.slice(findIndex + 1);
needCalculatelist.forEach((e: { id: string }) => { needCalculatelist.forEach((e: { id: string }) => {
let dom = document.getElementById(e.id)?.firstElementChild let dom = document.getElementById(e.id)?.firstElementChild?.firstElementChild as HTMLElement;
?.firstElementChild;
if (offsetType === "rt" || offsetType === "lt") { if (offsetType === "rt" || offsetType === "lt") {
// @ts-ignore dom.style["top"] = parseFloat(dom.style["top"]) - transOffsetTop - offsetHeight + "px";
dom.style["top"] =
// @ts-ignore
parseFloat(dom.style["top"]) - transOffsetTop - offsetHeight + "px";
} else { } else {
// @ts-ignore let bottom = parseFloat(dom.style["top"].split(" - ")[1]) - transOffsetTop - offsetHeight; dom.style["top"] = "calc(100vh - " + bottom + "px)";
let bottom =
// @ts-ignore
parseFloat(dom.style["top"].split(" - ")[1]) -
transOffsetTop -
offsetHeight;
// @ts-ignore
dom.style["top"] = "calc(100vh - " + bottom + "px)";
} }
}); });
notifiyQueen.splice(index, 1); //删除 notifiyQueen.splice(index, 1); //删除