Blame view
src/router/index.js
1.44 KB
93a68cfa1
|
1 2 3 4 5 |
import Vue from 'vue'; import Router from 'vue-router'; import paths from './paths'; import NProgress from 'nprogress'; import 'nprogress/nprogress.css'; |
612b79bb4
|
6 |
import store from '@/store/store' |
93a68cfa1
|
7 8 |
Vue.use(Router); |
0672ac8e0
|
9 |
const router = new Router({ |
93a68cfa1
|
10 11 12 |
base: '/', mode: 'history', linkActiveClass: 'active', |
0672ac8e0
|
13 14 |
routes: paths, scrollBehavior() { |
612b79bb4
|
15 |
window.scrollTo(0, 0); |
0672ac8e0
|
16 |
} |
93a68cfa1
|
17 |
}); |
0672ac8e0
|
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
// const scrollableElementId = 'content' // You should change this // const scrollPositions = Object.create(null) // router.beforeEach((to, from, next) => { // let element = document.getElementById(scrollableElementId) // if (element !== null) { // scrollPositions[from.name] = element.scrollTop // } // next() // }) // window.addEventListener('popstate', () => { // let currentRouteName = router.history.current.name // let element = document.getElementById(scrollableElementId) // if (element !== null && currentRouteName in scrollPositions) { // setTimeout(() => element.scrollTop = scrollPositions[currentRouteName], 50) // } // }) |
93a68cfa1
|
39 |
// router gards |
612b79bb4
|
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
// router.beforeEach((to, from, next) => { // NProgress.start(); // next(); // }); // router.beforeEach((to, from, next) => { // var token = store.getters.GET_TOKEN; // if (!token) { // console.log("yes yes yes") // window.getApp.$emit("APP_LOGOUT"); // } else { // NProgress.start(); // next(); // } // }); |
93a68cfa1
|
55 56 57 58 59 |
router.afterEach((to, from) => { // ... NProgress.done(); }); |
612b79bb4
|
60 |
export default router; |