From 13b6ad6047af4cf1444ff70353cb2a652f122ef7 Mon Sep 17 00:00:00 2001 From: YunYouJun Date: Sun, 17 Aug 2025 03:05:00 +0800 Subject: [PATCH] refactor: migrate nuxt gtm module to nuxt/scripts --- app/components/ChooseFood.vue | 7 +- app/components/RandomRecipe.vue | 4 +- app/components/ToggleMode.vue | 2 +- app/components/tags/DishTag.vue | 8 +- app/components/tags/MeatTag.vue | 2 +- app/components/tags/StapleTag.vue | 2 +- app/components/tags/ToolTag.vue | 2 +- app/components/tags/VegetableTag.vue | 2 +- app/composables/store/recipe.ts | 7 +- app/pages/404.vue | 2 +- nuxt.config.ts | 18 +- package.json | 68 +- pnpm-lock.yaml | 9034 ++++++++++++++++---------- 13 files changed, 5587 insertions(+), 3571 deletions(-) diff --git a/app/components/ChooseFood.vue b/app/components/ChooseFood.vue index 9e4a1a7..5a40ca7 100644 --- a/app/components/ChooseFood.vue +++ b/app/components/ChooseFood.vue @@ -12,7 +12,8 @@ const curStuff = computed(() => rStore.selectedStuff) const recipeBtnRef = ref() const { playAnimation } = useEmojiAnimation(recipeBtnRef) -const gtm = useGtm() +const { proxy } = useScriptGoogleTagManager() + const recipePanelRef = ref() const { isVisible, show } = useInvisibleElement(recipePanelRef) @@ -22,13 +23,13 @@ function toggleStuff(item: StuffItem, category = '', _e?: Event) { if (curStuff.value.includes(item.name)) playAnimation(item.emoji) - gtm?.trackEvent({ + proxy.dataLayer.push({ event: 'click', category: `${category}_${item.name}`, action: 'click_stuff', label: '食材', }) - gtm?.trackEvent({ + proxy.dataLayer.push({ event: 'click_stuff', action: item.name, }) diff --git a/app/components/RandomRecipe.vue b/app/components/RandomRecipe.vue index eb0c828..f4e1659 100644 --- a/app/components/RandomRecipe.vue +++ b/app/components/RandomRecipe.vue @@ -5,13 +5,13 @@ const { random, randomRecipes } = useRandomRecipe(count)