|
@@ -13,13 +13,16 @@ NProgress.configure({
|
|
|
|
|
|
const whiteList = ["/login"]; // no redirect whitelist
|
|
|
|
|
|
+var analytics = false;
|
|
|
+var interval = {};
|
|
|
+
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
|
// start progress bar
|
|
|
NProgress.start();
|
|
|
- console.log(to);
|
|
|
- if (to.path) {
|
|
|
- window._hmt.push(['_trackPageview', '/#' + to.fullPath]);
|
|
|
- }
|
|
|
+ // console.log(to);
|
|
|
+ // if (to.path) {
|
|
|
+ // window._hmt.push(['_trackPageview', '/#' + to.fullPath]);
|
|
|
+ // }
|
|
|
// set page title
|
|
|
document.title = getPageTitle(to.meta.title);
|
|
|
|
|
@@ -76,10 +79,17 @@ router.beforeEach(async (to, from, next) => {
|
|
|
}
|
|
|
} else {
|
|
|
// get analytics
|
|
|
- await store.dispatch("user/setNums");
|
|
|
- setInterval(() => {
|
|
|
- store.dispatch("user/setNums");
|
|
|
- }, 30000)
|
|
|
+ if (!analytics) {
|
|
|
+ await store.dispatch("user/setNums");
|
|
|
+ if (interval) {
|
|
|
+ clearInterval(interval);
|
|
|
+ }
|
|
|
+ interval = setInterval(() => {
|
|
|
+ console.log(">>> analytics ...");
|
|
|
+ store.dispatch("user/setNums");
|
|
|
+ }, 30000);
|
|
|
+ analytics = true;
|
|
|
+ }
|
|
|
|
|
|
const hasGetUserInfo = store.getters.name;
|
|
|
if (hasGetUserInfo) {
|