Compare commits

...
36 Commits
Author SHA1 Message Date
Baorong Li cf795c512a bump antd-admin@5.2.0 2020-03-05 20:21:22 +08:00
Baorong Li 18b499030d upgrade antd@4.0.0 2020-02-29 22:47:45 +08:00
zuiidea d800d6f3ce Merge branch 'master' into develop 2020-01-08 09:31:45 +08:00
zuiidea 185f706107 💚 Fixing now config. 2020-01-07 17:17:57 +08:00
zuiidea 5a4661cdad Merge branch 'develop' of https://github.com/zuiidea/antd-admin into develop 2020-01-07 16:02:51 +08:00
zuiidea 7abdd94a0e 🚀 Optimize deployment configuration. 2020-01-07 16:02:33 +08:00
Baorong Li 22f0684ab0 chore: docs normal 2020-01-07 15:58:48 +08:00
Baorong Li 80b2c63693 Merge pull request #1040 from vagusX/feat/migrate-antd-v4
feat: migrate to antd v4
2019-12-02 22:07:08 -06:00
vagusX 4b2a553bda feat: add antd v4 dependencies 2019-12-03 10:19:54 +08:00
vagusX ad30e73b10 feat: migrate to antd v4 2019-12-03 09:58:49 +08:00
Baorong Li 15b62e302d bump antd-admin@5.1.3 2019-10-22 10:38:52 +08:00
Baorong Li 9d5ec20f20 Merge branch 'develop' 2019-10-22 10:37:43 +08:00
Baorong Li c878425fd0 upgrade antd@3.24.x 2019-10-22 10:30:04 +08:00
Baorong Li 90e80dda64 Merge pull request #1022 from rioarray/feature/inline-conditional-rendering
inline conditional rendering in some components
2019-10-17 16:32:30 +08:00
rioarray 1db5bfeab5 inline conditional rendering in some components 2019-10-17 14:45:30 +07:00
zuiidea b2b3fcd4a3 ✨ Support disable i18n. 2019-10-09 20:20:11 +08:00
Baorong Li 9cf97375c7 fix 404 when path = '/' 2019-08-01 23:12:42 +08:00
Baorong Li 7839b6affb Merge pull request #1007 from Louis-7/master
[fix] add notification popup to #primaryLayout instead of #layoutHeader
2019-07-25 08:26:35 -05:00
Louis 597064a07d [fix] add notification popup to #primaryLayout instead of #layoutHeader 2019-07-25 11:47:32 +08:00
Baorong Li 0ea57d14c9 fix #980 cannot read property 'map' of null 2019-07-07 23:01:20 +08:00
Baorong Li afd736d615 bump antd-admin@5.1.2 2019-07-07 22:48:34 +08:00
Baorong Li ce9b8c376f Merge pull request #996 from tuantvk/master
🐛 fix bug sub menu Charts when collapsed
2019-07-07 08:03:31 -05:00
tuantv 79776e6752 🐛 fix bug sub menu Charts when collapsed 2019-07-07 11:56:52 +07:00
zuiidea a2432022a1 ✨ Updating manifest logo and adding portugal flag image. 2019-07-02 17:47:16 +08:00
zuiidea ea5ee96bdc 🎨 Improving format of the code. 2019-07-06 11:02:56 +08:00
zuiidea fe954092a4 🐛 Fixing dva history.listen multiple triggers. 2019-07-06 10:50:50 +08:00
zuiidea 5e148fec92 Merge branch 'develop' of https://github.com/zuiidea/antd-admin into develop 2019-07-06 09:43:30 +08:00
Baorong Li 5daa2a9548 add moment locale setting 2019-07-05 22:26:29 +08:00
Baorong Li f1913f7b18 add pt_BR locale-provider in layout 2019-07-05 22:16:54 +08:00
zuiidea 65a453553e ✨ Updating mock avatar image. 2019-07-05 19:52:37 +08:00
Baorong Li 29da8f24da Merge pull request #989 from tuantvk/master
🐛 fix remove and update user error handleRefresh
2019-06-29 09:57:46 -05:00
tuantv 3443ad9968 🐛 fix edit and update user error handleRefresh 2019-06-29 21:19:57 +07:00
Baorong Li 838dc93eff bump antd-admin@5.1.1 2019-06-29 10:56:03 +08:00
Baorong Li 07ef68ec1f Merge remote-tracking branch 'origin/develop' 2019-06-29 10:54:10 +08:00
Baorong Li 3cb7f86086 fix login jump to /enundefined 2019-06-29 10:49:11 +08:00
Baorong Li fc9565c157 add a flag to detect refresh saving query times in model/app.js 2019-06-24 20:50:09 +08:00
42 changed files with 416 additions and 206 deletions
+58 -2
View File
@@ -3,6 +3,8 @@ import { resolve } from 'path'
import { i18n } from './src/utils/config'
export default {
publicPath: 'https://cdn.antd-admin.zuiidea.com/',
hash: true,
ignoreMomentLocale: true,
targets: { ie: 9 },
treeShaking: true,
@@ -60,9 +62,9 @@ export default {
},
pwa: {
manifestOptions: {
srcPath: 'manifest.json'
srcPath: 'manifest.json',
},
}
},
},
],
],
@@ -99,4 +101,58 @@ export default {
'lodash',
],
],
chainWebpack: function(config, { webpack }) {
config.merge({
optimization: {
minimize: true,
splitChunks: {
chunks: 'all',
minSize: 30000,
minChunks: 3,
automaticNameDelimiter: '.',
cacheGroups: {
react: {
name: 'react',
priority: 20,
test: /[\\/]node_modules[\\/](react|react-dom|react-dom-router)[\\/]/,
},
antd: {
name: 'antd',
priority: 20,
test: /[\\/]node_modules[\\/](antd|@ant-design\/icons|@ant-design\/compatible|ant-design-pro)[\\/]/,
},
echarts: {
name: 'echarts',
priority: 20,
test: /[\\/]node_modules[\\/]echarts|echarts-for-react|echarts-gl|echarts-liquidfill[\\/]/,
},
highcharts: {
name: 'highcharts',
priority: 20,
test: /[\\/]node_modules[\\/](highcharts-exporting|highcharts-more|react-highcharts)[\\/]/,
},
recharts: {
name: 'recharts',
priority: 20,
test: /[\\/]node_modules[\\/](recharts)[\\/]/,
},
draftjs: {
name: 'draftjs',
priority: 20,
test: /[\\/]node_modules[\\/](draftjs-to-html|draftjs-to-markdown)[\\/]/,
},
async: {
chunks: 'async',
minChunks: 2,
name: 'async',
maxInitialRequests: 1,
minSize: 0,
priority: 5,
reuseExistingChunk: true,
},
},
},
},
})
},
}
+1
View File
@@ -9,3 +9,4 @@
- Guide
- [Deploy](deploy.md)
- [Change Log](change-log.md)
- [FAQ](faq.md)
+9
View File
@@ -0,0 +1,9 @@
# FAQ
Most asked
## create new page
1. just copy a page in /src/pages (route here auto generated by [umi](https://umijs.org/guide/router.html#basic-routing))
2. modify namespace/pathMatchRegexp in model.js
3. modify mock route.js to add a route
+1 -1
View File
@@ -1,6 +1,6 @@
{
"version": 2,
"name": "antd-admin-devdoc",
"alias": ["devdoc-antd-admin.now.sh", "devdoc.antd-admin.zuiidea.com"],
"type": "static",
"public": true
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"version": 2,
"name": "antd-admin-doc",
"alias": ["doc-antd-admin.now.sh", "doc.antd-admin.zuiidea.com"],
"type": "static",
"public": true
}
+7
View File
@@ -0,0 +1,7 @@
# 问题集锦
## 新建页面
1. 直接从/src/pages复制一个page (会自动创建路由[umi](https://umijs.org/zh/guide/router.html#%E7%BA%A6%E5%AE%9A%E5%BC%8F%E8%B7%AF%E7%94%B1))
2. 修改 namespace/pathMatchRegexp 在 model.js
3. 修改 mock中route.js增加一条route
+26 -3
View File
@@ -4,10 +4,33 @@
"display": "standalone",
"background_color": "#fff",
"description": "A front-end solution for enterprise applications built upon Ant Design and UmiJS",
"icons": [
"icons": [{
"src": "logo/logo@96.png",
"sizes": "72x72"
},
{
"src": "logo.svg",
"sizes": "72x72 96x96 128x128 144x144 152x152 192x192 384x384 512x512"
"src": "logo/logo@128.png",
"sizes": "128x128"
},
{
"src": "logo/logo@144.png",
"sizes": "144x144"
},
{
"src": "logo/logo@152.png",
"sizes": "152x152"
},
{
"src": "logo/logo@192.png",
"sizes": "192x192"
},
{
"src": "logo/logo@384.png",
"sizes": "384x384"
},
{
"src": "logo/logo@512.png",
"sizes": "512x512"
}
]
}
+14 -17
View File
@@ -17,25 +17,22 @@ export function randomNumber(min, max) {
}
export function randomAvatar() {
// https://uifaces.co
const avatarList = [
'https://randomuser.me/api/portraits/men/32.jpg',
'https://images.pexels.com/photos/415829/pexels-photo-415829.jpeg?h=350&auto=compress&cs=tinysrgb',
'https://d3iw72m71ie81c.cloudfront.net/female-17.jpg',
'https://randomuser.me/api/portraits/men/35.jpg',
'https://pbs.twimg.com/profile_images/835224725815246848/jdMBCxHS.jpg',
'https://pbs.twimg.com/profile_images/584098247641300992/N25WgvW_.png',
'https://d3iw72m71ie81c.cloudfront.net/male-5.jpg',
'https://images.pexels.com/photos/413723/pexels-photo-413723.jpeg?h=350&auto=compress&cs=tinysrgb',
'https://randomuser.me/api/portraits/women/44.jpg',
'https://randomuser.me/api/portraits/women/68.jpg',
'https://randomuser.me/api/portraits/women/65.jpg',
'https://randomuser.me/api/portraits/men/43.jpg',
'https://tinyfac.es/data/avatars/475605E3-69C5-4D2B-8727-61B7BB8C4699-500w.jpeg',
'https://pbs.twimg.com/profile_images/943227488292962306/teiNNAiy.jpg',
'https://randomuser.me/api/portraits/men/46.jpg'
'photo-1549492864-2ec7d66ffb04.jpeg',
'photo-1480535339474-e083439a320d.jpeg',
'photo-1523419409543-a5e549c1faa8.jpeg',
'photo-1519648023493-d82b5f8d7b8a.jpeg',
'photo-1523307730650-594bc63f9d67.jpeg',
'photo-1522962506050-a2f0267e4895.jpeg',
'photo-1489779162738-f81aed9b0a25.jpeg',
'photo-1534308143481-c55f00be8bd7.jpeg',
'photo-1519336555923-59661f41bb45.jpeg',
'photo-1551438632-e8c7d9a5d1b7.jpeg',
'photo-1525879000488-bff3b1c387cf.jpeg',
'photo-1487412720507-e7ab37603c6f.jpeg',
'photo-1510227272981-87123e259b17.jpeg'
]
return avatarList[randomNumber(0, avatarList.length - 1)]
return `//image.zuiidea.com/${avatarList[randomNumber(0, avatarList.length - 1)]}?imageView2/1/w/200/h/200/format/webp/q/75|imageslim`
}
export const Constant = {
+34 -28
View File
@@ -1,20 +1,23 @@
{
"name": "antd-admin",
"version": "5.1.0",
"version": "5.2.0",
"license": "MIT",
"description": "An admin dashboard application demo built upon Ant Design and UmiJS",
"dependencies": {
"@ant-design/compatible": "^0.0.1-rc.1",
"@ant-design/icons": "^4.0.0",
"@lingui/react": "^2.8.0",
"ant-design-pro": "^2.3.0",
"antd": "^3.19.0",
"antd": "^4.0.0",
"axios": "^0.19.0",
"classnames": "^2.2.6",
"d3-shape": "^1.3.0",
"draftjs-to-html": "^0.8.4",
"draftjs-to-markdown": "^0.5.1",
"draftjs-to-html": "^0.9.0",
"draftjs-to-markdown": "^0.6.0",
"dva": "2.4.1",
"dva-model-extend": "^0.1.2",
"echarts": "^4.2.0",
"echarts-for-react": "^2.0.15-beta.0",
"echarts": "^4.4.0",
"echarts-for-react": "^2.0.15-beta.1",
"echarts-gl": "^1.1.1",
"echarts-liquidfill": "^2.0.2",
"enquire-js": "^0.2.1",
@@ -24,16 +27,16 @@
"lodash": "^4.17.11",
"md5": "^2.2.1",
"nprogress": "^0.2.0",
"path-to-regexp": "^3.0.0",
"path-to-regexp": "^3.1.0",
"prop-types": "^15.7.0",
"qs": "^6.7.0",
"qs": "^6.9.0",
"react-adsense": "^0.1.0",
"react-countup": "^4.1.0",
"react-countup": "^4.2.0",
"react-draft-wysiwyg": "^1.13.0",
"react-helmet": "^5.2.0",
"react-highcharts": "^16.0.2",
"react-highcharts": "^16.1.0",
"react-perfect-scrollbar": "^1.5.0",
"recharts": "^1.6.0",
"recharts": "^1.8.0",
"store": "^2.0.0"
},
"devDependencies": {
@@ -44,27 +47,30 @@
"babel-eslint": "^10.0.1",
"babel-plugin-dev-expression": "^0.2.1",
"babel-plugin-import": "^1.12.0",
"babel-plugin-macros": "^2.5.0",
"babel-plugin-module-resolver": "^3.2.0",
"cross-env": "^5.2.0",
"eslint": "^5.15.0",
"eslint-config-react-app": "^4.0.0",
"eslint-plugin-flowtype": "^3.4.0",
"eslint-plugin-import": "^2.17.0",
"babel-plugin-macros": "^2.6.0",
"babel-plugin-module-resolver": "^4.0.0",
"cross-env": "^7.0.0",
"eslint": "^6.8.0",
"eslint-config-react-app": "^5.0.0",
"eslint-plugin-flowtype": "^4.6.0",
"eslint-plugin-import": "^2.18.0",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.13.0",
"eslint-plugin-react-hooks": "^1.6.0",
"husky": "^2.3.0",
"eslint-plugin-react": "^7.14.0",
"eslint-plugin-react-hooks": "^2.5.0",
"husky": "^4.2.0",
"less-vars-to-js": "^1.3.0",
"lint-staged": "^8.1.0",
"lint-staged": "^10.0.0",
"mockjs": "^1.0.1-beta3",
"module": "^1.2.5",
"prettier": "^1.16.0",
"stylelint": "^10.0.0",
"stylelint-config-prettier": "^5.2.0",
"stylelint-config-standard": "^18.3.0",
"umi": "^2.8.1",
"umi-plugin-react": "^1.9.1"
"prettier": "^1.18.0",
"stylelint": "^13.0.0",
"stylelint-config-prettier": "^8.0.0",
"stylelint-config-standard": "^20.0.0",
"umi": "^2.13.0",
"umi-plugin-react": "^1.15.0"
},
"engines": {
"node": ">= 10.0.0"
},
"lint-staged": {
"src/**/*.js": [
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

+40
View File
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
<rect style="fill:#D80027;" width="512" height="512"/>
<polygon style="fill:#6DA544;" points="196.641,0 196.641,264.348 196.641,512 0,512 0,0 "/>
<circle style="fill:#FFDA44;" cx="196.641" cy="256" r="96"/>
<path style="fill:#D80027;" d="M142.638,208v60c0,29.823,24.178,54,54,54s54-24.178,54-54v-60H142.638z"/>
<path style="fill:#F0F0F0;" d="M196.638,286c-9.925,0-18-8.075-18-18v-24.001h36V268C214.638,277.925,206.563,286,196.638,286z"/>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 973 B

+4 -3
View File
@@ -1,6 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Dropdown, Button, Icon, Menu } from 'antd'
import { BarsOutlined, DownOutlined } from '@ant-design/icons'
import { Dropdown, Button, Menu } from 'antd'
const DropOption = ({
onMenuClick,
@@ -17,8 +18,8 @@ const DropOption = ({
{...dropdownProps}
>
<Button style={{ border: 'none', ...buttonStyle }}>
<Icon style={{ marginRight: 2 }} type="bars" />
<Icon type="down" />
<BarsOutlined style={{ marginRight: 2 }} />
<DownOutlined />
</Button>
</Dropdown>
)
+1 -3
View File
@@ -6,7 +6,7 @@ const FilterItem = ({ label = '', children }) => {
const labelArray = label.split('')
return (
<div className={styles.filterItem}>
{labelArray.length > 0 ? (
{labelArray.length > 0 && (
<div className={styles.labelWrap}>
{labelArray.map((item, index) => (
<span className="labelText" key={index}>
@@ -14,8 +14,6 @@ const FilterItem = ({ label = '', children }) => {
</span>
))}
</div>
) : (
''
)}
<div className={styles.item}>{children}</div>
</div>
+5 -4
View File
@@ -1,8 +1,9 @@
import React, { PureComponent, Fragment } from 'react'
import PropTypes from 'prop-types'
import { Breadcrumb, Icon } from 'antd'
import { Breadcrumb } from 'antd'
import Link from 'umi/navlink'
import withRouter from 'umi/withRouter'
import { Icon as LegacyIcon } from '@ant-design/compatible'
import { withI18n } from '@lingui/react'
import { pathMatchRegexp, queryAncestors, addLangPrefix } from 'utils'
import styles from './Bread.less'
@@ -14,9 +15,9 @@ class Bread extends PureComponent {
return paths.map((item, key) => {
const content = item && (
<Fragment>
{item.icon ? (
<Icon type={item.icon} style={{ marginRight: 4 }} />
) : null}
{item.icon && (
<LegacyIcon type={item.icon} style={{ marginRight: 4 }} />
)}
{item.name}
</Fragment>
)
+7 -9
View File
@@ -1,7 +1,9 @@
import React, { PureComponent, Fragment } from 'react'
import PropTypes from 'prop-types'
import { Menu, Icon, Layout, Avatar, Popover, Badge, List } from 'antd'
import { Menu, Layout, Avatar, Popover, Badge, List } from 'antd'
import { Ellipsis } from 'ant-design-pro'
import { Icon as LegacyIcon } from '@ant-design/compatible'
import { BellOutlined, RightOutlined } from '@ant-design/icons'
import { Trans, withI18n } from '@lingui/react'
import { setLocale } from 'utils'
import moment from 'moment'
@@ -85,7 +87,7 @@ class Header extends PureComponent {
trigger="click"
key="notifications"
overlayClassName={styles.notificationPopover}
getPopupContainer={() => document.querySelector('#layoutHeader')}
getPopupContainer={() => document.querySelector('#primaryLayout')}
content={
<div className={styles.notification}>
<List
@@ -104,11 +106,7 @@ class Header extends PureComponent {
}
description={moment(item.date).fromNow()}
/>
<Icon
style={{ fontSize: 10, color: '#ccc' }}
type="right"
theme="outlined"
/>
<RightOutlined style={{ fontSize: 10, color: '#ccc' }} />
</List.Item>
)}
/>
@@ -129,7 +127,7 @@ class Header extends PureComponent {
offset={[-10, 10]}
className={styles.iconButton}
>
<Icon className={styles.iconFont} type="bell" />
<BellOutlined className={styles.iconFont} />
</Badge>
</Popover>
)
@@ -146,7 +144,7 @@ class Header extends PureComponent {
className={styles.button}
onClick={onCollapseChange.bind(this, !collapsed)}
>
<Icon
<LegacyIcon
type={classnames({
'menu-unfold': collapsed,
'menu-fold': !collapsed,
+4 -3
View File
@@ -1,6 +1,7 @@
import React, { PureComponent, Fragment } from 'react'
import PropTypes from 'prop-types'
import { Menu, Icon } from 'antd'
import { Icon as LegacyIcon } from '@ant-design/compatible'
import { Menu } from 'antd'
import Navlink from 'umi/navlink'
import withRouter from 'umi/withRouter'
import {
@@ -46,7 +47,7 @@ class SiderMenu extends PureComponent {
key={item.id}
title={
<Fragment>
{item.icon && <Icon type={item.icon} />}
{item.icon && <LegacyIcon type={item.icon} />}
<span>{item.name}</span>
</Fragment>
}
@@ -58,7 +59,7 @@ class SiderMenu extends PureComponent {
return (
<Menu.Item key={item.id}>
<Navlink to={addLangPrefix(item.route) || '#'}>
{item.icon && <Icon type={item.icon} />}
{item.icon && <LegacyIcon type={item.icon} />}
<span>{item.name}</span>
</Navlink>
</Menu.Item>
+7 -5
View File
@@ -1,6 +1,7 @@
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import { Icon, Switch, Layout } from 'antd'
import { Switch, Layout } from 'antd'
import { BulbOutlined } from '@ant-design/icons'
import { withI18n, Trans } from '@lingui/react'
import ScrollBar from '../ScrollBar'
import { config } from 'utils'
@@ -28,13 +29,13 @@ class Sider extends PureComponent {
trigger={null}
collapsible
collapsed={collapsed}
onBreakpoint={isMobile ? null : onCollapseChange}
onBreakpoint={!isMobile && onCollapseChange}
className={styles.sider}
>
<div className={styles.brand}>
<div className={styles.logo}>
<img alt="logo" src={config.logoPath} />
{collapsed ? null : <h1>{config.siteName}</h1>}
{!collapsed && <h1>{config.siteName}</h1>}
</div>
</div>
@@ -49,14 +50,15 @@ class Sider extends PureComponent {
menus={menus}
theme={theme}
isMobile={isMobile}
collapsed={collapsed}
onCollapseChange={onCollapseChange}
/>
</ScrollBar>
</div>
{collapsed ? null : (
{!collapsed && (
<div className={styles.switchTheme}>
<span>
<Icon type="bulb" />
<BulbOutlined />
<Trans>Switch Theme</Trans>
</span>
<Switch
+11 -7
View File
@@ -1,16 +1,18 @@
import React, { Component } from 'react'
import withRouter from 'umi/withRouter'
import { LocaleProvider } from 'antd'
import { ConfigProvider } from 'antd'
import { I18nProvider } from '@lingui/react'
import { langFromPath, defaultLanguage } from 'utils'
import zh_CN from 'antd/lib/locale-provider/zh_CN'
import en_US from 'antd/lib/locale-provider/en_US'
import pt_BR from 'antd/lib/locale-provider/pt_BR'
import BaseLayout from './BaseLayout'
const languages = {
zh: zh_CN,
en: en_US,
'pt-br': pt_BR,
}
@withRouter
@@ -24,7 +26,7 @@ class Layout extends Component {
componentDidMount() {
const language = langFromPath(this.props.location.pathname)
this.language = language
this.loadCatalog(language)
language && this.loadCatalog(language)
}
shouldComponentUpdate(nextProps, nextState) {
@@ -33,7 +35,7 @@ class Layout extends Component {
const { catalogs } = nextState
if (preLanguage !== language && !catalogs[language]) {
this.loadCatalog(language)
language && this.loadCatalog(language)
this.language = language
return false
}
@@ -43,8 +45,10 @@ class Layout extends Component {
}
loadCatalog = async language => {
const catalog = await import(/* webpackMode: "lazy", webpackChunkName: "i18n-[index]" */
`@lingui/loader!../locales/${language}/messages.json`)
const catalog = await import(
/* webpackMode: "lazy", webpackChunkName: "i18n-[index]" */
`@lingui/loader!../locales/${language}/messages.json`
)
this.setState(state => ({
catalogs: {
@@ -63,11 +67,11 @@ class Layout extends Component {
if (!catalogs[language]) language = defaultLanguage
return (
<LocaleProvider locale={languages[language]}>
<ConfigProvider locale={languages[language]}>
<I18nProvider language={language} catalogs={catalogs}>
<BaseLayout>{children}</BaseLayout>
</I18nProvider>
</LocaleProvider>
</ConfigProvider>
)
}
}
+18 -7
View File
@@ -11,6 +11,14 @@ import config from 'config'
const { queryRouteList, logoutUser, queryUserInfo } = api
const goDashboard = () => {
if (pathMatchRegexp(['/', '/login'], window.location.pathname)) {
router.push({
pathname: '/dashboard',
})
}
}
export default {
namespace: 'app',
state: {
@@ -69,9 +77,14 @@ export default {
},
effects: {
*query({ payload }, { call, put, select }) {
const { success, user } = yield call(queryUserInfo, payload)
// store isInit to prevent query trigger by refresh
const isInit = store.get('isInit')
if (isInit) {
goDashboard()
return
}
const { locationPathname } = yield select(_ => _.app)
const { success, user } = yield call(queryUserInfo, payload)
if (success && user) {
const { list } = yield call(queryRouteList)
const { permissions } = user
@@ -96,11 +109,8 @@ export default {
store.set('routeList', routeList)
store.set('permissions', permissions)
store.set('user', user)
if (pathMatchRegexp(['/', '/login'], window.location.pathname)) {
router.push({
pathname: '/dashboard',
})
}
store.set('isInit', true)
goDashboard()
} else if (queryLayout(config.layouts, locationPathname) !== 'public') {
router.push({
pathname: '/login',
@@ -117,6 +127,7 @@ export default {
store.set('routeList', [])
store.set('permissions', { visit: [] })
store.set('user', {})
store.set('isInit', false)
yield put({ type: 'query' })
} else {
throw data
+2 -2
View File
@@ -1,12 +1,12 @@
import React from 'react'
import { Icon } from 'antd'
import { FrownOutlined } from '@ant-design/icons'
import { Page } from 'components'
import styles from './404.less'
const Error = () => (
<Page inner>
<div className={styles.error}>
<Icon type="frown-o" />
<FrownOutlined />
<h1>404 Not Found</h1>
</div>
</Page>
+1 -1
View File
@@ -73,7 +73,7 @@ function Completed({ data }) {
return (
<div className={styles.tooltip}>
<p className={styles.tiptitle}>{content.label}</p>
<ul>{list}</ul>
{content.payload && <ul>{list}</ul>}
</div>
)
}}
+4 -3
View File
@@ -1,6 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Icon, Card } from 'antd'
import { Icon as LegacyIcon } from '@ant-design/compatible'
import { Card } from 'antd'
import CountUp from 'react-countup'
import styles from './numberCard.less'
@@ -11,7 +12,7 @@ function NumberCard({ icon, color, title, number, countUp }) {
bordered={false}
bodyStyle={{ padding: 10 }}
>
<Icon className={styles.iconWarp} style={{ color }} type={icon} />
<LegacyIcon className={styles.iconWarp} style={{ color }} type={icon} />
<div className={styles.content}>
<p className={styles.title}>{title || 'No Title'}</p>
<p className={styles.number}>
@@ -22,7 +23,7 @@ function NumberCard({ icon, color, title, number, countUp }) {
useEasing
useGrouping
separator=","
{...countUp || {}}
{...(countUp || {})}
/>
</p>
</div>
+1 -1
View File
@@ -73,7 +73,7 @@ function Sales({ data }) {
return (
<div className={styles.tooltip}>
<p className={styles.tiptitle}>{content.label}</p>
<ul>{list}</ul>
{content.payload && <ul>{list}</ul>}
</div>
)
}}
+5 -2
View File
@@ -1,8 +1,11 @@
import React, { PureComponent, Fragment } from 'react'
import PropTypes from 'prop-types'
import { connect } from 'dva'
import { Button, Row, Form, Icon, Input } from 'antd'
import { Button, Row, Input } from 'antd'
import { GlobalFooter } from 'ant-design-pro'
import { Form } from '@ant-design/compatible'
import '@ant-design/compatible/assets/index.css'
import { GithubOutlined } from '@ant-design/icons'
import { Trans, withI18n } from '@lingui/react'
import { setLocale } from 'utils'
import config from 'utils/config'
@@ -32,7 +35,7 @@ class Login extends PureComponent {
let footerLinks = [
{
key: 'github',
title: <Icon type="github" />,
title: <GithubOutlined />,
href: 'https://github.com/zuiidea/antd-admin',
blankTarget: true,
},
+1 -1
View File
@@ -16,7 +16,7 @@ export default {
const { from } = locationQuery
yield put({ type: 'app/query' })
if (!pathMatchRegexp('/login', from)) {
if (from === '/') router.push('/dashboard')
if (['', '/'].includes(from)) router.push('/dashboard')
else router.push(from)
} else {
router.push('/dashboard')
+21 -14
View File
@@ -18,12 +18,23 @@ const EnumPostStatus = {
@withI18n()
@connect(({ post, loading }) => ({ post, loading }))
class Post extends PureComponent {
render() {
const { post, loading, location, i18n } = this.props
handleTabClick = key => {
const { pathname } = this.props.location
router.push({
pathname,
search: stringify({
status: key,
}),
})
}
get listProps() {
const { post, loading, location } = this.props
const { list, pagination } = post
const { query, pathname } = location
const listProps = {
return {
pagination,
dataSource: list,
loading: loading.effects['post/query'],
@@ -38,15 +49,11 @@ class Post extends PureComponent {
})
},
}
}
const handleTabClick = key => {
router.push({
pathname,
search: stringify({
status: key,
}),
})
}
render() {
const { location, i18n } = this.props
const { query } = location
return (
<Page inner>
@@ -56,19 +63,19 @@ class Post extends PureComponent {
? String(EnumPostStatus.UNPUBLISH)
: String(EnumPostStatus.PUBLISHED)
}
onTabClick={handleTabClick}
onTabClick={this.handleTabClick}
>
<TabPane
tab={i18n.t`Publised`}
key={String(EnumPostStatus.PUBLISHED)}
>
<List {...listProps} />
<List {...this.listProps} />
</TabPane>
<TabPane
tab={i18n.t`Unpublished`}
key={String(EnumPostStatus.UNPUBLISH)}
>
<List {...listProps} />
<List {...this.listProps} />
</TabPane>
</Tabs>
</Page>
+5 -15
View File
@@ -1,19 +1,11 @@
import React from 'react'
import { request } from 'utils'
import { apiPrefix } from 'utils/config'
import {
Row,
Col,
Select,
Input,
Button,
List,
Tag,
Form,
Icon,
Checkbox,
} from 'antd'
import { Row, Col, Select, Input, Button, List, Tag, Checkbox } from 'antd'
import classnames from 'classnames'
import { Form } from '@ant-design/compatible'
import '@ant-design/compatible/assets/index.css'
import { CloseOutlined } from '@ant-design/icons'
import { Trans } from '@lingui/react'
import api from '@/services/api'
import { Page } from 'components'
@@ -226,11 +218,9 @@ class RequestPage extends React.Component {
)}
</Col>
<Col style={{ marginTop: 8 }}>
<Icon
<CloseOutlined
onClick={this.handleRemoveField.bind(this, key)}
style={{ cursor: 'pointer' }}
type="close"
theme="outlined"
/>
</Col>
</Row>
+6 -2
View File
@@ -1,10 +1,14 @@
/* global document */
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import moment from 'moment'
import { FilterItem } from 'components'
/* global document */
import { Form } from '@ant-design/compatible'
import '@ant-design/compatible/assets/index.css'
import { Trans, withI18n } from '@lingui/react'
import { Form, Button, Row, Col, DatePicker, Input, Cascader } from 'antd'
import { Button, Row, Col, DatePicker, Input, Cascader } from 'antd'
import city from 'utils/city'
const { Search } = Input
+3 -1
View File
@@ -1,6 +1,8 @@
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import { Form, Input, InputNumber, Radio, Modal, Cascader } from 'antd'
import { Input, InputNumber, Radio, Modal, Cascader } from 'antd'
import { Form } from '@ant-design/compatible'
import '@ant-design/compatible/assets/index.css'
import { Trans, withI18n } from '@lingui/react'
import city from 'utils/city'
+54 -49
View File
@@ -13,40 +13,46 @@ import Modal from './components/Modal'
@withI18n()
@connect(({ user, loading }) => ({ user, loading }))
class User extends PureComponent {
componentDidMount() {
this.handleRefresh({ page: 1, pageSize: 10 })
}
handleRefresh = newQuery => {
const { location, dispatch } = this.props
const { location } = this.props
const { query, pathname } = location
const payload = {
...query,
...newQuery,
}
dispatch({
type: 'user/query',
payload,
})
router.push({
pathname,
search: stringify(payload, { arrayFormat: 'repeat' }),
search: stringify(
{
...query,
...newQuery,
},
{ arrayFormat: 'repeat' }
),
})
}
render() {
const { location, dispatch, user, loading, i18n } = this.props
const { query } = location
const {
list,
pagination,
currentItem,
modalVisible,
modalType,
selectedRowKeys,
} = user
handleDeleteItems = () => {
const { dispatch, user } = this.props
const { list, pagination, selectedRowKeys } = user
const modalProps = {
dispatch({
type: 'user/multiDelete',
payload: {
ids: selectedRowKeys,
},
}).then(() => {
this.handleRefresh({
page:
list.length === selectedRowKeys.length && pagination.current > 1
? pagination.current - 1
: pagination.current,
})
})
}
get modalProps() {
const { dispatch, user, loading, i18n } = this.props
const { currentItem, modalVisible, modalType } = user
return {
item: modalType === 'create' ? {} : currentItem,
visible: modalVisible,
destroyOnClose: true,
@@ -56,7 +62,7 @@ class User extends PureComponent {
modalType === 'create' ? i18n.t`Create User` : i18n.t`Update User`
}`,
centered: true,
onOk(data) {
onOk: data => {
dispatch({
type: `user/${modalType}`,
payload: data,
@@ -70,8 +76,13 @@ class User extends PureComponent {
})
},
}
}
const listProps = {
get listProps() {
const { dispatch, user, loading } = this.props
const { list, pagination, selectedRowKeys } = user
return {
dataSource: list,
loading: loading.effects['user/query'],
pagination,
@@ -81,7 +92,7 @@ class User extends PureComponent {
pageSize: page.pageSize,
})
},
onDeleteItem(id) {
onDeleteItem: id => {
dispatch({
type: 'user/delete',
payload: id,
@@ -115,8 +126,13 @@ class User extends PureComponent {
},
},
}
}
const filterProps = {
get filterProps() {
const { location, dispatch } = this.props
const { query } = location
return {
filter: {
...query,
},
@@ -134,26 +150,15 @@ class User extends PureComponent {
})
},
}
}
const handleDeleteItems = () => {
dispatch({
type: 'user/multiDelete',
payload: {
ids: selectedRowKeys,
},
}).then(() => {
this.handleRefresh({
page:
list.length === selectedRowKeys.length && pagination.current > 1
? pagination.current - 1
: pagination.current,
})
})
}
render() {
const { user } = this.props
const { selectedRowKeys } = user
return (
<Page inner>
<Filter {...filterProps} />
<Filter {...this.filterProps} />
{selectedRowKeys.length > 0 && (
<Row style={{ marginBottom: 24, textAlign: 'right', fontSize: 13 }}>
<Col>
@@ -161,7 +166,7 @@ class User extends PureComponent {
<Popconfirm
title="Are you sure delete these items?"
placement="left"
onConfirm={handleDeleteItems}
onConfirm={this.handleDeleteItems}
>
<Button type="primary" style={{ marginLeft: 8 }}>
Remove
@@ -170,8 +175,8 @@ class User extends PureComponent {
</Col>
</Row>
)}
<List {...listProps} />
<Modal {...modalProps} />
<List {...this.listProps} />
<Modal {...this.modalProps} />
</Page>
)
}
+14 -1
View File
@@ -1,4 +1,3 @@
/* global window */
import modelExtend from 'dva-model-extend'
import { pathMatchRegexp } from 'utils'
import api from 'api'
@@ -22,6 +21,20 @@ export default modelExtend(pageModel, {
selectedRowKeys: [],
},
subscriptions: {
setup({ dispatch, history }) {
history.listen(location => {
if (pathMatchRegexp('/user', location.pathname)) {
const payload = location.query || { page: 1, pageSize: 10 }
dispatch({
type: 'query',
payload,
})
}
})
},
},
effects: {
*query({ payload = {} }, { call, put }) {
const data = yield call(queryUserList, payload)
+7 -2
View File
@@ -1,8 +1,13 @@
import { message } from 'antd'
export default {
onError(e) {
onError(e, a) {
e.preventDefault()
message.error(e.message)
if (e.message) {
message.error(e.message)
} else {
/* eslint-disable */
console.error(e)
}
},
}
+4
View File
@@ -86,6 +86,10 @@ body {
a:focus {
text-decoration: none;
}
.ant-table-layout-fixed table {
table-layout: auto;
}
}
@media (min-width: 1600px) {
:global {
+2 -2
View File
@@ -1,6 +1,6 @@
module.exports = {
siteName: 'AntD Admin',
copyright: 'Ant Design Admin © 2018 zuiidea',
copyright: 'Ant Design Admin ©2019 zuiidea',
logoPath: '/logo.svg',
apiPrefix: '/api/v1',
fixedHeader: true, // sticky primary layout header
@@ -21,7 +21,7 @@ module.exports = {
{
key: 'pt-br',
title: 'Português',
flag: '/brazil.svg',
flag: '/portugal.svg',
},
{
key: 'en',
+38 -17
View File
@@ -2,14 +2,18 @@ import { cloneDeep, isString, flow, curry } from 'lodash'
import umiRouter from 'umi/router'
import pathToRegexp from 'path-to-regexp'
import { i18n } from './config'
import moment from 'moment'
import 'moment/locale/zh-cn'
export classnames from 'classnames'
export config from './config'
export request from './request'
export { Color } from './theme'
export const { defaultLanguage } = i18n
export const languages = i18n.languages.map(item => item.key)
// export const { defaultLanguage } = i18n
// export const languages = i18n.languages.map(item => item.key)
export const languages = i18n ? i18n.languages.map(item => item.key) : []
export const defaultLanguage = i18n ? i18n.defaultLanguage : ''
/**
* Query objects that specify keys and values in an array where all values are objects.
@@ -59,23 +63,32 @@ export function arrayToTree(
return result
}
export const langFromPath = curry(
/**
* Query language from pathname.
* @param {array} languages Specify which languages are currently available.
* @param {string} defaultLanguage Specify the default language.
* @param {string} pathname Pathname to be queried.
* @return {string} Return the queryed language.
*/
(languages, defaultLanguage, pathname) => {
for (const item of languages) {
if (pathname.startsWith(`/${item}/`)) {
return item
}
// export const langFromPath = curry(
// /**
// * Query language from pathname.
// * @param {array} languages Specify which languages are currently available.
// * @param {string} defaultLanguage Specify the default language.
// * @param {string} pathname Pathname to be queried.
// * @return {string} Return the queryed language.
// */
// (languages, defaultLanguage, pathname) => {
// for (const item of languages) {
// if (pathname.startsWith(`/${item}/`)) {
// return item
// }
// }
// return defaultLanguage
// }
// )(languages)(defaultLanguage)
export const langFromPath = pathname => {
for (const item of languages) {
if (pathname.startsWith(`/${item}/`)) {
return item
}
return defaultLanguage
}
)(languages)(defaultLanguage)
return defaultLanguage
}
export const deLangPrefix = curry(
/**
@@ -104,11 +117,18 @@ export const deLangPrefix = curry(
* @return {string} Return the pathname after adding the language prefix.
*/
export function addLangPrefix(pathname) {
if (!i18n) {
return pathname
}
const prefix = langFromPath(window.location.pathname)
return `/${prefix}${deLangPrefix(pathname)}`
}
const routerAddLangPrefix = params => {
if (!i18n) {
return params
}
if (isString(params)) {
params = addLangPrefix(params)
} else {
@@ -245,6 +265,7 @@ export function getLocale() {
export function setLocale(language) {
if (getLocale() !== language) {
moment.locale(language === 'zh' ? 'zh-cn' : language)
umiRouter.push({
pathname: `/${language}${deLangPrefix(window.location.pathname)}`,
search: window.location.search,