This commit is contained in:
邓晓坤
2019-09-12 16:22:38 +08:00
parent 90ea054ae0
commit ff8a261f79
195 changed files with 65268 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
//权限控制
import router from '@/router'
// import NProgress from 'nprogress' // Progress 进度条
// import 'nprogress/nprogress.css' // Progress 进度条样式
export function permission() {
router.beforeEach((to, from, next) => {
// NProgress.start()
//修改title
const title = to.meta && to.meta.title
if (title) {
document.title = title
}
//判断是否登录
let token = localStorage.token
if (!token) {
localStorage.token = ''
//无token判断是否需要登录
if (to.meta.auth) {
if (window.WebViewJavascriptBridge) {
//eslint-disable-next-line
EWebBridge.webCallAppInJs('bridge', { flag: 'login' })
} else {
next(`/login?redirect=${to.path}`)
}
} else {
next()
}
} else {
if (to.path == '/login') {
next({ path: '/' })
} else {
next()
}
}
})
// 结束Progress
router.afterEach(() => {
// NProgress.done()
})
}