Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02280fbed9 | ||
|
|
d897eb205d | ||
|
|
b1f290ea32 | ||
|
|
0e36b6b7a0 | ||
|
|
d92f121cf4 | ||
|
|
0a73ba0f12 | ||
|
|
9e4e0efbab | ||
|
|
524dff07d2 | ||
|
|
8b3e5c08f7 | ||
|
|
c17444f5d6 | ||
|
|
df85ecdfff | ||
|
|
b8824141d6 | ||
|
|
aedd2ec3db | ||
|
|
5abad21082 | ||
|
|
1ae41c7ae5 | ||
|
|
e41671dbf9 | ||
|
|
eaeb9092e4 | ||
|
|
2f3ca0a006 | ||
|
|
1b65351be4 | ||
|
|
0422f6d51e | ||
|
|
8d050d4040 | ||
|
|
82b3a4b384 | ||
|
|
d2f391a881 | ||
|
|
9e778487d9 | ||
|
|
7938d71f2f | ||
|
|
422a6fed30 | ||
|
|
c6ea0454b3 | ||
|
|
467767a6c5 | ||
|
|
cf795c512a | ||
|
|
18b499030d | ||
|
|
d800d6f3ce | ||
|
|
185f706107 | ||
|
|
5a4661cdad | ||
|
|
7abdd94a0e | ||
|
|
22f0684ab0 | ||
|
|
80b2c63693 | ||
|
|
4b2a553bda | ||
|
|
ad30e73b10 | ||
|
|
15b62e302d | ||
|
|
9d5ec20f20 | ||
|
|
c878425fd0 | ||
|
|
90e80dda64 | ||
|
|
1db5bfeab5 | ||
|
|
b2b3fcd4a3 | ||
|
|
9cf97375c7 | ||
|
|
7839b6affb | ||
|
|
597064a07d | ||
|
|
0ea57d14c9 | ||
|
|
afd736d615 | ||
|
|
ce9b8c376f | ||
|
|
79776e6752 | ||
|
|
a2432022a1 | ||
|
|
ea5ee96bdc | ||
|
|
fe954092a4 | ||
|
|
5e148fec92 | ||
|
|
5daa2a9548 | ||
|
|
f1913f7b18 | ||
|
|
65a453553e | ||
|
|
29da8f24da | ||
|
|
3443ad9968 | ||
|
|
838dc93eff | ||
|
|
07ef68ec1f | ||
|
|
3cb7f86086 | ||
|
|
fc9565c157 | ||
|
|
557f6022f3 | ||
|
|
d0a56169e3 | ||
|
|
f7d6e2b4ed | ||
|
|
df82ee42fd | ||
|
|
a29d761483 | ||
|
|
713a86b9d6 | ||
|
|
d6250f16b0 | ||
|
|
1c5d5c3788 | ||
|
|
699e9d9ff1 | ||
|
|
fad0cb931a | ||
|
|
5d7ff55869 | ||
|
|
642ccb5b82 | ||
|
|
51a7ce0827 | ||
|
|
157a54b11d | ||
|
|
be083d81fc | ||
|
|
f6c869ad47 | ||
|
|
bef5b26509 | ||
|
|
59cfe24178 | ||
|
|
87d0d58ae8 | ||
|
|
de8b6c972d | ||
|
|
0ac4839e94 | ||
|
|
565bce6d8b | ||
|
|
b278b028cf | ||
|
|
33abd9369e | ||
|
|
e6b2f7f271 | ||
|
|
0bd1e9cf59 | ||
|
|
693625bf2c | ||
|
|
3a6c587569 | ||
|
|
bd85eaf0a0 | ||
|
|
29aa0f416e | ||
|
|
5b32607911 | ||
|
|
76e5359752 | ||
|
|
5ec4efbb6e | ||
|
|
f8bb7b421a | ||
|
|
887c169aa8 | ||
|
|
8c10dcc6c2 | ||
|
|
671da6b5fa | ||
|
|
7fdb2f4ea8 | ||
|
|
67388b31f5 | ||
|
|
2379cca765 | ||
|
|
34be6651e5 | ||
|
|
10f8e3e8ef | ||
|
|
0c6ea8eb5c | ||
|
|
6e69b06e61 | ||
|
|
98ba383a68 | ||
|
|
4e6d81a9bf | ||
|
|
0e2c206023 | ||
|
|
285f06d1e7 | ||
|
|
6aead03f3e | ||
|
|
7eb9e06452 | ||
|
|
fab06d5005 | ||
|
|
16860f93ad | ||
|
|
6ba45d5bc3 |
@@ -1,23 +1,18 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- node
|
||||
- node
|
||||
script:
|
||||
- npm run build
|
||||
- npm run build
|
||||
before_install:
|
||||
- |
|
||||
if [ "$TRAVIS_BRANCH" = "develop" ]; then
|
||||
for prefixed_envvar in ${!DEV_*}; do
|
||||
eval export ${prefixed_envvar#DEV_}="${!prefixed_envvar}"
|
||||
done
|
||||
elif [ "$TRAVIS_BRANCH" = "master" ]; then
|
||||
for prefixed_envvar in ${!PROD_*}; do
|
||||
eval export ${prefixed_envvar#PROD_}="${!prefixed_envvar}"
|
||||
done
|
||||
fi
|
||||
- openssl aes-256-cbc -K $encrypted_18b2305b78c9_key -iv $encrypted_18b2305b78c9_iv -in config/id_rsa.enc -out ~/.ssh/id_rsa -d
|
||||
- chmod 600 ~/.ssh/id_rsa
|
||||
- echo -e "Host $HOST\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
||||
- yarn global add now
|
||||
- yarn global add now
|
||||
after_script:
|
||||
- scp -o stricthostkeychecking=no -r ./dist root@$HOST:$BUILD_DIR
|
||||
- cd ./docs && now -A $DOC_NOW_CONFIG -t $NOW_TOKEN && now alias -A $DOC_NOW_CONFIG -t $NOW_TOKEN
|
||||
- |
|
||||
if [[ $TRAVIS_BRANCH == 'master' ]]; then
|
||||
echo $PROD_SITE_NOW_CONFIG >> dist/vercel.json && echo $PROD_DOC_NOW_CONFIG >> docs/vercel.json;
|
||||
else
|
||||
echo $DEV_SITE_NOW_CONFIG >> dist/vercel.json && echo $DEV_DOC_NOW_CONFIG >> docs/vercel.json;
|
||||
fi
|
||||
- cd ./dist
|
||||
- now -A vercel.json -t $NOW_TOKEN --prod -c
|
||||
- cd ../docs
|
||||
- now -A vercel.json -t $NOW_TOKEN --prod -c
|
||||
|
||||
@@ -1,93 +1,28 @@
|
||||
// https://umijs.org/config/
|
||||
import { resolve } from 'path'
|
||||
import { i18n } from './src/utils/config'
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const lessToJs = require('less-vars-to-js')
|
||||
const isDevelopment = process.env.NODE_ENV === 'development'
|
||||
|
||||
// how to speed compile: https://umijs.org/guide/boost-compile-speed
|
||||
export default {
|
||||
ignoreMomentLocale: true,
|
||||
targets: { ie: 9 },
|
||||
plugins: [
|
||||
[
|
||||
// https://umijs.org/plugin/umi-plugin-react.html
|
||||
'umi-plugin-react',
|
||||
{
|
||||
dva: { immer: true },
|
||||
antd: true,
|
||||
dynamicImport: {
|
||||
webpackChunkName: true,
|
||||
loadingComponent: './components/Loader/Loader',
|
||||
},
|
||||
routes: {
|
||||
exclude: [
|
||||
/model\.(j|t)sx?$/,
|
||||
/service\.(j|t)sx?$/,
|
||||
/models\//,
|
||||
/components\//,
|
||||
/services\//,
|
||||
/chart\/Container\.js$/,
|
||||
/chart\/ECharts\/.+Component\.js$/,
|
||||
/chart\/ECharts\/.+ComPonent\.js$/,
|
||||
/chart\/ECharts\/theme\/.+\.js$/,
|
||||
/chart\/highCharts\/.+Component\.js$/,
|
||||
/chart\/highCharts\/mapdata\/.+\.js$/,
|
||||
/chart\/Recharts\/.+Component\.js$/,
|
||||
/chart\/Recharts\/Container\.js$/,
|
||||
],
|
||||
update: routes => {
|
||||
if (!i18n) return routes
|
||||
|
||||
const newRoutes = []
|
||||
for (const item of routes[0].routes) {
|
||||
newRoutes.push(item)
|
||||
if (item.path) {
|
||||
newRoutes.push(
|
||||
Object.assign({}, item, {
|
||||
path:
|
||||
`/:lang(${i18n.languages
|
||||
.map(item => item.key)
|
||||
.join('|')})` + item.path,
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
routes[0].routes = newRoutes
|
||||
|
||||
return routes
|
||||
},
|
||||
},
|
||||
dll: {
|
||||
include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch', 'antd/es'],
|
||||
},
|
||||
hardSource: /* isMac */ process.platform === 'darwin',
|
||||
pwa: {
|
||||
manifestOptions: {
|
||||
srcPath: 'manifest.json'
|
||||
},
|
||||
}
|
||||
},
|
||||
],
|
||||
],
|
||||
// Theme for antd
|
||||
// https://ant.design/docs/react/customize-theme
|
||||
theme: './config/theme.config.js',
|
||||
// Webpack Configuration
|
||||
proxy: {
|
||||
'/api/v1/weather': {
|
||||
target: 'https://api.seniverse.com/',
|
||||
changeOrigin: true,
|
||||
pathRewrite: { '^/api/v1/weather': '/v3/weather' },
|
||||
},
|
||||
},
|
||||
// IMPORTANT! change next line to yours or delete. And hide in dev
|
||||
publicPath: isDevelopment ? '/' : 'https://cdn.antd-admin.zuiidea.com/',
|
||||
alias: {
|
||||
api: resolve(__dirname, './src/services/'),
|
||||
components: resolve(__dirname, './src/components'),
|
||||
config: resolve(__dirname, './src/utils/config'),
|
||||
models: resolve(__dirname, './src/models'),
|
||||
routes: resolve(__dirname, './src/routes'),
|
||||
services: resolve(__dirname, './src/services'),
|
||||
themes: resolve(__dirname, './src/themes'),
|
||||
utils: resolve(__dirname, './src/utils'),
|
||||
},
|
||||
extraBabelPresets: ['@lingui/babel-preset-react'],
|
||||
antd: {},
|
||||
// a lower cost way to genereate sourcemap, default is cheap-module-source-map, could save 60% time in dev hotload
|
||||
devtool: 'eval',
|
||||
dva: { immer: true },
|
||||
dynamicImport: {
|
||||
loading: 'components/Loader/Loader',
|
||||
},
|
||||
extraBabelPlugins: [
|
||||
[
|
||||
'import',
|
||||
@@ -98,5 +33,103 @@ export default {
|
||||
},
|
||||
'lodash',
|
||||
],
|
||||
[
|
||||
'import',
|
||||
{
|
||||
libraryName: '@ant-design/icons',
|
||||
libraryDirectory: 'es/icons',
|
||||
camel2DashComponentName: false,
|
||||
},
|
||||
'ant-design-icons',
|
||||
],
|
||||
[
|
||||
'macros'
|
||||
]
|
||||
],
|
||||
hash: true,
|
||||
ignoreMomentLocale: true,
|
||||
// umi3 comple node_modules by default, could be disable
|
||||
nodeModulesTransform: {
|
||||
type: 'none',
|
||||
exclude: [],
|
||||
},
|
||||
// Webpack Configuration
|
||||
proxy: {
|
||||
'/api/v1/weather': {
|
||||
target: 'https://api.seniverse.com/',
|
||||
changeOrigin: true,
|
||||
pathRewrite: { '^/api/v1/weather': '/v3/weather' },
|
||||
},
|
||||
},
|
||||
targets: { ie: 9 },
|
||||
// Theme for antd
|
||||
// https://ant.design/docs/react/customize-theme
|
||||
theme: lessToJs(
|
||||
fs.readFileSync(path.join(__dirname, './src/themes/default.less'), 'utf8')
|
||||
),
|
||||
webpack5: {},
|
||||
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)[\\/]/,
|
||||
},
|
||||
'echarts-gl': {
|
||||
name: 'echarts-gl',
|
||||
priority: 30,
|
||||
test: /[\\/]node_modules[\\/]echarts-gl[\\/]/,
|
||||
},
|
||||
zrender: {
|
||||
name: 'zrender',
|
||||
priority: 30,
|
||||
test: /[\\/]node_modules[\\/]zrender[\\/]/,
|
||||
},
|
||||
echarts: {
|
||||
name: 'echarts',
|
||||
priority: 20,
|
||||
test: /[\\/]node_modules[\\/](echarts|echarts-for-react|echarts-liquidfill)[\\/]/,
|
||||
},
|
||||
highcharts: {
|
||||
name: 'highcharts',
|
||||
priority: 20,
|
||||
test: /[\\/]node_modules[\\/]highcharts[\\/]/,
|
||||
},
|
||||
recharts: {
|
||||
name: 'recharts',
|
||||
priority: 20,
|
||||
test: /[\\/]node_modules[\\/]recharts[\\/]/,
|
||||
},
|
||||
draftjs: {
|
||||
name: 'draftjs',
|
||||
priority: 30,
|
||||
test: /[\\/]node_modules[\\/](draft-js|react-draft-wysiwyg|draftjs-to-html|draftjs-to-markdown)[\\/]/,
|
||||
},
|
||||
async: {
|
||||
chunks: 'async',
|
||||
minChunks: 2,
|
||||
name: 'async',
|
||||
maxInitialRequests: 1,
|
||||
minSize: 0,
|
||||
priority: 5,
|
||||
reuseExistingChunk: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
## 使用
|
||||
|
||||
1. 下载项目代码。
|
||||
1. 下载项目代码。
|
||||
|
||||
```bash
|
||||
git clone https://github.com/zuiidea/antd-admin.git my-project
|
||||
@@ -71,11 +71,11 @@ npm run start
|
||||
|
||||
## 支持环境
|
||||
|
||||
现代浏览器及 IE9。
|
||||
现代浏览器。
|
||||
|
||||
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png" alt="Opera" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Opera |
|
||||
| --------- | --------- | --------- | --------- | --------- |
|
||||
| IE9, IE10, IE11, Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions
|
||||
|IE11, Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions
|
||||
|
||||
## 参与贡献
|
||||
|
||||
@@ -84,4 +84,4 @@ npm run start
|
||||
- 通过 [Issue](http://github.com/zuiidea/antd-admin/issues) 报告 bug 或进行咨询。
|
||||
- 提交 [Pull Request](http://github.com/zuiidea/antd-admin/pulls) 改进代码。
|
||||
|
||||
> 强烈推荐阅读 [《提问的智慧》](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way)、[《如何向开源社区提问题》](https://github.com/seajs/seajs/issues/545) 和 [《如何有效地报告 Bug》](http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html)、[《如何向开源项目提交无法解答的问题》](https://zhuanlan.zhihu.com/p/25795393),更好的问题更容易获得帮助。
|
||||
> 强烈推荐阅读 [《提问的智慧》](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way)、[《如何向开源社区提问题》](https://github.com/seajs/seajs/issues/545) 和 [《如何有效地报告 Bug》](http://www.chiark.greenend.org.uk/%7Esgtatham/bugs-cn.html)、[《如何向开源项目提交无法解答的问题》](https://zhuanlan.zhihu.com/p/25795393),更好的问题更容易获得帮助。
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
A excellent front-end solution for enterprise applications.
|
||||
An excellent front-end solution for enterprise applications.
|
||||
|
||||
[](https://github.com/ant-design/ant-design)
|
||||
[](https://github.com/ant-design/ant-design)
|
||||
[](https://github.com/umijs/umi)
|
||||
[](https://github.com/zuiidea/antd-admin/issues)
|
||||
[](http://opensource.org/licenses/MIT)
|
||||
@@ -71,11 +71,11 @@ npm run start
|
||||
|
||||
## Browsers support
|
||||
|
||||
Modern browsers and IE9.
|
||||
Modern browsers.
|
||||
|
||||
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png" alt="Opera" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Opera |
|
||||
| --------- | --------- | --------- | --------- | --------- |
|
||||
| IE9, IE10, IE11, Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions
|
||||
|IE11, Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const lessToJs = require('less-vars-to-js')
|
||||
|
||||
module.exports = () => {
|
||||
const themePath = path.join(__dirname, '../src/themes/default.less')
|
||||
return lessToJs(fs.readFileSync(themePath, 'utf8'))
|
||||
}
|
||||
@@ -5,11 +5,11 @@
|
||||
In the use of `redux` or `dva` projects, we often write functions like the following `service` layer to make the code structure clearer, but it is easy to see that we will write a lot of similar code in `antd -admin@5.0`, using the more concise configuration method to achieve the same function.
|
||||
|
||||
```javascript
|
||||
Export async function login(data) {
|
||||
Return request({
|
||||
Url: '/api/v1/user/login',
|
||||
Method: 'post',
|
||||
Data,
|
||||
export async function login(data) {
|
||||
return request({
|
||||
url: '/api/v1/user/login',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
```
|
||||
@@ -19,7 +19,7 @@ Export async function login(data) {
|
||||
In the `src/services/api.js` file, you will see the following configuration object, the object's key is used to call the function name, the object's value is the requested `url`, the default request method is `GET`, The format of the value of the other request mode object is `'method url'`.
|
||||
|
||||
```javascript
|
||||
Export default {
|
||||
export default {
|
||||
...
|
||||
queryUser: '/user/:id',
|
||||
queryUserList: '/users',
|
||||
@@ -34,7 +34,7 @@ Export default {
|
||||
Used in other files
|
||||
|
||||
```javascript
|
||||
Import { queryUser } from 'api'
|
||||
import { queryUser } from 'api'
|
||||
|
||||
// in the general file
|
||||
...
|
||||
@@ -43,7 +43,7 @@ queryUser(option).then(data => console.log(data))
|
||||
|
||||
/ / Model file
|
||||
...
|
||||
Yield call(queryUser, option)
|
||||
yield call(queryUser, option)
|
||||
...
|
||||
```
|
||||
|
||||
@@ -52,35 +52,35 @@ Yield call(queryUser, option)
|
||||
Refer to the `src/services/index.js` file to traverse the api configuration. Each property returns the corresponding encapsulated request function.
|
||||
|
||||
```javascript
|
||||
Import request from 'utils/request'
|
||||
Import { apiPrefix } from 'utils/config'
|
||||
import request from 'utils/request'
|
||||
import { apiPrefix } from 'utils/config'
|
||||
|
||||
Import api from './api'
|
||||
import api from './api'
|
||||
|
||||
Const gen = params => {
|
||||
Let url = apiPrefix + params
|
||||
Let method = 'GET'
|
||||
const gen = params => {
|
||||
let url = apiPrefix + params
|
||||
let method = 'GET'
|
||||
|
||||
Const paramsArray = params.split(' ')
|
||||
If (paramsArray.length === 2) {
|
||||
Method = paramsArray[0]
|
||||
Url = apiPrefix + paramsArray[1]
|
||||
const paramsArray = params.split(' ')
|
||||
if (paramsArray.length === 2) {
|
||||
method = paramsArray[0]
|
||||
url = apiPrefix + paramsArray[1]
|
||||
}
|
||||
|
||||
Return function(data) {
|
||||
Return request({
|
||||
Url,
|
||||
Data,
|
||||
Method,
|
||||
return function(data) {
|
||||
return request({
|
||||
url,
|
||||
data,
|
||||
method,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Const APIFunction = {}
|
||||
For (const key in api) {
|
||||
const APIFunction = {}
|
||||
for (const key in api) {
|
||||
APIFunction[key] = gen(api[key])
|
||||
}
|
||||
|
||||
Module.exports = APIFunction
|
||||
module.exports = APIFunction
|
||||
|
||||
```
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
<div align="center">
|
||||
|
||||
A excellent front-end solution for enterprise applications.
|
||||
An excellent front-end solution for enterprise applications.
|
||||
|
||||
[](https://github.com/ant-design/ant-design)
|
||||
[](https://github.com/umijs/umi)
|
||||
@@ -68,11 +68,11 @@ npm run start
|
||||
|
||||
## Browsers support
|
||||
|
||||
Modern browsers and IE9.
|
||||
Modern browsers.
|
||||
|
||||
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png" alt="Opera" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Opera |
|
||||
| --------- | --------- | --------- | --------- | --------- |
|
||||
| IE9, IE10, IE11, Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions
|
||||
|IE11, Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
@@ -9,3 +9,4 @@
|
||||
- Guide
|
||||
- [Deploy](deploy.md)
|
||||
- [Change Log](change-log.md)
|
||||
- [FAQ](faq.md)
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
- Support internationalization, extract source fields from source code, load language packs on demand, and automatically translate online.
|
||||
|
||||
- Support for the introduction of `ant-design-pro` components, `lodash` functions on demand.
|
||||
- Support for the introduction `lodash` functions on demand.
|
||||
|
||||
- Support multiple layouts, which rules can be used according to the rules.
|
||||
|
||||
|
||||
@@ -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/pathToRegexp in model.js
|
||||
3. modify mock route.js to add a route
|
||||
@@ -12,7 +12,7 @@ Take Japanese as an example.
|
||||
npm run add-locale ja
|
||||
```
|
||||
|
||||
2. Extract the fields in the code that need to be translated, ie `<Trans>?message</Trans>`, `` i18n.t`message `` in the `message` field, run the following command after `src/locales/ja /messages.json` will appear after the extracted field configuration.
|
||||
2. Extract the fields in the code that need to be translated, ie `<Trans>?message</Trans>`, `` t`message `` in the `message` field, run the following command after `src/locales/ja /messages.json` will appear after the extracted field configuration.
|
||||
|
||||
```bash
|
||||
npm run extract
|
||||
|
||||
@@ -2,59 +2,59 @@
|
||||
|
||||
## Add a new layout
|
||||
|
||||
Take a new layout named `secondary` as an example to make the route starting with `seconday` use this layout.
|
||||
Take a new layout named `secondary` as an example to make the route starting with `secondary` use this layout.
|
||||
|
||||
1. Add related configuration in `src/utils/config.js`. For details, please refer to [layouts](/configuration?id=layouts).
|
||||
|
||||
```javascript
|
||||
```javascript
|
||||
layouts: [
|
||||
{
|
||||
name: 'primary',
|
||||
include: [/.*/],
|
||||
exlude: [/(\/(en|zh))*\/login/, /(\/(en|zh))*\/seconday\/(.*)/],
|
||||
exclude: [/(\/(en|zh))*\/login/, /(\/(en|zh))*\/secondary\/(.*)/],
|
||||
},
|
||||
{
|
||||
name: 'secondary',
|
||||
include: [/(\/(en|zh))*\/seconday\/(.*)/],
|
||||
include: [/(\/(en|zh))*\/secondary\/(.*)/],
|
||||
},
|
||||
],
|
||||
```
|
||||
```
|
||||
|
||||
2. Add the `secondary` layout component to the `src/layouts/BaseLayout.js` file.
|
||||
|
||||
```javascript
|
||||
```javascript
|
||||
import SecondaryLayout from './SecondaryLayout'
|
||||
|
||||
const LayoutMap = {
|
||||
Primary: PrimaryLayout,
|
||||
Public: PublicLayout,
|
||||
Secondary: SecondaryLayout,
|
||||
primary: PrimaryLayout,
|
||||
public: PublicLayout,
|
||||
secondary: SecondaryLayout,
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
3. Add the `SecondaryLayout.js` file to the `src/layouts/` directory.
|
||||
|
||||
```javascript
|
||||
```javascript
|
||||
import React from 'react'
|
||||
|
||||
export default ({ children }) => {
|
||||
Return (
|
||||
return (
|
||||
<div>
|
||||
<h1>Seconday</h1>
|
||||
<h1>Secondary</h1>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
4. Add a `seconday/index.js` file to the `src/pages/` directory.
|
||||
4. Add a `secondary/index.js` file to the `src/pages/` directory.
|
||||
|
||||
```javascript
|
||||
```javascript
|
||||
import React from 'react'
|
||||
|
||||
export default ({ children }) => {
|
||||
Return <div>Seconday page Content</div>
|
||||
Return <div>Secondary page Content</div>
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
5. Finally, start the development mode `npm run start`, open [http://localhost:7000/seconday/](http://localhost:7000/seconday/) and you will see the page for the `seconday` layout.
|
||||
5. Finally, start the development mode `npm run start`, open [http://localhost:7000/secondary/](http://localhost:7000/secondary/) and you will see the page for the `secondary` layout.
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"name": "antd-admin-devdoc",
|
||||
"alias": ["devdoc-antd-admin.now.sh", "devdoc.antd-admin.zuiidea.com"],
|
||||
"type": "static",
|
||||
"public": true
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"name": "antd-admin-doc",
|
||||
"alias": ["doc-antd-admin.now.sh", "doc.antd-admin.zuiidea.com"],
|
||||
"type": "static",
|
||||
"public": true
|
||||
}
|
||||
@@ -68,11 +68,11 @@ npm run start
|
||||
|
||||
## 支持环境
|
||||
|
||||
现代浏览器及 IE9。
|
||||
现代浏览器。
|
||||
|
||||
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Safari | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/opera/opera_48x48.png" alt="Opera" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)</br>Opera |
|
||||
| --------- | --------- | --------- | --------- | --------- |
|
||||
| IE9, IE10, IE11, Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions
|
||||
|IE11, Edge| last 2 versions| last 2 versions| last 2 versions| last 2 versions
|
||||
|
||||
## 参与贡献
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
- 支持国际化,源码中抽离翻译字段,按需加载语言包,自动在线翻译。
|
||||
|
||||
- 支持按需引入 `ant-design-pro` 组件、`lodash` 函数。
|
||||
- 支持按需引入 `lodash` 函数。
|
||||
|
||||
- 支持多布局,可根据规则规定哪些路由使用哪种布局。
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
{
|
||||
name: 'primary',
|
||||
include: [/.*/],
|
||||
exlude: [/(\/(en|zh))*\/login/],
|
||||
exclude: [/(\/(en|zh))*\/login/],
|
||||
},
|
||||
],
|
||||
```
|
||||
@@ -55,9 +55,9 @@
|
||||
|
||||
- `include` - 指定使用该布局的路由规则列表,规则可为正则表达式或者字符串;
|
||||
|
||||
- `exlude` - 指定不使用该布局的路由规则列表,规则可为正则表达式或者字符串。
|
||||
- `exclude` - 指定不使用该布局的路由规则列表,规则可为正则表达式或者字符串。
|
||||
|
||||
> 注意:`exlude` 优先级高于 `include`,前面的布局优先级高于后面的布局。开发过程中可能需要结合`src/layouts`目录下的布局使用,具体方法可查看 [使用布局](./layout.md)。
|
||||
> 注意:`exclude` 优先级高于 `include`,前面的布局优先级高于后面的布局。开发过程中可能需要结合`src/layouts`目录下的布局使用,具体方法可查看 [使用布局](./layout.md)。
|
||||
|
||||
## i18n
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ File sizes after gzip:
|
||||
|
||||
`build` 命令会打包所有的资源,包含 JavaScript, CSS, web fonts, images, html 等。你可以在 `dist/` 目录下找到这些文件。
|
||||
|
||||
> 如果 有使用 HashHistory 、 部署 html 到非根目录、静态化等需求,请查看[Umi 部署](https://umijs.org/zh/guide/deploy.html)。
|
||||
> 如果有使用 HashHistory 、 部署 html 到非根目录、静态化等需求,请查看[Umi 部署](https://umijs.org/zh/guide/deploy.html)。
|
||||
|
||||
## 本地验证
|
||||
|
||||
|
||||
@@ -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/pathToRegexp 在 model.js
|
||||
3. 修改 mock中route.js增加一条route
|
||||
@@ -12,7 +12,7 @@
|
||||
npm run add-locale ja
|
||||
```
|
||||
|
||||
2. 提取代码中需要翻译的字段,即 `<Trans>message</Trans>`、`` i18n.t`message `` 中 `message` 字段,运行下面命令后 `src/locales/ja/messages.json` 将会出现提取后的字段配置。
|
||||
2. 提取代码中需要翻译的字段,即 `<Trans>message</Trans>`、`` intl.formatMessage({ id: 'message `` 中 `message` 字段,运行下面命令后 `src/locales/ja/messages.json' }) 将会出现提取后的字段配置。
|
||||
|
||||
```bash
|
||||
npm run extract
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
## 新增布局
|
||||
|
||||
以新增名为 `secondary` 的布局为例,使以 `seconday` 开头的路由都使用该布局。
|
||||
以新增名为 `secondary` 的布局为例,使以 `secondary` 开头的路由都使用该布局。
|
||||
|
||||
1. 在 `src/utils/config.js` 新增相关配置,参数详细请查看 [layouts](/zh-cn/configuration?id=layouts)。
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
{
|
||||
name: 'primary',
|
||||
include: [/.*/],
|
||||
exlude: [/(\/(en|zh))*\/login/, /(\/(en|zh))*\/seconday\/(.*)/],
|
||||
exclude: [/(\/(en|zh))*\/login/, /(\/(en|zh))*\/secondary\/(.*)/],
|
||||
},
|
||||
{
|
||||
name: 'secondary',
|
||||
include: [/(\/(en|zh))*\/seconday\/(.*)/],
|
||||
include: [/(\/(en|zh))*\/secondary\/(.*)/],
|
||||
},
|
||||
],
|
||||
```
|
||||
@@ -40,21 +40,21 @@
|
||||
export default ({ children }) => {
|
||||
return (
|
||||
<div>
|
||||
<h1>Seconday</h1>
|
||||
<h1>Secondary</h1>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
4. 在`src/pages/` 目录中新增 `seconday/index.js` 文件。
|
||||
4. 在`src/pages/` 目录中新增 `secondary/index.js` 文件。
|
||||
|
||||
```javascript
|
||||
import React from 'react'
|
||||
|
||||
export default ({ children }) => {
|
||||
return <div>Seconday page Content</div>
|
||||
return <div>Secondary page Content</div>
|
||||
}
|
||||
```
|
||||
|
||||
5. 最后,启动开发模式 `npm run start`,打开 [http://localhost:7000/seconday/](http://localhost:7000/seconday/),你将看到 `seconday` 布局的页面。
|
||||
5. 最后,启动开发模式 `npm run start`,打开 [http://localhost:7000/secondary/](http://localhost:7000/secondary/),你将看到 `secondary` 布局的页面。
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -105,7 +105,7 @@ const Dashboard = Mock.mock({
|
||||
content:
|
||||
"I'm selfish, impatient and a little insecure. I make mistakes, I am out of control and at times hard to handle. But if you can't handle me at my worst, then you sure as hell don't deserve me at my best.",
|
||||
avatar:
|
||||
'http://img.hb.aicdn.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236',
|
||||
'//cdn.antd-admin.zuiidea.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236',
|
||||
},
|
||||
numbers: [
|
||||
{
|
||||
|
||||
@@ -6,14 +6,24 @@ const database = [
|
||||
id: '1',
|
||||
icon: 'dashboard',
|
||||
name: 'Dashboard',
|
||||
zhName: '仪表盘',
|
||||
zh: {
|
||||
name: '仪表盘'
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'Dashboard'
|
||||
},
|
||||
route: '/dashboard',
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
breadcrumbParentId: '1',
|
||||
name: 'Users',
|
||||
zhName: '用户管理',
|
||||
zh: {
|
||||
name: '用户管理'
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'Usuário'
|
||||
},
|
||||
icon: 'user',
|
||||
route: '/user',
|
||||
},
|
||||
@@ -21,7 +31,12 @@ const database = [
|
||||
id: '7',
|
||||
breadcrumbParentId: '1',
|
||||
name: 'Posts',
|
||||
zhName: '文章管理',
|
||||
zh: {
|
||||
name: '用户管理'
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'Posts'
|
||||
},
|
||||
icon: 'shopping-cart',
|
||||
route: '/post',
|
||||
},
|
||||
@@ -30,14 +45,24 @@ const database = [
|
||||
menuParentId: '-1',
|
||||
breadcrumbParentId: '2',
|
||||
name: 'User Detail',
|
||||
zhName: '用户详情',
|
||||
zh: {
|
||||
name: '用户详情'
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'Detalhes do usuário'
|
||||
},
|
||||
route: '/user/:id',
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
breadcrumbParentId: '1',
|
||||
name: 'Request',
|
||||
zhName: 'Request',
|
||||
zh: {
|
||||
name: 'Request'
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'Requisição'
|
||||
},
|
||||
icon: 'api',
|
||||
route: '/request',
|
||||
},
|
||||
@@ -45,7 +70,12 @@ const database = [
|
||||
id: '4',
|
||||
breadcrumbParentId: '1',
|
||||
name: 'UI Element',
|
||||
zhName: 'UI组件',
|
||||
zh: {
|
||||
name: 'UI组件'
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'Elementos UI'
|
||||
},
|
||||
icon: 'camera-o',
|
||||
},
|
||||
{
|
||||
@@ -53,15 +83,25 @@ const database = [
|
||||
breadcrumbParentId: '4',
|
||||
menuParentId: '4',
|
||||
name: 'Editor',
|
||||
zhName: 'Editor',
|
||||
zh: {
|
||||
name: 'Editor'
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'Editor'
|
||||
},
|
||||
icon: 'edit',
|
||||
route: '/UIElement/editor',
|
||||
route: '/editor',
|
||||
},
|
||||
{
|
||||
id: '5',
|
||||
breadcrumbParentId: '1',
|
||||
name: 'Charts',
|
||||
zhName: 'Charts',
|
||||
zh: {
|
||||
name: 'Charts'
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'Graficos'
|
||||
},
|
||||
icon: 'code-o',
|
||||
},
|
||||
{
|
||||
@@ -69,7 +109,12 @@ const database = [
|
||||
breadcrumbParentId: '5',
|
||||
menuParentId: '5',
|
||||
name: 'ECharts',
|
||||
zhName: 'ECharts',
|
||||
zh: {
|
||||
name: 'ECharts'
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'ECharts'
|
||||
},
|
||||
icon: 'line-chart',
|
||||
route: '/chart/ECharts',
|
||||
},
|
||||
@@ -78,7 +123,12 @@ const database = [
|
||||
breadcrumbParentId: '5',
|
||||
menuParentId: '5',
|
||||
name: 'HighCharts',
|
||||
zhName: 'HighCharts',
|
||||
zh: {
|
||||
name: 'HighCharts'
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'HighCharts'
|
||||
},
|
||||
icon: 'bar-chart',
|
||||
route: '/chart/highCharts',
|
||||
},
|
||||
@@ -87,7 +137,12 @@ const database = [
|
||||
breadcrumbParentId: '5',
|
||||
menuParentId: '5',
|
||||
name: 'Rechartst',
|
||||
zhName: 'Rechartst',
|
||||
zh: {
|
||||
name: 'Rechartst'
|
||||
},
|
||||
'pt-br': {
|
||||
name: 'Rechartst'
|
||||
},
|
||||
icon: 'area-chart',
|
||||
route: '/chart/Recharts',
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Mock, Constant, qs, randomAvatar } from './_utils'
|
||||
import { Mock, Constant, randomAvatar } from './_utils'
|
||||
import qs from 'qs'
|
||||
|
||||
const { ApiPrefix } = Constant
|
||||
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
{
|
||||
"name": "antd-admin",
|
||||
"version": "5.0.1",
|
||||
"private": true,
|
||||
"version": "5.3.0",
|
||||
"license": "MIT",
|
||||
"description": "An admin dashboard application demo built upon Ant Design and UmiJS",
|
||||
"dependencies": {
|
||||
"@lingui/react": "^2.7.1",
|
||||
"ant-design-pro": "^2.1.1",
|
||||
"antd": "^3.10.7",
|
||||
"axios": "^0.18.0",
|
||||
"babel-core": "7.0.0-bridge.0",
|
||||
"@ant-design/icons": "^4.2.2",
|
||||
"@lingui/react": "^3.7.0",
|
||||
"antd": "^4.0.0",
|
||||
"axios": "^0.21.0",
|
||||
"classnames": "^2.2.6",
|
||||
"d3-shape": "^1.2.2",
|
||||
"draftjs-to-html": "^0.8.4",
|
||||
"draftjs-to-markdown": "^0.5.1",
|
||||
"d3-shape": "^2.1.0",
|
||||
"draft-js": "^0.11.7",
|
||||
"draftjs-to-html": "^0.9.0",
|
||||
"draftjs-to-markdown": "^0.6.0",
|
||||
"dva-model-extend": "^0.1.2",
|
||||
"echarts": "^4.2.0-rc.2",
|
||||
"echarts-for-react": "^2.0.15-beta.0",
|
||||
"echarts-gl": "^1.1.1",
|
||||
"echarts-liquidfill": "^2.0.2",
|
||||
"echarts": "^5.0.0",
|
||||
"echarts-for-react": "^3.0.0",
|
||||
"echarts-gl": "^2.0.2",
|
||||
"echarts-liquidfill": "^3.0.0",
|
||||
"enquire-js": "^0.2.1",
|
||||
"highcharts-exporting": "^0.1.7",
|
||||
"highcharts-more": "^0.1.7",
|
||||
@@ -25,49 +25,50 @@
|
||||
"lodash": "^4.17.11",
|
||||
"md5": "^2.2.1",
|
||||
"nprogress": "^0.2.0",
|
||||
"path-to-regexp": "^2.4.0",
|
||||
"prop-types": "^15.6.2",
|
||||
"qs": "^6.5.2",
|
||||
"rc-tween-one": "^2.2.17",
|
||||
"react-adsense": "^0.0.6",
|
||||
"react-countup": "^4.0.0-alpha.6",
|
||||
"react-draft-wysiwyg": "^1.12.13",
|
||||
"react-helmet": "^5.2.0",
|
||||
"react-highcharts": "^16.0.2",
|
||||
"react-perfect-scrollbar": "^1.4.2",
|
||||
"recharts": "^1.3.6",
|
||||
"store": "^2.0.12"
|
||||
"path-to-regexp": "^6.1.0",
|
||||
"prop-types": "^15.7.0",
|
||||
"qs": "^6.9.0",
|
||||
"react-adsense": "^0.1.0",
|
||||
"react-countup": "^4.2.0",
|
||||
"react-draft-wysiwyg": "^1.13.0",
|
||||
"react-helmet": "^6.0.0",
|
||||
"react-highcharts": "^16.1.0",
|
||||
"react-perfect-scrollbar": "^1.5.0",
|
||||
"recharts": "^2.0.0-beta.3",
|
||||
"store": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@lingui/babel-preset-react": "^2.7.1",
|
||||
"@lingui/cli": "^2.7.1",
|
||||
"@lingui/loader": "^2.7.1",
|
||||
"@babel/preset-react": "^7.12.13",
|
||||
"@lingui/cli": "^3.7.0",
|
||||
"@lingui/macro": "^3.7.2",
|
||||
"@umijs/preset-react": "^1.4.0",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"babel-plugin-dev-expression": "^0.2.1",
|
||||
"babel-plugin-import": "^1.10.0",
|
||||
"babel-plugin-macros": "^2.4.2",
|
||||
"babel-plugin-module-resolver": "^3.1.1",
|
||||
"cross-env": "^5.2.0",
|
||||
"eslint": "^5.9.0",
|
||||
"eslint-config-react-app": "^3.0.5",
|
||||
"eslint-plugin-flowtype": "^3.0.0",
|
||||
"eslint-plugin-import": "^2.6.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.1.1",
|
||||
"eslint-plugin-react": "^7.1.0",
|
||||
"husky": "^1.1.4",
|
||||
"babel-plugin-import": "^1.13.3",
|
||||
"babel-plugin-macros": "^3.0.1",
|
||||
"babel-plugin-module-resolver": "^4.0.0",
|
||||
"cross-env": "^7.0.0",
|
||||
"eslint": "^7.0.0",
|
||||
"eslint-config-react-app": "^6.0.0",
|
||||
"eslint-plugin-flowtype": "^5.1.0",
|
||||
"eslint-plugin-import": "^2.18.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.2.1",
|
||||
"eslint-plugin-react": "^7.14.0",
|
||||
"eslint-plugin-react-hooks": "^4.0.0",
|
||||
"husky": "^4.2.0",
|
||||
"less-vars-to-js": "^1.3.0",
|
||||
"lint-staged": "^8.0.4",
|
||||
"mockjs": "^1.0.1-beta3",
|
||||
"lint-staged": "^10.0.0",
|
||||
"mockjs": "^1.1.0",
|
||||
"module": "^1.2.5",
|
||||
"prettier": "^1.15.2",
|
||||
"stylelint": "^9.8.0",
|
||||
"stylelint-config-prettier": "^4.0.0",
|
||||
"stylelint-config-standard": "^18.2.0",
|
||||
"umi": "^2.2.8",
|
||||
"umi-plugin-react": "^1.2.3"
|
||||
"prettier": "^2.0.0",
|
||||
"stylelint": "^13.2.0",
|
||||
"stylelint-config-prettier": "^8.0.0",
|
||||
"stylelint-config-standard": "^21.0.0",
|
||||
"typescript": "^4.2.3",
|
||||
"umi": "^3.2.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"puppeteer": "^1.10.0"
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
},
|
||||
"lint-staged": {
|
||||
"src/**/*.js": [
|
||||
@@ -82,30 +83,43 @@
|
||||
]
|
||||
},
|
||||
"lingui": {
|
||||
"fallbackLocale": "en",
|
||||
"fallbackLocales": {
|
||||
"default": "en"
|
||||
},
|
||||
"sourceLocale": "en",
|
||||
"localeDir": "src/locales",
|
||||
"srcPathDirs": [
|
||||
"src/pages",
|
||||
"src/layouts",
|
||||
"src/components",
|
||||
"src/layouts"
|
||||
"locales": [
|
||||
"en",
|
||||
"zh",
|
||||
"pt-br"
|
||||
],
|
||||
"catalogs": [
|
||||
{
|
||||
"path": "src/locales/{locale}/messages",
|
||||
"include": [
|
||||
"src/pages",
|
||||
"src/layouts",
|
||||
"src/components",
|
||||
"src/layouts"
|
||||
]
|
||||
}
|
||||
],
|
||||
"format": "minimal",
|
||||
"extractBabelOptions": {
|
||||
"presets": [
|
||||
"umi/babel"
|
||||
"@umijs/babel-preset-umi",
|
||||
"@babel/preset-react"
|
||||
]
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"analyze": "cross-env ANALYZE=1 umi build",
|
||||
"build": "umi build",
|
||||
"check:model": "umi dva list model",
|
||||
"lint:js": "eslint --ext .js src",
|
||||
"lint:style": "stylelint \"src/**/*.less\" --syntax less",
|
||||
"start": "umi dev",
|
||||
"test": "cross-env BABELRC=none umi test",
|
||||
"prettier": "prettier --write 'src/**/*.(js|less)'",
|
||||
"prettier": "prettier --write 'src/**/*.{js,less}'",
|
||||
"precommit": "lint-staged",
|
||||
"add-locale": "lingui add-locale",
|
||||
"extract": "lingui extract",
|
||||
|
||||
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 9.7 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
@@ -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 |
@@ -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>
|
||||
)
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import React from 'react';
|
||||
import { TooltipProps } from 'antd/lib/tooltip';
|
||||
|
||||
export interface EllipsisTooltipProps extends TooltipProps {
|
||||
title?: undefined;
|
||||
overlayStyle?: undefined;
|
||||
}
|
||||
|
||||
export interface EllipsisProps {
|
||||
tooltip?: boolean | EllipsisTooltipProps;
|
||||
length?: number;
|
||||
lines?: number;
|
||||
style?: React.CSSProperties;
|
||||
className?: string;
|
||||
fullWidthRecognition?: boolean;
|
||||
}
|
||||
|
||||
export function getStrFullLength(str: string): number;
|
||||
export function cutStrByFullLength(str: string, maxLength: number): string;
|
||||
|
||||
export default class Ellipsis extends React.Component<EllipsisProps, any> {}
|
||||
@@ -0,0 +1,270 @@
|
||||
import React, { Component } from 'react';
|
||||
import { Tooltip } from 'antd';
|
||||
import classNames from 'classnames';
|
||||
import styles from './index.less';
|
||||
|
||||
/* eslint react/no-did-mount-set-state: 0 */
|
||||
/* eslint no-param-reassign: 0 */
|
||||
|
||||
const isSupportLineClamp = document.body.style.webkitLineClamp !== undefined;
|
||||
|
||||
const TooltipOverlayStyle = {
|
||||
overflowWrap: 'break-word',
|
||||
wordWrap: 'break-word',
|
||||
};
|
||||
|
||||
export const getStrFullLength = (str = '') =>
|
||||
str.split('').reduce((pre, cur) => {
|
||||
const charCode = cur.charCodeAt(0);
|
||||
if (charCode >= 0 && charCode <= 128) {
|
||||
return pre + 1;
|
||||
}
|
||||
return pre + 2;
|
||||
}, 0);
|
||||
|
||||
export const cutStrByFullLength = (str = '', maxLength) => {
|
||||
let showLength = 0;
|
||||
return str.split('').reduce((pre, cur) => {
|
||||
const charCode = cur.charCodeAt(0);
|
||||
if (charCode >= 0 && charCode <= 128) {
|
||||
showLength += 1;
|
||||
} else {
|
||||
showLength += 2;
|
||||
}
|
||||
if (showLength <= maxLength) {
|
||||
return pre + cur;
|
||||
}
|
||||
return pre;
|
||||
}, '');
|
||||
};
|
||||
|
||||
const getTooltip = ({ tooltip, overlayStyle, title, children }) => {
|
||||
if (tooltip) {
|
||||
const props = tooltip === true ? { overlayStyle, title } : { ...tooltip, overlayStyle, title };
|
||||
return <Tooltip {...props}>{children}</Tooltip>;
|
||||
}
|
||||
return children;
|
||||
};
|
||||
|
||||
const EllipsisText = ({ text, length, tooltip, fullWidthRecognition, ...other }) => {
|
||||
if (typeof text !== 'string') {
|
||||
throw new Error('Ellipsis children must be string.');
|
||||
}
|
||||
const textLength = fullWidthRecognition ? getStrFullLength(text) : text.length;
|
||||
if (textLength <= length || length < 0) {
|
||||
return <span {...other}>{text}</span>;
|
||||
}
|
||||
const tail = '...';
|
||||
let displayText;
|
||||
if (length - tail.length <= 0) {
|
||||
displayText = '';
|
||||
} else {
|
||||
displayText = fullWidthRecognition ? cutStrByFullLength(text, length) : text.slice(0, length);
|
||||
}
|
||||
|
||||
const spanAttrs = tooltip ? {} : { ...other };
|
||||
return getTooltip({
|
||||
tooltip,
|
||||
overlayStyle: TooltipOverlayStyle,
|
||||
title: text,
|
||||
children: (
|
||||
<span {...spanAttrs}>
|
||||
{displayText}
|
||||
{tail}
|
||||
</span>
|
||||
),
|
||||
});
|
||||
};
|
||||
|
||||
export default class Ellipsis extends Component {
|
||||
state = {
|
||||
text: '',
|
||||
targetCount: 0,
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
if (this.node) {
|
||||
this.computeLine();
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(perProps) {
|
||||
const { lines } = this.props;
|
||||
if (lines !== perProps.lines) {
|
||||
this.computeLine();
|
||||
}
|
||||
}
|
||||
|
||||
computeLine = () => {
|
||||
const { lines } = this.props;
|
||||
if (lines && !isSupportLineClamp) {
|
||||
const text = this.shadowChildren.innerText || this.shadowChildren.textContent;
|
||||
const lineHeight = parseInt(getComputedStyle(this.root).lineHeight, 10);
|
||||
const targetHeight = lines * lineHeight;
|
||||
this.content.style.height = `${targetHeight}px`;
|
||||
const totalHeight = this.shadowChildren.offsetHeight;
|
||||
const shadowNode = this.shadow.firstChild;
|
||||
|
||||
if (totalHeight <= targetHeight) {
|
||||
this.setState({
|
||||
text,
|
||||
targetCount: text.length,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// bisection
|
||||
const len = text.length;
|
||||
const mid = Math.ceil(len / 2);
|
||||
|
||||
const count = this.bisection(targetHeight, mid, 0, len, text, shadowNode);
|
||||
|
||||
this.setState({
|
||||
text,
|
||||
targetCount: count,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
bisection = (th, m, b, e, text, shadowNode) => {
|
||||
const suffix = '...';
|
||||
let mid = m;
|
||||
let end = e;
|
||||
let begin = b;
|
||||
shadowNode.innerHTML = text.substring(0, mid) + suffix;
|
||||
let sh = shadowNode.offsetHeight;
|
||||
|
||||
if (sh <= th) {
|
||||
shadowNode.innerHTML = text.substring(0, mid + 1) + suffix;
|
||||
sh = shadowNode.offsetHeight;
|
||||
if (sh > th || mid === begin) {
|
||||
return mid;
|
||||
}
|
||||
begin = mid;
|
||||
if (end - begin === 1) {
|
||||
mid = 1 + begin;
|
||||
} else {
|
||||
mid = Math.floor((end - begin) / 2) + begin;
|
||||
}
|
||||
return this.bisection(th, mid, begin, end, text, shadowNode);
|
||||
}
|
||||
if (mid - 1 < 0) {
|
||||
return mid;
|
||||
}
|
||||
shadowNode.innerHTML = text.substring(0, mid - 1) + suffix;
|
||||
sh = shadowNode.offsetHeight;
|
||||
if (sh <= th) {
|
||||
return mid - 1;
|
||||
}
|
||||
end = mid;
|
||||
mid = Math.floor((end - begin) / 2) + begin;
|
||||
return this.bisection(th, mid, begin, end, text, shadowNode);
|
||||
};
|
||||
|
||||
handleRoot = n => {
|
||||
this.root = n;
|
||||
};
|
||||
|
||||
handleContent = n => {
|
||||
this.content = n;
|
||||
};
|
||||
|
||||
handleNode = n => {
|
||||
this.node = n;
|
||||
};
|
||||
|
||||
handleShadow = n => {
|
||||
this.shadow = n;
|
||||
};
|
||||
|
||||
handleShadowChildren = n => {
|
||||
this.shadowChildren = n;
|
||||
};
|
||||
|
||||
render() {
|
||||
const { text, targetCount } = this.state;
|
||||
const {
|
||||
children,
|
||||
lines,
|
||||
length,
|
||||
className,
|
||||
tooltip,
|
||||
fullWidthRecognition,
|
||||
...restProps
|
||||
} = this.props;
|
||||
|
||||
const cls = classNames(styles.ellipsis, className, {
|
||||
[styles.lines]: lines && !isSupportLineClamp,
|
||||
[styles.lineClamp]: lines && isSupportLineClamp,
|
||||
});
|
||||
|
||||
if (!lines && !length) {
|
||||
return (
|
||||
<span className={cls} {...restProps}>
|
||||
{children}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
// length
|
||||
if (!lines) {
|
||||
return (
|
||||
<EllipsisText
|
||||
className={cls}
|
||||
length={length}
|
||||
text={children || ''}
|
||||
tooltip={tooltip}
|
||||
fullWidthRecognition={fullWidthRecognition}
|
||||
{...restProps}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const id = `antd-pro-ellipsis-${`${new Date().getTime()}${Math.floor(Math.random() * 100)}`}`;
|
||||
|
||||
// support document.body.style.webkitLineClamp
|
||||
if (isSupportLineClamp) {
|
||||
const style = `#${id}{-webkit-line-clamp:${lines};-webkit-box-orient: vertical;}`;
|
||||
|
||||
const node = (
|
||||
<div id={id} className={cls} {...restProps}>
|
||||
<style>{style}</style>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
|
||||
return getTooltip({
|
||||
tooltip,
|
||||
overlayStyle: TooltipOverlayStyle,
|
||||
title: children,
|
||||
children: node,
|
||||
});
|
||||
}
|
||||
|
||||
const childNode = (
|
||||
<span ref={this.handleNode}>
|
||||
{targetCount > 0 && text.substring(0, targetCount)}
|
||||
{targetCount > 0 && targetCount < text.length && '...'}
|
||||
</span>
|
||||
);
|
||||
|
||||
return (
|
||||
<div {...restProps} ref={this.handleRoot} className={cls}>
|
||||
<div ref={this.handleContent}>
|
||||
{getTooltip({
|
||||
tooltip,
|
||||
overlayStyle: TooltipOverlayStyle,
|
||||
title: text,
|
||||
children: childNode,
|
||||
})}
|
||||
<div className={styles.shadow} ref={this.handleShadowChildren}>
|
||||
{children}
|
||||
</div>
|
||||
<div className={styles.shadow} ref={this.handleShadow}>
|
||||
<span>{text}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
.ellipsis {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.lines {
|
||||
position: relative;
|
||||
.shadow {
|
||||
position: absolute;
|
||||
z-index: -999;
|
||||
display: block;
|
||||
color: transparent;
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.lineClamp {
|
||||
position: relative;
|
||||
display: -webkit-box;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
title: Ellipsis
|
||||
subtitle: 文本自动省略号
|
||||
cols: 1
|
||||
order: 10
|
||||
---
|
||||
|
||||
文本过长自动处理省略号,支持按照文本长度和最大行数两种方式截取。
|
||||
|
||||
## API
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| -------------------- | ------------------------------------------------ | ------- | ------ |
|
||||
| tooltip | 移动到文本展示完整内容的提示 | boolean | - |
|
||||
| length | 在按照长度截取下的文本最大字符数,超过则截取省略 | number | - |
|
||||
| lines | 在按照行数截取下最大的行数,超过则截取省略 | number | `1` |
|
||||
| fullWidthRecognition | 是否将全角字符的长度视为 2 来计算字符串长度 | boolean | - |
|
||||
@@ -0,0 +1,13 @@
|
||||
import { getStrFullLength, cutStrByFullLength } from './index';
|
||||
|
||||
describe('test calculateShowLength', () => {
|
||||
it('get full length', () => {
|
||||
expect(getStrFullLength('一二,a,')).toEqual(8);
|
||||
});
|
||||
it('cut str by full length', () => {
|
||||
expect(cutStrByFullLength('一二,a,', 7)).toEqual('一二,a');
|
||||
});
|
||||
it('cut str when length small', () => {
|
||||
expect(cutStrByFullLength('一22三', 5)).toEqual('一22');
|
||||
});
|
||||
});
|
||||
@@ -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>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import React from 'react';
|
||||
export interface GlobalFooterProps {
|
||||
links?: Array<{
|
||||
key?: string;
|
||||
title: React.ReactNode;
|
||||
href: string;
|
||||
blankTarget?: boolean;
|
||||
}>;
|
||||
copyright?: React.ReactNode;
|
||||
style?: React.CSSProperties;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export default class GlobalFooter extends React.Component<GlobalFooterProps, any> {}
|
||||
@@ -0,0 +1,28 @@
|
||||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import styles from './index.less';
|
||||
|
||||
const GlobalFooter = ({ className, links, copyright }) => {
|
||||
const clsString = classNames(styles.globalFooter, className);
|
||||
return (
|
||||
<footer className={clsString}>
|
||||
{links && (
|
||||
<div className={styles.links}>
|
||||
{links.map(link => (
|
||||
<a
|
||||
key={link.key}
|
||||
title={link.key}
|
||||
target={link.blankTarget ? '_blank' : '_self'}
|
||||
href={link.href}
|
||||
>
|
||||
{link.title}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{copyright && <div className={styles.copyright}>{copyright}</div>}
|
||||
</footer>
|
||||
);
|
||||
};
|
||||
|
||||
export default GlobalFooter;
|
||||
@@ -0,0 +1,29 @@
|
||||
@import '~antd/lib/style/themes/default.less';
|
||||
|
||||
.globalFooter {
|
||||
margin: 48px 0 24px 0;
|
||||
padding: 0 16px;
|
||||
text-align: center;
|
||||
|
||||
.links {
|
||||
margin-bottom: 8px;
|
||||
|
||||
a {
|
||||
color: @text-color-secondary;
|
||||
transition: all 0.3s;
|
||||
|
||||
&:not(:last-child) {
|
||||
margin-right: 40px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: @text-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.copyright {
|
||||
color: @text-color-secondary;
|
||||
font-size: @font-size-base;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
title: GlobalFooter
|
||||
subtitle: 全局页脚
|
||||
cols: 1
|
||||
order: 7
|
||||
---
|
||||
|
||||
页脚属于全局导航的一部分,作为对顶部导航的补充,通过传递数据控制展示内容。
|
||||
|
||||
## API
|
||||
|
||||
| 参数 | 说明 | 类型 | 默认值 |
|
||||
| --------- | -------- | ---------------------------------------------------------------- | ------ |
|
||||
| links | 链接数据 | array<{ title: ReactNode, href: string, blankTarget?: boolean }> | - |
|
||||
| copyright | 版权信息 | ReactNode | - |
|
||||
@@ -1,43 +1,45 @@
|
||||
import React, { PureComponent, Fragment } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Breadcrumb, Icon } from 'antd'
|
||||
import Link from 'umi/navlink'
|
||||
import withRouter from 'umi/withRouter'
|
||||
import { withI18n } from '@lingui/react'
|
||||
import { pathMatchRegexp, queryAncestors } from 'utils'
|
||||
import { Breadcrumb } from 'antd'
|
||||
import { Link, withRouter } from 'umi'
|
||||
import { t } from "@lingui/macro"
|
||||
import iconMap from 'utils/iconMap'
|
||||
const { pathToRegexp } = require('path-to-regexp')
|
||||
import { queryAncestors } from 'utils'
|
||||
import styles from './Bread.less'
|
||||
|
||||
@withI18n()
|
||||
@withRouter
|
||||
class Bread extends PureComponent {
|
||||
generateBreadcrumbs = paths => {
|
||||
generateBreadcrumbs = (paths) => {
|
||||
return paths.map((item, key) => {
|
||||
const content = (
|
||||
const content = item && (
|
||||
<Fragment>
|
||||
{item.icon ? (
|
||||
<Icon type={item.icon} style={{ marginRight: 4 }} />
|
||||
) : null}
|
||||
{item.icon && (
|
||||
<span style={{ marginRight: 4 }}>{iconMap[item.icon]}</span>
|
||||
)}
|
||||
{item.name}
|
||||
</Fragment>
|
||||
)
|
||||
|
||||
return (
|
||||
<Breadcrumb.Item key={key}>
|
||||
{paths.length - 1 !== key ? (
|
||||
<Link to={item.route || '#'}>{content}</Link>
|
||||
) : (
|
||||
content
|
||||
)}
|
||||
</Breadcrumb.Item>
|
||||
item && (
|
||||
<Breadcrumb.Item key={key}>
|
||||
{paths.length - 1 !== key ? (
|
||||
<Link to={item.route || '#'}>{content}</Link>
|
||||
) : (
|
||||
content
|
||||
)}
|
||||
</Breadcrumb.Item>
|
||||
)
|
||||
)
|
||||
})
|
||||
}
|
||||
render() {
|
||||
const { routeList, location, i18n } = this.props
|
||||
const { routeList, location } = this.props
|
||||
|
||||
// Find a route that matches the pathname.
|
||||
const currentRoute = routeList.find(
|
||||
_ => _.route && pathMatchRegexp(_.route, location.pathname)
|
||||
(_) => _.route && pathToRegexp(_.route).exec(location.pathname)
|
||||
)
|
||||
|
||||
// Find the breadcrumb navigation of the current route match and all its ancestors.
|
||||
@@ -47,7 +49,7 @@ class Bread extends PureComponent {
|
||||
routeList[0],
|
||||
{
|
||||
id: 404,
|
||||
name: i18n.t`Not Found`,
|
||||
name: t`Not Found`,
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
import React, { PureComponent, Fragment } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Menu, Icon, Layout, Avatar, Popover, Badge, List } from 'antd'
|
||||
import { Ellipsis } from 'ant-design-pro'
|
||||
import { Trans, withI18n } from '@lingui/react'
|
||||
import { setLocale } from 'utils'
|
||||
import { Menu, Layout, Avatar, Popover, Badge, List } from 'antd'
|
||||
import { Ellipsis } from 'components'
|
||||
import {
|
||||
BellOutlined,
|
||||
RightOutlined,
|
||||
MenuFoldOutlined,
|
||||
MenuUnfoldOutlined,
|
||||
} from '@ant-design/icons'
|
||||
import { Trans } from "@lingui/macro"
|
||||
import { getLocale, setLocale } from 'utils'
|
||||
import moment from 'moment'
|
||||
import classnames from 'classnames'
|
||||
import config from 'config'
|
||||
@@ -11,14 +17,12 @@ import styles from './Header.less'
|
||||
|
||||
const { SubMenu } = Menu
|
||||
|
||||
@withI18n()
|
||||
class Header extends PureComponent {
|
||||
handleClickMenu = e => {
|
||||
e.key === 'SignOut' && this.props.onSignOut()
|
||||
}
|
||||
render() {
|
||||
const {
|
||||
i18n,
|
||||
fixed,
|
||||
avatar,
|
||||
username,
|
||||
@@ -50,8 +54,9 @@ class Header extends PureComponent {
|
||||
|
||||
if (config.i18n) {
|
||||
const { languages } = config.i18n
|
||||
const language = getLocale()
|
||||
const currentLanguage = languages.find(
|
||||
item => item.key === i18n._language
|
||||
item => item.key === language
|
||||
)
|
||||
|
||||
rightContent.unshift(
|
||||
@@ -85,7 +90,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 +109,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 +130,7 @@ class Header extends PureComponent {
|
||||
offset={[-10, 10]}
|
||||
className={styles.iconButton}
|
||||
>
|
||||
<Icon className={styles.iconFont} type="bell" />
|
||||
<BellOutlined className={styles.iconFont} />
|
||||
</Badge>
|
||||
</Popover>
|
||||
)
|
||||
@@ -146,14 +147,8 @@ class Header extends PureComponent {
|
||||
className={styles.button}
|
||||
onClick={onCollapseChange.bind(this, !collapsed)}
|
||||
>
|
||||
<Icon
|
||||
type={classnames({
|
||||
'menu-unfold': collapsed,
|
||||
'menu-fold': !collapsed,
|
||||
})}
|
||||
/>
|
||||
{collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
|
||||
</div>
|
||||
|
||||
<div className={styles.rightContainer}>{rightContent}</div>
|
||||
</Layout.Header>
|
||||
)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: ~'calc(100% - 256px)';
|
||||
z-index: 9;
|
||||
z-index: 29;
|
||||
transition: width 0.2s;
|
||||
|
||||
&.collapsed {
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
import React, { PureComponent, Fragment } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Menu, Icon } from 'antd'
|
||||
import Navlink from 'umi/navlink'
|
||||
import withRouter from 'umi/withRouter'
|
||||
import {
|
||||
arrayToTree,
|
||||
queryAncestors,
|
||||
pathMatchRegexp,
|
||||
addLangPrefix,
|
||||
} from 'utils'
|
||||
import { Menu } from 'antd'
|
||||
import { NavLink, withRouter } from 'umi'
|
||||
import { pathToRegexp } from 'path-to-regexp'
|
||||
import { arrayToTree, queryAncestors } from 'utils'
|
||||
import iconMap from 'utils/iconMap'
|
||||
import store from 'store'
|
||||
|
||||
const { SubMenu } = Menu
|
||||
@@ -46,7 +42,7 @@ class SiderMenu extends PureComponent {
|
||||
key={item.id}
|
||||
title={
|
||||
<Fragment>
|
||||
{item.icon && <Icon type={item.icon} />}
|
||||
{item.icon && iconMap[item.icon]}
|
||||
<span>{item.name}</span>
|
||||
</Fragment>
|
||||
}
|
||||
@@ -57,10 +53,10 @@ class SiderMenu extends PureComponent {
|
||||
}
|
||||
return (
|
||||
<Menu.Item key={item.id}>
|
||||
<Navlink to={addLangPrefix(item.route) || '#'}>
|
||||
{item.icon && <Icon type={item.icon} />}
|
||||
<NavLink to={item.route || '#'}>
|
||||
{item.icon && iconMap[item.icon]}
|
||||
<span>{item.name}</span>
|
||||
</Navlink>
|
||||
</NavLink>
|
||||
</Menu.Item>
|
||||
)
|
||||
})
|
||||
@@ -81,7 +77,7 @@ class SiderMenu extends PureComponent {
|
||||
|
||||
// Find a menu that matches the pathname.
|
||||
const currentMenu = menus.find(
|
||||
_ => _.route && pathMatchRegexp(_.route, location.pathname)
|
||||
_ => _.route && pathToRegexp(_.route).exec(location.pathname)
|
||||
)
|
||||
|
||||
// Find the key that should be selected according to the current menu.
|
||||
@@ -89,13 +85,17 @@ class SiderMenu extends PureComponent {
|
||||
? queryAncestors(menus, currentMenu, 'menuParentId').map(_ => _.id)
|
||||
: []
|
||||
|
||||
const menuProps = collapsed
|
||||
? {}
|
||||
: {
|
||||
openKeys: this.state.openKeys,
|
||||
}
|
||||
|
||||
return (
|
||||
<Menu
|
||||
mode="inline"
|
||||
theme={theme}
|
||||
onOpenChange={this.onOpenChange}
|
||||
openKeys={this.state.openKeys}
|
||||
inlineCollapsed={collapsed}
|
||||
selectedKeys={selectedKeys}
|
||||
onClick={
|
||||
isMobile
|
||||
@@ -104,6 +104,7 @@ class SiderMenu extends PureComponent {
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
{...menuProps}
|
||||
>
|
||||
{this.generateMenus(menuTree)}
|
||||
</Menu>
|
||||
@@ -115,7 +116,6 @@ SiderMenu.propTypes = {
|
||||
menus: PropTypes.array,
|
||||
theme: PropTypes.string,
|
||||
isMobile: PropTypes.bool,
|
||||
collapsed: PropTypes.bool,
|
||||
onCollapseChange: PropTypes.func,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import React, { PureComponent } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Icon, Switch, Layout } from 'antd'
|
||||
import { withI18n, Trans } from '@lingui/react'
|
||||
import { Switch, Layout } from 'antd'
|
||||
import { t } from "@lingui/macro"
|
||||
import { Trans } from "@lingui/macro"
|
||||
import { BulbOutlined } from '@ant-design/icons'
|
||||
import ScrollBar from '../ScrollBar'
|
||||
import { config } from 'utils'
|
||||
import SiderMenu from './Menu'
|
||||
import styles from './Sider.less'
|
||||
|
||||
@withI18n()
|
||||
class Sider extends PureComponent {
|
||||
render() {
|
||||
const {
|
||||
i18n,
|
||||
menus,
|
||||
theme,
|
||||
isMobile,
|
||||
@@ -28,19 +28,19 @@ 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>
|
||||
|
||||
<div className={styles.menuContainer}>
|
||||
<ScrollBar
|
||||
option={{
|
||||
options={{
|
||||
// Disabled horizontal scrolling, https://github.com/utatti/perfect-scrollbar#options
|
||||
suppressScrollX: true,
|
||||
}}
|
||||
@@ -54,10 +54,10 @@ class Sider extends PureComponent {
|
||||
/>
|
||||
</ScrollBar>
|
||||
</div>
|
||||
{collapsed ? null : (
|
||||
{!collapsed && (
|
||||
<div className={styles.switchTheme}>
|
||||
<span>
|
||||
<Icon type="bulb" />
|
||||
<BulbOutlined />
|
||||
<Trans>Switch Theme</Trans>
|
||||
</span>
|
||||
<Switch
|
||||
@@ -66,8 +66,8 @@ class Sider extends PureComponent {
|
||||
theme === 'dark' ? 'light' : 'dark'
|
||||
)}
|
||||
defaultChecked={theme === 'dark'}
|
||||
checkedChildren={i18n.t`Dark`}
|
||||
unCheckedChildren={i18n.t`Light`}
|
||||
checkedChildren={t`Dark`}
|
||||
unCheckedChildren={t`Light`}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
|
||||
import classNames from 'classnames'
|
||||
import styles from './Loader.less'
|
||||
|
||||
const Loader = ({ spinning = true, fullScreen }) => {
|
||||
const Loader = ({ spinning = false, fullScreen }) => {
|
||||
return (
|
||||
<div
|
||||
className={classNames(styles.loader, {
|
||||
|
||||
@@ -3,7 +3,9 @@ import FilterItem from './FilterItem'
|
||||
import DropOption from './DropOption'
|
||||
import Loader from './Loader'
|
||||
import ScrollBar from './ScrollBar'
|
||||
import GlobalFooter from './GlobalFooter'
|
||||
import Ellipsis from './Ellipsis'
|
||||
import * as MyLayout from './Layout/index.js'
|
||||
import Page from './Page'
|
||||
|
||||
export { MyLayout, Editor, FilterItem, DropOption, Loader, Page, ScrollBar }
|
||||
export { MyLayout, Editor, GlobalFooter, Ellipsis, FilterItem, DropOption, Loader, Page, ScrollBar }
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import React, { PureComponent, Fragment } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'dva'
|
||||
import { connect } from 'umi'
|
||||
import { Helmet } from 'react-helmet'
|
||||
import { Loader } from 'components'
|
||||
import { queryLayout } from 'utils'
|
||||
import NProgress from 'nprogress'
|
||||
import config from 'utils/config'
|
||||
import withRouter from 'umi/withRouter'
|
||||
import { withRouter } from 'umi'
|
||||
|
||||
import PublicLayout from './PublicLayout'
|
||||
import PrimaryLayout from './PrimaryLayout'
|
||||
|
||||
@@ -2,15 +2,16 @@
|
||||
/* global document */
|
||||
import React, { PureComponent, Fragment } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import withRouter from 'umi/withRouter'
|
||||
import { connect } from 'dva'
|
||||
import { MyLayout } from 'components'
|
||||
import { withRouter } from 'umi'
|
||||
import { connect } from 'umi'
|
||||
import { MyLayout, GlobalFooter } from 'components'
|
||||
import { BackTop, Layout, Drawer } from 'antd'
|
||||
import { GlobalFooter } from 'ant-design-pro'
|
||||
import { enquireScreen, unenquireScreen } from 'enquire-js'
|
||||
import { config, pathMatchRegexp, langFromPath } from 'utils'
|
||||
const { pathToRegexp } = require("path-to-regexp")
|
||||
import { config, getLocale } from 'utils'
|
||||
import Error from '../pages/404'
|
||||
import styles from './PrimaryLayout.less'
|
||||
import store from 'store'
|
||||
|
||||
const { Content } = Layout
|
||||
const { Header, Bread, Sider } = MyLayout
|
||||
@@ -46,32 +47,30 @@ class PrimaryLayout extends PureComponent {
|
||||
|
||||
render() {
|
||||
const { app, location, dispatch, children } = this.props
|
||||
const {
|
||||
user,
|
||||
theme,
|
||||
routeList,
|
||||
collapsed,
|
||||
permissions,
|
||||
notifications,
|
||||
} = app
|
||||
const { theme, collapsed, notifications } = app
|
||||
const user = store.get('user') || {}
|
||||
const permissions = store.get('permissions') || {}
|
||||
const routeList = store.get('routeList') || []
|
||||
const { isMobile } = this.state
|
||||
const { onCollapseChange } = this
|
||||
|
||||
// Localized route name.
|
||||
|
||||
const lang = getLocale()
|
||||
const newRouteList =
|
||||
langFromPath(location.pathname) === 'zh'
|
||||
lang !== 'en'
|
||||
? routeList.map(item => {
|
||||
const { zhName, ...other } = item
|
||||
const { name, ...other } = item
|
||||
return {
|
||||
...other,
|
||||
name: zhName,
|
||||
name: (item[lang] || {}).name || name,
|
||||
}
|
||||
})
|
||||
: routeList
|
||||
|
||||
// Find a route that matches the pathname.
|
||||
const currentRoute = newRouteList.find(
|
||||
_ => _.route && pathMatchRegexp(_.route, location.pathname)
|
||||
_ => _.route && pathToRegexp(_.route).exec(location.pathname)
|
||||
)
|
||||
|
||||
// Query whether you have permission to enter this page
|
||||
@@ -145,7 +144,7 @@ class PrimaryLayout extends PureComponent {
|
||||
</Content>
|
||||
<BackTop
|
||||
className={styles.backTop}
|
||||
target={() => document.querySelector('#primaryLayout>div')}
|
||||
target={() => document.querySelector('#primaryLayout')}
|
||||
/>
|
||||
<GlobalFooter
|
||||
className={styles.footer}
|
||||
|
||||
@@ -1,39 +1,48 @@
|
||||
import React, { Component } from 'react'
|
||||
import withRouter from 'umi/withRouter'
|
||||
import { LocaleProvider } from 'antd'
|
||||
import { withRouter } from 'umi'
|
||||
import { ConfigProvider } from 'antd'
|
||||
import { i18n } from "@lingui/core"
|
||||
import { I18nProvider } from '@lingui/react'
|
||||
import { langFromPath, defaultLanguage } from 'utils'
|
||||
import { getLocale } from 'utils'
|
||||
import { zh, en, pt } from 'make-plural/plurals'
|
||||
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 plurals = {
|
||||
zh,
|
||||
en,
|
||||
'pt-br': pt,
|
||||
}
|
||||
|
||||
const languages = {
|
||||
zh: zh_CN,
|
||||
en: en_US,
|
||||
'pt-br': pt_BR,
|
||||
}
|
||||
const { defaultLanguage } = i18n
|
||||
|
||||
@withRouter
|
||||
class Layout extends Component {
|
||||
state = {
|
||||
catalogs: {},
|
||||
}
|
||||
|
||||
language = defaultLanguage
|
||||
|
||||
componentDidMount() {
|
||||
const language = langFromPath(this.props.location.pathname)
|
||||
const language = getLocale()
|
||||
this.language = language
|
||||
this.loadCatalog(language)
|
||||
language && this.loadCatalog(language)
|
||||
}
|
||||
|
||||
shouldComponentUpdate(nextProps, nextState) {
|
||||
const language = langFromPath(nextProps.location.pathname)
|
||||
const language = getLocale()
|
||||
const preLanguage = this.language
|
||||
const { catalogs } = nextState
|
||||
|
||||
if (preLanguage !== language && !catalogs[language]) {
|
||||
this.loadCatalog(language)
|
||||
if (preLanguage !== language && !languages[language]) {
|
||||
language && this.loadCatalog(language)
|
||||
this.language = language
|
||||
return false
|
||||
}
|
||||
@@ -43,31 +52,31 @@ 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(
|
||||
`../locales/${language}/messages.json`
|
||||
)
|
||||
|
||||
this.setState(state => ({
|
||||
catalogs: {
|
||||
...state.catalogs,
|
||||
[language]: catalog,
|
||||
},
|
||||
}))
|
||||
i18n.load(language, catalog)
|
||||
i18n.activate(language)
|
||||
}
|
||||
|
||||
render() {
|
||||
const { location, children } = this.props
|
||||
const { catalogs } = this.state
|
||||
const { children } = this.props
|
||||
|
||||
let language = langFromPath(location.pathname)
|
||||
let language = getLocale()
|
||||
// If the language pack is not loaded or is loading, use the default language
|
||||
if (!catalogs[language]) language = defaultLanguage
|
||||
if (!languages[language]) language = defaultLanguage
|
||||
|
||||
i18n.loadLocaleData(language, { plurals: plurals[language] })
|
||||
i18n.load(language, languages[language])
|
||||
i18n.activate(language)
|
||||
|
||||
return (
|
||||
<LocaleProvider locale={languages[language]}>
|
||||
<I18nProvider language={language} catalogs={catalogs}>
|
||||
<ConfigProvider locale={language}>
|
||||
<I18nProvider i18n={i18n}>
|
||||
<BaseLayout>{children}</BaseLayout>
|
||||
</I18nProvider>
|
||||
</LocaleProvider>
|
||||
</ConfigProvider>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
{
|
||||
"/dashboard": "/dashboard",
|
||||
"Add Param": "Add Parametro",
|
||||
"Address": "Endereço",
|
||||
"Age": "Ano",
|
||||
"Are you sure delete this record?": "Tem certeza de excluir este registro?",
|
||||
"Author": "Autor",
|
||||
"Avatar": "Avatar",
|
||||
"Categories": "Categorias",
|
||||
"Clear notifications": "limpar notificações",
|
||||
"Comments": "Comentarios",
|
||||
"Create": "Criar",
|
||||
"Create User": "Criar Usuário",
|
||||
"CreateTime": "CreateTime",
|
||||
"Dark": "Escuro",
|
||||
"Delete": "Deletar",
|
||||
"Email": "Email",
|
||||
"Female": "Feminino",
|
||||
"Gender": "Genero",
|
||||
"Hi,": "Olá,",
|
||||
"Image": "Imagem",
|
||||
"Light": "Claro",
|
||||
"Male": "masculino",
|
||||
"Name": "Nome",
|
||||
"NickName": "NickName",
|
||||
"Not Found": "Não Encontrado",
|
||||
"Operation": "Operation",
|
||||
"Params": "Parametros",
|
||||
"Password": "Senha",
|
||||
"Phone": "Fone",
|
||||
"Pick an address": "Escolha um endereço",
|
||||
"Please pick an address": "Por favor, escolha um endereço",
|
||||
"Publised": "Publicado",
|
||||
"Publish Date": "Data de publicação",
|
||||
"Reset": "Reset",
|
||||
"Search": "procurar",
|
||||
"Search Name": "Search Name",
|
||||
"Send": "Enviar",
|
||||
"Sign in": "Sign in",
|
||||
"Sign out": "Sign out",
|
||||
"Switch Theme": "Trocar tema",
|
||||
"Tags": "Tags",
|
||||
"The input is not valid E-mail!": "Não é um E-mail valido!",
|
||||
"The input is not valid phone!": "Não é um telefone Valido!",
|
||||
"Title": "Titulo",
|
||||
"Total {total} Items": "Total {total} Items",
|
||||
"Unpublished": "Não publicado",
|
||||
"Update": "Atualizar",
|
||||
"Update User": "Atualizar Usuário",
|
||||
"Username": "Usuário",
|
||||
"Views": "visualizações",
|
||||
"Visibility": "Visibilidade",
|
||||
"You have viewed all notifications.": "Você visualizou todas as notificações."
|
||||
}
|
||||
@@ -1,21 +1,28 @@
|
||||
/* global window */
|
||||
|
||||
import { router } from 'utils'
|
||||
import { history } from 'umi'
|
||||
import { stringify } from 'qs'
|
||||
import store from 'store'
|
||||
const { pathToRegexp } = require("path-to-regexp")
|
||||
import { ROLE_TYPE } from 'utils/constant'
|
||||
import { queryLayout, pathMatchRegexp } from 'utils'
|
||||
import { queryLayout } from 'utils'
|
||||
import { CANCEL_REQUEST_MESSAGE } from 'utils/constant'
|
||||
import { queryRouteList, logoutUser, queryUserInfo } from 'api'
|
||||
import api from 'api'
|
||||
import config from 'config'
|
||||
|
||||
const { queryRouteList, logoutUser, queryUserInfo } = api
|
||||
|
||||
const goDashboard = () => {
|
||||
if (pathToRegexp(['/', '/login']).exec(window.location.pathname)) {
|
||||
history.push({
|
||||
pathname: '/dashboard',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
namespace: 'app',
|
||||
state: {
|
||||
user: {},
|
||||
permissions: {
|
||||
visit: [],
|
||||
},
|
||||
routeList: [
|
||||
{
|
||||
id: '1',
|
||||
@@ -41,6 +48,9 @@ export default {
|
||||
],
|
||||
},
|
||||
subscriptions: {
|
||||
setup({ dispatch }) {
|
||||
dispatch({ type: 'query' })
|
||||
},
|
||||
setupHistory({ dispatch, history }) {
|
||||
history.listen(location => {
|
||||
dispatch({
|
||||
@@ -65,16 +75,17 @@ export default {
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
setup({ dispatch }) {
|
||||
dispatch({ type: 'query' })
|
||||
},
|
||||
},
|
||||
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,21 +107,13 @@ export default {
|
||||
return cases.every(_ => _)
|
||||
})
|
||||
}
|
||||
yield put({
|
||||
type: 'updateState',
|
||||
payload: {
|
||||
user,
|
||||
permissions,
|
||||
routeList,
|
||||
},
|
||||
})
|
||||
if (pathMatchRegexp('/login', window.location.pathname)) {
|
||||
router.push({
|
||||
pathname: '/dashboard',
|
||||
})
|
||||
}
|
||||
store.set('routeList', routeList)
|
||||
store.set('permissions', permissions)
|
||||
store.set('user', user)
|
||||
store.set('isInit', true)
|
||||
goDashboard()
|
||||
} else if (queryLayout(config.layouts, locationPathname) !== 'public') {
|
||||
router.push({
|
||||
history.push({
|
||||
pathname: '/login',
|
||||
search: stringify({
|
||||
from: locationPathname,
|
||||
@@ -122,22 +125,10 @@ export default {
|
||||
*signOut({ payload }, { call, put }) {
|
||||
const data = yield call(logoutUser)
|
||||
if (data.success) {
|
||||
yield put({
|
||||
type: 'updateState',
|
||||
payload: {
|
||||
user: {},
|
||||
permissions: { visit: [] },
|
||||
menu: [
|
||||
{
|
||||
id: '1',
|
||||
icon: 'laptop',
|
||||
name: 'Dashboard',
|
||||
zhName: '仪表盘',
|
||||
router: '/dashboard',
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
store.set('routeList', [])
|
||||
store.set('permissions', { visit: [] })
|
||||
store.set('user', {})
|
||||
store.set('isInit', false)
|
||||
yield put({ type: 'query' })
|
||||
} else {
|
||||
throw data
|
||||
|
||||
@@ -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,27 +0,0 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { ResponsiveContainer } from 'recharts'
|
||||
import styles from './Container.less'
|
||||
|
||||
const Container = ({
|
||||
children,
|
||||
ratio = 5 / 2,
|
||||
minHeight = 250,
|
||||
maxHeight = 350,
|
||||
}) => (
|
||||
<div className={styles.container} style={{ minHeight, maxHeight }}>
|
||||
<div style={{ marginTop: `${100 / ratio}%` || '100%' }} />
|
||||
<div className={styles.content} style={{ minHeight, maxHeight }}>
|
||||
<ResponsiveContainer>{children}</ResponsiveContainer>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
Container.propTypes = {
|
||||
children: PropTypes.element.isRequired,
|
||||
ratio: PropTypes.number,
|
||||
minHeight: PropTypes.number,
|
||||
maxHeight: PropTypes.number,
|
||||
}
|
||||
|
||||
export default Container
|
||||
@@ -1,20 +0,0 @@
|
||||
.container {
|
||||
width: 100%;
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
|
||||
:global {
|
||||
.recharts-responsive-container {
|
||||
width: e('calc(100% + 56px)') !important;
|
||||
margin-left: -32px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react'
|
||||
import ReactEcharts from 'echarts-for-react'
|
||||
|
||||
require('echarts/map/js/china.js')
|
||||
require('./map/js/china.js')
|
||||
|
||||
const AirportCoordComponent = () => {
|
||||
let geoCoordMap = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import ReactEcharts from 'echarts-for-react'
|
||||
import echarts from 'echarts'
|
||||
import * as echarts from 'echarts'
|
||||
|
||||
const currentData = [
|
||||
[
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import ReactEcharts from 'echarts-for-react'
|
||||
import echarts from 'echarts'
|
||||
import * as echarts from 'echarts'
|
||||
|
||||
const CalendarComponent = () => {
|
||||
const getVirtulData = year => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import ReactEcharts from 'echarts-for-react'
|
||||
import echarts from 'echarts'
|
||||
import * as echarts from 'echarts'
|
||||
|
||||
const GCalendarComponent = () => {
|
||||
const getVirtulData = year => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import ReactEcharts from 'echarts-for-react'
|
||||
import echarts from 'echarts'
|
||||
import * as echarts from 'echarts'
|
||||
|
||||
const LunarCalendarComponent = () => {
|
||||
const getOtion = () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import AdSense from 'react-adsense'
|
||||
import { Link } from 'react-router'
|
||||
import { Link } from 'umi'
|
||||
import DynamicChartComponent from './DynamicChartComponent.js'
|
||||
|
||||
const MainPageComponent = () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react'
|
||||
import ReactEcharts from 'echarts-for-react'
|
||||
|
||||
require('echarts/map/js/china.js')
|
||||
require('./map/js/china.js')
|
||||
|
||||
class MapChartComponent extends React.Component {
|
||||
constructor() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react'
|
||||
import ReactEcharts from 'echarts-for-react'
|
||||
|
||||
import echarts from 'echarts'
|
||||
import * as echarts from 'echarts'
|
||||
|
||||
const ThemeChartComponent = () => {
|
||||
const option = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import ReactEcharts from 'echarts-for-react'
|
||||
import echarts from 'echarts'
|
||||
import * as echarts from 'echarts'
|
||||
|
||||
const TreemapComponent = () => {
|
||||
let diskData = [
|
||||
|
||||
@@ -38,7 +38,7 @@ function Browser({ data }) {
|
||||
pagination={false}
|
||||
showHeader={false}
|
||||
columns={columns}
|
||||
rowKey={(record, key) => key}
|
||||
rowKey='name'
|
||||
dataSource={data}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -54,7 +54,7 @@ function Comments({ data }) {
|
||||
pagination={false}
|
||||
showHeader={false}
|
||||
columns={columns}
|
||||
rowKey={(record, key) => key}
|
||||
rowKey='avatar'
|
||||
dataSource={data.filter((item, key) => key < 3)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -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>
|
||||
)
|
||||
}}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Icon, Card } from 'antd'
|
||||
import { Card } from 'antd'
|
||||
import CountUp from 'react-countup'
|
||||
import iconMap from 'utils/iconMap'
|
||||
import styles from './numberCard.less'
|
||||
|
||||
|
||||
function NumberCard({ icon, color, title, number, countUp }) {
|
||||
return (
|
||||
<Card
|
||||
@@ -11,7 +13,9 @@ function NumberCard({ icon, color, title, number, countUp }) {
|
||||
bordered={false}
|
||||
bodyStyle={{ padding: 10 }}
|
||||
>
|
||||
<Icon className={styles.iconWarp} style={{ color }} type={icon} />
|
||||
<span className={styles.iconWarp} style={{ color }}>
|
||||
{iconMap[icon]}
|
||||
</span>
|
||||
<div className={styles.content}>
|
||||
<p className={styles.title}>{title || 'No Title'}</p>
|
||||
<p className={styles.number}>
|
||||
@@ -22,7 +26,7 @@ function NumberCard({ icon, color, title, number, countUp }) {
|
||||
useEasing
|
||||
useGrouping
|
||||
separator=","
|
||||
{...countUp || {}}
|
||||
{...(countUp || {})}
|
||||
/>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -53,7 +53,7 @@ function RecentSales({ data }) {
|
||||
<Table
|
||||
pagination={false}
|
||||
columns={columns}
|
||||
rowKey={(record, key) => key}
|
||||
rowKey='id'
|
||||
dataSource={data.filter((item, key) => key < 5)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -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>
|
||||
)
|
||||
}}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { PureComponent } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'dva'
|
||||
import { connect } from 'umi'
|
||||
import { Row, Col, Card } from 'antd'
|
||||
import { Color } from 'utils'
|
||||
import { Page, ScrollBar } from 'components'
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
User,
|
||||
} from './components'
|
||||
import styles from './index.less'
|
||||
import store from 'store'
|
||||
|
||||
const bodyStyle = {
|
||||
bodyStyle: {
|
||||
@@ -26,14 +27,14 @@ const bodyStyle = {
|
||||
}
|
||||
|
||||
@connect(({ app, dashboard, loading }) => ({
|
||||
avatar: app.user.avatar,
|
||||
username: app.user.username,
|
||||
dashboard,
|
||||
loading,
|
||||
}))
|
||||
class Dashboard extends PureComponent {
|
||||
render() {
|
||||
const { avatar, username, dashboard, loading } = this.props
|
||||
const userDetail = store.get('user')
|
||||
const { avatar, username } = userDetail
|
||||
const { dashboard, loading } = this.props
|
||||
const {
|
||||
weather,
|
||||
sales,
|
||||
@@ -154,8 +155,6 @@ class Dashboard extends PureComponent {
|
||||
}
|
||||
|
||||
Dashboard.propTypes = {
|
||||
avatar: PropTypes.string,
|
||||
username: PropTypes.string,
|
||||
dashboard: PropTypes.object,
|
||||
loading: PropTypes.object,
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import { parse } from 'qs'
|
||||
import modelExtend from 'dva-model-extend'
|
||||
import { queryDashboard, queryWeather } from 'api'
|
||||
import { pathMatchRegexp } from 'utils'
|
||||
import api from 'api'
|
||||
const { pathToRegexp } = require("path-to-regexp")
|
||||
import { model } from 'utils/model'
|
||||
|
||||
const { queryDashboard, queryWeather } = api
|
||||
const avatar = '//cdn.antd-admin.zuiidea.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236.jpeg'
|
||||
|
||||
export default modelExtend(model, {
|
||||
namespace: 'dashboard',
|
||||
state: {
|
||||
@@ -11,12 +14,11 @@ export default modelExtend(model, {
|
||||
city: '深圳',
|
||||
temperature: '30',
|
||||
name: '晴',
|
||||
icon: '//s5.sencdn.com/web/icons/3d_50/2.png',
|
||||
icon: '//cdn.antd-admin.zuiidea.com/sun.png',
|
||||
},
|
||||
sales: [],
|
||||
quote: {
|
||||
avatar:
|
||||
'http://img.hb.aicdn.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236',
|
||||
avatar,
|
||||
},
|
||||
numbers: [],
|
||||
recentSales: [],
|
||||
@@ -25,16 +27,15 @@ export default modelExtend(model, {
|
||||
browser: [],
|
||||
cpu: {},
|
||||
user: {
|
||||
avatar:
|
||||
'http://img.hb.aicdn.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236',
|
||||
avatar,
|
||||
},
|
||||
},
|
||||
subscriptions: {
|
||||
setup({ dispatch, history }) {
|
||||
history.listen(({ pathname }) => {
|
||||
if (
|
||||
pathMatchRegexp('/dashboard', pathname) ||
|
||||
pathMatchRegexp('/', pathname)
|
||||
pathToRegexp('/dashboard').exec(pathname) ||
|
||||
pathToRegexp('/').exec(pathname)
|
||||
) {
|
||||
dispatch({ type: 'query' })
|
||||
dispatch({ type: 'queryWeather' })
|
||||
@@ -60,7 +61,7 @@ export default modelExtend(model, {
|
||||
city: data.location.name,
|
||||
temperature: data.now.temperature,
|
||||
name: data.now.text,
|
||||
icon: `//s5.sencdn.com/web/icons/3d_50/${data.now.code}.png`,
|
||||
icon: `//cdn.antd-admin.zuiidea.com/web/icons/3d_50/${data.now.code}.png`,
|
||||
}
|
||||
yield put({
|
||||
type: 'updateState',
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import React from 'react'
|
||||
import { Editor } from 'components'
|
||||
import { Component } from 'react'
|
||||
import { Editor, Page } from 'components'
|
||||
import { convertToRaw } from 'draft-js'
|
||||
import { Row, Col, Card } from 'antd'
|
||||
import draftToHtml from 'draftjs-to-html'
|
||||
import draftToMarkdown from 'draftjs-to-markdown'
|
||||
|
||||
export default class EditorPage extends React.Component {
|
||||
export default class EditorPage extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
@@ -26,17 +26,18 @@ export default class EditorPage extends React.Component {
|
||||
md: 24,
|
||||
style: {
|
||||
marginBottom: 32,
|
||||
},
|
||||
}
|
||||
}
|
||||
const textareaStyle = {
|
||||
minHeight: 496,
|
||||
width: '100%',
|
||||
background: '#f7f7f7',
|
||||
borderColor: '#F1F1F1',
|
||||
padding: '16px 8px',
|
||||
padding: '16px 8px'
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="content-inner">
|
||||
<Page inner>
|
||||
<Row gutter={32}>
|
||||
<Col {...colProps}>
|
||||
<Card title="Editor" style={{ overflow: 'visible' }}>
|
||||
@@ -98,7 +99,7 @@ export default class EditorPage extends React.Component {
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
import React, { PureComponent } from 'react'
|
||||
import Redirect from 'umi/redirect'
|
||||
import { withI18n } from '@lingui/react'
|
||||
import { Redirect } from 'umi'
|
||||
import { t } from "@lingui/macro"
|
||||
|
||||
@withI18n()
|
||||
class Index extends PureComponent {
|
||||
render() {
|
||||
const { i18n } = this.props
|
||||
return <Redirect to={i18n.t`/dashboard`} />
|
||||
return <Redirect to={t`/dashboard`} />
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,38 +1,31 @@
|
||||
import React, { PureComponent, Fragment } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'dva'
|
||||
import { Button, Row, Form, Icon, Input } from 'antd'
|
||||
import { GlobalFooter } from 'ant-design-pro'
|
||||
import { Trans, withI18n } from '@lingui/react'
|
||||
import { connect } from 'umi'
|
||||
import { Button, Row, Input, Form } from 'antd'
|
||||
import { GlobalFooter } from 'components'
|
||||
import { GithubOutlined } from '@ant-design/icons'
|
||||
import { t } from "@lingui/macro"
|
||||
import { Trans } from "@lingui/macro"
|
||||
import { setLocale } from 'utils'
|
||||
import config from 'utils/config'
|
||||
|
||||
import styles from './index.less'
|
||||
|
||||
const FormItem = Form.Item
|
||||
|
||||
@withI18n()
|
||||
@connect(({ loading }) => ({ loading }))
|
||||
@Form.create()
|
||||
@connect(({ loading, dispatch }) => ({ loading, dispatch }))
|
||||
class Login extends PureComponent {
|
||||
handleOk = () => {
|
||||
const { dispatch, form } = this.props
|
||||
const { validateFieldsAndScroll } = form
|
||||
validateFieldsAndScroll((errors, values) => {
|
||||
if (errors) {
|
||||
return
|
||||
}
|
||||
dispatch({ type: 'login/login', payload: values })
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
const { loading, form, i18n } = this.props
|
||||
const { getFieldDecorator } = form
|
||||
|
||||
const { dispatch, loading } = this.props
|
||||
|
||||
const handleOk = values => {
|
||||
dispatch({ type: 'login/login', payload: values })
|
||||
}
|
||||
let footerLinks = [
|
||||
{
|
||||
key: 'github',
|
||||
title: <Icon type="github" />,
|
||||
title: <GithubOutlined />,
|
||||
href: 'https://github.com/zuiidea/antd-admin',
|
||||
blankTarget: true,
|
||||
},
|
||||
@@ -56,46 +49,32 @@ class Login extends PureComponent {
|
||||
<img alt="logo" src={config.logoPath} />
|
||||
<span>{config.siteName}</span>
|
||||
</div>
|
||||
<form>
|
||||
<FormItem hasFeedback>
|
||||
{getFieldDecorator('username', {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
})(
|
||||
<Form
|
||||
onFinish={handleOk}
|
||||
>
|
||||
<FormItem name="username"
|
||||
rules={[{ required: true }]} hasFeedback>
|
||||
<Input
|
||||
onPressEnter={this.handleOk}
|
||||
placeholder={i18n.t`Username`}
|
||||
placeholder={t`Username`}
|
||||
/>
|
||||
)}
|
||||
</FormItem>
|
||||
<FormItem hasFeedback>
|
||||
{getFieldDecorator('password', {
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
})(
|
||||
<FormItem name="password"
|
||||
rules={[{ required: true }]} hasFeedback>
|
||||
<Input
|
||||
type="password"
|
||||
onPressEnter={this.handleOk}
|
||||
placeholder={i18n.t`Password`}
|
||||
placeholder={t`Password`}
|
||||
/>
|
||||
)}
|
||||
</FormItem>
|
||||
<Row>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={this.handleOk}
|
||||
htmlType="submit"
|
||||
loading={loading.effects.login}
|
||||
>
|
||||
<Trans>Sign in</Trans>
|
||||
</Button>
|
||||
<p>
|
||||
<span>
|
||||
<span className="margin-right">
|
||||
<Trans>Username</Trans>
|
||||
:guest
|
||||
</span>
|
||||
@@ -105,7 +84,7 @@ class Login extends PureComponent {
|
||||
</span>
|
||||
</p>
|
||||
</Row>
|
||||
</form>
|
||||
</Form>
|
||||
</div>
|
||||
<div className={styles.footer}>
|
||||
<GlobalFooter links={footerLinks} copyright={config.copyright} />
|
||||
|
||||
@@ -1,11 +1,21 @@
|
||||
import { router, pathMatchRegexp } from 'utils'
|
||||
import { loginUser } from 'api'
|
||||
import { history } from 'umi'
|
||||
const { pathToRegexp } = require("path-to-regexp")
|
||||
import api from 'api'
|
||||
|
||||
const { loginUser } = api
|
||||
|
||||
export default {
|
||||
namespace: 'login',
|
||||
|
||||
state: {},
|
||||
|
||||
// subscriptions: {
|
||||
// setup({ dispatch, history }) {
|
||||
// history.listen(location => {
|
||||
// if (pathToRegexp('/login').exec(location.pathname)) {
|
||||
// }
|
||||
// })
|
||||
// },
|
||||
// },
|
||||
effects: {
|
||||
*login({ payload }, { put, call, select }) {
|
||||
const data = yield call(loginUser, payload)
|
||||
@@ -13,11 +23,11 @@ export default {
|
||||
if (data.success) {
|
||||
const { from } = locationQuery
|
||||
yield put({ type: 'app/query' })
|
||||
if (!pathMatchRegexp('/login', from)) {
|
||||
if (from === '/') router.push('/dashboard')
|
||||
else router.push(from)
|
||||
if (!pathToRegexp('/login').exec(from)) {
|
||||
if (['', '/'].includes(from)) history.push('/dashboard')
|
||||
else history.push(from)
|
||||
} else {
|
||||
router.push('/dashboard')
|
||||
history.push('/dashboard')
|
||||
}
|
||||
} else {
|
||||
throw data
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
import React, { PureComponent } from 'react'
|
||||
import { Table, Avatar } from 'antd'
|
||||
import { withI18n } from '@lingui/react'
|
||||
import { Ellipsis } from 'ant-design-pro'
|
||||
import { t } from "@lingui/macro"
|
||||
import { Ellipsis } from 'components'
|
||||
import styles from './List.less'
|
||||
|
||||
@withI18n()
|
||||
class List extends PureComponent {
|
||||
render() {
|
||||
const { i18n, ...tableProps } = this.props
|
||||
const { ...tableProps } = this.props
|
||||
const columns = [
|
||||
{
|
||||
title: i18n.t`Image`,
|
||||
title: t`Image`,
|
||||
dataIndex: 'image',
|
||||
render: text => <Avatar shape="square" src={text} />,
|
||||
},
|
||||
{
|
||||
title: i18n.t`Title`,
|
||||
title: t`Title`,
|
||||
dataIndex: 'title',
|
||||
render: text => (
|
||||
<Ellipsis tooltip length={30}>
|
||||
@@ -24,31 +23,31 @@ class List extends PureComponent {
|
||||
),
|
||||
},
|
||||
{
|
||||
title: i18n.t`Author`,
|
||||
title: t`Author`,
|
||||
dataIndex: 'author',
|
||||
},
|
||||
{
|
||||
title: i18n.t`Categories`,
|
||||
title: t`Categories`,
|
||||
dataIndex: 'categories',
|
||||
},
|
||||
{
|
||||
title: i18n.t`Tags`,
|
||||
title: t`Tags`,
|
||||
dataIndex: 'tags',
|
||||
},
|
||||
{
|
||||
title: i18n.t`Visibility`,
|
||||
title: t`Visibility`,
|
||||
dataIndex: 'visibility',
|
||||
},
|
||||
{
|
||||
title: i18n.t`Comments`,
|
||||
title: t`Comments`,
|
||||
dataIndex: 'comments',
|
||||
},
|
||||
{
|
||||
title: i18n.t`Views`,
|
||||
title: t`Views`,
|
||||
dataIndex: 'views',
|
||||
},
|
||||
{
|
||||
title: i18n.t`Publish Date`,
|
||||
title: t`Publish Date`,
|
||||
dataIndex: 'date',
|
||||
},
|
||||
]
|
||||
@@ -58,7 +57,7 @@ class List extends PureComponent {
|
||||
{...tableProps}
|
||||
pagination={{
|
||||
...tableProps.pagination,
|
||||
showTotal: total => i18n.t`Total ${total} Items`,
|
||||
showTotal: total => t`Total ${total} Items`,
|
||||
}}
|
||||
bordered
|
||||
scroll={{ x: 1200 }}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import React, { PureComponent } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'dva'
|
||||
import { connect } from 'umi'
|
||||
import { Tabs } from 'antd'
|
||||
import { router } from 'utils'
|
||||
import { history } from 'umi'
|
||||
import { stringify } from 'qs'
|
||||
import { withI18n } from '@lingui/react'
|
||||
import { t } from "@lingui/macro"
|
||||
import { Page } from 'components'
|
||||
import List from './components/List'
|
||||
|
||||
@@ -15,20 +15,30 @@ const EnumPostStatus = {
|
||||
PUBLISHED: 2,
|
||||
}
|
||||
|
||||
@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
|
||||
|
||||
history.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'],
|
||||
onChange(page) {
|
||||
router.push({
|
||||
history.push({
|
||||
pathname,
|
||||
search: stringify({
|
||||
...query,
|
||||
@@ -38,15 +48,11 @@ class Post extends PureComponent {
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const handleTabClick = key => {
|
||||
router.push({
|
||||
pathname,
|
||||
search: stringify({
|
||||
status: key,
|
||||
}),
|
||||
})
|
||||
}
|
||||
render() {
|
||||
const { location } = this.props
|
||||
const { query } = location
|
||||
|
||||
return (
|
||||
<Page inner>
|
||||
@@ -56,19 +62,19 @@ class Post extends PureComponent {
|
||||
? String(EnumPostStatus.UNPUBLISH)
|
||||
: String(EnumPostStatus.PUBLISHED)
|
||||
}
|
||||
onTabClick={handleTabClick}
|
||||
onTabClick={this.handleTabClick}
|
||||
>
|
||||
<TabPane
|
||||
tab={i18n.t`Publised`}
|
||||
tab={t`Publised`}
|
||||
key={String(EnumPostStatus.PUBLISHED)}
|
||||
>
|
||||
<List {...listProps} />
|
||||
<List {...this.listProps} />
|
||||
</TabPane>
|
||||
<TabPane
|
||||
tab={i18n.t`Unpublished`}
|
||||
tab={t`Unpublished`}
|
||||
key={String(EnumPostStatus.UNPUBLISH)}
|
||||
>
|
||||
<List {...listProps} />
|
||||
<List {...this.listProps} />
|
||||
</TabPane>
|
||||
</Tabs>
|
||||
</Page>
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
import modelExtend from 'dva-model-extend'
|
||||
import { queryPostList } from 'api'
|
||||
import { pathMatchRegexp } from 'utils'
|
||||
import api from 'api'
|
||||
const { pathToRegexp } = require("path-to-regexp")
|
||||
import { pageModel } from 'utils/model'
|
||||
|
||||
const { queryPostList } = api
|
||||
|
||||
export default modelExtend(pageModel, {
|
||||
namespace: 'post',
|
||||
|
||||
subscriptions: {
|
||||
setup({ dispatch, history }) {
|
||||
history.listen(location => {
|
||||
if (pathMatchRegexp('/post', location.pathname)) {
|
||||
if (pathToRegexp('/post').exec(location.pathname)) {
|
||||
dispatch({
|
||||
type: 'query',
|
||||
payload: {
|
||||
|
||||
@@ -1,20 +1,10 @@
|
||||
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, Form, Input, Button, List, Tag, Checkbox } from 'antd'
|
||||
import classnames from 'classnames'
|
||||
import { Trans } from '@lingui/react'
|
||||
import { CloseOutlined } from '@ant-design/icons'
|
||||
import { Trans } from "@lingui/macro"
|
||||
import api from '@/services/api'
|
||||
import { Page } from 'components'
|
||||
|
||||
@@ -46,8 +36,8 @@ const requests = Object.values(api).map(item => {
|
||||
})
|
||||
|
||||
let uuid = 2
|
||||
@Form.create()
|
||||
class RequestPage extends React.Component {
|
||||
formRef = React.createRef()
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
@@ -62,15 +52,17 @@ class RequestPage extends React.Component {
|
||||
handleRequest = () => {
|
||||
const { method, url } = this.state
|
||||
|
||||
this.props.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
this.formRef.current.validateFields()
|
||||
.then(values => {
|
||||
// values: { check[1]: true, key[1]: 'username', value[1]: 'admin' }
|
||||
|
||||
const params = {}
|
||||
if (values.key) {
|
||||
values.key.forEach((item, index) => {
|
||||
if (item && values.check[index]) {
|
||||
params[item] = values.value[index]
|
||||
}
|
||||
})
|
||||
for (let i in values) {
|
||||
if (i.startsWith('check')) {
|
||||
const index = i.match(/check\[(\d+)\]/)[1]
|
||||
const key = values[`key[${index}]`]
|
||||
params[key] = values[`value[${index}]`]
|
||||
}
|
||||
}
|
||||
|
||||
request({ method, url, data: params }).then(data => {
|
||||
@@ -78,8 +70,23 @@ class RequestPage extends React.Component {
|
||||
result: JSON.stringify(data),
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
.catch(errorInfo => {
|
||||
console.log(errorInfo)
|
||||
/*
|
||||
errorInfo:
|
||||
{
|
||||
values: {
|
||||
username: 'username',
|
||||
password: 'password',
|
||||
},
|
||||
errorFields: [
|
||||
{ password: ['username'], errors: ['Please input your Password!'] },
|
||||
],
|
||||
outOfDate: false,
|
||||
}
|
||||
*/
|
||||
})
|
||||
}
|
||||
|
||||
handleClickListItem = ({ method, url }) => {
|
||||
@@ -127,7 +134,6 @@ class RequestPage extends React.Component {
|
||||
|
||||
render() {
|
||||
const { result, url, method, keys, visible } = this.state
|
||||
const { getFieldDecorator } = this.props.form
|
||||
|
||||
return (
|
||||
<Page inner>
|
||||
@@ -196,53 +202,51 @@ class RequestPage extends React.Component {
|
||||
<Trans>Send</Trans>
|
||||
</Button>
|
||||
</Row>
|
||||
<Form ref={this.formRef} name="control-ref" >
|
||||
<div
|
||||
className={classnames(styles.paramsBlock, {
|
||||
[styles.hideParams]: !visible,
|
||||
})}
|
||||
>
|
||||
{keys.map((key, index) => (
|
||||
<Row
|
||||
gutter={8}
|
||||
type="flex"
|
||||
justify="start"
|
||||
align="middle"
|
||||
key={key}
|
||||
>
|
||||
<Col style={{ marginTop: 8 }}>
|
||||
<Form.Item name={`check[${key}]`} valuePropName="checked">
|
||||
<Checkbox defaultChecked />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col style={{ marginTop: 8 }}>
|
||||
<Form.Item name={`key[${key}]`}>
|
||||
<Input placeholder="Key" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col style={{ marginTop: 8 }}>
|
||||
<Form.Item name={`value[${key}]`}>
|
||||
<Input placeholder="Value" />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col style={{ marginTop: 8 }}>
|
||||
<CloseOutlined
|
||||
onClick={this.handleRemoveField.bind(this, key)}
|
||||
style={{ cursor: 'pointer' }}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
))}
|
||||
|
||||
<div
|
||||
className={classnames(styles.paramsBlock, {
|
||||
[styles.hideParams]: !visible,
|
||||
})}
|
||||
>
|
||||
{keys.map((key, index) => (
|
||||
<Row
|
||||
gutter={8}
|
||||
type="flex"
|
||||
justify="start"
|
||||
align="middle"
|
||||
key={key}
|
||||
>
|
||||
<Col style={{ marginTop: 8 }}>
|
||||
{getFieldDecorator(`check[${key}]`, {
|
||||
initialValue: true,
|
||||
})(<Checkbox defaultChecked />)}
|
||||
</Col>
|
||||
<Col style={{ marginTop: 8 }}>
|
||||
{getFieldDecorator(`key[${key}]`)(
|
||||
<Input placeholder="Key" />
|
||||
)}
|
||||
</Col>
|
||||
<Col style={{ marginTop: 8 }}>
|
||||
{getFieldDecorator(`value[${key}]`)(
|
||||
<Input placeholder="Value" />
|
||||
)}
|
||||
</Col>
|
||||
<Col style={{ marginTop: 8 }}>
|
||||
<Icon
|
||||
onClick={this.handleRemoveField.bind(this, key)}
|
||||
style={{ cursor: 'pointer' }}
|
||||
type="close"
|
||||
theme="outlined"
|
||||
/>
|
||||
</Col>
|
||||
<Row style={{ marginTop: 8 }}>
|
||||
<Button onClick={this.handleAddField}>
|
||||
<Trans>Add Param</Trans>
|
||||
</Button>
|
||||
</Row>
|
||||
))}
|
||||
|
||||
<Row style={{ marginTop: 8 }}>
|
||||
<Button onClick={this.handleAddField}>
|
||||
<Trans>Add Param</Trans>
|
||||
</Button>
|
||||
</Row>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</Form>
|
||||
<div className={styles.result}>{result}</div>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { PureComponent } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'dva'
|
||||
import { connect } from 'umi'
|
||||
import { Page } from 'components'
|
||||
import styles from './index.less'
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { pathMatchRegexp } from 'utils'
|
||||
import { queryUser } from 'api'
|
||||
const { pathToRegexp } = require("path-to-regexp")
|
||||
import api from 'api'
|
||||
|
||||
const { queryUser } = api
|
||||
|
||||
export default {
|
||||
namespace: 'userDetail',
|
||||
@@ -11,7 +13,7 @@ export default {
|
||||
subscriptions: {
|
||||
setup({ dispatch, history }) {
|
||||
history.listen(({ pathname }) => {
|
||||
const match = pathMatchRegexp('/user/:id', pathname)
|
||||
const match = pathToRegexp('/user/:id').exec(pathname)
|
||||
if (match) {
|
||||
dispatch({ type: 'query', payload: { id: match[1] } })
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
/* global document */
|
||||
import React, { PureComponent } from 'react'
|
||||
import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import moment from 'moment'
|
||||
import { FilterItem } from 'components'
|
||||
import { Trans, withI18n } from '@lingui/react'
|
||||
import { Form, Button, Row, Col, DatePicker, Input, Cascader } from 'antd'
|
||||
import { Trans } from "@lingui/macro"
|
||||
import { t } from "@lingui/macro"
|
||||
import { Button, Row, Col, DatePicker, Form, Input, Cascader } from 'antd'
|
||||
import city from 'utils/city'
|
||||
|
||||
const { Search } = Input
|
||||
@@ -23,12 +23,12 @@ const TwoColProps = {
|
||||
xl: 96,
|
||||
}
|
||||
|
||||
@withI18n()
|
||||
@Form.create()
|
||||
class Filter extends PureComponent {
|
||||
class Filter extends Component {
|
||||
formRef = React.createRef()
|
||||
|
||||
handleFields = fields => {
|
||||
const { createTime } = fields
|
||||
if (createTime.length) {
|
||||
if (createTime && createTime.length) {
|
||||
fields.createTime = [
|
||||
moment(createTime[0]).format('YYYY-MM-DD'),
|
||||
moment(createTime[1]).format('YYYY-MM-DD'),
|
||||
@@ -38,19 +38,14 @@ class Filter extends PureComponent {
|
||||
}
|
||||
|
||||
handleSubmit = () => {
|
||||
const { onFilterChange, form } = this.props
|
||||
const { getFieldsValue } = form
|
||||
|
||||
let fields = getFieldsValue()
|
||||
fields = this.handleFields(fields)
|
||||
const { onFilterChange } = this.props
|
||||
const values = this.formRef.current.getFieldsValue()
|
||||
const fields = this.handleFields(values)
|
||||
onFilterChange(fields)
|
||||
}
|
||||
|
||||
handleReset = () => {
|
||||
const { form } = this.props
|
||||
const { getFieldsValue, setFieldsValue } = form
|
||||
|
||||
const fields = getFieldsValue()
|
||||
const fields = this.formRef.current.getFieldsValue()
|
||||
for (let item in fields) {
|
||||
if ({}.hasOwnProperty.call(fields, item)) {
|
||||
if (fields[item] instanceof Array) {
|
||||
@@ -60,22 +55,19 @@ class Filter extends PureComponent {
|
||||
}
|
||||
}
|
||||
}
|
||||
setFieldsValue(fields)
|
||||
this.formRef.current.setFieldsValue(fields)
|
||||
this.handleSubmit()
|
||||
}
|
||||
handleChange = (key, values) => {
|
||||
const { form, onFilterChange } = this.props
|
||||
const { getFieldsValue } = form
|
||||
|
||||
let fields = getFieldsValue()
|
||||
const { onFilterChange } = this.props
|
||||
let fields = this.formRef.current.getFieldsValue()
|
||||
fields[key] = values
|
||||
fields = this.handleFields(fields)
|
||||
onFilterChange(fields)
|
||||
}
|
||||
|
||||
render() {
|
||||
const { onAdd, filter, form, i18n } = this.props
|
||||
const { getFieldDecorator } = form
|
||||
const { onAdd, filter } = this.props
|
||||
const { name, address } = filter
|
||||
|
||||
let initialCreateTime = []
|
||||
@@ -87,86 +79,77 @@ class Filter extends PureComponent {
|
||||
}
|
||||
|
||||
return (
|
||||
<Row gutter={24}>
|
||||
<Col {...ColProps} xl={{ span: 4 }} md={{ span: 8 }}>
|
||||
{getFieldDecorator('name', { initialValue: name })(
|
||||
<Search
|
||||
placeholder={i18n.t`Search Name`}
|
||||
onSearch={this.handleSubmit}
|
||||
/>
|
||||
)}
|
||||
</Col>
|
||||
<Col
|
||||
{...ColProps}
|
||||
xl={{ span: 4 }}
|
||||
md={{ span: 8 }}
|
||||
id="addressCascader"
|
||||
>
|
||||
{getFieldDecorator('address', { initialValue: address })(
|
||||
<Cascader
|
||||
style={{ width: '100%' }}
|
||||
options={city}
|
||||
placeholder={i18n.t`Please pick an address`}
|
||||
onChange={this.handleChange.bind(this, 'address')}
|
||||
getPopupContainer={() =>
|
||||
document.getElementById('addressCascader')
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</Col>
|
||||
<Col
|
||||
{...ColProps}
|
||||
xl={{ span: 6 }}
|
||||
md={{ span: 8 }}
|
||||
sm={{ span: 12 }}
|
||||
id="createTimeRangePicker"
|
||||
>
|
||||
<FilterItem label={i18n.t`CreateTime`}>
|
||||
{getFieldDecorator('createTime', {
|
||||
initialValue: initialCreateTime,
|
||||
})(
|
||||
<RangePicker
|
||||
style={{ width: '100%' }}
|
||||
onChange={this.handleChange.bind(this, 'createTime')}
|
||||
getCalendarContainer={() => {
|
||||
return document.getElementById('createTimeRangePicker')
|
||||
}}
|
||||
<Form ref={this.formRef} name="control-ref" initialValues={{ name, address, createTime: initialCreateTime }}>
|
||||
<Row gutter={24}>
|
||||
<Col {...ColProps} xl={{ span: 4 }} md={{ span: 8 }}>
|
||||
<Form.Item name="name">
|
||||
<Search
|
||||
placeholder={t`Search Name`}
|
||||
onSearch={this.handleSubmit}
|
||||
/>
|
||||
)}
|
||||
</FilterItem>
|
||||
</Col>
|
||||
<Col
|
||||
{...TwoColProps}
|
||||
xl={{ span: 10 }}
|
||||
md={{ span: 24 }}
|
||||
sm={{ span: 24 }}
|
||||
>
|
||||
<Row type="flex" align="middle" justify="space-between">
|
||||
<div>
|
||||
<Button
|
||||
type="primary"
|
||||
className="margin-right"
|
||||
onClick={this.handleSubmit}
|
||||
>
|
||||
<Trans>Search</Trans>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col
|
||||
{...ColProps}
|
||||
xl={{ span: 4 }}
|
||||
md={{ span: 8 }}
|
||||
id="addressCascader"
|
||||
>
|
||||
<Form.Item name="address">
|
||||
<Cascader
|
||||
style={{ width: '100%' }}
|
||||
options={city}
|
||||
placeholder={t`Please pick an address`}
|
||||
/>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col
|
||||
{...ColProps}
|
||||
xl={{ span: 6 }}
|
||||
md={{ span: 8 }}
|
||||
sm={{ span: 12 }}
|
||||
id="createTimeRangePicker"
|
||||
>
|
||||
<FilterItem label={t`CreateTime`}>
|
||||
<Form.Item name="createTime">
|
||||
<RangePicker
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</Form.Item>
|
||||
</FilterItem>
|
||||
</Col>
|
||||
<Col
|
||||
{...TwoColProps}
|
||||
xl={{ span: 10 }}
|
||||
md={{ span: 24 }}
|
||||
sm={{ span: 24 }}
|
||||
>
|
||||
<Row type="flex" align="middle" justify="space-between">
|
||||
<div>
|
||||
<Button
|
||||
type="primary" htmlType="submit"
|
||||
className="margin-right"
|
||||
onClick={this.handleSubmit}
|
||||
>
|
||||
<Trans>Search</Trans>
|
||||
</Button>
|
||||
<Button onClick={this.handleReset}>
|
||||
<Trans>Reset</Trans>
|
||||
</Button>
|
||||
</div>
|
||||
<Button type="ghost" onClick={onAdd}>
|
||||
<Trans>Create</Trans>
|
||||
</Button>
|
||||
<Button onClick={this.handleReset}>
|
||||
<Trans>Reset</Trans>
|
||||
</Button>
|
||||
</div>
|
||||
<Button type="ghost" onClick={onAdd}>
|
||||
<Trans>Create</Trans>
|
||||
</Button>
|
||||
</Row>
|
||||
</Col>
|
||||
</Row>
|
||||
</Row>
|
||||
</Col>
|
||||
</Row>
|
||||
</Form>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Filter.propTypes = {
|
||||
onAdd: PropTypes.func,
|
||||
form: PropTypes.object,
|
||||
filter: PropTypes.object,
|
||||
onFilterChange: PropTypes.func,
|
||||
}
|
||||
|
||||
@@ -2,22 +2,22 @@ import React, { PureComponent } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Table, Modal, Avatar } from 'antd'
|
||||
import { DropOption } from 'components'
|
||||
import { Trans, withI18n } from '@lingui/react'
|
||||
import Link from 'umi/link'
|
||||
import { t } from "@lingui/macro"
|
||||
import { Trans } from "@lingui/macro"
|
||||
import { Link } from 'umi'
|
||||
import styles from './List.less'
|
||||
|
||||
const { confirm } = Modal
|
||||
|
||||
@withI18n()
|
||||
class List extends PureComponent {
|
||||
handleMenuClick = (record, e) => {
|
||||
const { onDeleteItem, onEditItem, i18n } = this.props
|
||||
const { onDeleteItem, onEditItem } = this.props
|
||||
|
||||
if (e.key === '1') {
|
||||
onEditItem(record)
|
||||
} else if (e.key === '2') {
|
||||
confirm({
|
||||
title: i18n.t`Are you sure delete this record?`,
|
||||
title: t`Are you sure delete this record?`,
|
||||
onOk() {
|
||||
onDeleteItem(record.id)
|
||||
},
|
||||
@@ -26,14 +26,14 @@ class List extends PureComponent {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { onDeleteItem, onEditItem, i18n, ...tableProps } = this.props
|
||||
const { onDeleteItem, onEditItem, ...tableProps } = this.props
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: <Trans>Avatar</Trans>,
|
||||
dataIndex: 'avatar',
|
||||
key: 'avatar',
|
||||
width: 72,
|
||||
width: '7%',
|
||||
fixed: 'left',
|
||||
render: text => <Avatar style={{ marginLeft: 8 }} src={text} />,
|
||||
},
|
||||
@@ -51,12 +51,14 @@ class List extends PureComponent {
|
||||
{
|
||||
title: <Trans>Age</Trans>,
|
||||
dataIndex: 'age',
|
||||
width: '6%',
|
||||
key: 'age',
|
||||
},
|
||||
{
|
||||
title: <Trans>Gender</Trans>,
|
||||
dataIndex: 'isMale',
|
||||
key: 'isMale',
|
||||
width: '7%',
|
||||
render: text => <span>{text ? 'Male' : 'Female'}</span>,
|
||||
},
|
||||
{
|
||||
@@ -83,13 +85,14 @@ class List extends PureComponent {
|
||||
title: <Trans>Operation</Trans>,
|
||||
key: 'operation',
|
||||
fixed: 'right',
|
||||
width: '8%',
|
||||
render: (text, record) => {
|
||||
return (
|
||||
<DropOption
|
||||
onMenuClick={e => this.handleMenuClick(record, e)}
|
||||
menuOptions={[
|
||||
{ key: '1', name: i18n.t`Update` },
|
||||
{ key: '2', name: i18n.t`Delete` },
|
||||
{ key: '1', name: t`Update` },
|
||||
{ key: '2', name: t`Delete` },
|
||||
]}
|
||||
/>
|
||||
)
|
||||
@@ -102,7 +105,7 @@ class List extends PureComponent {
|
||||
{...tableProps}
|
||||
pagination={{
|
||||
...tableProps.pagination,
|
||||
showTotal: total => i18n.t`Total ${total} Items`,
|
||||
showTotal: total => t`Total ${total} Items`,
|
||||
}}
|
||||
className={styles.table}
|
||||
bordered
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import React, { PureComponent } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Form, Input, InputNumber, Radio, Modal, Cascader } from 'antd'
|
||||
import { Trans, withI18n } from '@lingui/react'
|
||||
import { Trans } from "@lingui/macro"
|
||||
import city from 'utils/city'
|
||||
import { t } from "@lingui/macro"
|
||||
|
||||
const FormItem = Form.Item
|
||||
|
||||
@@ -14,123 +15,70 @@ const formItemLayout = {
|
||||
span: 14,
|
||||
},
|
||||
}
|
||||
@withI18n()
|
||||
@Form.create()
|
||||
class UserModal extends PureComponent {
|
||||
handleOk = () => {
|
||||
const { item = {}, onOk, form } = this.props
|
||||
const { validateFields, getFieldsValue } = form
|
||||
|
||||
validateFields(errors => {
|
||||
if (errors) {
|
||||
return
|
||||
}
|
||||
const data = {
|
||||
...getFieldsValue(),
|
||||
key: item.key,
|
||||
}
|
||||
data.address = data.address.join(' ')
|
||||
onOk(data)
|
||||
})
|
||||
class UserModal extends PureComponent {
|
||||
formRef = React.createRef()
|
||||
|
||||
handleOk = () => {
|
||||
const { item = {}, onOk } = this.props
|
||||
|
||||
this.formRef.current.validateFields()
|
||||
.then(values => {
|
||||
const data = {
|
||||
...values,
|
||||
key: item.key,
|
||||
}
|
||||
data.address = data.address.join(' ')
|
||||
onOk(data)
|
||||
})
|
||||
.catch(errorInfo => {
|
||||
console.log(errorInfo)
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
const { item = {}, onOk, form, i18n, ...modalProps } = this.props
|
||||
const { getFieldDecorator } = form
|
||||
const { item = {}, onOk, form, ...modalProps } = this.props
|
||||
|
||||
return (
|
||||
<Modal {...modalProps} onOk={this.handleOk}>
|
||||
<Form layout="horizontal">
|
||||
<FormItem label={i18n.t`Name`} hasFeedback {...formItemLayout}>
|
||||
{getFieldDecorator('name', {
|
||||
initialValue: item.name,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
})(<Input />)}
|
||||
<Form ref={this.formRef} name="control-ref" initialValues={{ ...item, address: item.address && item.address.split(' ') }} layout="horizontal">
|
||||
<FormItem name='name' rules={[{ required: true }]}
|
||||
label={t`Name`} hasFeedback {...formItemLayout}>
|
||||
<Input />
|
||||
</FormItem>
|
||||
<FormItem label={i18n.t`NickName`} hasFeedback {...formItemLayout}>
|
||||
{getFieldDecorator('nickName', {
|
||||
initialValue: item.nickName,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
})(<Input />)}
|
||||
<FormItem name='nickName' rules={[{ required: true }]}
|
||||
label={t`NickName`} hasFeedback {...formItemLayout}>
|
||||
<Input />
|
||||
</FormItem>
|
||||
<FormItem label={i18n.t`Gender`} hasFeedback {...formItemLayout}>
|
||||
{getFieldDecorator('isMale', {
|
||||
initialValue: item.isMale,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
type: 'boolean',
|
||||
},
|
||||
],
|
||||
})(
|
||||
<Radio.Group>
|
||||
<Radio value>
|
||||
<Trans>Male</Trans>
|
||||
</Radio>
|
||||
<Radio value={false}>
|
||||
<Trans>Female</Trans>
|
||||
</Radio>
|
||||
</Radio.Group>
|
||||
)}
|
||||
<FormItem name='isMale' rules={[{ required: true }]}
|
||||
label={t`Gender`} hasFeedback {...formItemLayout}>
|
||||
<Radio.Group>
|
||||
<Radio value>
|
||||
<Trans>Male</Trans>
|
||||
</Radio>
|
||||
<Radio value={false}>
|
||||
<Trans>Female</Trans>
|
||||
</Radio>
|
||||
</Radio.Group>
|
||||
</FormItem>
|
||||
<FormItem label={i18n.t`Age`} hasFeedback {...formItemLayout}>
|
||||
{getFieldDecorator('age', {
|
||||
initialValue: item.age,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
},
|
||||
],
|
||||
})(<InputNumber min={18} max={100} />)}
|
||||
<FormItem name='age' label={t`Age`} hasFeedback {...formItemLayout}>
|
||||
<InputNumber min={18} max={100} />
|
||||
</FormItem>
|
||||
<FormItem label={i18n.t`Phone`} hasFeedback {...formItemLayout}>
|
||||
{getFieldDecorator('phone', {
|
||||
initialValue: item.phone,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
pattern: /^1[34578]\d{9}$/,
|
||||
message: i18n.t`The input is not valid phone!`,
|
||||
},
|
||||
],
|
||||
})(<Input />)}
|
||||
<FormItem name='phone' rules={[{ required: true, pattern: /^1[34578]\d{9}$/, message: t`The input is not valid phone!`, }]}
|
||||
label={t`Phone`} hasFeedback {...formItemLayout}>
|
||||
<Input />
|
||||
</FormItem>
|
||||
<FormItem label={i18n.t`Email`} hasFeedback {...formItemLayout}>
|
||||
{getFieldDecorator('email', {
|
||||
initialValue: item.email,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
pattern: /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/,
|
||||
message: i18n.t`The input is not valid E-mail!`,
|
||||
},
|
||||
],
|
||||
})(<Input />)}
|
||||
<FormItem name='email' rules={[{ required: true, pattern: /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/, message: t`The input is not valid E-mail!`, }]}
|
||||
label={t`Email`} hasFeedback {...formItemLayout}>
|
||||
<Input />
|
||||
</FormItem>
|
||||
<FormItem label={i18n.t`Address`} hasFeedback {...formItemLayout}>
|
||||
{getFieldDecorator('address', {
|
||||
initialValue: item.address && item.address.split(' '),
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
})(
|
||||
<Cascader
|
||||
style={{ width: '100%' }}
|
||||
options={city}
|
||||
placeholder={i18n.t`Pick an address`}
|
||||
/>
|
||||
)}
|
||||
<FormItem name='address' rules={[{ required: true, }]}
|
||||
label={t`Address`} hasFeedback {...formItemLayout}>
|
||||
<Cascader
|
||||
style={{ width: '100%' }}
|
||||
options={city}
|
||||
placeholder={t`Pick an address`}
|
||||
/>
|
||||
</FormItem>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
@@ -1,58 +1,72 @@
|
||||
import React, { PureComponent } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { router } from 'utils'
|
||||
import { connect } from 'dva'
|
||||
import { history } from 'umi'
|
||||
import { connect } from 'umi'
|
||||
import { Row, Col, Button, Popconfirm } from 'antd'
|
||||
import { withI18n } from '@lingui/react'
|
||||
import { t } from "@lingui/macro"
|
||||
import { Page } from 'components'
|
||||
import { stringify } from 'qs'
|
||||
import List from './components/List'
|
||||
import Filter from './components/Filter'
|
||||
import Modal from './components/Modal'
|
||||
|
||||
@withI18n()
|
||||
@connect(({ user, loading }) => ({ user, loading }))
|
||||
class User extends PureComponent {
|
||||
render() {
|
||||
const { location, dispatch, user, loading, i18n } = this.props
|
||||
handleRefresh = newQuery => {
|
||||
const { location } = this.props
|
||||
const { query, pathname } = location
|
||||
const {
|
||||
list,
|
||||
pagination,
|
||||
currentItem,
|
||||
modalVisible,
|
||||
modalType,
|
||||
selectedRowKeys,
|
||||
} = user
|
||||
|
||||
const handleRefresh = newQuery => {
|
||||
router.push({
|
||||
pathname,
|
||||
search: stringify(
|
||||
{
|
||||
...query,
|
||||
...newQuery,
|
||||
},
|
||||
{ arrayFormat: 'repeat' }
|
||||
),
|
||||
history.push({
|
||||
pathname,
|
||||
search: stringify(
|
||||
{
|
||||
...query,
|
||||
...newQuery,
|
||||
},
|
||||
{ arrayFormat: 'repeat' }
|
||||
),
|
||||
})
|
||||
}
|
||||
|
||||
handleDeleteItems = () => {
|
||||
const { dispatch, user } = this.props
|
||||
const { list, pagination, selectedRowKeys } = user
|
||||
|
||||
dispatch({
|
||||
type: 'user/multiDelete',
|
||||
payload: {
|
||||
ids: selectedRowKeys,
|
||||
},
|
||||
}).then(() => {
|
||||
this.handleRefresh({
|
||||
page:
|
||||
list.length === selectedRowKeys.length && pagination.current > 1
|
||||
? pagination.current - 1
|
||||
: pagination.current,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const modalProps = {
|
||||
get modalProps() {
|
||||
const { dispatch, user, loading } = this.props
|
||||
const { currentItem, modalVisible, modalType } = user
|
||||
|
||||
return {
|
||||
item: modalType === 'create' ? {} : currentItem,
|
||||
visible: modalVisible,
|
||||
destroyOnClose: true,
|
||||
maskClosable: false,
|
||||
confirmLoading: loading.effects[`user/${modalType}`],
|
||||
title: `${
|
||||
modalType === 'create' ? i18n.t`Create User` : i18n.t`Update User`
|
||||
modalType === 'create' ? t`Create User` : t`Update User`
|
||||
}`,
|
||||
wrapClassName: 'vertical-center-modal',
|
||||
onOk(data) {
|
||||
centered: true,
|
||||
onOk: data => {
|
||||
dispatch({
|
||||
type: `user/${modalType}`,
|
||||
payload: data,
|
||||
}).then(() => {
|
||||
handleRefresh()
|
||||
this.handleRefresh()
|
||||
})
|
||||
},
|
||||
onCancel() {
|
||||
@@ -61,23 +75,28 @@ 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,
|
||||
onChange(page) {
|
||||
handleRefresh({
|
||||
onChange: page => {
|
||||
this.handleRefresh({
|
||||
page: page.current,
|
||||
pageSize: page.pageSize,
|
||||
})
|
||||
},
|
||||
onDeleteItem(id) {
|
||||
onDeleteItem: id => {
|
||||
dispatch({
|
||||
type: 'user/delete',
|
||||
payload: id,
|
||||
}).then(() => {
|
||||
handleRefresh({
|
||||
this.handleRefresh({
|
||||
page:
|
||||
list.length === 1 && pagination.current > 1
|
||||
? pagination.current - 1
|
||||
@@ -106,15 +125,19 @@ class User extends PureComponent {
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const filterProps = {
|
||||
get filterProps() {
|
||||
const { location, dispatch } = this.props
|
||||
const { query } = location
|
||||
|
||||
return {
|
||||
filter: {
|
||||
...query,
|
||||
},
|
||||
onFilterChange(value) {
|
||||
handleRefresh({
|
||||
onFilterChange: value => {
|
||||
this.handleRefresh({
|
||||
...value,
|
||||
page: 1,
|
||||
})
|
||||
},
|
||||
onAdd() {
|
||||
@@ -126,26 +149,15 @@ class User extends PureComponent {
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
const handleDeleteItems = () => {
|
||||
dispatch({
|
||||
type: 'user/multiDelete',
|
||||
payload: {
|
||||
ids: selectedRowKeys,
|
||||
},
|
||||
}).then(() => {
|
||||
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>
|
||||
@@ -153,7 +165,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
|
||||
@@ -162,8 +174,8 @@ class User extends PureComponent {
|
||||
</Col>
|
||||
</Row>
|
||||
)}
|
||||
<List {...listProps} />
|
||||
{modalVisible && <Modal {...modalProps} />}
|
||||
<List {...this.listProps} />
|
||||
<Modal {...this.modalProps} />
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
/* global window */
|
||||
import modelExtend from 'dva-model-extend'
|
||||
import { pathMatchRegexp } from 'utils'
|
||||
import {
|
||||
const { pathToRegexp } = require("path-to-regexp")
|
||||
import api from 'api'
|
||||
import { pageModel } from 'utils/model'
|
||||
|
||||
const {
|
||||
queryUserList,
|
||||
createUser,
|
||||
removeUser,
|
||||
updateUser,
|
||||
removeUserList,
|
||||
} from 'api'
|
||||
import { pageModel } from 'utils/model'
|
||||
} = api
|
||||
|
||||
export default modelExtend(pageModel, {
|
||||
namespace: 'user',
|
||||
@@ -23,7 +24,7 @@ export default modelExtend(pageModel, {
|
||||
subscriptions: {
|
||||
setup({ dispatch, history }) {
|
||||
history.listen(location => {
|
||||
if (pathMatchRegexp('/user', location.pathname)) {
|
||||
if (pathToRegexp('/user').exec(location.pathname)) {
|
||||
const payload = location.query || { page: 1, pageSize: 10 }
|
||||
dispatch({
|
||||
type: 'query',
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -35,4 +35,4 @@ APIFunction.queryWeather = params => {
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = APIFunction
|
||||
export default APIFunction
|
||||
|
||||
@@ -15,6 +15,10 @@ body {
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
.margin-right {
|
||||
margin-right: 16px;
|
||||
}
|
||||
|
||||
:global {
|
||||
.ant-breadcrumb {
|
||||
& > span {
|
||||
@@ -63,21 +67,6 @@ body {
|
||||
box-shadow: 0 0 20px rgba(100, 100, 100, 0.2);
|
||||
}
|
||||
|
||||
.vertical-center-modal {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.ant-modal {
|
||||
top: 0;
|
||||
|
||||
.ant-modal-body {
|
||||
max-height: 80vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ant-form-item-control {
|
||||
vertical-align: middle;
|
||||
}
|
||||
@@ -94,13 +83,13 @@ body {
|
||||
padding: 12px 16px !important;
|
||||
}
|
||||
|
||||
.margin-right {
|
||||
margin-right: 16px;
|
||||
}
|
||||
|
||||
a:focus {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.ant-table-layout-fixed table {
|
||||
table-layout: auto;
|
||||
}
|
||||
}
|
||||
@media (min-width: 1600px) {
|
||||
:global {
|
||||
|
||||