Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.

Commit a209933

Browse files
author
chengpeiquan
committed
Release v1.0.0
1 parent 7b498b8 commit a209933

18 files changed

Lines changed: 743 additions & 0 deletions

.babelrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"modules": false,
7+
"targets": {
8+
"browsers": "> 1%, IE 11, not op_mini all, not dead"
9+
},
10+
"useBuiltIns": "usage",
11+
"corejs": 2
12+
}
13+
]
14+
],
15+
"plugins": [
16+
"@babel/plugin-proposal-class-properties"
17+
]
18+
}

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
indent_size = 2
8+
indent_style = space
9+
insert_final_newline = true
10+
max_line_length = 80
11+
trim_trailing_whitespace = true
12+
13+
[*.md]
14+
max_line_length = 0
15+
trim_trailing_whitespace = false

demo/index.html

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>vue cnzz analytics demo</title>
7+
<script src="https://unpkg.com/vue/dist/vue.js"></script>
8+
<script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
9+
<style>
10+
#app,
11+
.section {
12+
display: flex;
13+
flex-direction: column;
14+
justify-content: flex-start;
15+
align-items: center;
16+
}
17+
.section {
18+
margin-bottom: 40px;
19+
}
20+
.nav {
21+
margin-bottom: 20px;
22+
}
23+
.nav .item {
24+
color: #666;
25+
margin: 0 10px 20px;
26+
}
27+
.nav .cur {
28+
color: #000;
29+
font-weight: bold;
30+
}
31+
.label {
32+
display: flex;
33+
justify-content: center;
34+
align-items: center;
35+
margin-bottom: 20px;
36+
}
37+
.text {
38+
display: flex;
39+
justify-content: flex-end;
40+
align-items: center;
41+
width: 60px;
42+
font-size: 14px;
43+
margin-right: 20px;
44+
}
45+
.input {
46+
display: flex;
47+
align-items: center;
48+
width: 240px;
49+
height: 40px;
50+
font-size: 14px;
51+
box-sizing: border-box;
52+
padding: 0 10px;
53+
}
54+
.button {
55+
padding: 5px 20px;
56+
cursor: pointer;
57+
}
58+
</style>
59+
</head>
60+
<body>
61+
62+
<div id="app">
63+
<h1>Hello App!</h1>
64+
65+
<section class="section">
66+
<h2>切换路由自动上报测试</h2>
67+
<div class="nav">
68+
<router-link class="item" to="/page1" exact>Go to Page1</router-link>
69+
<router-link class="item" to="/page2">Go to Page2</router-link>
70+
<router-link class="item" to="/page3">Go to Page3</router-link>
71+
</div>
72+
<router-view></router-view>
73+
</section>
74+
75+
<section class="section">
76+
<h2>提交pv测试</h2>
77+
<label class="label">
78+
<span class="text">pageUrl</span>
79+
<input class="input" type="text" placeholder="输入页面的url" v-model="pageUrl">
80+
</label>
81+
<label class="label">
82+
<span class="text">fromUrl</span>
83+
<input class="input" type="text" placeholder="输入来路的url" v-model="fromUrl">
84+
</label>
85+
<button class="button" @click="pv">提交一个pv</button>
86+
</section>
87+
88+
<section class="section">
89+
<h2>提交event测试</h2>
90+
<label class="label">
91+
<span class="text">category</span>
92+
<input class="input" type="text" placeholder="输入产生该事件的位置名称" v-model="category">
93+
</label>
94+
<label class="label">
95+
<span class="text">action</span>
96+
<input class="input" type="text" placeholder="输入产生该事件的行为描述" v-model="action">
97+
</label>
98+
<label class="label">
99+
<span class="text">label</span>
100+
<input class="input" type="text" placeholder="输入产生该事件的标签名称" v-model="label">
101+
</label>
102+
<label class="label">
103+
<span class="text">value</span>
104+
<input class="input" type="text" placeholder="输入该事件的分值" v-model="value">
105+
</label>
106+
<label class="label">
107+
<span class="text">nodeId</span>
108+
<input class="input" type="text" placeholder="输入产生该事件的元素id" v-model="nodeId">
109+
</label>
110+
<button class="button" @click="event">提交一个event</button>
111+
</section>
112+
</div>
113+
114+
<script src="../dist/vue-cnzz-analytics.js"></script>
115+
<script src="js/main.js"></script>
116+
117+
</body>
118+
</html>

demo/js/main.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// 定义路由信息
2+
const routes = [
3+
{
4+
path: '/',
5+
redirect: '/page1'
6+
},
7+
{
8+
path: '/page1',
9+
component: {
10+
template: '<div class="view">当前是 <strong>Page1</strong> 的路由</div>'
11+
}
12+
},
13+
{
14+
path: '/page2',
15+
component: {
16+
template: '<div class="view">当前是 <strong>Page2</strong> 的路由</div>'
17+
}
18+
},
19+
{
20+
path: '/page3',
21+
component: {
22+
template: '<div class="view">当前是 <strong>Page3</strong> 的路由</div>'
23+
}
24+
}
25+
];
26+
27+
// 初始化路由
28+
const router = new VueRouter({
29+
routes,
30+
linkActiveClass: 'cur',
31+
linkExactActiveClass: 'cur'
32+
});
33+
34+
// 引入统计插件
35+
Vue.use(cnzzAnalytics, {
36+
router: router,
37+
siteIdList: [
38+
11111,
39+
22222,
40+
33333
41+
],
42+
isDebug: true
43+
});
44+
45+
// 初始化Vue
46+
const app = new Vue({
47+
el: '#app',
48+
router,
49+
data () {
50+
return {
51+
pageUrl: '',
52+
fromUrl: '',
53+
category: '',
54+
action: '',
55+
label: '',
56+
value: '',
57+
nodeId: ''
58+
}
59+
},
60+
mounted () {
61+
this.init();
62+
},
63+
methods: {
64+
init () {
65+
console.log(this.$pushCNZZ);
66+
},
67+
pv () {
68+
this.$pushCNZZ.pv(this.pageUrl, this.fromUrl);
69+
},
70+
event () {
71+
this.$pushCNZZ.event(this.category, this.action, this.label, this.value, this.nodeId);
72+
}
73+
}
74+
});

dist/main.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default function install(Vue: Vue, { router, siteIdList, isDebug }: Partial<Options>): boolean;

dist/modules/cnzz.d.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
declare class CNZZ {
2+
siteId: number;
3+
isDebug: boolean;
4+
constructor(siteId?: number, isDebug?: boolean);
5+
init(): void;
6+
setAccount(): void;
7+
trackPageview(pageUrl: string, fromUrl?: string): void;
8+
trackEvent(category: string, action: string, label: string, value: number, nodeId: string): boolean;
9+
}
10+
export default CNZZ;

dist/modules/pushCNZZ.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
declare class PushCNZZ {
2+
siteIdList: number[];
3+
isDebug: boolean;
4+
constructor(siteIdList: number[], isDebug: boolean);
5+
init(): void;
6+
pv(pageUrl: string, fromUrl?: string): void;
7+
event(category: string, action: string, label: string, value: number, nodeId: string): void;
8+
}
9+
export default PushCNZZ;

dist/vue-cnzz-analytics.js

Lines changed: 141 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)