refactor: 빌드 오류 수정

This commit is contained in:
“hyeonggkim”
2026-01-29 21:32:33 +09:00
parent a9c0182f5e
commit ee68a02751

View File

@@ -631,34 +631,34 @@
{ immediate: true }, { immediate: true },
) )
// onMounted에서 초기화 코드 실행 (CSR에서만) // 이벤트 위임 핸들러
onMounted(() => {
if (!import.meta.client) return
const container = customContainerRef.value
if (!container) return
// onclick="fnCustomAction(this)", fnCustomLog(this) 지원 (CSR에서만)
;window.fnCustomAction = handleCustomAction
;window.fnCustomLog = handleCustomLog
// onclick을 못 쓰는 케이스 대비: 이벤트 위임도 같이 지원
const onDelegatedClick = (e: MouseEvent) => { const onDelegatedClick = (e: MouseEvent) => {
const target = e.target as HTMLElement | null const target = e.target as HTMLElement | null
const el = const el =
(target?.closest?.('[data-action], [data-log]') as HTMLElement | null) ?? (target?.closest?.('[data-action]') as HTMLElement | null) ?? null
null
handleCustomAction(el) handleCustomAction(el)
} }
// onMounted에서 초기화 코드 실행 (CSR에서만)
if (import.meta.client) {
onMounted(() => {
const container = customContainerRef.value
if (!container) return
// fnCustomAction, fnCustomLog 전역 등록
window.fnCustomAction = handleCustomAction
window.fnCustomLog = handleCustomLog
// 이벤트 위임 등록
container.addEventListener('click', onDelegatedClick) container.addEventListener('click', onDelegatedClick)
onBeforeUnmount(() => {
container.removeEventListener('click', onDelegatedClick)
})
}) })
onBeforeUnmount(() => { onBeforeUnmount(() => {
if (!import.meta.client) return const container = customContainerRef.value
if (container) {
container.removeEventListener('click', onDelegatedClick)
}
const w = window as any const w = window as any
if (w.fnCustomAction === handleCustomAction) { if (w.fnCustomAction === handleCustomAction) {
delete w.fnCustomAction delete w.fnCustomAction
@@ -667,6 +667,7 @@
delete w.fnCustomLog delete w.fnCustomLog
} }
}) })
}
</script> </script>
<template> <template>