Skip to content

Commit 7b00083

Browse files
committed
update
1 parent 0c2bac4 commit 7b00083

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

nuxt.config.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,10 @@ export default {
4141
'@/plugins/element-ui',
4242
'@/plugins/api',
4343
'@/plugins/filters',
44-
{
45-
src: '~/plugins/swiper.js',
46-
ssr: false
47-
},
44+
{src: '~/plugins/swiper.js', ssr: false},
4845
'@/plugins/utils',
49-
{
50-
src: '~/plugins/cropper.js',
51-
ssr: false
52-
},
53-
"@/plugins/goatcounter"
46+
{src: '~/plugins/cropper.js', ssr: false},
47+
{src: "@/plugins/goatcounter", ssr: false}
5448
],
5549

5650
// Auto import components: https://go.nuxtjs.dev/config-components

plugins/goatcounter.js

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
export default ({ router }) => {
2-
if (typeof window !== 'undefined') {
3-
(function() {
4-
var goatcounter = document.createElement("script")
5-
goatcounter.setAttribute("data-goatcounter","http://cms.vispp.cn/analytics/count")
6-
goatcounter.setAttribute("async","true");
1+
export default ({app}) => {
2+
console.log('全局插件执行了')
3+
app.router.afterEach((to, from) => {
4+
if (typeof window !== 'undefined') {
5+
(function () {
6+
var goatcounter = document.createElement("script")
7+
goatcounter.setAttribute("data-goatcounter", "http://cms.vispp.cn/analytics/count")
8+
goatcounter.setAttribute("async", "true");
79
// goatcounter.setAttribute("src","//gc.zgo.at/count.js");
8-
goatcounter.setAttribute("src","http://cms.vispp.cn/analytics/count.js");
9-
var s = document.getElementsByTagName("script")[0]
10-
s.parentNode.insertBefore(goatcounter, s)
11-
})()
12-
}
10+
goatcounter.setAttribute("src", "http://cms.vispp.cn/analytics/count.js");
11+
var s = document.getElementsByTagName("script")[0]
12+
s.parentNode.insertBefore(goatcounter, s)
13+
})()
14+
}
15+
})
1316
}
17+

0 commit comments

Comments
 (0)