路由

分为 视图页面。这两者配置相同,唯一的区别就是 视图 挂载在 / 路由下。

配置路由

WARNING

默认路由是动态添加的(在系统菜单中配置)。当参数 list 不为空时,则为自定义菜单模式

编辑在 /src/cool/config/index.ts

{
    router: {
        // 模式
        mode: "history",
        // 自定义菜单列表
        list: [
            {
                name: '目录A',
                type: 0,
                isShow: true,
                children: [
                    {
                        name: '菜单B',
                        type: 1,
                        path: '/a',
                        isShow: true,
                        icon: 'icon-like',
                        component: () => import('/$/demo/views/crud.vue'),
                        meta: {
                            keepAlive: true
                        },
                    },
                    {
                        name: '菜单B',
                        type: 1,
                        isShow: false,
                    }
                ]
            }
        ],
    }
}

参数 list 完整描述如下:

type list = {
    // 类型 0-目录 1-菜单
    type: 0 | 1;
    // 访问路径, / 开头。菜单可用
    router?: `/${string}`;
    // 渲染组件。菜单可用
    component?: Component;
    // 是否显示
    isShow?: boolean;
    // svg 图标
    icon?: string;
    // 其他配置
    meta?: {
        // 是否添加到进程栏
        process?: boolean;
        // 是否缓存
        keepAlive?: boolean;
        // 菜单名称
        label?: string;
    };
    // 子菜单
    children?: list
}[]

忽略 token

编辑在 /@/cool/config/index.ts

{
	ignore: {
		// 页面不需要登录验证
		token: ["/login", "/401", "/403", "/404", "/500", "/502"];
	}
}

注意事项

WARNING

使用 history 模式时,需要服务器配置,文档地址点我open in new window

Last Updated: