diff --git a/nuxt.config.js b/nuxt.config.js index 6d0b7c0..d9167b2 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -59,7 +59,8 @@ export default { {src: '~/plugins/element-ui'}, {src: '~/plugins/vditor', ssr: false}, {src: '~/plugins/vue-sse'}, - {src: '~/plugins/vue-cropper', ssr: false} + {src: '~/plugins/vue-cropper', ssr: false}, + {src: '~/plugins/goatcounter.js', ssr: false} ], /* ** Nuxt.js dev-modules diff --git a/plugins/goatcounter.js b/plugins/goatcounter.js new file mode 100644 index 0000000..ab8d1cc --- /dev/null +++ b/plugins/goatcounter.js @@ -0,0 +1,15 @@ +// plugins/goatcounter.js + +export default ({ app }) => { + // 检查 window 是否已经定义,因为插件在服务端渲染时也会执行 + if (process.client) { + // 创建 script 标签 + let script = document.createElement('script'); + script.async = true; + script.dataset.goatcounter = "https://statis.atduck.com/count"; + script.src = "//statis.atduck.com/count.js"; + + // 将 script 标签插入到页面中 + document.head.appendChild(script); + } +};