123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- const { Router } = require('express');
- const gaf = require('./gaf');
- const user = require('./user');
- const log = require('./log');
- const app = require('./app');
- const authorize = require('./authorize');
- const policy = require('./policy');
- const link = require('./link');
- const register = require('./register');
- const cred = require('./cred');
- const journal = require('./journal');
- const dev = require('./dev');
- const terminal = require('./terminal');
- const router = Router();
- const navDatas = [
- {
- title: '用户管理',
- path: '/xms',
- module: '@user',
- },
- {
- title: '终端管理',
- path: '/xms',
- module: '@terminal',
- },
- {
- title: '用户审核',
- path: '/xms/',
- module: '@register',
- },
- {
- title: '授权管理',
- path: '/xms',
- module: '@auth',
- },
- {
- title: '凭证管理',
- path: '/xms',
- module: '@cred',
- },
- {
- title: '凭证设备',
- path: '/xms',
- module: '@dev',
- },
- {
- title: '应用管理',
- path: '/xms',
- module: '@app',
- },
- {
- title: '策略管理',
- path: '/xms',
- module: '@policy',
- },
- {
- title: '用户审计',
- path: '/log/audit/logon',
- module: '@log',
- },
- {
- title: '责任认定',
- path: '/log/audit/duty',
- module: '@log',
- },
- {
- title: '日志审计',
- path: '/log/query/c1',
- module: '@log',
- },
- {
- title: '系统管理',
- path: '/gaf',
- module: '@gaf',
- },
- // ...link,
- ];
- const home = [
- {
- title: '工作台',
- path: '/xms/dashboard',
- icon: 'home',
- module: '@user',
- },
- ];
- const transItems = (items, pid) =>
- items.map((p, i) => {
- p.pid = pid || '0';
- p.id = p.id || (pid ? `${pid}-${i + 1}` : `${i + 1}`);
- if (p.children && p.children.length > 0) p.children = transItems(p.children, p.id);
- return p;
- });
- const datas = transItems([...home, ...user, ...terminal, ...register, ...authorize, ...cred, ...dev, ...app, ...policy, ...log, ...journal, ...gaf]);
- const MapMenu = (catalog = [], module = undefined) => item => ({
- title: item.title,
- options: {
- icon: item.icon,
- path: `/${item.module || module}${item.path}`,
- url: item.url,
- target: item.target,
- tooltip: item.tooltip,
- module: item.module,
- platform: item.platform,
- roles: item.roels,
- tags: item.tags,
- meta: { catalog: catalog.concat(item.title) },
- },
- children: (item.children || []).map(MapMenu(catalog.concat(item.title), item.module || module)),
- });
- const menus = datas.map(MapMenu());
- const modules = navDatas.map(MapMenu());
- /* GET menus define. */
- router.get('/menu/load', function(req, res, next) {
- console.log("!!!I'm menu/load!!!");
- res.json({ errcode: 0, errmsg: 'ok', data: { items: menus, modules } });
- });
- // router.get('/menu/:module', function(req, res, next) {
- // const module = req.params.module;
- // const items = menus.filter(p => p.options.module == module);
- // res.json({ errcode: 0, errmsg: 'ok', data: { items, modules } });
- // });
- router.get('/menu/items', function(req, res, next) {
- res.json({ errcode: 0, errmsg: 'ok', data: datas });
- });
- router.get('/menu/menus', function(req, res, next) {
- res.json({ errcode: 0, errmsg: 'ok', data: navDatas });
- });
- router.get('/menu/:module/items', function(req, res, next) {
- const module = req.params.module;
- const items = datas.filter(p => p.options.module == module);
- res.json({ errcode: 0, errmsg: 'ok', data: items });
- });
- module.exports = router;
|