进入需要关联项目的页面拦截
This commit is contained in:
parent
09c37a069b
commit
2a9933b1ba
@ -5,10 +5,12 @@ import NProgress from 'nprogress'
|
||||
import 'nprogress/nprogress.css'
|
||||
import { getToken } from '@/utils/auth'
|
||||
import { isRelogin } from '@/utils/request'
|
||||
import { getApplicationId } from './utils/application'
|
||||
|
||||
NProgress.configure({ showSpinner: false })
|
||||
|
||||
const whiteList = ['/login', '/register']
|
||||
const needApplicationList = ['/build/installationList', '/build/whiteListManagement', '/build/publish']
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
NProgress.start()
|
||||
@ -25,7 +27,9 @@ router.beforeEach((to, from, next) => {
|
||||
store.dispatch('GetInfo').then(() => {
|
||||
isRelogin.show = false
|
||||
if (to.path === '/index') {
|
||||
next()
|
||||
next();
|
||||
} else if (checkApplication(to.path)) {
|
||||
next({ path: '/' })
|
||||
} else {
|
||||
store.dispatch('GenerateRoutes').then(accessRoutes => {
|
||||
// 根据roles权限生成可访问的路由表
|
||||
@ -40,7 +44,12 @@ router.beforeEach((to, from, next) => {
|
||||
})
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
if (checkApplication(to.path)) {
|
||||
next({ path: '/' })
|
||||
NProgress.done()
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -55,6 +64,10 @@ router.beforeEach((to, from, next) => {
|
||||
}
|
||||
})
|
||||
|
||||
function checkApplication(path) {
|
||||
return needApplicationList.includes(path) && !getApplicationId();
|
||||
}
|
||||
|
||||
router.afterEach(() => {
|
||||
NProgress.done()
|
||||
})
|
||||
|
@ -31,7 +31,7 @@ const user = {
|
||||
},
|
||||
SET_APPLICATION: (state, applicationInfo) => {
|
||||
const { id } = applicationInfo;
|
||||
state.applicationId = id;
|
||||
state.applicationId = id || '';
|
||||
state.applicationInfo = applicationInfo;
|
||||
},
|
||||
},
|
||||
@ -106,7 +106,12 @@ const user = {
|
||||
// 设置选中的项目应用信息
|
||||
SetApplication({ commit }, applicationInfo) {
|
||||
commit('SET_APPLICATION', applicationInfo)
|
||||
setApplicationId(applicationInfo?.id);
|
||||
const { id } = applicationInfo || {};
|
||||
if (id) {
|
||||
setApplicationId(applicationInfo.id);
|
||||
} else {
|
||||
removeApplicationId();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user