Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ant-design-pro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
ant-design-pro
Commits
b0816a4c
Commit
b0816a4c
authored
Aug 23, 2018
by
愚道
Committed by
陈帅
Aug 23, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: remove unnecessary files
parent
ffc305e4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
0 additions
and
579 deletions
+0
-579
src/common/menu.js
src/common/menu.js
+0
-152
src/common/router.js
src/common/router.js
+0
-343
src/locales/localeContext.js
src/locales/localeContext.js
+0
-53
src/router.js
src/router.js
+0
-31
No files found.
src/common/menu.js
deleted
100644 → 0
View file @
ffc305e4
// // TODO: authority
// const menuData = [
// {
// name: 'dashboard',
// icon: 'dashboard',
// path: 'dashboard',
// children: [
// {
// name: 'analysis',
// path: 'analysis',
// },
// {
// name: 'monitor',
// path: 'monitor',
// },
// {
// name: 'workplace',
// path: 'workplace',
// // hideInBreadcrumb: true,
// // hideInMenu: true,
// },
// ],
// },
// {
// name: 'form',
// icon: 'form',
// path: 'form',
// children: [
// {
// name: 'basicform',
// path: 'basic-form',
// },
// {
// name: 'stepform',
// path: 'step-form',
// },
// {
// // authority: 'admin',
// name: 'advancedform',
// authority: 'admin',
// path: 'advanced-form',
// },
// ],
// },
// {
// name: 'list',
// icon: 'table',
// path: 'list',
// children: [
// {
// name: 'searchlist',
// path: 'table-list',
// },
// {
// name: 'basiclist',
// path: 'basic-list',
// },
// {
// name: 'cardlist',
// path: 'card-list',
// },
// {
// name: 'searchlist',
// path: 'search',
// children: [
// {
// name: 'articles',
// path: 'articles',
// },
// {
// name: 'projects',
// path: 'projects',
// },
// {
// name: 'applications',
// path: 'applications',
// },
// ],
// },
// ],
// },
// {
// name: 'profile',
// icon: 'profile',
// path: 'profile',
// children: [
// {
// name: 'basic',
// path: 'basic',
// },
// {
// name: 'advanced',
// path: 'advanced',
// // authority: 'admin',
// },
// ],
// },
// {
// name: 'result',
// icon: 'check-circle-o',
// path: 'result',
// children: [
// {
// name: 'success',
// path: 'success',
// },
// {
// name: 'fail',
// path: 'fail',
// },
// ],
// },
// {
// name: 'exception',
// icon: 'warning',
// path: 'exception',
// children: [
// {
// name: 'not-permission',
// path: '403',
// },
// {
// name: 'not-find',
// path: '404',
// },
// {
// name: 'server-error',
// path: '500',
// },
// {
// name: 'trigger',
// path: 'trigger',
// hideInMenu: true,
// },
// ],
// },
// {
// name: 'account',
// icon: 'user',
// path: 'account',
// children: [
// {
// name: 'center',
// path: 'center',
// },
// {
// name: 'settings',
// path: 'settings',
// },
// ],
// },
// ];
src/common/router.js
deleted
100644 → 0
View file @
ffc305e4
// TODO:remove
// import { createElement } from 'react';
// import dynamic from 'dva/dynamic';
// import pathToRegexp from 'path-to-regexp';
// import { getMenuData } from './menu';
// let routerDataCache;
// const modelNotExisted = (app, model) =>
// // eslint-disable-next-line
// !app._models.some(({ namespace }) => {
// return namespace === model.substring(model.lastIndexOf('/') + 1);
// });
// // wrapper of dynamic
// const dynamicWrapper = (app, models, component) => {
// // () => require('module')
// // transformed by babel-plugin-dynamic-import-node-sync
// if (component.toString().indexOf('.then(') < 0) {
// models.forEach(model => {
// if (modelNotExisted(app, model)) {
// // eslint-disable-next-line
// app.model(require(`../models/${model}`).default);
// }
// });
// return props => {
// if (!routerDataCache) {
// routerDataCache = getRouterData(app);
// }
// return createElement(component().default, {
// ...props,
// routerData: routerDataCache,
// });
// };
// }
// // () => import('module')
// return dynamic({
// app,
// models: () =>
// models.filter(model => modelNotExisted(app, model)).map(m => import(`../models/${m}.js`)),
// // add routerData prop
// component: () => {
// if (!routerDataCache) {
// routerDataCache = getRouterData(app);
// }
// return component().then(raw => {
// const Component = raw.default || raw;
// return props =>
// createElement(Component, {
// ...props,
// routerData: routerDataCache,
// });
// });
// },
// });
// };
// function getFlatMenuData(menus) {
// let keys = {};
// menus.forEach(item => {
// if (item.children) {
// keys[item.path] = { ...item };
// keys = { ...keys, ...getFlatMenuData(item.children) };
// } else {
// keys[item.path] = { ...item };
// }
// });
// return keys;
// }
// export const getRouterData = app => {
// const routerConfig = {
// '/': {
// component: dynamicWrapper(app, ['user', 'login', 'setting'], () =>
// import('../layouts/LoadingPage')
// ),
// },
// '/dashboard/analysis': {
// component: dynamicWrapper(app, ['chart'], () => import('../pages/Dashboard/Analysis')),
// },
// '/dashboard/monitor': {
// component: dynamicWrapper(app, ['monitor'], () => import('../pages/Dashboard/Monitor')),
// },
// '/dashboard/workplace': {
// component: dynamicWrapper(app, ['user', 'project', 'activities', 'chart'], () =>
// import('../pages/Dashboard/Workplace')
// ),
// // hideInBreadcrumb: true,
// // name: '工作台',
// // authority: 'admin',
// },
// '/form/basic-form': {
// component: dynamicWrapper(app, ['form'], () => import('../pages/Forms/BasicForm')),
// },
// '/form/step-form': {
// component: dynamicWrapper(app, ['form'], () => import('../pages/Forms/StepForm')),
// },
// '/form/step-form/info': {
// name: '分步表单(填写转账信息)',
// component: dynamicWrapper(app, ['form'], () => import('../pages/Forms/StepForm/Step1')),
// },
// '/form/step-form/confirm': {
// name: '分步表单(确认转账信息)',
// component: dynamicWrapper(app, ['form'], () => import('../pages/Forms/StepForm/Step2')),
// },
// '/form/step-form/result': {
// name: '分步表单(完成)',
// component: dynamicWrapper(app, ['form'], () => import('../pages/Forms/StepForm/Step3')),
// },
// '/form/advanced-form': {
// component: dynamicWrapper(app, ['form'], () => import('../pages/Forms/AdvancedForm')),
// },
// '/list/table-list': {
// component: dynamicWrapper(app, ['rule'], () => import('../pages/List/TableList')),
// },
// '/list/basic-list': {
// component: dynamicWrapper(app, ['list'], () => import('../pages/List/BasicList')),
// },
// '/list/card-list': {
// component: dynamicWrapper(app, ['list'], () => import('../pages/List/CardList')),
// },
// '/list/search': {
// component: dynamicWrapper(app, ['list'], () => import('../pages/List/List')),
// },
// '/list/search/projects': {
// component: dynamicWrapper(app, ['list'], () => import('../pages/List/Projects')),
// },
// '/list/search/applications': {
// component: dynamicWrapper(app, ['list'], () => import('../pages/List/Applications')),
// },
// '/list/search/articles': {
// component: dynamicWrapper(app, ['list'], () => import('../pages/List/Articles')),
// },
// '/profile/basic': {
// component: dynamicWrapper(app, ['profile'], () => import('../pages/Profile/BasicProfile')),
// },
// '/profile/advanced': {
// component: dynamicWrapper(app, ['profile'], () => import('../pages/Profile/AdvancedProfile')),
// },
// '/result/success': {
// component: dynamicWrapper(app, [], () => import('../pages/Result/Success')),
// },
// '/result/fail': {
// component: dynamicWrapper(app, [], () => import('../pages/Result/Error')),
// },
// '/exception/403': {
// component: dynamicWrapper(app, [], () => import('../pages/Exception/403')),
// },
// '/exception/404': {
// component: dynamicWrapper(app, [], () => import('../pages/Exception/404')),
// },
// '/exception/500': {
// component: dynamicWrapper(app, [], () => import('../pages/Exception/500')),
// },
// '/exception/trigger': {
// component: dynamicWrapper(app, ['error'], () =>
// import('../pages/Exception/triggerException')
// ),
// },
// '/user': {
// component: dynamicWrapper(app, [], () => import('../layouts/UserLayout')),
// },
// '/user/login': {
// component: dynamicWrapper(app, ['login'], () => import('../pages/User/Login')),
// },
// '/user/register': {
// component: dynamicWrapper(app, ['register'], () => import('../pages/User/Register')),
// },
// '/user/register-result': {
// component: dynamicWrapper(app, [], () => import('../pages/User/RegisterResult')),
// },
// '/account/center': {
// component: dynamicWrapper(app, ['list', 'user', 'project'], () =>
// import('../pages/Account/Center/Center')
// ),
// },
// '/account/center/articles': {
// component: dynamicWrapper(app, [], () => import('../pages/Account/Center/Articles')),
// },
// '/account/center/applications': {
// component: dynamicWrapper(app, [], () => import('../pages/Account/Center/Applications')),
// },
// '/account/center/projects': {
// component: dynamicWrapper(app, [], () => import('../pages/Account/Center/Projects')),
// },
// '/account/settings': {
// component: dynamicWrapper(app, ['geographic'], () =>
// import('../pages/Account/Settings/Info')
// ),
// },
// '/account/settings/base': {
// component: dynamicWrapper(app, ['geographic'], () =>
// import('../pages/Account/Settings/BaseView')
// ),
// },
// '/account/settings/security': {
// component: dynamicWrapper(app, ['geographic'], () =>
// import('../pages/Account/Settings/SecurityView')
// ),
// },
// '/account/settings/binding': {
// component: dynamicWrapper(app, ['geographic'], () =>
// import('../pages/Account/Settings/BindingView')
// ),
// },
// '/account/settings/notification': {
// component: dynamicWrapper(app, ['geographic'], () =>
// import('../pages/Account/Settings/NotificationView')
// ),
// },
// // '/user/:id': {
// // component: dynamicWrapper(app, [], () => import('../pages/User/SomeComponent')),
// // },
// };
// // Get name from ./menu.js or just set it in the router data.
// const menuData = getFlatMenuData(getMenuData());
// // Route configuration data
// // eg. {name,authority ...routerConfig }
// const routerData = {};
// // The route matches the menu
// Object.keys(routerConfig).forEach(path => {
// // Regular match item name
// // eg. router /user/:id === /user/chen
// const pathRegexp = pathToRegexp(path);
// const menuKey = Object.keys(menuData).find(key => pathRegexp.test(`${key}`));
// let menuItem = {};
// // If menuKey is not empty
// if (menuKey) {
// menuItem = menuData[menuKey];
// }
// let router = routerConfig[path];
// // If you need to configure complex parameter routing,
// // https://github.com/ant-design/ant-design-pro-site/blob/master/docs/router-and-nav.md#%E5%B8%A6%E5%8F%82%E6%95%B0%E7%9A%84%E8%B7%AF%E7%94%B1%E8%8F%9C%E5%8D%95
// // eg . /list/:type/user/info/:id
// router = {
// ...router,
// name: router.name || menuItem.name,
// authority: router.authority || menuItem.authority,
// hideInBreadcrumb: router.hideInBreadcrumb || menuItem.hideInBreadcrumb,
// };
// routerData[path] = router;
// });
// return routerData;
// };
import
pathToRegexp
from
'
path-to-regexp
'
;
import
{
getMenuData
}
from
'
./menu
'
;
function
getFlatMenuData
(
menus
)
{
let
keys
=
{};
menus
.
forEach
(
item
=>
{
if
(
item
.
children
)
{
keys
[
item
.
path
]
=
{
...
item
};
keys
=
{
...
keys
,
...
getFlatMenuData
(
item
.
children
)
};
}
else
{
keys
[
item
.
path
]
=
{
...
item
};
}
});
return
keys
;
}
export
const
getRouterData
=
()
=>
{
const
routerConfig
=
{
'
/
'
:
{
name
:
'
Ant-Design-Pro
'
,
},
'
/Dashboard/Analysis
'
:
{
name
:
'
分析页
'
,
},
'
/Dashboard/Monitor
'
:
{},
'
/Dashboard/Workplace
'
:
{
// component: dynamicWrapper(app, ['project', 'activities', 'chart'], () => import('../routes/Dashboard/Workplace')),
// hideInBreadcrumb: true,
// name: '工作台',
// authority: 'admin',
},
'
/Forms/BasicForm
'
:
{},
'
/Forms/StepForm
'
:
{},
'
/Forms/StepForm/Step1
'
:
{
name
:
'
分步表单(填写转账信息)
'
,
},
'
/Forms/StepForm/Step2
'
:
{
name
:
'
分步表单(确认转账信息)
'
,
},
'
/Forms/StepForm/Step3
'
:
{
name
:
'
分步表单(完成)
'
,
},
'
/Forms/AdvancedForm
'
:
{},
'
/List/TableList
'
:
{},
'
/List/BasicList
'
:
{},
'
/List/CardList
'
:
{},
'
/List
'
:
{},
'
/List/Search/Projects
'
:
{},
'
/List/Search/Applications
'
:
{},
'
/List/Search/Articles
'
:
{},
'
/Profile/BasicProfile
'
:
{},
'
/Profile/AdvancedProfile
'
:
{},
'
/Result/success
'
:
{},
'
/Result/Error
'
:
{},
'
/Exception/403
'
:
{},
'
/Exception/404
'
:
{},
'
/Exception/500
'
:
{},
'
/Exception/triggerException
'
:
{},
'
/User
'
:
{},
'
/User/Login
'
:
{},
'
/User/Register
'
:
{},
'
/User/RegisterResult
'
:
{},
// '/user/:id': {
// component: dynamicWrapper(app, [], () => console.log('../routes/User/SomeComponent')),
// },
};
// Get name from ./menu.js or just set it in the router data.
const
menuData
=
getFlatMenuData
(
getMenuData
());
// Route configuration data
// eg. {name,authority ...routerConfig }
const
routerData
=
{};
// The route matches the menu
Object
.
keys
(
routerConfig
).
forEach
(
path
=>
{
// Regular match item name
// eg. router /user/:id === /user/chen
const
pathRegexp
=
pathToRegexp
(
path
);
const
menuKey
=
Object
.
keys
(
menuData
).
find
(
key
=>
pathRegexp
.
test
(
`
${
key
}
`
));
let
menuItem
=
{};
// If menuKey is not empty
if
(
menuKey
)
{
menuItem
=
menuData
[
menuKey
];
}
let
router
=
routerConfig
[
path
];
// If you need to configure complex parameter routing,
// https://github.com/ant-design/ant-design-pro-site/blob/master/docs/router-and-nav.md#%E5%B8%A6%E5%8F%82%E6%95%B0%E7%9A%84%E8%B7%AF%E7%94%B1%E8%8F%9C%E5%8D%95
// eg . /list/:type/user/info/:id
router
=
{
...
router
,
name
:
router
.
name
||
menuItem
.
name
,
authority
:
router
.
authority
||
menuItem
.
authority
,
};
routerData
[
path
]
=
router
;
});
return
routerData
;
};
src/locales/localeContext.js
deleted
100644 → 0
View file @
ffc305e4
import
React
from
'
react
'
;
import
{
addLocaleData
,
IntlProvider
}
from
'
umi/locale
'
;
import
{
LocaleProvider
}
from
'
antd
'
;
import
enLocale
from
'
./en-US
'
;
import
cnLocale
from
'
./zh-CN
'
;
const
Context
=
React
.
createContext
();
function
getLang
()
{
if
(
window
.
localStorage
&&
localStorage
.
getItem
(
'
locale
'
))
{
return
localStorage
.
getItem
(
'
locale
'
);
}
return
(
navigator
.
language
||
navigator
.
browserLanguage
).
toLowerCase
()
===
'
en-us
'
?
'
en-US
'
:
'
zh-CN
'
;
}
export
class
LocalComponent
extends
React
.
PureComponent
{
state
=
{
locale
:
getLang
(),
};
changeLocal
=
()
=>
{
this
.
setState
({
locale
:
getLang
(),
});
};
render
()
{
const
{
children
}
=
this
.
props
;
const
{
locale
}
=
this
.
state
;
return
(
<
Context
.
Provider
value
=
{{
appLocale
:
locale
===
'
zh-CN
'
?
cnLocale
:
enLocale
,
changeLocal
:
this
.
changeLocal
,
}}
>
<
Context
.
Consumer
>
{({
appLocale
})
=>
{
addLocaleData
(
appLocale
.
data
);
return
(
<
IntlProvider
locale
=
{
appLocale
.
locale
}
messages
=
{
appLocale
.
messages
}
>
<
LocaleProvider
locale
=
{
appLocale
.
antd
}
>
{
children
}
<
/LocaleProvider
>
<
/IntlProvider
>
);
}}
<
/Context.Consumer
>
<
/Context.Provider
>
);
}
}
export
default
Context
;
src/router.js
deleted
100644 → 0
View file @
ffc305e4
import
React
from
'
react
'
;
import
{
routerRedux
,
Route
,
Switch
}
from
'
dva/router
'
;
import
{
getRouterData
}
from
'
./common/router
'
;
import
Authorized
from
'
./utils/Authorized
'
;
import
{
getQueryPath
}
from
'
./utils/utils
'
;
const
{
ConnectedRouter
}
=
routerRedux
;
const
{
AuthorizedRoute
}
=
Authorized
;
function
RouterConfig
({
history
,
app
})
{
const
routerData
=
getRouterData
(
app
);
const
UserLayout
=
routerData
[
'
/user
'
].
component
;
const
BasicLayout
=
routerData
[
'
/
'
].
component
;
return
(
<
ConnectedRouter
history
=
{
history
}
>
<
Switch
>
<
Route
path
=
"
/user
"
component
=
{
UserLayout
}
/
>
<
AuthorizedRoute
path
=
"
/
"
render
=
{
props
=>
<
BasicLayout
{...
props
}
/>
}
authority
=
{[
'
admin
'
,
'
user
'
]}
redirectPath
=
{
getQueryPath
(
'
/user/login
'
,
{
redirect
:
window
.
location
.
href
,
})}
/
>
<
/Switch
>
<
/ConnectedRouter
>
);
}
export
default
RouterConfig
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment