You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.7 KiB

/*
* @Descripttion:
* @version:
* @Author: Wiley.Yang
* @Date: 2022-02-11 17:24:07
* @LastEditors: Wiley.Yang
* @LastEditTime: 2022-02-16 15:50:20
*/
import store from './store'
import router from './router'
// import store from './store'
import { Message } from 'element-ui'
import NProgress from 'nprogress' // progress bar
import 'nprogress/nprogress.css' // progress bar style
import getPageTitle from '@/utils/get-page-title'
// import { error } from 'jquery'
// import { asyncRoutes, constantRoutes } from '@/router'
NProgress.configure({ showSpinner: false }) // NProgress Configuration
// const whiteList = ['/Screen'] // no redirect whitelist
router.beforeEach(async(to, from, next) => {
// start progress bar
NProgress.start()
// set page title
document.title = getPageTitle(to.meta.title)
// if (whiteList.indexOf(to.path) !== -1) {
// // in the free login whitelist, go directly
// next();
// } else {
// // other pages that do not have permission to access are redirected to the login page.
// next(`/Screen`);
// NProgress.done();
// }
// 获取大屏所用到的接口
if (JSON.stringify(store.state.dict.dictObject) === '{}') {
// store
// .dispatch('getDictType')
// .then((res) => {
next()
// })
.catch((error) => {
Message.error(error)
})
} else {
next()
}
NProgress.done()
})
router.afterEach(() => {
// finish progress bar
NProgress.done()
})
// function insetLog(to) {
// console.log(to)
// const parame = {
// pageName: to.name,
// pagePath: to.path,
// params: JSON.stringify(to.params)
// }
// insertLog(parame).then(res => {})
// }