mirror of
http://112.124.100.131/GFRS/ebiz-h5.git
synced 2025-12-11 16:46:43 +08:00
提交
This commit is contained in:
40
src/assets/js/utils/permission.js
Normal file
40
src/assets/js/utils/permission.js
Normal 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()
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user