Merge pull request 'feat : 测试sso单点登录之后的重定向路径4' (#108) from master into prod

Reviewed-on: http://git.feashow.cn/clay/mosr-web/pulls/108
This commit is contained in:
clay
2024-04-29 03:50:07 +00:00
4 changed files with 246 additions and 225 deletions

View File

@@ -9,211 +9,216 @@ import {useAuthStore} from '@/stores/userstore.js'
NProgress.configure({showSpinner: false}) NProgress.configure({showSpinner: false})
const router = createRouter({ const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL), history: createWebHistory(import.meta.env.BASE_URL),
routes: [ 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: [
{ {
path: '/home', path: '/login',
name: 'home', name: 'login',
component: () => import('@/views/home/index.vue'), component: () => import('@/views/login/index.vue'),
meta: { meta: {
title: '首页', hidden: true,
breadcrumb: true title: '登录'
} }
}, },
{ {
path: '/auth', path: '/cas/login',
name: 'auth', name: 'casLogin',
component: () => import('@/views/auth/index.vue'), component: () => import('@/views/cas-login/index.vue'),
meta: {
title: '个人中心',
breadcrumb: true
}
}, },
{ {
path: '/rapid/gen/edit/:tableId(\\d+)', path: '/',
name: 'genEdit', name: 'layout',
component: () => import('@/views/rapid/gen/editTable.vue'), component: Layout,
meta: { redirect: '/home',
title: '数据库生成配置', meta: {
breadcrumb: true 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', path: '/topo/design/:queryId',
name: 'processEdit', name: 'topEdit',
component: () => import('@/views/workflow/process/ProcessEdit.vue'), component: () => import('@/views/custom-query/topo/topologyDesign.vue'),
meta: { meta: {
title: '编辑流程', title: 'top',
breadcrumb: true breadcrumb: false
} }
}, },
{ {
path: '/workflow/process', path: '/forbidden',
name: 'process', name: 'forbidden',
component: () => import('@/views/workflow/process/index.vue'), component: () => import('@/views/forbidden/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'),
}
]
}) })
router.beforeEach(async (to, form, next) => { router.beforeEach(async (to, form, next) => {
const permisstionStore = usePermisstionStroe() const permisstionStore = usePermisstionStroe()
const authStore = useAuthStore() const authStore = useAuthStore()
NProgress.start() NProgress.start()
if (!getToken()) { if (!getToken()) {
if (to.path === '/login' || to.path === '/cas/login' || to.path === '/forbidden') { if (to.path === '/login' || to.path === '/cas/login' || to.path === '/forbidden') {
next() next()
NProgress.done() 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 { } else {
sessionStorage.setItem('toView', JSON.stringify(to)) if (to.path === '/login' || to.path === '/cas/login') {
window.location.href = `${window.location.origin}/api/auth/cas/login` next('/')
// next({path: '/api/auth/cas/login'}) NProgress.done()
} } else {
} else { permisstionStore.setIsLoadRoutes(true)
if (to.path === '/login'|| to.path === '/cas/login') { if (permisstionStore.isLoadRoutes && permisstionStore.asyncRouters.length == 0) {
next('/') await permisstionStore.setAsyncRouters()
NProgress.done() await authStore.setUserInfo()
} else { next({...to, replace: true})
permisstionStore.setIsLoadRoutes(true) } else {
if (permisstionStore.isLoadRoutes && permisstionStore.asyncRouters.length == 0) { next()
await permisstionStore.setAsyncRouters() }
await authStore.setUserInfo() }
next({...to, replace: true})
} else {
next()
}
}
} }
}) })
router.afterEach(() => { router.afterEach(() => {
NProgress.done() NProgress.done()
}) })
export default router export default router

View File

@@ -29,7 +29,8 @@ serveice.interceptors.response.use(response => {
if (response.request.responseType === 'blob' || response.request.responseType === 'arraybuffer') { if (response.request.responseType === 'blob' || response.request.responseType === 'arraybuffer') {
return response.data return response.data
} }
console.log("windows", window.location.pathname) console.log("window.location.pathname", window.location.pathname)
console.log("windows", window.location.search)
return response.data return response.data
}, error => { }, error => {
let response = error.response let response = error.response
@@ -43,8 +44,13 @@ serveice.interceptors.response.use(response => {
closeOnClickModal: false closeOnClickModal: false
}).then(() => { }).then(() => {
removeToken() removeToken()
sessionStorage.setItem('toView', window.location.pathname) let path = window.location.pathname;
window.location = '/api/auth/cas/login' let query = window.location.search
sessionStorage.setItem('toView', JSON.stringify({
path: path,
query: query
}))
window.location.href = `${window.location.origin}/api/auth/cas/login`
}) })
return Promise.reject('会话已过期,请重新登录') return Promise.reject('会话已过期,请重新登录')
case 402: case 402:

View File

@@ -15,7 +15,14 @@ const init = () => {
}) })
if (authStore.casToken(tokenValue)) { if (authStore.casToken(tokenValue)) {
loading.close() loading.close()
router.push('/') const toView = sessionStorage.getItem('toView')
console.log(toView, 'toView');
if (toView) {
let parse = JSON.parse(toView);
window.location.href = window.location.origin + parse.path + parse.query
} else {
router.push('/')
}
} }
} }
init() init()

View File

@@ -12,28 +12,28 @@
<span>科研管理平台</span> <span>科研管理平台</span>
</div> </div>
</div> </div>
<!-- <el-row :gutter="10" type="flex">--> <!-- <el-row :gutter="10" type="flex">-->
<!-- <el-col :span="6" :xs="8" :sm="16" :md="18" :lg="20" :xl="24" >--> <!-- <el-col :span="6" :xs="8" :sm="16" :md="18" :lg="20" :xl="24" >-->
<!-- <div v-for="(item,index) in list" :key="index" class="block">--> <!-- <div v-for="(item,index) in list" :key="index" class="block">-->
<!-- <div>{{item.title}}</div>--> <!-- <div>{{item.title}}</div>-->
<!-- <div>--> <!-- <div>-->
<!-- <el-icon><User/></el-icon>--> <!-- <el-icon><User/></el-icon>-->
<!-- <span>{{item.num}}</span>--> <!-- <span>{{item.num}}</span>-->
<!-- </div>--> <!-- </div>-->
<!-- </div>--> <!-- </div>-->
<!-- </el-col>--> <!-- </el-col>-->
<!-- </el-row>--> <!-- </el-row>-->
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="6" v-for="item in 4">1</el-col> <el-col :span="6" v-for="item in 4">1</el-col>
<!-- <el-col :xs="4" :sm="6" :md="8" :lg="9" :xl="11"--> <!-- <el-col :xs="4" :sm="6" :md="8" :lg="9" :xl="11"-->
<!-- >2<div class="grid-content ep-bg-purple-light"--> <!-- >2<div class="grid-content ep-bg-purple-light"-->
<!-- /></el-col>--> <!-- /></el-col>-->
<!-- <el-col :xs="4" :sm="6" :md="8" :lg="9" :xl="11"--> <!-- <el-col :xs="4" :sm="6" :md="8" :lg="9" :xl="11"-->
<!-- >3<div class="grid-content ep-bg-purple"--> <!-- >3<div class="grid-content ep-bg-purple"-->
<!-- /></el-col>--> <!-- /></el-col>-->
<!-- <el-col :xs="8" :sm="6" :md="4" :lg="3" :xl="1"--> <!-- <el-col :xs="8" :sm="6" :md="4" :lg="3" :xl="1"-->
<!-- >4<div class="grid-content ep-bg-purple-light"--> <!-- >4<div class="grid-content ep-bg-purple-light"-->
<!-- /></el-col>--> <!-- /></el-col>-->
</el-row> </el-row>
<div class="container"> <div class="container">
<div id="bar1" ref="bar1"></div> <div id="bar1" ref="bar1"></div>
@@ -51,25 +51,25 @@
import * as echarts from 'echarts' import * as echarts from 'echarts'
import homeImage from "@/assets/home/home.png" import homeImage from "@/assets/home/home.png"
import coffee from "@/assets/home/coffee.png" import coffee from "@/assets/home/coffee.png"
import { useRouter } from 'vue-router'; import {useRouter} from 'vue-router';
const router = useRouter() const router = useRouter()
const list=ref([ const list = ref([
{ {
title: '在线用户量', title: '在线用户量',
num:2142 num: 2142
}, },
{ {
title: '在线用户量', title: '在线用户量',
num:2142 num: 2142
}, },
{ {
title: '在线用户量', title: '在线用户量',
num:2142 num: 2142
}, },
{ {
title: '在线用户量', title: '在线用户量',
num:2142 num: 2142
} }
]) ])
const barOption = { const barOption = {
@@ -178,14 +178,15 @@ const init = () => {
const redirectView = () => { const redirectView = () => {
const toView = sessionStorage.getItem('toView') const toView = sessionStorage.getItem('toView')
console.log(toView, 'toView'); console.log(toView, 'toView');
let jsonView = JSON.parse(toView)
toView ? toView ?
router.push({ router.push({
path: JSON.parse(toView).path, path: jsonView.path,
query: { query: {
...JSON.parse(toView).query ...jsonView.query
} }
}) : }) :
null null
} }
onMounted(() => { onMounted(() => {
@@ -242,12 +243,14 @@ window.addEventListener('resize', () => {
flex-direction: column; flex-direction: column;
} }
} }
.statistics{
.statistics {
//display: flex; //display: flex;
.block{ .block {
} }
} }
.container { .container {
height: calc((100vh / 2) - 150px); height: calc((100vh / 2) - 150px);
display: flex; display: flex;