Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
router.beforeEach((to, from, next) => {
iView.LoadingBar.start()
iView.LoadingBar.config({ color: '#0e406d' })
// window.console.log('Transition', transition)
// router.app.$store.state.token
let obId = false
let location = psl.parse(window.location.hostname) // get parent domain
location = location.domain === null ? location.input : location.domain
if (to.query.ob_id) {
// let location = psl.parse(window.location.hostname) // get parent domain
// location = location.domain === null ? location.input : location.domain
// router.app.$cookie.set('auth_token', to.query.ob_id, { expires: 1, domain: location })
obId = to.query.ob_id
}
if (to.query.token) {
router.app.$cookie.set('auth_token', to.query.token, { expires: 1, domain: location })
}
const token = router.app.$cookie.get('auth_token')
store.state.token = token
router.beforeEach((to, from, next) => {
iView.LoadingBar.start();
// to.param;
let code = to.query.code
handleAuth(code, () => {
if(to.name === LOGIN_PAGE_NAME){
next({
name: homeName // 跳转到homeName页
})
}else{
next();
}
})
// if (!token && to.name !== LOGIN_PAGE_NAME) {
router.beforeEach((to, from, next) => {
iView.LoadingBar.start()
const token = getToken()
const loginRequired = to.name === HOME_PAGE || to.name.startsWith('admin') || to.name.startsWith('user')
if (!token && loginRequired) {
next({
name: LOGIN_PAGE_NAME, // 跳转到登录页
query: {
next: to.name
}
})
} else if (token && loginRequired) {
store.dispatch('getUserInfo').then(user => {
if (canTurnTo(to.name, user.role, routes)) {
next() // 有权限,可访问
} else next({ replace: true, name: 'error_401' }) // 无权限,重定向到401页面
})
} else if (!token && to.name === LOGIN_PAGE_NAME) {
.then((response) => {
if (response.data) {
resolve(response.data)
iView.LoadingBar.finish()
}
})
.catch((error) => {
router.afterEach((to) => {
Util.openNewPage(router.app, to.name, to.params, to.query);
iView.LoadingBar.finish();
window.scrollTo(0, 0);
});
router.beforeEach((to, from, next) => {
iView.LoadingBar.start();
next();
});
router.afterEach((to, from) => {
router.afterEach(to => {
iView.LoadingBar.finish()
window.scrollTo(0, 0)
})
router.beforeEach((to, from, next) => {
iView.LoadingBar.start();
Util.title(to.meta.title);
if (Cookies.get('locking') === '1' && to.name !== 'locking') {
next({
replace: true,
name: 'locking'
});
}else if (Cookies.get('locking') === '0' && to.name === 'locking') {
next(false);
} else {
if (!Util.abp.session.userId&& to.name !== 'login') {
next({
name: 'login'
});
} else if (!!Util.abp.session.userId && to.name === 'login') {
Util.title(to.meta.title);
next({
router.afterEach(to => {
setTitle(to, router.app)
iView.LoadingBar.finish()
window.scrollTo(0, 0)
})
done () {
this.count = 0
this.isLoading = false
iView.LoadingBar.finish()
},
checkLoading () {