From 04dd4ab102f8ef00fda9b353d5a4ec0a79558918 Mon Sep 17 00:00:00 2001 From: sight <1453017105@qq.com> Date: Sat, 9 Jul 2022 10:32:27 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B:=20layer=20=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/src/component/input/index.vue | 8 +++++-- package/layer/src/component/Notifiy.vue | 24 +++++++++---------- package/layer/src/component/index.vue | 13 +++++----- package/layer/src/utils/index.ts | 5 +++- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/package/component/src/component/input/index.vue b/package/component/src/component/input/index.vue index c3650b54..9d4cbc39 100644 --- a/package/component/src/component/input/index.vue +++ b/package/component/src/component/input/index.vue @@ -45,13 +45,17 @@ const emit = defineEmits(); const { t } = useI18n(); const slots = useSlots(); -const currentValue = ref(String(props.modelValue == null ? '' : props.modelValue)); +const currentValue = ref( + String(props.modelValue == null ? "" : props.modelValue) +); const hasContent = computed(() => (props.modelValue as string)?.length > 0); watch( () => props.modelValue, () => { - currentValue.value = String(props.modelValue == null ? '' : props.modelValue); + currentValue.value = String( + props.modelValue == null ? "" : props.modelValue + ); } ); diff --git a/package/layer/src/component/Notifiy.vue b/package/layer/src/component/Notifiy.vue index 3bf8f629..7359bcf6 100644 --- a/package/layer/src/component/Notifiy.vue +++ b/package/layer/src/component/Notifiy.vue @@ -17,7 +17,7 @@ export default { }; diff --git a/package/layer/src/component/index.vue b/package/layer/src/component/index.vue index 0ece2861..db41c292 100644 --- a/package/layer/src/component/index.vue +++ b/package/layer/src/component/index.vue @@ -177,7 +177,6 @@ const firstOpenDelayCalculation = function () { area.value = calculateDrawerArea(props.offset, props.area); } if (type == 5) { - // @ts-ignore area.value = await calculatePhotosArea( props.imgList[props.startIndex].src, props @@ -395,13 +394,14 @@ const boxClasses = computed(() => { const supportMove = function () { if (props.move && type != 4) { nextTick(() => { - // @ts-ignore 拖拽 - useMove(layero.value, (left, top) => { + // 拖拽 + if (!layero.value) return; + useMove(layero.value, (left: string, top: string) => { l.value = left; t.value = top; }); - // @ts-ignore 拉伸 - useResize(layero.value, (width, height) => { + // 拉伸 + useResize(layero.value, (width: string, height: string) => { h.value = height; w.value = width; }); @@ -524,7 +524,7 @@ const leaveActiveClass = computed(() => { }); /** - * 打卡弹层 + * 打开弹层 *

*/ const open = () => { @@ -576,7 +576,6 @@ const showTitle = computed(() => { */ const resetCalculationPohtosArea = function (index: number) { nextTick(async () => { - // @ts-ignore area.value = await calculatePhotosArea(props.imgList[index].src, props); offset.value = calculateOffset(props.offset, area.value, props.type); w.value = area.value[0]; diff --git a/package/layer/src/utils/index.ts b/package/layer/src/utils/index.ts index 780d1595..c6f4adfc 100644 --- a/package/layer/src/utils/index.ts +++ b/package/layer/src/utils/index.ts @@ -264,7 +264,10 @@ export function getDrawerAnimationClass(offset: any, isClose: boolean = false) { } //计算图片大小 并缩放 -export async function calculatePhotosArea(url: string, options: object) { +export async function calculatePhotosArea( + url: string, + options: object +): Promise> { let img = new Image(); img.src = url; return new Promise((resolve, reject) => { From c8cadea60a8a3250d32dc3c9d6aed9fe0e75c6e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?0o=E5=BC=A0=E4=B8=8D=E6=AD=AAo0?= Date: Sat, 9 Jul 2022 19:38:53 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E2=99=BB=EF=B8=8F(component):=20=E6=B8=85?= =?UTF-8?q?=E9=99=A4layer.notifiy=E5=B7=A5=E5=85=B7=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E4=B8=AD=E7=9A=84ts-ignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package/layer/src/component/index.vue | 1 + package/layer/src/utils/index.ts | 40 ++++++++------------------- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/package/layer/src/component/index.vue b/package/layer/src/component/index.vue index db41c292..90e41765 100644 --- a/package/layer/src/component/index.vue +++ b/package/layer/src/component/index.vue @@ -450,6 +450,7 @@ const closeHandle = () => { //Notify 从队列中移除当前实例 if (type === 6) { + //@ts-ignore removeNotifiyFromQueen(props.id); } }; diff --git a/package/layer/src/utils/index.ts b/package/layer/src/utils/index.ts index c6f4adfc..2ae14591 100644 --- a/package/layer/src/utils/index.ts +++ b/package/layer/src/utils/index.ts @@ -314,10 +314,8 @@ export function calculateNotifOffset(offset: any, area: any, layerId: string) { // 间隙 let transOffsetLeft = 15; let transOffsetTop = 15; - // @ts-ignore - window.NotifiyQueen = window.NotifiyQueen || []; - // @ts-ignore - let notifiyQueen = window.NotifiyQueen; + (window as any).NotifiyQueen = (window as any).NotifiyQueen || []; + let notifiyQueen = (window as any).NotifiyQueen; if (typeof offset != "string" || arr.indexOf(offset) === -1) { offset = "rt"; } @@ -369,19 +367,14 @@ export function calculateNotifOffset(offset: any, area: any, layerId: string) { } //移除Notify队列中某项,并且重新计算其他Notify位置 -export function removeNotifiyFromQueen(layerId: string | undefined) { +export function removeNotifiyFromQueen(layerId: string) { // 间隙 let transOffsetTop = 15; - // @ts-ignore 删除项的高度 - let offsetHeight = - // @ts-ignore - // @ts-ignore - document.getElementById(layerId)?.firstElementChild?.firstElementChild - ?.offsetHeight; - // @ts-ignore - window.NotifiyQueen = window.NotifiyQueen || []; - // @ts-ignore - let notifiyQueen = window.NotifiyQueen; + // 删除项的高度 + let notifiyDom = document.getElementById(layerId)?.firstElementChild?.firstElementChild as HTMLElement; + let offsetHeight = notifiyDom.offsetHeight; + (window as any).NotifiyQueen = (window as any).NotifiyQueen || []; + let notifiyQueen = (window as any).NotifiyQueen; let index = notifiyQueen.findIndex((e: { id: string }) => e.id === layerId); let offsetType = notifiyQueen[index].offset; let list = notifiyQueen.filter((e: { offset: any }) => { @@ -393,22 +386,11 @@ export function removeNotifiyFromQueen(layerId: string | undefined) { // //得到需要修改的定位的Notifiy集合 let needCalculatelist = list.slice(findIndex + 1); needCalculatelist.forEach((e: { id: string }) => { - let dom = document.getElementById(e.id)?.firstElementChild - ?.firstElementChild; + let dom = document.getElementById(e.id)?.firstElementChild?.firstElementChild as HTMLElement; if (offsetType === "rt" || offsetType === "lt") { - // @ts-ignore - dom.style["top"] = - // @ts-ignore - parseFloat(dom.style["top"]) - transOffsetTop - offsetHeight + "px"; + dom.style["top"] = parseFloat(dom.style["top"]) - transOffsetTop - offsetHeight + "px"; } else { - // @ts-ignore - let bottom = - // @ts-ignore - parseFloat(dom.style["top"].split(" - ")[1]) - - transOffsetTop - - offsetHeight; - // @ts-ignore - dom.style["top"] = "calc(100vh - " + bottom + "px)"; + let bottom = parseFloat(dom.style["top"].split(" - ")[1]) - transOffsetTop - offsetHeight; dom.style["top"] = "calc(100vh - " + bottom + "px)"; } }); notifiyQueen.splice(index, 1); //删除