原创

若依管理系统根据不同角色展示不同首页

在router目录下,修改index.js文件中将默认路由组件

引入store

import store from '../store'

修改component的返回

{
    path: '',
    component: Layout,
    redirect: 'index',
    children: [
        {
            path: 'index',
            name: 'Index',
            meta: { title: '首页', icon: 'dashboard', affix: true },
            component: () => {
                const { roles } = store.getters;
                if (roles.includes('admin') || roles.includes('administrator')) {
                    return import('@/views/index');
                } else if (roles.includes('wy_manager') || roles.includes('scope_user_01')) {
                    return import('@/views/index_v1');
                }
            }
        }
    ]
}
正文到此结束