Commit 44d2c7bb authored by nikogu's avatar nikogu

refactor inhuman code of nav.js

parent 5a47aa03
import dynamic from 'dva/dynamic'; import dynamic from 'dva/dynamic';
export const getNavData = app => [{ // models
component: dynamic({ import UserModel from '../models/user';
app, import ChartModel from '../models/chart';
models: () => [ import MonitorModel from '../models/monitor';
import('../models/user'), import ProjectModel from '../models/project';
], import ActivitiesModel from '../models/activities';
component: () => import('../layouts/BasicLayout'), import FormModel from '../models/form';
}), import RuleModel from '../models/rule';
layout: 'BasicLayout', import ListModel from '../models/list';
name: '首页', // for breadcrumb import ProfileModel from '../models/profile';
path: '/', import LoginModel from '../models/login';
children: [{ import RegisterModel from '../models/register';
name: 'Dashboard',
icon: 'dashboard', // components
path: 'dashboard', import BasicLayout from '../layouts/BasicLayout';
children: [{ import UserLayout from '../layouts/UserLayout';
name: '分析页', import BlankLayout from '../layouts/BlankLayout';
path: 'analysis',
component: dynamic({ import Analysis from '../routes/Dashboard/Analysis';
app, import Monitor from '../routes/Dashboard/Monitor';
models: () => [ import Workplace from '../routes/Dashboard/Workplace';
import('../models/chart'),
], import BasicForm from '../routes/Forms/BasicForm';
component: () => import('../routes/Dashboard/Analysis'), import AdvancedForm from '../routes/Forms/AdvancedForm';
}), import StepForm from '../routes/Forms/StepForm';
}, { import Step2 from '../routes/Forms/StepForm/Step2';
name: '监控页', import Step3 from '../routes/Forms/StepForm/Step3';
path: 'monitor',
component: dynamic({ import TableList from '../routes/List/TableList';
app, import BasicList from '../routes/List/BasicList';
models: () => [ import CardList from '../routes/List/CardList';
import('../models/monitor'), import CoverCardList from '../routes/List/CoverCardList';
], import FilterCardList from '../routes/List/FilterCardList';
component: () => import('../routes/Dashboard/Monitor'), import SearchList from '../routes/List/SearchList';
}),
}, { import BasicProfile from '../routes/Profile/BasicProfile';
name: '工作台', import AdvancedProfile from '../routes/Profile/AdvancedProfile';
path: 'workplace',
component: dynamic({ import Success from '../routes/Result/Success';
app, import Error from '../routes/Result/Error';
models: () => [ import Exception403 from '../routes/Exception/403';
import('../models/project'), import Exception404 from '../routes/Exception/404';
import('../models/activities'), import Exception500 from '../routes/Exception/500';
import('../models/chart'),
], import Login from '../routes/User/Login';
component: () => import('../routes/Dashboard/Workplace'), import Register from '../routes/User/Register';
}), import RegisterResult from '../routes/User/RegisterResult';
}],
}, { // wrapper of dynamic
name: '表单页', const dy = (app, models, component) => dynamic({
path: 'form', app,
icon: 'form', models: () => models,
children: [{ component: () => component,
name: '基础表单', });
path: 'basic-form',
component: dynamic({ // nav data
app, export const getNavData = app => [
models: () => [ {
import('../models/form'), component: dy(app, [UserModel], BasicLayout),
], layout: 'BasicLayout',
component: () => import('../routes/Forms/BasicForm'), name: '首页', // for breadcrumb
}), path: '/',
}, { children: [
name: '分步表单', {
path: 'step-form', name: 'Dashboard',
component: dynamic({ icon: 'dashboard',
app, path: 'dashboard',
models: () => [ children: [
import('../models/form'), {
name: '分析页',
path: 'analysis',
component: dy(app, [ChartModel], Analysis),
},
{
name: '监控页',
path: 'monitor',
component: dy(app, [MonitorModel], Monitor),
},
{
name: '工作台',
path: 'workplace',
component: dy(app, [ProjectModel, ActivitiesModel, ChartModel], Workplace),
},
],
},
{
name: '表单页',
path: 'form',
icon: 'form',
children: [
{
name: '基础表单',
path: 'basic-form',
component: dy(app, [FormModel], BasicForm),
},
{
name: '分步表单',
path: 'step-form',
component: dy(app, [FormModel], StepForm),
children: [
{
path: 'confirm',
component: dy(app, [FormModel], Step2),
},
{
path: 'result',
component: dy(app, [FormModel], Step3),
},
],
},
{
name: '高级表单',
path: 'advanced-form',
component: dy(app, [FormModel], AdvancedForm),
},
], ],
component: () => import('../routes/Forms/StepForm'),
}),
children: [{
path: 'confirm',
component: dynamic({
app,
models: () => [
import('../models/form'),
],
component: () => import('../routes/Forms/StepForm/Step2'),
}),
}, { }, {
name: '列表页',
path: 'list',
icon: 'table',
children: [
{
name: '查询表格',
path: 'table-list',
component: dy(app, [RuleModel], TableList),
},
{
name: '标准列表',
path: 'basic-list',
component: dy(app, [ListModel], BasicList),
},
{
name: '卡片列表',
path: 'card-list',
component: dy(app, [ListModel], CardList),
},
{
name: '搜索列表(项目)',
path: 'cover-card-list',
component: dy(app, [ListModel], CoverCardList),
},
{
name: '搜索列表(应用)',
path: 'filter-card-list',
component: dy(app, [ListModel], FilterCardList),
},
{
name: '搜索列表(文章)',
path: 'search',
component: dy(app, [ListModel], SearchList),
},
],
},
{
name: '详情页',
path: 'profile',
icon: 'profile',
children: [
{
name: '基础详情页',
path: 'basic',
component: dy(app, [ProfileModel], BasicProfile),
},
{
name: '高级详情页',
path: 'advanced',
component: dy(app, [ProfileModel], AdvancedProfile),
},
],
},
{
name: '结果',
path: 'result', path: 'result',
component: dynamic({ icon: 'check-circle-o',
app, children: [
models: () => [ {
import('../models/form'), name: '成功',
], path: 'success',
component: () => import('../routes/Forms/StepForm/Step3'), component: dy(app, [], Success),
}), },
}], {
}, { name: '失败',
name: '高级表单', path: 'fail',
path: 'advanced-form', component: dy(app, [], Error),
component: dynamic({ },
app, ],
models: () => [ },
import('../models/form'), {
], name: '异常',
component: () => import('../routes/Forms/AdvancedForm'), path: 'exception',
}), icon: 'warning',
}], children: [
}, { {
name: '列表页', name: '403',
path: 'list', path: '403',
icon: 'table', component: dy(app, [], Exception403),
children: [{ },
name: '查询表格', {
path: 'table-list', name: '404',
component: dynamic({ path: '404',
app, component: dy(app, [], Exception404),
models: () => [ },
import('../models/rule'), {
], name: '500',
component: () => import('../routes/List/TableList'), path: '500',
}), component: dy(app, [], Exception500),
}, { },
name: '标准列表', ],
path: 'basic-list', },
component: dynamic({ ],
app, },
models: () => [ {
import('../models/list'), component: dy(app, [], UserLayout),
], path: '/user',
component: () => import('../routes/List/BasicList'), layout: 'UserLayout',
}), children: [
}, { {
name: '卡片列表', name: '帐户',
path: 'card-list', icon: 'user',
component: dynamic({ path: 'user',
app, children: [
models: () => [ {
import('../models/list'), name: '登录',
], path: 'login',
component: () => import('../routes/List/CardList'), component: dy(app, [LoginModel], Login),
}), },
}, { {
name: '搜索列表(项目)', name: '注册',
path: 'cover-card-list', path: 'register',
component: dynamic({ component: dy(app, [RegisterModel], Register),
app, },
models: () => [ {
import('../models/list'), name: '注册结果',
], path: 'register-result',
component: () => import('../routes/List/CoverCardList'), component: dy(app, [], RegisterResult),
}), },
}, { ],
name: '搜索列表(应用)', },
path: 'filter-card-list', ],
component: dynamic({ },
app, {
models: () => [ component: dy(app, [], BlankLayout),
import('../models/list'), layout: 'BlankLayout',
], children: {
component: () => import('../routes/List/FilterCardList'), name: '使用文档',
}), path: 'http://pro.ant.design/docs/getting-started',
}, { target: '_blank',
name: '搜索列表(文章)', icon: 'book',
path: 'search', },
component: dynamic({
app,
models: () => [
import('../models/list'),
],
component: () => import('../routes/List/SearchList'),
}),
}],
}, {
name: '详情页',
path: 'profile',
icon: 'profile',
children: [{
name: '基础详情页',
path: 'basic',
component: dynamic({
app,
models: () => [
import('../models/profile'),
],
component: () => import('../routes/Profile/BasicProfile'),
}),
}, {
name: '高级详情页',
path: 'advanced',
component: dynamic({
app,
models: () => [
import('../models/profile'),
],
component: () => import('../routes/Profile/AdvancedProfile'),
}),
}],
}, {
name: '结果',
path: 'result',
icon: 'check-circle-o',
children: [{
name: '成功',
path: 'success',
component: dynamic({
app,
component: () => import('../routes/Result/Success'),
}),
}, {
name: '失败',
path: 'fail',
component: dynamic({
app,
component: () => import('../routes/Result/Error'),
}),
}],
}, {
name: '异常',
path: 'exception',
icon: 'warning',
children: [{
name: '403',
path: '403',
component: dynamic({
app,
component: () => import('../routes/Exception/403'),
}),
}, {
name: '404',
path: '404',
component: dynamic({
app,
component: () => import('../routes/Exception/404'),
}),
}, {
name: '500',
path: '500',
component: dynamic({
app,
component: () => import('../routes/Exception/500'),
}),
}],
}],
}, {
component: dynamic({
app,
component: () => import('../layouts/UserLayout'),
}),
path: '/user',
layout: 'UserLayout',
children: [{
name: '帐户',
icon: 'user',
path: 'user',
children: [{
name: '登录',
path: 'login',
component: dynamic({
app,
models: () => [
import('../models/login'),
],
component: () => import('../routes/User/Login'),
}),
}, {
name: '注册',
path: 'register',
component: dynamic({
app,
models: () => [
import('../models/register'),
],
component: () => import('../routes/User/Register'),
}),
}, {
name: '注册结果',
path: 'register-result',
component: dynamic({
app,
component: () => import('../routes/User/RegisterResult'),
}),
}],
}],
}, {
component: dynamic({
app,
component: () => import('../layouts/BlankLayout'),
}),
layout: 'BlankLayout',
children: {
name: '使用文档',
path: 'http://pro.ant.design/docs/getting-started',
target: '_blank',
icon: 'book',
}, },
}]; ];
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment