diff --git a/pages/[lang]/word/[id].vue b/pages/[lang]/word/[id].vue index 77f8bf10..81a5a737 100644 --- a/pages/[lang]/word/[id].vue +++ b/pages/[lang]/word/[id].vue @@ -162,7 +162,38 @@ function shareWord() { const asyncDef = ref(null); const showAsyncDef = ref(false); +// Client-side: reveal today's word if game is over +const todayRevealed = ref(null); +const todayRevealedDef = ref(null); + onMounted(async () => { + // Check if today's word should be revealed (game over) + if (d.is_today && !word) { + try { + const saved = localStorage.getItem(lang); + if (saved) { + const state = JSON.parse(saved); + if (state.game_over && state.todays_word) { + todayRevealed.value = state.todays_word; + // Fetch definition for the revealed word + try { + const defData = await $fetch( + `/api/${lang}/definition/${encodeURIComponent(state.todays_word)}` + ); + if (defData && (defData as any).definition) { + todayRevealedDef.value = defData; + } + } catch { + // definition not available + } + } + } + } catch { + // localStorage unavailable + } + return; + } + if (!word || (definition && definition.definition)) return; try { const data = await $fetch(`/api/${lang}/definition/${word}`); @@ -283,8 +314,8 @@ onMounted(() => { - -