Feat(页面):监听页面打开次数和页面停留时长逻辑初步实现
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import Vue from 'vue'
|
||||
|
||||
// 日期格式化
|
||||
export function formatterDate(date, flag = '-', mode = 'date') {
|
||||
const year = new Date(date).getFullYear()
|
||||
@@ -22,3 +24,36 @@ export function formatContent(html) {
|
||||
contentData = contentData.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;margin:0 auto;"')
|
||||
return contentData
|
||||
}
|
||||
|
||||
/**
|
||||
* desc: 监听页面访问次数
|
||||
* auth: lifizer
|
||||
* date: 2024-05-16
|
||||
* @param key-页面唯一标识
|
||||
* @param cb-回调函数
|
||||
* @returns {null}
|
||||
*/
|
||||
export function pageToWatchShowCount(key, cb = '') {
|
||||
if (Vue.prototype.$pageToWatchData[key]) {
|
||||
Vue.prototype.$pageToWatchData[key].count++
|
||||
} else {
|
||||
Vue.prototype.$pageToWatchData[key] = {
|
||||
count: 1,
|
||||
timer: 0
|
||||
}
|
||||
}
|
||||
cb && cb()
|
||||
}
|
||||
|
||||
/**
|
||||
* desc: 监听页面访问时长
|
||||
* auth: lifizer
|
||||
* date: 2024-05-16
|
||||
* @param key-页面唯一标识
|
||||
* @returns {null}
|
||||
*/
|
||||
export function pageToWatchShowTimer(key) {
|
||||
if (Vue.prototype.$pageToWatchData[key]) {
|
||||
Vue.prototype.$pageToWatchData[key].timer++
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user