mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-28 17:50:56 +01:00
added baidu tongji for analytics
This commit is contained in:
@@ -10,8 +10,45 @@ import DialogView from './components/Common/DialogView'
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
data () {
|
||||
return {
|
||||
msgPopup: undefined
|
||||
}
|
||||
},
|
||||
components: {
|
||||
DialogView
|
||||
},
|
||||
computed: {
|
||||
useStats () {
|
||||
return localStorage.getItem('useStats')
|
||||
}
|
||||
},
|
||||
methods: {},
|
||||
mounted () {
|
||||
window.setUseStats = (value) => {
|
||||
localStorage.setItem('useStats', value)
|
||||
document.querySelector('.el-message__closeBtn').click()
|
||||
if (value === 1) {
|
||||
_hmt.push(['_trackPageview', '/allow_stats'])
|
||||
} else {
|
||||
_hmt.push(['_trackPageview', '/disallow_stats'])
|
||||
}
|
||||
}
|
||||
|
||||
// first-time user
|
||||
if (this.useStats === undefined || this.useStats === null) {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
dangerouslyUseHTMLString: true,
|
||||
showClose: true,
|
||||
duration: 0,
|
||||
message: this.$t('<p>Do you allow us to collect some statistics to improve Crawlab?</p>' +
|
||||
'<div style="text-align: center;margin-top: 10px;">' +
|
||||
'<button class="message-btn" onclick="setUseStats(1)">' + this.$t('Yes') + '</button>' +
|
||||
'<button class="message-btn" onclick="setUseStats(0)">' + this.$t('No') + '</button>' +
|
||||
'</div>')
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -52,4 +89,31 @@ export default {
|
||||
.el-form .el-form-item {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.message-btn {
|
||||
margin: 0 5px;
|
||||
padding: 5px 10px;
|
||||
background: transparent;
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.message-btn:hover {
|
||||
opacity: 0.8;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.message-btn.success {
|
||||
background: #67c23a;
|
||||
border-color: #67c23a;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.message-btn.danger {
|
||||
background: #f56c6c;
|
||||
border-color: #f56c6c;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -12,6 +12,8 @@ import 'font-awesome/scss/font-awesome.scss'// FontAwesome
|
||||
|
||||
import 'codemirror/lib/codemirror.css'
|
||||
|
||||
// import ba from 'vue-ba'
|
||||
|
||||
import App from './App'
|
||||
import store from './store'
|
||||
import router from './router'
|
||||
@@ -24,8 +26,23 @@ import i18n from './i18n'
|
||||
|
||||
Vue.use(ElementUI, { locale })
|
||||
|
||||
// Vue.use(ba, 'c35e3a563a06caee2524902c81975add')
|
||||
// Vue.use(ba, {
|
||||
// siteId: 'c35e3a563a06caee2524902c81975add'
|
||||
// })
|
||||
|
||||
Vue.config.productionTip = false
|
||||
|
||||
// 百度统计
|
||||
window._hmt = window._hmt || [];
|
||||
(function () {
|
||||
let hm = document.createElement('script')
|
||||
hm.src = 'https://hm.baidu.com/hm.js?c35e3a563a06caee2524902c81975add'
|
||||
let s = document.getElementsByTagName('script')[0]
|
||||
s.parentNode.insertBefore(hm, s)
|
||||
})()
|
||||
|
||||
// inject request api
|
||||
Vue.prototype.$request = request
|
||||
|
||||
const app = new Vue({
|
||||
|
||||
@@ -222,4 +222,12 @@ router.beforeEach((to, from, next) => {
|
||||
next()
|
||||
})
|
||||
|
||||
router.afterEach((to, from, next) => {
|
||||
if (to.path) {
|
||||
if (localStorage.getItem('useStats') !== '0') {
|
||||
window._hmt.push(['_trackPageview', to.path])
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export default router
|
||||
|
||||
@@ -12,6 +12,7 @@ import file from './modules/file'
|
||||
import schedule from './modules/schedule'
|
||||
import lang from './modules/lang'
|
||||
import site from './modules/site'
|
||||
import stats from './modules/stats'
|
||||
import getters from './getters'
|
||||
|
||||
Vue.use(Vuex)
|
||||
@@ -29,7 +30,9 @@ const store = new Vuex.Store({
|
||||
file,
|
||||
schedule,
|
||||
lang,
|
||||
site
|
||||
site,
|
||||
// 百度统计
|
||||
stats
|
||||
},
|
||||
getters
|
||||
})
|
||||
|
||||
14
frontend/src/store/modules/stats.js
Normal file
14
frontend/src/store/modules/stats.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const state = {}
|
||||
const getters = {
|
||||
useStats () {
|
||||
return localStorage.getItem('useStats')
|
||||
}
|
||||
}
|
||||
const mutations = {}
|
||||
const actions = {}
|
||||
export default {
|
||||
state,
|
||||
getters,
|
||||
mutations,
|
||||
actions
|
||||
}
|
||||
@@ -85,6 +85,9 @@ export default {
|
||||
this.dailyTasks = response.data.daily_tasks
|
||||
this.initEchartsDailyTasks()
|
||||
})
|
||||
},
|
||||
mounted () {
|
||||
// this.$ba.trackPageview('/')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
<div class="tags-view-container">
|
||||
<scroll-pane ref="scrollPane" class="tags-view-wrapper">
|
||||
<router-link
|
||||
v-for="tag in visitedViews"
|
||||
ref="tag"
|
||||
:class="isActive(tag)?'active':''"
|
||||
:to="{ path: tag.path, query: tag.query, fullPath: tag.fullPath }"
|
||||
:key="tag.path"
|
||||
tag="span"
|
||||
class="tags-view-item"
|
||||
@click.middle.native="closeSelectedTag(tag)"
|
||||
@contextmenu.prevent.native="openMenu(tag,$event)">
|
||||
v-for="tag in visitedViews"
|
||||
ref="tag"
|
||||
:class="isActive(tag)?'active':''"
|
||||
:to="{ path: tag.path, query: tag.query, fullPath: tag.fullPath }"
|
||||
:key="tag.path"
|
||||
tag="span"
|
||||
class="tags-view-item"
|
||||
@click.middle.native="closeSelectedTag(tag)"
|
||||
@contextmenu.prevent.native="openMenu(tag,$event)">
|
||||
{{ $t(generateTitle(tag.title)) }}
|
||||
<span v-if="!tag.meta.affix" class="el-icon-close" @click.prevent.stop="closeSelectedTag(tag)"/>
|
||||
</router-link>
|
||||
@@ -47,7 +47,7 @@ export default {
|
||||
return this.$store.state.tagsView.visitedViews
|
||||
},
|
||||
routers () {
|
||||
return this.$store.state.permission.routers
|
||||
return this.$store.state.permission ? this.$store.state.permission.routers : []
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
Reference in New Issue
Block a user