0.3.1 • Published 3 years ago

@bingoit/cms-desktop v0.3.1

Weekly downloads
29
License
ISC
Repository
-
Last release
3 years ago

cms-desktop

信息公告PC端,主要功能有:信息公告的发布、分类管理、标签管理、群组管理等;

安装方法

npm install @bingoit/cms-desktop --save

使用方法

直接引入信息公告导出的路由,并配置路由就可以使用了。
配置路由的实例代码如下所示:

import Vue from 'vue';
import Router from 'vue-router';
import { isNotEmpty } from '@bingoit/utils';
import { routerInterceptor, registerRouter, getParentRouteByPath } from '@bingoit/desktop-base/lib/router/helper';
import store from './store';
Vue.use(Router);

import CmsRoutes from '@bingoit/cms-desktop/lib/router';
let routeArray = [];
let cmsStaticRoutes = registerRouter(CmsRoutes);
let notMenuDynamicRouters = [];
//CMS路由有点特别:返回的路由中,除了静态路由,还有需要添加到子路由的非菜单路由
if(cmsStaticRoutes) {
    cmsStaticRoutes.forEach(route => {
        //判断是否需要添加到指定路由中;
        // 指定了siblingPath参数的路由,需要添加到对应父路由的子路由中
        if(isNotEmpty(route.siblingPath)) {
            notMenuDynamicRouters.push(route);
        } else {
            routeArray.push(route);
        }
    });
}

const router = new Router({
    routes: routeArray
});
//设置路由拦截;主要是登录拦截
routerInterceptor(router, store, routes => {
    //当动态路由注册完成前,会执行该方法,继续处理动态路由
    //注册非菜单的动态路由;如有些路由需要动态添加到指定路由的子路由中
    if(notMenuDynamicRouters) {
        notMenuDynamicRouters.forEach(route => {
            let parentRoute = getParentRouteByPath(routes, route.siblingPath);
            if(parentRoute) {
                if(!parentRoute.children) {
                    parentRoute.children = new Array();
                }
                parentRoute.children.push(route);
            }
        })
    }
});
export default router;
0.3.0

3 years ago

0.3.1

3 years ago

0.2.0

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.2

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.0

4 years ago

0.1.1

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago