feat: 登录默认页改为我的工作台
This commit is contained in:
@@ -3,7 +3,7 @@ import { hasRouteAccess } from '../permission'
|
||||
|
||||
const routes = [
|
||||
{ path: '/login', name: 'Login', component: () => import('@/views/Login.vue'), meta: { noAuth: true } },
|
||||
{ path: '/', component: () => import('@/layouts/MainLayout.vue'), redirect: '/dashboard',
|
||||
{ path: '/', component: () => import('@/layouts/MainLayout.vue'), redirect: '/my-dashboard',
|
||||
children: [
|
||||
{ path: 'dashboard', name: 'Dashboard', component: () => import('@/views/Dashboard.vue'), meta: { title: '经营看板', roles: ['ceo', 'finance', 'business', 'it'] } },
|
||||
{ path: 'kpis', name: 'KPIs', component: () => import('@/views/KPIList.vue'), meta: { title: 'KPI字典', roles: ['ceo', 'finance', 'business', 'it'] } },
|
||||
@@ -62,7 +62,7 @@ router.beforeEach((to, _from, next) => {
|
||||
// 不需要登录的页面(如登录页)
|
||||
if (to.meta.noAuth) {
|
||||
if (token && to.path === '/login') {
|
||||
next('/dashboard')
|
||||
next('/my-dashboard')
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
@@ -82,8 +82,8 @@ router.beforeEach((to, _from, next) => {
|
||||
const routeRoles = to.meta.roles as string[] | undefined
|
||||
|
||||
if (routeRoles && !routeRoles.includes(role)) {
|
||||
// 权限不足,跳转到经营看板或401页
|
||||
next('/dashboard')
|
||||
// 权限不足,跳转到我的工作台
|
||||
next('/my-dashboard')
|
||||
return
|
||||
}
|
||||
} catch {
|
||||
|
||||
@@ -62,7 +62,7 @@ async function handleLogin() {
|
||||
localStorage.setItem('cma_user', JSON.stringify(res.user))
|
||||
localStorage.setItem('cma_entity_id', String(res.entity_id ?? res.user?.entity_id ?? 1))
|
||||
localStorage.setItem('cma_entity_name', res.entity_short_name || res.entity_name || '')
|
||||
router.push('/dashboard')
|
||||
router.push('/my-dashboard')
|
||||
} catch (e: any) {
|
||||
ElMessage.error(e?.response?.data?.detail || '登录失败')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user