permission.js
768 Bytes
import router from './router'
import store from './store'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
import getPageTitle from '@/utils/get-page-title'
import Cookies from 'js-cookie'
NProgress.configure({ showSpinner: false }) // NProgress Configuration
router.beforeEach(async (to, from, next) => {
NProgress.start()
document.title = getPageTitle(to.meta.title)
let hasAddDict = store.state.dict.addDict
if (!hasAddDict) {
store.dispatch('dict/generateDic')
}
NProgress.done()
next()
})
router.afterEach(to => {
// 解决刷新页面报404问题
sessionStorage.setItem('routerTo', to.fullPath)
Cookies.set("routerTo", to.fullPath)
NProgress.done()
})