admin管理员组

文章数量:1633804

修改如下:

step1 :修改src\utils\authority.ts中的配置:

export function getAuthority(str?: string): string | string[] {
    const authorityString =
        typeof str === 'undefined' && localStorage ? localStorage.getItem('antd-pro-authority') : str;
    // authorityString could be admin, "admin", ["admin"]
    let authority;
    try {
        if (authorityString) {
            authority = JSON.parse(authorityString);
        }
    } catch (e) {
        authority = authorityString;
    }
    if (typeof authority === 'string') {
        return [authority];
    }
    // 注释以下代码即可
    // preview.pro.ant.design only do not use in your production.
    // preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
    // if (!authority && ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') {
    //     return ['admin'];
    // }
    return authority;

step2 :修改config\config.ts中的配置: 

 routes: [
        {
            path: '/',
            component: '../layouts/BlankLayout',
            routes: [
                {
                    path: '/',
                    component: '../layouts/UserLayout',
                    routes: [
                        // 新增重定向
                        {
                            path: '/',
                            redirect: '/user/login',
                        },
                        {
                            path: '/user/login',
                            name: 'login',
                            component: './User/login',
                        },
                        {
                            path: '/user',
                            redirect: '/user/login',
                        },
                        {
                            name: 'register-result',
                            icon: 'smile',
                            path: '/user/register-result',
                            component: './user/register-result',
                        },
                        {
                            name: 'register',
                            icon: 'smile',
                            path: '/user/register',
                            component: './user/register',
                        },
                        {
                            component: '404',
                        },
                    ],
                },

              ...  ...

            ],
        },
    ],

 

 

本文标签: DesignAntpro