Compare commits

...
3 Commits
Author SHA1 Message Date
zuiidea 5abad21082 ✨ Optimization Split Chunks, Antd Icon, CI. 2020-08-20 14:16:32 +08:00
Baorong Li 1ae41c7ae5 Merge pull request #1060 from mlboy/patch-1
Update README.md
2020-06-03 14:46:44 +08:00
mlboy e41671dbf9 Update README.md
调整antd版本
2020-05-13 07:42:01 +08:00
17 changed files with 139 additions and 122 deletions
+10 -19
View File
@@ -4,24 +4,15 @@ node_js:
script: script:
- npm run build - npm run build
before_install: 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
else
for prefixed_envvar in ${!TEST_*}; do
eval export ${prefixed_envvar#TEST_}="${!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: 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
+57 -47
View File
@@ -3,46 +3,26 @@ import { resolve } from 'path'
const fs = require('fs') const fs = require('fs')
const path = require('path') const path = require('path')
const lessToJs = require('less-vars-to-js') 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 { export default {
// IMPORTANT! change next line to yours or delete. And hide in dev // IMPORTANT! change next line to yours or delete. And hide in dev
// publicPath: 'https://cdn.antd-admin.zuiidea.com/', publicPath: isDevelopment ? '/' : 'https://cdn.antd-admin.zuiidea.com/',
hash: true,
ignoreMomentLocale: true,
targets: { ie: 9 },
dva: { immer: true },
antd: {},
dynamicImport: {
loading: 'components/Loader/Loader',
},
// not support in umi@3
// pwa: {
// manifestOptions: {
// srcPath: 'manifest.json',
// },
// },
// Theme for antd
// https://ant.design/docs/react/customize-theme
theme: lessToJs(
fs.readFileSync(path.join(__dirname, './src/themes/default.less'), 'utf8')
),
// Webpack Configuration
proxy: {
'/api/v1/weather': {
target: 'https://api.seniverse.com/',
changeOrigin: true,
pathRewrite: { '^/api/v1/weather': '/v3/weather' },
},
},
alias: { alias: {
api: resolve(__dirname, './src/services/'), api: resolve(__dirname, './src/services/'),
components: resolve(__dirname, './src/components'), components: resolve(__dirname, './src/components'),
config: resolve(__dirname, './src/utils/config'), config: resolve(__dirname, './src/utils/config'),
models: resolve(__dirname, './src/models'),
services: resolve(__dirname, './src/services'),
themes: resolve(__dirname, './src/themes'), themes: resolve(__dirname, './src/themes'),
utils: resolve(__dirname, './src/utils'), utils: resolve(__dirname, './src/utils'),
}, },
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',
},
extraBabelPresets: ['@lingui/babel-preset-react'], extraBabelPresets: ['@lingui/babel-preset-react'],
extraBabelPlugins: [ extraBabelPlugins: [
[ [
@@ -54,18 +34,38 @@ export default {
}, },
'lodash', 'lodash',
], ],
[
'import',
{
libraryName: '@ant-design/icons',
libraryDirectory: 'es/icons',
camel2DashComponentName: false,
},
'ant-design-icons',
],
], ],
chainWebpack: function(config, { webpack }) { hash: true,
config.module ignoreMomentLocale: true,
.rule('js-in-node_modules') // umi3 comple node_modules by default, could be disable
.exclude.add(/node_modules/) nodeModulesTransform: {
.end() type: 'none',
exclude: [],
config.module },
.rule('ts-in-node_modules') // Webpack Configuration
.exclude.add(/node_modules/) proxy: {
.end() '/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')
),
chainWebpack: function (config, { webpack }) {
config.merge({ config.merge({
optimization: { optimization: {
minimize: true, minimize: true,
@@ -83,27 +83,37 @@ export default {
antd: { antd: {
name: 'antd', name: 'antd',
priority: 20, priority: 20,
test: /[\\/]node_modules[\\/](antd|@ant-design\/icons|@ant-design\/compatible)[\\/]/, 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: { echarts: {
name: 'echarts', name: 'echarts',
priority: 20, priority: 20,
test: /[\\/]node_modules[\\/]echarts|echarts-for-react|echarts-gl|echarts-liquidfill[\\/]/, test: /[\\/]node_modules[\\/](echarts|echarts-for-react|echarts-liquidfill)[\\/]/,
}, },
highcharts: { highcharts: {
name: 'highcharts', name: 'highcharts',
priority: 20, priority: 20,
test: /[\\/]node_modules[\\/](highcharts-exporting|highcharts-more|react-highcharts)[\\/]/, test: /[\\/]node_modules[\\/]highcharts[\\/]/,
}, },
recharts: { recharts: {
name: 'recharts', name: 'recharts',
priority: 20, priority: 20,
test: /[\\/]node_modules[\\/](recharts)[\\/]/, test: /[\\/]node_modules[\\/]recharts[\\/]/,
}, },
draftjs: { draftjs: {
name: 'draftjs', name: 'draftjs',
priority: 20, priority: 30,
test: /[\\/]node_modules[\\/](draftjs-to-html|draftjs-to-markdown)[\\/]/, test: /[\\/]node_modules[\\/](draft-js|react-draft-wysiwyg|draftjs-to-html|draftjs-to-markdown)[\\/]/,
}, },
async: { async: {
chunks: 'async', chunks: 'async',
+1 -1
View File
@@ -11,7 +11,7 @@
An excellent front-end solution for enterprise applications. An excellent front-end solution for enterprise applications.
[![antd](https://img.shields.io/badge/antd-^3.10.0-blue.svg?style=flat-square)](https://github.com/ant-design/ant-design) [![antd](https://img.shields.io/badge/antd-^4.0.0-blue.svg?style=flat-square)](https://github.com/ant-design/ant-design)
[![umi](https://img.shields.io/badge/umi-^2.2.1-orange.svg?style=flat-square)](https://github.com/umijs/umi) [![umi](https://img.shields.io/badge/umi-^2.2.1-orange.svg?style=flat-square)](https://github.com/umijs/umi)
[![GitHub issues](https://img.shields.io/github/issues/zuiidea/antd-admin.svg?style=flat-square)](https://github.com/zuiidea/antd-admin/issues) [![GitHub issues](https://img.shields.io/github/issues/zuiidea/antd-admin.svg?style=flat-square)](https://github.com/zuiidea/antd-admin/issues)
[![MIT](https://img.shields.io/dub/l/vibe-d.svg?style=flat-square)](http://opensource.org/licenses/MIT) [![MIT](https://img.shields.io/dub/l/vibe-d.svg?style=flat-square)](http://opensource.org/licenses/MIT)
BIN
View File
Binary file not shown.
-6
View File
@@ -1,6 +0,0 @@
{
"version": 2,
"name": "antd-admin-devdoc",
"alias": ["devdoc-antd-admin.now.sh", "devdoc.antd-admin.zuiidea.com"],
"public": true
}
-6
View File
@@ -1,6 +0,0 @@
{
"version": 2,
"name": "antd-admin-doc",
"alias": ["doc-antd-admin.now.sh", "doc.antd-admin.zuiidea.com"],
"public": true
}
+1 -1
View File
@@ -105,7 +105,7 @@ const Dashboard = Mock.mock({
content: 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.", "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: avatar:
'http://img.hb.aicdn.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236', '//cdn.antd-admin.zuiidea.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236',
}, },
numbers: [ numbers: [
{ {
+9 -9
View File
@@ -4,13 +4,13 @@
"license": "MIT", "license": "MIT",
"description": "An admin dashboard application demo built upon Ant Design and UmiJS", "description": "An admin dashboard application demo built upon Ant Design and UmiJS",
"dependencies": { "dependencies": {
"@ant-design/compatible": "^1.0.0", "@ant-design/icons": "^4.2.2",
"@ant-design/icons": "^4.0.0",
"@lingui/react": "^2.8.0", "@lingui/react": "^2.8.0",
"antd": "^4.0.0", "antd": "^4.0.0",
"axios": "^0.19.0", "axios": "^0.19.0",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"d3-shape": "^1.3.0", "d3-shape": "^1.3.0",
"draft-js": "^0.11.7",
"draftjs-to-html": "^0.9.0", "draftjs-to-html": "^0.9.0",
"draftjs-to-markdown": "^0.6.0", "draftjs-to-markdown": "^0.6.0",
"dva-model-extend": "^0.1.2", "dva-model-extend": "^0.1.2",
@@ -31,7 +31,7 @@
"react-adsense": "^0.1.0", "react-adsense": "^0.1.0",
"react-countup": "^4.2.0", "react-countup": "^4.2.0",
"react-draft-wysiwyg": "^1.13.0", "react-draft-wysiwyg": "^1.13.0",
"react-helmet": "^5.2.0", "react-helmet": "^6.0.0",
"react-highcharts": "^16.1.0", "react-highcharts": "^16.1.0",
"react-perfect-scrollbar": "^1.5.0", "react-perfect-scrollbar": "^1.5.0",
"recharts": "^2.0.0-beta.3", "recharts": "^2.0.0-beta.3",
@@ -45,25 +45,25 @@
"babel-eslint": "^10.0.1", "babel-eslint": "^10.0.1",
"babel-plugin-dev-expression": "^0.2.1", "babel-plugin-dev-expression": "^0.2.1",
"babel-plugin-module-resolver": "^4.0.0", "babel-plugin-module-resolver": "^4.0.0",
"cross-env": "^6.0.0", "cross-env": "^7.0.0",
"eslint": "^6.8.0", "eslint": "^7.0.0",
"eslint-config-react-app": "^5.0.0", "eslint-config-react-app": "^5.0.0",
"eslint-plugin-flowtype": "^4.6.0", "eslint-plugin-flowtype": "^5.1.0",
"eslint-plugin-import": "^2.18.0", "eslint-plugin-import": "^2.18.0",
"eslint-plugin-jsx-a11y": "^6.2.1", "eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.14.0", "eslint-plugin-react": "^7.14.0",
"eslint-plugin-react-hooks": "^2.5.0", "eslint-plugin-react-hooks": "^4.0.0",
"husky": "^4.2.0", "husky": "^4.2.0",
"less-vars-to-js": "^1.3.0", "less-vars-to-js": "^1.3.0",
"lint-staged": "^10.0.0", "lint-staged": "^10.0.0",
"mockjs": "^1.1.0", "mockjs": "^1.1.0",
"module": "^1.2.5", "module": "^1.2.5",
"prettier": "^1.19.0", "prettier": "^2.0.0",
"stylelint": "^13.2.0", "stylelint": "^13.2.0",
"stylelint-config-prettier": "^8.0.0", "stylelint-config-prettier": "^8.0.0",
"stylelint-config-standard": "^20.0.0", "stylelint-config-standard": "^20.0.0",
"typescript": "^3.8.3", "typescript": "^3.8.3",
"umi": "^3.0.0" "umi": "^3.2.0"
}, },
"engines": { "engines": {
"node": ">= 10.0.0" "node": ">= 10.0.0"
+5 -5
View File
@@ -3,20 +3,20 @@ import PropTypes from 'prop-types'
import { Breadcrumb } from 'antd' import { Breadcrumb } from 'antd'
import { Link, withRouter } from 'umi' import { Link, withRouter } from 'umi'
import { withI18n } from '@lingui/react' import { withI18n } from '@lingui/react'
import { Icon as LegacyIcon } from '@ant-design/compatible' import iconMap from 'utils/iconMap'
const { pathToRegexp } = require("path-to-regexp") const { pathToRegexp } = require('path-to-regexp')
import { queryAncestors } from 'utils' import { queryAncestors } from 'utils'
import styles from './Bread.less' import styles from './Bread.less'
@withI18n() @withI18n()
@withRouter @withRouter
class Bread extends PureComponent { class Bread extends PureComponent {
generateBreadcrumbs = paths => { generateBreadcrumbs = (paths) => {
return paths.map((item, key) => { return paths.map((item, key) => {
const content = item && ( const content = item && (
<Fragment> <Fragment>
{item.icon && ( {item.icon && (
<LegacyIcon type={item.icon} style={{ marginRight: 4 }} /> <span style={{ marginRight: 4 }}>{iconMap[item.icon]}</span>
)} )}
{item.name} {item.name}
</Fragment> </Fragment>
@@ -40,7 +40,7 @@ class Bread extends PureComponent {
// Find a route that matches the pathname. // Find a route that matches the pathname.
const currentRoute = routeList.find( const currentRoute = routeList.find(
_ => _.route && pathToRegexp(_.route).exec(location.pathname) (_) => _.route && pathToRegexp(_.route).exec(location.pathname)
) )
// Find the breadcrumb navigation of the current route match and all its ancestors. // Find the breadcrumb navigation of the current route match and all its ancestors.
+7 -9
View File
@@ -2,8 +2,12 @@ import React, { PureComponent, Fragment } from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { Menu, Layout, Avatar, Popover, Badge, List } from 'antd' import { Menu, Layout, Avatar, Popover, Badge, List } from 'antd'
import { Ellipsis } from 'components' import { Ellipsis } from 'components'
import { Icon as LegacyIcon } from '@ant-design/compatible' import {
import { BellOutlined, RightOutlined } from '@ant-design/icons' BellOutlined,
RightOutlined,
MenuFoldOutlined,
MenuUnfoldOutlined,
} from '@ant-design/icons'
import { Trans, withI18n } from '@lingui/react' import { Trans, withI18n } from '@lingui/react'
import { setLocale } from 'utils' import { setLocale } from 'utils'
import moment from 'moment' import moment from 'moment'
@@ -144,14 +148,8 @@ class Header extends PureComponent {
className={styles.button} className={styles.button}
onClick={onCollapseChange.bind(this, !collapsed)} onClick={onCollapseChange.bind(this, !collapsed)}
> >
<LegacyIcon {collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
type={classnames({
'menu-unfold': collapsed,
'menu-fold': !collapsed,
})}
/>
</div> </div>
<div className={styles.rightContainer}>{rightContent}</div> <div className={styles.rightContainer}>{rightContent}</div>
</Layout.Header> </Layout.Header>
) )
+5 -8
View File
@@ -1,13 +1,10 @@
import React, { PureComponent, Fragment } from 'react' import React, { PureComponent, Fragment } from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { Icon as LegacyIcon } from '@ant-design/compatible'
import { Menu } from 'antd' import { Menu } from 'antd'
import { NavLink, withRouter } from 'umi' import { NavLink, withRouter } from 'umi'
const { pathToRegexp } = require("path-to-regexp") import { pathToRegexp } from 'path-to-regexp'
import { import { arrayToTree, queryAncestors } from 'utils'
arrayToTree, import iconMap from 'utils/iconMap'
queryAncestors,
} from 'utils'
import store from 'store' import store from 'store'
const { SubMenu } = Menu const { SubMenu } = Menu
@@ -45,7 +42,7 @@ class SiderMenu extends PureComponent {
key={item.id} key={item.id}
title={ title={
<Fragment> <Fragment>
{item.icon && <LegacyIcon type={item.icon} />} {item.icon && iconMap[item.icon]}
<span>{item.name}</span> <span>{item.name}</span>
</Fragment> </Fragment>
} }
@@ -57,7 +54,7 @@ class SiderMenu extends PureComponent {
return ( return (
<Menu.Item key={item.id}> <Menu.Item key={item.id}>
<NavLink to={item.route || '#'}> <NavLink to={item.route || '#'}>
{item.icon && <LegacyIcon type={item.icon} />} {item.icon && iconMap[item.icon]}
<span>{item.name}</span> <span>{item.name}</span>
</NavLink> </NavLink>
</Menu.Item> </Menu.Item>
+1 -1
View File
@@ -38,7 +38,7 @@ function Browser({ data }) {
pagination={false} pagination={false}
showHeader={false} showHeader={false}
columns={columns} columns={columns}
rowKey={(record, key) => key} rowKey='name'
dataSource={data} dataSource={data}
/> />
) )
+1 -1
View File
@@ -54,7 +54,7 @@ function Comments({ data }) {
pagination={false} pagination={false}
showHeader={false} showHeader={false}
columns={columns} columns={columns}
rowKey={(record, key) => key} rowKey='avatar'
dataSource={data.filter((item, key) => key < 3)} dataSource={data.filter((item, key) => key < 3)}
/> />
</div> </div>
+5 -2
View File
@@ -1,10 +1,11 @@
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { Icon as LegacyIcon } from '@ant-design/compatible'
import { Card } from 'antd' import { Card } from 'antd'
import CountUp from 'react-countup' import CountUp from 'react-countup'
import iconMap from 'utils/iconMap'
import styles from './numberCard.less' import styles from './numberCard.less'
function NumberCard({ icon, color, title, number, countUp }) { function NumberCard({ icon, color, title, number, countUp }) {
return ( return (
<Card <Card
@@ -12,7 +13,9 @@ function NumberCard({ icon, color, title, number, countUp }) {
bordered={false} bordered={false}
bodyStyle={{ padding: 10 }} bodyStyle={{ padding: 10 }}
> >
<LegacyIcon className={styles.iconWarp} style={{ color }} type={icon} /> <span className={styles.iconWarp} style={{ color }}>
{iconMap[icon]}
</span>
<div className={styles.content}> <div className={styles.content}>
<p className={styles.title}>{title || 'No Title'}</p> <p className={styles.title}>{title || 'No Title'}</p>
<p className={styles.number}> <p className={styles.number}>
@@ -53,7 +53,7 @@ function RecentSales({ data }) {
<Table <Table
pagination={false} pagination={false}
columns={columns} columns={columns}
rowKey={(record, key) => key} rowKey='id'
dataSource={data.filter((item, key) => key < 5)} dataSource={data.filter((item, key) => key < 5)}
/> />
</div> </div>
+5 -6
View File
@@ -5,6 +5,7 @@ const { pathToRegexp } = require("path-to-regexp")
import { model } from 'utils/model' import { model } from 'utils/model'
const { queryDashboard, queryWeather } = api const { queryDashboard, queryWeather } = api
const avatar = '//cdn.antd-admin.zuiidea.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236.jpeg'
export default modelExtend(model, { export default modelExtend(model, {
namespace: 'dashboard', namespace: 'dashboard',
@@ -13,12 +14,11 @@ export default modelExtend(model, {
city: '深圳', city: '深圳',
temperature: '30', temperature: '30',
name: '晴', name: '晴',
icon: '//s5.sencdn.com/web/icons/3d_50/2.png', icon: '//cdn.antd-admin.zuiidea.com/sun.png',
}, },
sales: [], sales: [],
quote: { quote: {
avatar: avatar,
'http://img.hb.aicdn.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236',
}, },
numbers: [], numbers: [],
recentSales: [], recentSales: [],
@@ -27,8 +27,7 @@ export default modelExtend(model, {
browser: [], browser: [],
cpu: {}, cpu: {},
user: { user: {
avatar: avatar,
'http://img.hb.aicdn.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236',
}, },
}, },
subscriptions: { subscriptions: {
@@ -62,7 +61,7 @@ export default modelExtend(model, {
city: data.location.name, city: data.location.name,
temperature: data.now.temperature, temperature: data.now.temperature,
name: data.now.text, 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({ yield put({
type: 'updateState', type: 'updateState',
+31
View File
@@ -0,0 +1,31 @@
import {
PayCircleOutlined,
ShoppingCartOutlined,
MessageOutlined,
TeamOutlined,
UserOutlined,
DashboardOutlined,
ApiOutlined,
CameraOutlined,
EditOutlined,
CodeOutlined,
LineOutlined,
BarChartOutlined,
AreaChartOutlined,
} from '@ant-design/icons'
export default {
'pay-circle-o': <PayCircleOutlined />,
'shopping-cart': <ShoppingCartOutlined />,
'camera-o': <CameraOutlined />,
'line-chart': <LineOutlined />,
'code-o': <CodeOutlined />,
'area-chart': <AreaChartOutlined />,
'bar-chart': <BarChartOutlined />,
message: <MessageOutlined />,
team: <TeamOutlined />,
dashboard: <DashboardOutlined />,
user: <UserOutlined />,
api: <ApiOutlined />,
edit: <EditOutlined />,
}