index.js 677 Bytes
Newer Older
wb-ct393452's avatar
wb-ct393452 committed
1 2 3 4
import syncConfig from './config';

// 不需要登录拦截的路由配置
const loginIgnore = {
水落(YangLei)'s avatar
水落(YangLei) committed
5 6 7 8 9 10 11 12 13 14
    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
15 16 17 18 19 20 21
};

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

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