export default ({ app }) => {
  // 在客户端（浏览器）中执行
  if (process.client) {
    // 只在生产环境加载 Google Analytics 脚本
    const script = document.createElement('script');
    script.async = true;
    script.src = 'https://www.googletagmanager.com/gtag/js?id=G-7NHZ6CX5DC';
    document.head.appendChild(script);

    window.dataLayer = window.dataLayer || [];
    function gtag() {
      window.dataLayer.push(arguments);
    }
    gtag('js', new Date());
    gtag('config', 'G-7NHZ6CX5DC');
  }
};
