<!-- @format -->

<script setup>
import '@unocss/reset/tailwind.css'
import LoginModal from '~/components/common/login/index.vue'

const router = useRouter()
router.beforeEach(() => {
  const timer = setTimeout(() => {
    const dom = document.getElementById('app-scroller')
    dom.scrollTo({
      top: 0,
      behavior: 'smooth',
    })
    clearTimeout(timer)
  }, 500)
})

useHead({
  script: [
    // Google Tag Manager
    // {
    //   children: `(function (w, d, s, l, i) {
    //     w[l] = w[l] || []
    //     function gtag() {  w[l].push(arguments) }
    //     w.$gtag = gtag
    //     const j = d.createElement(s)
    //     j.src = "https://www.googletagmanager.com/gtag/js?id=" + i
    //     j.async = true
    //     j.onload = function () {
    //        gtag("js", new Date())
    //        gtag("config", i)
    //     }
    //     d.head.appendChild(j)
    // })(window, document, "script", "dataLayer", "G-XNX7ZDX7QY")`,
    // },
    // 第三方客服工具
    // {
    //   children: `!function(){const c=document.createElement("script");c.src="https://plugin-code.salesmartly.com/js/project_270819_277882_1741848946.js",c.async=!0,c.onload=function(){window.__ssc.setting={hideIcon:!1}},document.head.appendChild(c)}();`,
    // },
    // JSON-LD
    {
      type: 'application/ld+json',
      children: JSON.stringify({
        datePublished: '2024-12-01T00:00:00.000Z',
        dateModified: new Date().toISOString(),
      }),
    },
  ],
  noscript: [
    // Google Tag Manager (noscript)
    {
      children: '<iframe src="https://www.googletagmanager.com/gtag/js?id=G-XNX7ZDX7QY" height="0" width="0" style="display:none;visibility:hidden"></iframe>', // 替换为您的 GTM ID
      tagPosition: 'bodyOpen',
    },
  ],
})
</script>

<template>
  <NuxtLayout>
    <NuxtPage />
    <LoginModal />
  </NuxtLayout>
</template>

<style lang="less">
.page-enter-active,
.page-leave-active {
  transition: opacity .5s;
}
.page-enter-from,
.page-leave-to {
  opacity: 0;
}
html,
body,
#__nuxt {
  height: 100vh;
  margin: 0;
  padding: 0;
  background: #fff;
  color: var(--primary-color);
  font-size: var(--font-size-base);
  font-family: 'CommonFont';
}
</style>