From 6677b1a846aa283f8e596ce15c34c794f63b0a54 Mon Sep 17 00:00:00 2001 From: taiy <53635909+taiyme@users.noreply.github.com> Date: Fri, 11 Oct 2024 16:57:37 +0900 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20getBgColor=E9=96=A2=E6=95=B0?= =?UTF-8?q?=E3=81=AE=E5=88=87=E3=82=8A=E5=87=BA=E3=81=97=20+=20fix=20types?= =?UTF-8?q?=20(taiyme#291)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frontend/src/components/MkContainer.vue | 24 ++++---- .../src/components/MkDateSeparatedList.vue | 8 +-- .../src/components/MkFoldableSection.vue | 58 ++++++++----------- packages/frontend/src/components/MkFolder.vue | 38 ++++++------ .../components/global/MkPageHeader.tabs.vue | 27 ++++----- .../frontend/src/directives/adaptive-bg.ts | 12 +--- .../src/directives/adaptive-border.ts | 12 +--- packages/frontend/src/directives/panel.ts | 12 +--- .../frontend/src/scripts/tms/get-bg-color.ts | 18 ++++++ 9 files changed, 97 insertions(+), 112 deletions(-) create mode 100644 packages/frontend/src/scripts/tms/get-bg-color.ts diff --git a/packages/frontend/src/components/MkContainer.vue b/packages/frontend/src/components/MkContainer.vue index 8ab01d7db817..f513795c5619 100644 --- a/packages/frontend/src/components/MkContainer.vue +++ b/packages/frontend/src/components/MkContainer.vue @@ -64,26 +64,30 @@ const showBody = ref(props.expanded); const ignoreOmit = ref(false); const omitted = ref(false); -function enter(el) { +function enter(el: Element) { + if (!(el instanceof HTMLElement)) return; const elementHeight = el.getBoundingClientRect().height; - el.style.height = 0; + el.style.height = '0'; el.offsetHeight; // reflow - el.style.height = Math.min(elementHeight, props.maxHeight ?? Infinity) + 'px'; + el.style.height = `${Math.min(elementHeight, props.maxHeight ?? Infinity)}px`; } -function afterEnter(el) { - el.style.height = null; +function afterEnter(el: Element) { + if (!(el instanceof HTMLElement)) return; + el.style.height = ''; } -function leave(el) { +function leave(el: Element) { + if (!(el instanceof HTMLElement)) return; const elementHeight = el.getBoundingClientRect().height; - el.style.height = elementHeight + 'px'; + el.style.height = `${elementHeight}px`; el.offsetHeight; // reflow - el.style.height = 0; + el.style.height = '0'; } -function afterLeave(el) { - el.style.height = null; +function afterLeave(el: Element) { + if (!(el instanceof HTMLElement)) return; + el.style.height = ''; } const calcOmit = () => { diff --git a/packages/frontend/src/components/MkDateSeparatedList.vue b/packages/frontend/src/components/MkDateSeparatedList.vue index f04e5cf7c63c..9c75f91cb207 100644 --- a/packages/frontend/src/components/MkDateSeparatedList.vue +++ b/packages/frontend/src/components/MkDateSeparatedList.vue @@ -128,14 +128,14 @@ export default defineComponent({ return children; }; - function onBeforeLeave(element: Element) { - const el = element as HTMLElement; + function onBeforeLeave(el: Element) { + if (!(el instanceof HTMLElement)) return; el.style.top = `${el.offsetTop}px`; el.style.left = `${el.offsetLeft}px`; } - function onLeaveCancelled(element: Element) { - const el = element as HTMLElement; + function onLeaveCancelled(el: Element) { + if (!(el instanceof HTMLElement)) return; el.style.top = ''; el.style.left = ''; } diff --git a/packages/frontend/src/components/MkFoldableSection.vue b/packages/frontend/src/components/MkFoldableSection.vue index 1717f8fc9898..7bdedc8f8f6c 100644 --- a/packages/frontend/src/components/MkFoldableSection.vue +++ b/packages/frontend/src/components/MkFoldableSection.vue @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only