diff --git a/middleware/burying-point.js b/middleware/burying-point.js index 8ef0041..0253cee 100644 --- a/middleware/burying-point.js +++ b/middleware/burying-point.js @@ -1,21 +1,10 @@ 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, - equipment: store.state.device, - } - if (url && url !== '') { - console.log("url", url) - $axios.post('/web/pageSave',data) - } } \ No newline at end of file diff --git a/plugins/router.js b/plugins/router.js index 13ccc29..4203e7c 100644 --- a/plugins/router.js +++ b/plugins/router.js @@ -1,6 +1,17 @@ -export default ({ app,$cookies,$config, store }) => { +export default ({ app,$cookies,$config, store, $axios }) => { app.router.beforeEach((to, from, next) => { app.i18n.locale = store.state.locale next() }) + app.router.afterEach((to, from) => { + if (process.client) { + let data = { + url: window.location.href, + equipment: store.state.device, + } + if (data.url && data.url !== '') { + $axios.post('/web/pageSave',data) + } + } + }) }