WindowFormElement

This commit is contained in:
2025-09-15 16:25:15 +08:00
parent 9a30c2b3d7
commit 08e08043d7
4 changed files with 48 additions and 5 deletions

View File

@@ -0,0 +1,20 @@
import type { WindowFormEventMap } from '@/core/window/ui/WindowFormElement.ts'
export function addWindowFormEventListener<K extends keyof WindowFormEventMap>(
el: HTMLElement,
type: K,
listener: (ev: WindowFormEventMap[K]) => any,
options?: boolean | AddEventListenerOptions
) {
// 强制类型转换,保证 TS 不报错
el.addEventListener(type, listener as EventListener, options);
}
export function removeWindowFormEventListener<K extends keyof WindowFormEventMap>(
el: HTMLElement,
type: K,
listener: (ev: WindowFormEventMap[K]) => any,
options?: boolean | EventListenerOptions
) {
el.removeEventListener(type, listener as EventListener, options);
}