refactor: migrate nuxt gtm module to nuxt/scripts

This commit is contained in:
YunYouJun
2025-08-17 03:05:00 +08:00
parent 190c05918b
commit 13b6ad6047
13 changed files with 5587 additions and 3571 deletions

View File

@@ -1,5 +1,4 @@
import type { RecipeItem, StuffItem } from '~/types'
import { useGtm } from '@gtm-support/vue-gtm'
import { useStorage } from '@vueuse/core'
import { acceptHMRUpdate, defineStore } from 'pinia'
import { computed, onMounted, ref, watch } from 'vue'
@@ -16,7 +15,7 @@ const namespace = 'cook'
export type SearchMode = 'survival' | 'loose' | 'strict'
export const useRecipeStore = defineStore('recipe', () => {
const gtm = useGtm()
const { proxy } = useScriptGoogleTagManager()
const { settings } = useAppStore()
/**
@@ -136,13 +135,13 @@ export const useRecipeStore = defineStore('recipe', () => {
const value = item.name
toggleTools(value)
gtm?.trackEvent({
proxy.dataLayer.push({
event: 'click',
category: `tool_${value}`,
action: 'click_tool',
label: '工具',
})
gtm?.trackEvent({
proxy.dataLayer.push({
event: 'click_tool',
action: item.name,
})