From 618b260bbea7d177d0bff287c573c3b382bad599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chyeonggkim=E2=80=9D?= <“hyeonggkim@smilegate.com”> Date: Wed, 21 Jan 2026 18:53:48 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20CSR=EC=97=90=EC=84=9C=20=5F=5FcustomAct?= =?UTF-8?q?ion=20=EC=84=A4=EC=A0=95=20=EB=B0=8F=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- layers/templates/CtLayout01/index.vue | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/layers/templates/CtLayout01/index.vue b/layers/templates/CtLayout01/index.vue index f01867b..d3c9c41 100644 --- a/layers/templates/CtLayout01/index.vue +++ b/layers/templates/CtLayout01/index.vue @@ -15,6 +15,15 @@ const runtimeConfig = useRuntimeConfig() const staticUrl = runtimeConfig.public.staticUrl + // CSR에서만 __customAction 즉시 설정 (HTML 렌더링 전에 필요) + // handleCustomAction이 정의되기 전이므로 나중에 업데이트됨 + if (import.meta.client) { + ;(window as any).__customAction = () => { + // handleCustomAction이 아직 정의되지 않았을 수 있으므로 무시 + // onMounted에서 실제 함수로 교체됨 + } + } + const coerceToString = (value: unknown): string => { if (typeof value === 'string') return value if (typeof value === 'number') return String(value) @@ -474,6 +483,11 @@ if (!import.meta.client) return if (!html) return + // HTML이 업데이트될 때마다 __customAction 재설정 (CSR에서만) + if (import.meta.client) { + ;(window as any).__customAction = handleCustomAction + } + scriptsLoaded.value = false let cancelled = false @@ -498,19 +512,25 @@ } } - if (!cancelled) scriptsLoaded.value = true + // 스크립트 로드 후에도 __customAction 재설정 (CSR에서만) + if (!cancelled && import.meta.client) { + scriptsLoaded.value = true + ;(window as any).__customAction = handleCustomAction + } else if (!cancelled) { + scriptsLoaded.value = true + } }, { immediate: true }, ) - // onMounted에서 초기화 코드 실행 + // onMounted에서 초기화 코드 실행 (CSR에서만) onMounted(() => { if (!import.meta.client) return const container = customContainerRef.value if (!container) return - // onclick="window.__customAction(this)" 지원 + // onclick="window.__customAction(this)" 지원 (CSR에서만) ;(window as any).__customAction = handleCustomAction // onclick을 못 쓰는 케이스 대비: 이벤트 위임도 같이 지원