添加数据埋点,盘点接口添加设备类型字段

This commit is contained in:
hejin 2025-08-08 00:00:06 +08:00
parent 52e80be212
commit 49c72167ae
5 changed files with 26 additions and 3 deletions

View File

@ -0,0 +1,17 @@
export default async function ({
$axios,
store,
req
}) {
let userAgent = process.server ? req.headers['user-agent'] : navigator.userAgent
let url = process.server ? req.headers['referer'] : window.location.href
const isMobile = (userAgent) => {
return /Mobile|Android|iPhone|iPad|iPod|Opera Mini|IEMobile|BlackBerry|webOS/i.test(userAgent);
}
store.commit('SET_DEVICE', isMobile(userAgent))
let data = {
url: url,
equipment: store.state.device,
}
$axios.post('/web/pageSave',data)
}

View File

@ -156,7 +156,7 @@ export default {
]
},
router: {
middleware: ['i18n', 'footer', 'header']
middleware: ['i18n', 'footer', 'header', 'burying-point']
},
/*
** Build configuration

View File

@ -185,7 +185,8 @@ export default {
company: '',
email: '',
tel: '',
content: ''
content: '',
equipment: this.$store.state.device
}
}
},

View File

@ -228,7 +228,8 @@ export default {
company: '',
email: '',
tel: '',
content: ''
content: '',
equipment: this.$store.state.device
},
swiperOptions: {
slidesPerView :'auto',

View File

@ -11,6 +11,7 @@ export const state = () => ({
menuTree: [],
footerInfo: {},
footerPordCategory: [],
device: ''
})
export const mutations = {
@ -44,6 +45,9 @@ export const mutations = {
}
fn(tree)
state.menuTree = [...state.menuTree, ...tree]
},
SET_DEVICE (state, isMob) {
state.device = isMob ? '手机端' : '电脑端'
}
}