index.js 763 Bytes
Newer Older
wb-ct393452's avatar
wb-ct393452 committed
1 2 3 4 5
import syncConfig from './config';
import { formatRoutes } from '../utils/routerUtil';

// 不需要登录拦截的路由配置
const loginIgnore = {
水落(YangLei)'s avatar
水落(YangLei) committed
6 7 8 9 10 11 12 13 14 15
    names: ['404', '403'], //根据路由名称匹配
    paths: ['/login'], //根据路由fullPath匹配
    /**
     * 判断路由是否包含在该配置中
     * @param route vue-router 的 route 对象
     * @returns {boolean}
     */
    includes(route) {
        return this.names.includes(route.name) || this.paths.includes(route.path);
    },
wb-ct393452's avatar
wb-ct393452 committed
16 17 18 19 20 21 22
};

/**
 * 初始化路由实例
 * @param isAsync 是否异步路由模式
 * @returns {options.routes}
 */
水落(YangLei)'s avatar
水落(YangLei) committed
23 24 25 26
function initRouter() {
    const options = syncConfig;
    formatRoutes(options.routes);
    return options;
wb-ct393452's avatar
wb-ct393452 committed
27 28
}

水落(YangLei)'s avatar
水落(YangLei) committed
29
export { loginIgnore, initRouter };