test : 测试cas登录

This commit is contained in:
2024-03-05 20:48:52 +08:00
parent 8a7594b675
commit 768b467e6d
4 changed files with 83 additions and 43 deletions

View File

@@ -1,11 +1,12 @@
import { createRouter, createWebHistory } from 'vue-router'
import {createRouter, createWebHistory} from 'vue-router'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import Layout from '@/layout/index.vue'
import { getToken } from '../utils/auth'
import { usePermisstionStroe } from '@/stores/permisstion.js'
import { useAuthStore } from '@/stores/userstore.js'
NProgress.configure({ showSpinner: false })
import {getToken} from '../utils/auth'
import {usePermisstionStroe} from '@/stores/permisstion.js'
import {useAuthStore} from '@/stores/userstore.js'
NProgress.configure({showSpinner: false})
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
@@ -13,12 +14,17 @@ const router = createRouter({
{
path: '/login',
name: 'login',
component: ()=>import('@/views/login/index.vue'),
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',
@@ -31,7 +37,7 @@ const router = createRouter({
{
path: '/home',
name: 'home',
component: ()=>import('@/views/home/index.vue'),
component: () => import('@/views/home/index.vue'),
meta: {
title: '首页',
breadcrumb: true
@@ -40,7 +46,7 @@ const router = createRouter({
{
path: '/auth',
name: 'auth',
component: ()=>import('@/views/auth/index.vue'),
component: () => import('@/views/auth/index.vue'),
meta: {
title: '个人中心',
breadcrumb: true
@@ -49,7 +55,7 @@ const router = createRouter({
{
path: '/rapid/gen/edit/:tableId(\\d+)',
name: 'genEdit',
component: ()=>import('@/views/rapid/gen/editTable.vue'),
component: () => import('@/views/rapid/gen/editTable.vue'),
meta: {
title: '数据库生成配置',
breadcrumb: true
@@ -58,7 +64,7 @@ const router = createRouter({
{
path: '/workflow/process/edit/:deploymentId',
name: 'processEdit',
component: ()=>import('@/views/workflow/process/ProcessEdit.vue'),
component: () => import('@/views/workflow/process/ProcessEdit.vue'),
meta: {
title: '编辑流程',
breadcrumb: true
@@ -69,14 +75,14 @@ const router = createRouter({
name: 'processAdd',
component: () => import('@/views/workflow/process/ProcessEdit.vue'),
meta: {
title: '新增流程',
breadcrumb: true
title: '新增流程',
breadcrumb: true
}
},
{
path: '/role-auth/user/:roleId(\\d+)/:roleName',
name: 'distribute',
component: ()=>import('@/views/system/role/DistributeUser.vue'),
component: () => import('@/views/system/role/DistributeUser.vue'),
meta: {
title: '角色分配用户',
breadcrumb: true
@@ -85,7 +91,7 @@ const router = createRouter({
{
path: '/post-auth/user/:postId(\\d+)/:postName',
name: 'assignUser',
component: ()=>import('@/views/system/post/DistributeUser.vue'),
component: () => import('@/views/system/post/DistributeUser.vue'),
meta: {
title: '岗位分配用户',
breadcrumb: true
@@ -94,7 +100,7 @@ const router = createRouter({
{
path: '/menu-auth/role/:menuId(\\d+)/:menuName',
name: 'assignRole',
component: ()=>import('@/views/system/menu/DistributeRole.vue'),
component: () => import('@/views/system/menu/DistributeRole.vue'),
meta: {
title: '菜单分配角色',
breadcrumb: true
@@ -103,7 +109,7 @@ const router = createRouter({
{
path: '/system/notice/inform/index/:queryId',
name: 'notify',
component: ()=>import('@/views/system/notice/inform/index.vue'),
component: () => import('@/views/system/notice/inform/index.vue'),
meta: {
title: '通知公告',
breadcrumb: false
@@ -112,7 +118,7 @@ const router = createRouter({
{
path: '/custom/query/sql/design/:queryId',
name: 'sql',
component: ()=>import('@/views/custom-query/sql/SqlDesign.vue'),
component: () => import('@/views/custom-query/sql/SqlDesign.vue'),
meta: {
title: '自定义sql查询配置',
breadcrumb: true
@@ -121,7 +127,7 @@ const router = createRouter({
{
path: '/custom/query/data/adapter/design/:queryId',
name: 'dataAdapter',
component: ()=>import('@/views/custom-query/data-adapter/DataAdapterDesign.vue'),
component: () => import('@/views/custom-query/data-adapter/DataAdapterDesign.vue'),
meta: {
title: '自定义数据适配器',
breadcrumb: true
@@ -130,7 +136,7 @@ const router = createRouter({
{
path: '/custom/query/echarts/design/:queryId',
name: 'echarts',
component: ()=>import('@/views/custom-query/echarts-editor/EchartsDesign.vue'),
component: () => import('@/views/custom-query/echarts-editor/EchartsDesign.vue'),
meta: {
title: '自定义echarts查询配置',
breadcrumb: true
@@ -139,7 +145,7 @@ const router = createRouter({
{
path: '/rapid/data/:dsId(\\d+)',
name: 'rapid',
component: ()=>import('@/views/rapid/gen/index.vue'),
component: () => import('@/views/rapid/gen/index.vue'),
meta: {
title: '数据源关联数据',
breadcrumb: true
@@ -150,7 +156,7 @@ const router = createRouter({
{
path: '/topo/design/:queryId',
name: 'topEdit',
component: ()=>import('@/views/custom-query/topo/topologyDesign.vue'),
component: () => import('@/views/custom-query/topo/topologyDesign.vue'),
meta: {
title: 'top',
breadcrumb: false
@@ -159,29 +165,29 @@ const router = createRouter({
{
path: '/forbidden',
name: 'forbidden',
component: ()=>import('@/views/forbidden/index.vue'),
component: () => import('@/views/forbidden/index.vue'),
}
]
})
router.beforeEach(async (to,form,next)=>{
router.beforeEach(async (to, form, next) => {
const permisstionStore = usePermisstionStroe()
const authStore = useAuthStore()
NProgress.start()
if(!getToken()) {
if(to.path === '/login' || to.path === '/forbidden') {
if (!getToken()) {
if (to.path === '/login' || to.path === '/cas/login' || to.path === '/forbidden') {
next()
NProgress.done()
}else {
} else {
next({path: '/login'})
}
}else {
if(to.path === '/login') {
} else {
if (to.path === '/login'|| to.path === '/cas/login') {
next('/')
NProgress.done()
}else {
} else {
permisstionStore.setIsLoadRoutes(true)
if(permisstionStore.isLoadRoutes && permisstionStore.asyncRouters.length==0){
if (permisstionStore.isLoadRoutes && permisstionStore.asyncRouters.length == 0) {
await permisstionStore.setAsyncRouters()
await authStore.setUserInfo()
next({...to, replace: true})
@@ -195,7 +201,7 @@ router.beforeEach(async (to,form,next)=>{
})
router.afterEach(()=>{
router.afterEach(() => {
NProgress.done()
})