feat : 测试sso单点登录之后的重定向路径4
This commit is contained in:
@@ -9,211 +9,216 @@ import {useAuthStore} from '@/stores/userstore.js'
|
||||
NProgress.configure({showSpinner: false})
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
routes: [
|
||||
{
|
||||
path: '/login',
|
||||
name: 'login',
|
||||
component: () => import('@/views/login/index.vue'),
|
||||
meta: {
|
||||
hidden: true,
|
||||
title: '登录'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/cas/login',
|
||||
name: 'casLogin',
|
||||
component: () => import('@/views/cas-login/index.vue'),
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
name: 'layout',
|
||||
component: Layout,
|
||||
redirect: '/home',
|
||||
meta: {
|
||||
hidden: false
|
||||
},
|
||||
children: [
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
routes: [
|
||||
{
|
||||
path: '/home',
|
||||
name: 'home',
|
||||
component: () => import('@/views/home/index.vue'),
|
||||
meta: {
|
||||
title: '首页',
|
||||
breadcrumb: true
|
||||
}
|
||||
path: '/login',
|
||||
name: 'login',
|
||||
component: () => import('@/views/login/index.vue'),
|
||||
meta: {
|
||||
hidden: true,
|
||||
title: '登录'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/auth',
|
||||
name: 'auth',
|
||||
component: () => import('@/views/auth/index.vue'),
|
||||
meta: {
|
||||
title: '个人中心',
|
||||
breadcrumb: true
|
||||
}
|
||||
path: '/cas/login',
|
||||
name: 'casLogin',
|
||||
component: () => import('@/views/cas-login/index.vue'),
|
||||
},
|
||||
{
|
||||
path: '/rapid/gen/edit/:tableId(\\d+)',
|
||||
name: 'genEdit',
|
||||
component: () => import('@/views/rapid/gen/editTable.vue'),
|
||||
meta: {
|
||||
title: '数据库生成配置',
|
||||
breadcrumb: true
|
||||
}
|
||||
path: '/',
|
||||
name: 'layout',
|
||||
component: Layout,
|
||||
redirect: '/home',
|
||||
meta: {
|
||||
hidden: false
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '/home',
|
||||
name: 'home',
|
||||
component: () => import('@/views/home/index.vue'),
|
||||
meta: {
|
||||
title: '首页',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/auth',
|
||||
name: 'auth',
|
||||
component: () => import('@/views/auth/index.vue'),
|
||||
meta: {
|
||||
title: '个人中心',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/rapid/gen/edit/:tableId(\\d+)',
|
||||
name: 'genEdit',
|
||||
component: () => import('@/views/rapid/gen/editTable.vue'),
|
||||
meta: {
|
||||
title: '数据库生成配置',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/workflow/process/edit/:deploymentId',
|
||||
name: 'processEdit',
|
||||
component: () => import('@/views/workflow/process/ProcessEdit.vue'),
|
||||
meta: {
|
||||
title: '编辑流程',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/workflow/process',
|
||||
name: 'process',
|
||||
component: () => import('@/views/workflow/process/index.vue'),
|
||||
meta: {
|
||||
title: '流程管理',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/workflow/process/edit',
|
||||
name: 'processAdd',
|
||||
component: () => import('@/views/workflow/process/ProcessEdit.vue'),
|
||||
meta: {
|
||||
title: '新增流程',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/role-auth/user/:roleId(\\d+)/:roleName',
|
||||
name: 'distribute',
|
||||
component: () => import('@/views/system/role/DistributeUser.vue'),
|
||||
meta: {
|
||||
title: '角色分配用户',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/post-auth/user/:postId(\\d+)/:postName',
|
||||
name: 'assignUser',
|
||||
component: () => import('@/views/system/post/DistributeUser.vue'),
|
||||
meta: {
|
||||
title: '岗位分配用户',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/menu-auth/role/:menuId(\\d+)/:menuName',
|
||||
name: 'assignRole',
|
||||
component: () => import('@/views/system/menu/DistributeRole.vue'),
|
||||
meta: {
|
||||
title: '菜单分配角色',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/system/notice/inform/index/:queryId',
|
||||
name: 'notify',
|
||||
component: () => import('@/views/system/notice/inform/index.vue'),
|
||||
meta: {
|
||||
title: '通知公告',
|
||||
breadcrumb: false
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/custom/query/sql/design/:queryId',
|
||||
name: 'sql',
|
||||
component: () => import('@/views/custom-query/sql/SqlDesign.vue'),
|
||||
meta: {
|
||||
title: '自定义sql查询配置',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/custom/query/data/adapter/design/:queryId',
|
||||
name: 'dataAdapter',
|
||||
component: () => import('@/views/custom-query/data-adapter/DataAdapterDesign.vue'),
|
||||
meta: {
|
||||
title: '自定义数据适配器',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/custom/query/echarts/design/:queryId',
|
||||
name: 'echarts',
|
||||
component: () => import('@/views/custom-query/echarts-editor/EchartsDesign.vue'),
|
||||
meta: {
|
||||
title: '自定义echarts查询配置',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/rapid/data/:dsId(\\d+)',
|
||||
name: 'rapid',
|
||||
component: () => import('@/views/rapid/gen/index.vue'),
|
||||
meta: {
|
||||
title: '数据源关联数据',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/workflow/process/edit/:deploymentId',
|
||||
name: 'processEdit',
|
||||
component: () => import('@/views/workflow/process/ProcessEdit.vue'),
|
||||
meta: {
|
||||
title: '编辑流程',
|
||||
breadcrumb: true
|
||||
}
|
||||
path: '/topo/design/:queryId',
|
||||
name: 'topEdit',
|
||||
component: () => import('@/views/custom-query/topo/topologyDesign.vue'),
|
||||
meta: {
|
||||
title: 'top',
|
||||
breadcrumb: false
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/workflow/process',
|
||||
name: 'process',
|
||||
component: () => import('@/views/workflow/process/index.vue'),
|
||||
meta: {
|
||||
title: '流程管理',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/workflow/process/edit',
|
||||
name: 'processAdd',
|
||||
component: () => import('@/views/workflow/process/ProcessEdit.vue'),
|
||||
meta: {
|
||||
title: '新增流程',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/role-auth/user/:roleId(\\d+)/:roleName',
|
||||
name: 'distribute',
|
||||
component: () => import('@/views/system/role/DistributeUser.vue'),
|
||||
meta: {
|
||||
title: '角色分配用户',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/post-auth/user/:postId(\\d+)/:postName',
|
||||
name: 'assignUser',
|
||||
component: () => import('@/views/system/post/DistributeUser.vue'),
|
||||
meta: {
|
||||
title: '岗位分配用户',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/menu-auth/role/:menuId(\\d+)/:menuName',
|
||||
name: 'assignRole',
|
||||
component: () => import('@/views/system/menu/DistributeRole.vue'),
|
||||
meta: {
|
||||
title: '菜单分配角色',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/system/notice/inform/index/:queryId',
|
||||
name: 'notify',
|
||||
component: () => import('@/views/system/notice/inform/index.vue'),
|
||||
meta: {
|
||||
title: '通知公告',
|
||||
breadcrumb: false
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/custom/query/sql/design/:queryId',
|
||||
name: 'sql',
|
||||
component: () => import('@/views/custom-query/sql/SqlDesign.vue'),
|
||||
meta: {
|
||||
title: '自定义sql查询配置',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/custom/query/data/adapter/design/:queryId',
|
||||
name: 'dataAdapter',
|
||||
component: () => import('@/views/custom-query/data-adapter/DataAdapterDesign.vue'),
|
||||
meta: {
|
||||
title: '自定义数据适配器',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/custom/query/echarts/design/:queryId',
|
||||
name: 'echarts',
|
||||
component: () => import('@/views/custom-query/echarts-editor/EchartsDesign.vue'),
|
||||
meta: {
|
||||
title: '自定义echarts查询配置',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/rapid/data/:dsId(\\d+)',
|
||||
name: 'rapid',
|
||||
component: () => import('@/views/rapid/gen/index.vue'),
|
||||
meta: {
|
||||
title: '数据源关联数据',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/topo/design/:queryId',
|
||||
name: 'topEdit',
|
||||
component: () => import('@/views/custom-query/topo/topologyDesign.vue'),
|
||||
meta: {
|
||||
title: 'top',
|
||||
breadcrumb: false
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/forbidden',
|
||||
name: 'forbidden',
|
||||
component: () => import('@/views/forbidden/index.vue'),
|
||||
}
|
||||
]
|
||||
path: '/forbidden',
|
||||
name: 'forbidden',
|
||||
component: () => import('@/views/forbidden/index.vue'),
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
router.beforeEach(async (to, form, next) => {
|
||||
const permisstionStore = usePermisstionStroe()
|
||||
const authStore = useAuthStore()
|
||||
NProgress.start()
|
||||
if (!getToken()) {
|
||||
if (to.path === '/login' || to.path === '/cas/login' || to.path === '/forbidden') {
|
||||
next()
|
||||
NProgress.done()
|
||||
const permisstionStore = usePermisstionStroe()
|
||||
const authStore = useAuthStore()
|
||||
NProgress.start()
|
||||
if (!getToken()) {
|
||||
if (to.path === '/login' || to.path === '/cas/login' || to.path === '/forbidden') {
|
||||
next()
|
||||
NProgress.done()
|
||||
} else {
|
||||
let path = window.location.pathname;
|
||||
let query = window.location.search
|
||||
sessionStorage.setItem('toView', JSON.stringify({
|
||||
path: path,
|
||||
query: query
|
||||
}))
|
||||
window.location.href = `${window.location.origin}/api/auth/cas/login`
|
||||
// next({path: '/api/auth/cas/login'})
|
||||
}
|
||||
} else {
|
||||
sessionStorage.setItem('toView', JSON.stringify(to))
|
||||
window.location.href = `${window.location.origin}/api/auth/cas/login`
|
||||
// next({path: '/api/auth/cas/login'})
|
||||
}
|
||||
} else {
|
||||
if (to.path === '/login'|| to.path === '/cas/login') {
|
||||
next('/')
|
||||
NProgress.done()
|
||||
} else {
|
||||
permisstionStore.setIsLoadRoutes(true)
|
||||
if (permisstionStore.isLoadRoutes && permisstionStore.asyncRouters.length == 0) {
|
||||
await permisstionStore.setAsyncRouters()
|
||||
await authStore.setUserInfo()
|
||||
next({...to, replace: true})
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
}
|
||||
if (to.path === '/login' || to.path === '/cas/login') {
|
||||
next('/')
|
||||
NProgress.done()
|
||||
} else {
|
||||
permisstionStore.setIsLoadRoutes(true)
|
||||
if (permisstionStore.isLoadRoutes && permisstionStore.asyncRouters.length == 0) {
|
||||
await permisstionStore.setAsyncRouters()
|
||||
await authStore.setUserInfo()
|
||||
next({...to, replace: true})
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
router.afterEach(() => {
|
||||
NProgress.done()
|
||||
NProgress.done()
|
||||
})
|
||||
|
||||
export default router
|
||||
|
||||
Reference in New Issue
Block a user