Compare commits

..
155 Commits
Author SHA1 Message Date
superlbr ca1d182795 upgrade dep: umi^4.0.0-canary.20220429.4 2022-04-30 06:41:00 +08:00
superlbr 4042d5ba3a upgrade dep: umi 4.x & react 18 2022-04-28 10:44:42 +08:00
zuiidea da4abc2293 ✨ adding page, removing some components 2021-06-06 16:27:47 +08:00
zuiidea 13c13961c7 ✨ improving useRequest 2021-04-18 21:57:18 +08:00
zuiidea 0d1c4f23e9 Merge branch 'develop-next' of https://github.com/zuiidea/antd-admin into develop-next 2021-04-18 17:03:50 +08:00
Baorong Li f3c6ccf7b2 chore config 2021-04-13 16:11:45 +08:00
zuiidea a18c9bcb7e ✨
adding user page
2021-04-12 22:32:51 +08:00
zuiidea 12eab5f5c7 ✨ adding useRequest 2021-04-11 22:14:18 +08:00
zuiidea 1dbeb05005 ✨ Upgrading components to typescript 2021-04-05 22:54:36 +08:00
zuiidea a0000d7371 ✨ adding login page. 2021-04-05 16:54:22 +08:00
zuiidea b0cb27712d Merge branch 'master' into develop-next
Conflicts:
	.umirc.js
	mock/route.js
	package.json
	src/components/Layout/Bread.js
	src/components/Layout/Menu.js
	src/components/index.js
	src/layouts/BaseLayout.js
	src/layouts/PrimaryLayout.js
	src/layouts/index.js
	src/models/app.js
	src/pages/404.tsx
	src/pages/chart/ECharts/AirportCoordComponent.js
	src/pages/chart/ECharts/BubbleGradientComponent.js
	src/pages/chart/ECharts/CalendarComponent.js
	src/pages/chart/ECharts/GCalendarComponent.js
	src/pages/chart/ECharts/LunarCalendarComponent.js
	src/pages/chart/ECharts/MainPageComponent.js
	src/pages/chart/ECharts/MapChartComponent.js
	src/pages/chart/ECharts/ThemeChartComponent.js
	src/pages/chart/ECharts/TreemapComponent.js
	src/pages/dashboard/components/browser.js
	src/pages/dashboard/components/comments.js
	src/pages/dashboard/components/completed.js
	src/pages/dashboard/components/numberCard.js
	src/pages/dashboard/components/recentSales.js
	src/pages/dashboard/components/sales.js
	src/pages/dashboard/index.js
	src/pages/dashboard/model.js
	src/pages/editor/index.js
	src/pages/index.js
	src/pages/login/index.js
	src/pages/login/model.js
	src/pages/post/components/List.js
	src/pages/post/index.js
	src/pages/post/model.js
	src/pages/request/index.js
	src/pages/user/[id]/index.js
	src/pages/user/[id]/index.less
	src/pages/user/[id]/models/detail.js
	src/pages/user/components/Filter.js
	src/pages/user/components/List.js
	src/pages/user/components/Modal.js
	src/pages/user/index.js
	src/pages/user/model.js
	src/services/index.js
	src/utils/index.js
2021-04-05 16:14:07 +08:00
zainchen 0bb381f419 feat: updating umi and typescript 2021-04-04 23:20:50 +08:00
zuiidea 8c01bc1488 ⚡️ Upgrading umi@3.4 2021-04-04 10:42:59 +08:00
zuiidea d8baaad3b1 🔥 Removing unnecessary pages. 2021-04-03 21:52:26 +08:00
Baorong Li e32a19fe3b chore dep: normal 2021-03-26 22:22:33 +08:00
Baorong Li c6382c6221 chore umi: use default targets no ie support 2021-03-26 22:20:53 +08:00
Baorong Li 02280fbed9 Merge pull request #1091 from jaywhen/patch-1
fix garbled characters in README-zh_CN.md
2021-03-17 17:46:29 +08:00
zainchen d897eb205d fix: adding babel preset to fixing extract command 2021-03-17 17:44:38 +08:00
Baorong Li b1f290ea32 upgrade dep: echarts@5.x 2021-03-17 17:28:05 +08:00
Baorong Li 0e36b6b7a0 fix utils: remove params to close #1067 in request 2021-03-17 17:03:14 +08:00
Baorong Li d92f121cf4 upgrade lingui: 3.x 2021-03-17 16:50:49 +08:00
Xiang Jaywhen 0a73ba0f12 fix garbled characters in README-zh_CN.md 2021-02-19 23:19:51 +08:00
Baorong Li 9e4e0efbab Merge pull request #1082 from AmagiDDmxh/master
Fix en layout doc typo, same as before #1081
2020-12-21 23:27:57 -06:00
amagiddmxh 524dff07d2 Fix en layout doc typo 2020-12-21 16:05:47 +08:00
Baorong Li 8b3e5c08f7 Merge pull request #1081 from AmagiDDmxh/master
There were some type in the API-config doc, https://doc.antd-admin.zuiidea.com/#/API-configuration
2020-12-21 00:23:22 -06:00
amagiddmxh c17444f5d6 Fix API config uppercase typo 2020-12-21 12:55:26 +08:00
Baorong Li df85ecdfff Merge pull request #1080 from karlhorky/patch-1
Fix typo
2020-12-15 08:24:21 -06:00
Karl Horky b8824141d6 Fix typo 2020-12-15 15:21:29 +01:00
Karl Horky aedd2ec3db Fix typo 2020-12-15 15:20:49 +01:00
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
Baorong Li eaeb9092e4 bump antd-admin@5.3.0 2020-05-10 21:05:23 +08:00
Baorong Li 2f3ca0a006 Merge branch 'develop' 2020-05-10 21:04:40 +08:00
Baorong Li 1b65351be4 upgrade umi@3 fin. 2020-03-24 15:17:57 +08:00
Baorong Li 0422f6d51e upgrade umi@3 partly 2020-03-24 12:12:20 +08:00
Baorong Li 8d050d4040 fix pathToRegexp not work 2020-03-20 11:59:04 +08:00
zuiidea 82b3a4b384 ⚡️ Exclude node_modules by babel-loader. 2020-03-19 22:26:55 +08:00
Baorong Li d2f391a881 upgrade umi@3 partly 2020-03-19 17:06:31 +08:00
Baorong Li 9e778487d9 upgrade umi@3 partly 2020-03-19 12:50:12 +08:00
Baorong Li 7938d71f2f upgrade umi@3 partly 2020-03-19 00:05:44 +08:00
Baorong Li 422a6fed30 upgrade umi@3 partly 2020-03-18 16:17:25 +08:00
Baorong Li c6ea0454b3 upgrade umi@3 partly 2020-03-15 08:24:05 +08:00
Baorong Li 467767a6c5 upgrade umi@3 partly 2020-03-05 23:22:02 +08:00
Baorong Li cf795c512a bump antd-admin@5.2.0 2020-03-05 20:21:22 +08:00
Baorong Li 18b499030d upgrade antd@4.0.0 2020-02-29 22:47:45 +08:00
zuiidea d800d6f3ce Merge branch 'master' into develop 2020-01-08 09:31:45 +08:00
zuiidea 185f706107 💚 Fixing now config. 2020-01-07 17:17:57 +08:00
zuiidea 5a4661cdad Merge branch 'develop' of https://github.com/zuiidea/antd-admin into develop 2020-01-07 16:02:51 +08:00
zuiidea 7abdd94a0e 🚀 Optimize deployment configuration. 2020-01-07 16:02:33 +08:00
Baorong Li 22f0684ab0 chore: docs normal 2020-01-07 15:58:48 +08:00
Baorong Li 80b2c63693 Merge pull request #1040 from vagusX/feat/migrate-antd-v4
feat: migrate to antd v4
2019-12-02 22:07:08 -06:00
vagusX 4b2a553bda feat: add antd v4 dependencies 2019-12-03 10:19:54 +08:00
vagusX ad30e73b10 feat: migrate to antd v4 2019-12-03 09:58:49 +08:00
Baorong Li 15b62e302d bump antd-admin@5.1.3 2019-10-22 10:38:52 +08:00
Baorong Li 9d5ec20f20 Merge branch 'develop' 2019-10-22 10:37:43 +08:00
Baorong Li c878425fd0 upgrade antd@3.24.x 2019-10-22 10:30:04 +08:00
Baorong Li 90e80dda64 Merge pull request #1022 from rioarray/feature/inline-conditional-rendering
inline conditional rendering in some components
2019-10-17 16:32:30 +08:00
rioarray 1db5bfeab5 inline conditional rendering in some components 2019-10-17 14:45:30 +07:00
zuiidea b2b3fcd4a3 ✨ Support disable i18n. 2019-10-09 20:20:11 +08:00
Baorong Li 9cf97375c7 fix 404 when path = '/' 2019-08-01 23:12:42 +08:00
Baorong Li 7839b6affb Merge pull request #1007 from Louis-7/master
[fix] add notification popup to #primaryLayout instead of #layoutHeader
2019-07-25 08:26:35 -05:00
Louis 597064a07d [fix] add notification popup to #primaryLayout instead of #layoutHeader 2019-07-25 11:47:32 +08:00
Baorong Li 0ea57d14c9 fix #980 cannot read property 'map' of null 2019-07-07 23:01:20 +08:00
Baorong Li afd736d615 bump antd-admin@5.1.2 2019-07-07 22:48:34 +08:00
Baorong Li ce9b8c376f Merge pull request #996 from tuantvk/master
🐛 fix bug sub menu Charts when collapsed
2019-07-07 08:03:31 -05:00
tuantv 79776e6752 🐛 fix bug sub menu Charts when collapsed 2019-07-07 11:56:52 +07:00
zuiidea a2432022a1 ✨ Updating manifest logo and adding portugal flag image. 2019-07-02 17:47:16 +08:00
zuiidea ea5ee96bdc 🎨 Improving format of the code. 2019-07-06 11:02:56 +08:00
zuiidea fe954092a4 🐛 Fixing dva history.listen multiple triggers. 2019-07-06 10:50:50 +08:00
zuiidea 5e148fec92 Merge branch 'develop' of https://github.com/zuiidea/antd-admin into develop 2019-07-06 09:43:30 +08:00
Baorong Li 5daa2a9548 add moment locale setting 2019-07-05 22:26:29 +08:00
Baorong Li f1913f7b18 add pt_BR locale-provider in layout 2019-07-05 22:16:54 +08:00
zuiidea 65a453553e ✨ Updating mock avatar image. 2019-07-05 19:52:37 +08:00
Baorong Li 29da8f24da Merge pull request #989 from tuantvk/master
🐛 fix remove and update user error handleRefresh
2019-06-29 09:57:46 -05:00
tuantv 3443ad9968 🐛 fix edit and update user error handleRefresh 2019-06-29 21:19:57 +07:00
Baorong Li 838dc93eff bump antd-admin@5.1.1 2019-06-29 10:56:03 +08:00
Baorong Li 07ef68ec1f Merge remote-tracking branch 'origin/develop' 2019-06-29 10:54:10 +08:00
Baorong Li 3cb7f86086 fix login jump to /enundefined 2019-06-29 10:49:11 +08:00
Baorong Li fc9565c157 add a flag to detect refresh saving query times in model/app.js 2019-06-24 20:50:09 +08:00
Baorong Li 557f6022f3 bump antd-admin@5.1.0 2019-06-24 16:05:28 +08:00
Baorong Li d0a56169e3 revert dispatch query in model/app.js 2019-06-24 15:40:44 +08:00
Baorong Li f7d6e2b4ed Merge pull request #984 from lovemegowin/master
refactor user,menu,permission storage strategy
2019-06-24 15:26:06 +08:00
lovemegowin df82ee42fd fix #985 , close #985 2019-06-24 15:20:25 +08:00
lovemegowin a29d761483 refactor user, menu, permission storage strategy then make full loader unnecessary 2019-06-21 15:26:06 +08:00
lovemegowin 713a86b9d6 add null point assert 2019-06-21 15:23:19 +08:00
lovemegowin d6250f16b0 fullScreen loader is not always necessary refactor default spinning to false 2019-06-21 14:12:15 +08:00
Baorong Li 1c5d5c3788 upgrade umi@2.8.x 2019-06-20 16:31:00 +08:00
Baorong Li 699e9d9ff1 fix warning inlineCollapsed not control Menu under Sider 2019-06-04 15:47:35 +08:00
Baorong Li fad0cb931a use options instead of option in react-perfect-scrollbar 2019-06-04 15:34:45 +08:00
Baorong Li 5d7ff55869 upgrade dependency 2019-06-04 15:09:51 +08:00
Baorong Li 642ccb5b82 Merge pull request #975 from deepred5/master
fix: 关闭弹窗时有动画效果
2019-05-27 23:59:48 -05:00
深红 51a7ce0827 update: 关闭弹窗时销毁子元素,保证initialValue更新并且关闭弹窗时有动画效果 2019-05-28 10:27:27 +08:00
Baorong Li 157a54b11d Merge pull request #969 from ccyanxyz/patch-1
fix markdown code block in docs/layout.md
2019-05-04 18:32:34 -05:00
cyan be083d81fc fix markdown code block 2019-05-05 00:38:43 +08:00
zuiidea f6c869ad47 Merge pull request #965 from zuiidea/develop
✏️  Fixing typos, exlude => exclude.
2019-04-18 10:10:14 +08:00
zuiidea bef5b26509 ✏️ Fixing typos, exlude => exclude. 2019-04-18 09:58:16 +08:00
Baorong Li 59cfe24178 Merge branch 'develop'
# Conflicts:
#	package.json
2019-04-10 07:27:25 +08:00
Baorong Li 87d0d58ae8 Merge commit '0ac4839e948f7b1d34c90d33f4ece483bd9d2f48' 2019-04-10 07:24:20 +08:00
Baorong Li de8b6c972d bump antd-admin@5.0.6 2019-04-10 07:24:06 +08:00
Baorong Li 0ac4839e94 upgrade umi@2.6.x 2019-04-10 07:22:53 +08:00
Baorong Li 565bce6d8b refix #958 by reset form in componentDidUpdate 2019-04-05 09:02:25 +08:00
Baorong Li b278b028cf fix #958 redux form initialValues not updating with state 2019-04-04 16:45:28 +08:00
Baorong Li 33abd9369e fix #957 an flaw ignored 2019-03-19 10:59:37 +08:00
Baorong Li e6b2f7f271 fix #950 modify z-index in header 2019-03-13 16:59:12 +08:00
Baorong Li 0bd1e9cf59 fix #947 misspelled word cancel 2019-03-06 12:11:42 +08:00
Baorong Li 693625bf2c bump antd-admin@5.0.5 2019-03-05 16:23:16 +08:00
Baorong Li 3a6c587569 upgrade antd@3.14 2019-03-05 16:17:12 +08:00
Baorong Li bd85eaf0a0 fix less is not a command in prettier 2019-03-05 16:15:33 +08:00
Baorong Li 29aa0f416e fix Cannot read property 'addEventListener' of null #946 2019-03-05 16:15:02 +08:00
Baorong Li 5b32607911 bump antd-admin@5.0.4 2019-02-19 22:00:36 +08:00
Baorong Li 76e5359752 upgrade umi@2.5.0 2019-02-19 21:46:01 +08:00
Baorong Li 5ec4efbb6e reset default lang to en 2019-02-07 09:19:39 +08:00
Baorong Li f8bb7b421a remove description about support IE9/IE10 that not working well 2019-02-07 08:52:40 +08:00
Baorong Li 887c169aa8 upgrade and lock antd@3.13.0 2019-02-07 08:36:53 +08:00
Baorong Li 8c10dcc6c2 Merge pull request #939 from rrfaria/feature/pt-br
added pt-br language and some improvements to language control to route mocks
2019-02-07 08:08:01 +08:00
Rafael Faria 671da6b5fa added pt-br and some improvements to language control 2019-02-06 14:39:02 -02:00
Baorong Li 7fdb2f4ea8 bump antd-admin@5.0.3 2019-01-11 18:43:48 +08:00
Baorong Li 67388b31f5 enable umi treeShaking 2019-01-11 18:40:39 +08:00
Baorong Li 2379cca765 upgrade umi@2.4.0 & antd@3.12.x 2019-01-11 18:39:19 +08:00
Baorong Li 34be6651e5 fix #935 root path / will be not found after login 2019-01-10 17:36:23 +08:00
Baorong Li 10f8e3e8ef fix mix require / module.exports and import / export #934 2019-01-08 23:30:18 +08:00
Baorong Li 0c6ea8eb5c fix cannot read property 'hash' of undefined by turn off hardSource 2019-01-08 22:56:23 +08:00
Baorong Li 6e69b06e61 Publish antd-admin@5.0.2 2018-12-28 14:01:51 +08:00
Baorong Li 98ba383a68 upgrade umi@2.3 antd@3.11 2018-12-28 11:42:44 +08:00
Baorong Li 4e6d81a9bf Merge pull request #928 from luckcoding/fix-bread-link
fix bread route has no matching lang
2018-12-13 22:35:56 +08:00
Baorong Li 0e2c206023 Merge branch 'develop' into fix-bread-link 2018-12-13 22:35:47 +08:00
luckcoding 285f06d1e7 fix bread route has no matching lang 2018-12-13 16:57:49 +08:00
Baorong Li d03787a871 Publish antd-admin@5.0.1 2018-12-12 13:48:34 +08:00
zuiidea 6aead03f3e 🐛 Fix style error when menu is collapsed. 2018-12-12 11:35:44 +08:00
Baorong Li 0949a298c9 fix #924 404 Not Found after router change 2018-12-12 06:53:26 +08:00
Baorong Li 94c8e2168f fix #926 createUser api in services 2018-12-12 06:17:30 +08:00
Baorong Li 358134f417 fallback umi to 2.2.8 to fix #923 2018-12-09 23:07:16 +08:00
Baorong Li 7eb9e06452 upgrade antd@3.10.9, umi@2.3.0-beta.3 2018-12-01 11:29:09 +08:00
zuiidea fab06d5005 fix: 🐛 CI fails when pull request 2018-11-29 10:00:11 +08:00
Baorong Li 7483572b1d Merge pull request #921 from francolaiuppa/patch-1
Mini typo fixes for English docs, Configuration section.
2018-11-29 09:45:38 +08:00
Franco Laiuppa d1ce8e0739 Mini typo fixes
Hi! Great project!

I was reading the docs and noticed some typos regarding the layout names and the `exclude` parameter, so I've decided to fix it.
I'm new to this repo so I hope this is a valid edit if not please let me know and I'll change it.

Thanks!
2018-11-28 16:53:25 +01:00
zuiidea 16860f93ad Merge pull request #920 from alexxyzeng/alex
fix: show vertical centered modal in ie
2018-11-28 10:18:22 +08:00
xiayao 6ba45d5bc3 fix: show vertical centered modal in ie 2018-11-28 00:44:21 +08:00
zuiidea f230429ddd Merge branch 'develop' of https://github.com/zuiidea/antd-admin into develop 2018-11-21 10:36:51 +08:00
zuiidea 78c3b6d597 📝 Add some comments image to document. 2018-11-20 21:30:22 +08:00
Baorong Li cdbc2782ff chore: remove beta tag in version from package.json 2018-11-20 17:50:20 +08:00
zuiidea 108aca99b9 📝 Add documentation for Add Layout. 2018-11-18 23:08:12 +08:00
Baorong Li 7dd5dfb1bf fix: icons' format not right in manifest.json 2018-11-15 14:11:47 +08:00
zuiidea ee7a0fffc2 ⚡ Update manifest.json. 2018-11-15 00:11:17 +08:00
zuiidea 6999871860 📝 Add documentation for Add Luanguage. 2018-11-14 23:46:59 +08:00
zuiidea 6742207c77 🐛 Fix cannot translate fields with variables. 2018-11-14 22:44:46 +08:00
Baorong Li d71c29ee2e feat: enable pwa 2018-11-14 13:37:34 +08:00
zuiidea 6917d6b89a Merge branch 'develop' of https://github.com/zuiidea/antd-admin into develop 2018-11-12 23:31:11 +08:00
zuiidea c3f369f0b3 📝 Add documentation for API configuration. 2018-11-12 23:30:56 +08:00
Baorong Li 01abc5ca38 upgrade antd@3.10.5 2018-11-10 09:50:20 +08:00
Baorong Li 08a348090c upgrade umi@2.3.0-beta.1 2018-11-09 23:16:42 +08:00
Baorong Li 63b1ecf79f Upgrade umi@2.2.5 2018-11-09 11:26:19 +08:00
Baorong Li efe7e74375 fix #913 handleMenuClick is not defined 2018-11-07 16:23:36 +08:00
Baorong Li 6d552d22d9 add doc about custom http header #829 2018-11-05 11:23:43 +08:00
242 changed files with 7279 additions and 21425 deletions
-6
View File
@@ -1,7 +1 @@
src/**/*-test.js
src/public
src/routes/chart/ECharts/theme
src/routes/chart/highCharts/mapdata
src/locales/_build/
src/locales/**/*.js
docs/**/*.js
+2 -1
View File
@@ -1,7 +1,8 @@
{
"extends": "react-app",
"rules": {
"jsx-a11y/href-no-hash": "off",
"import/no-anonymous-default-export": 0,
"jsx-a11y/href-no-hash": 0,
"no-console": "warn",
"valid-jsdoc": "warn"
}
+4 -1
View File
@@ -5,6 +5,7 @@ npm-debug.log
yarn-error.log
yarn.lock
package-lock.json
pnpm-lock.yaml
# ide
.idea
@@ -20,4 +21,6 @@ package-lock.json
# jslingui
src/locales/_build
src/locales/**/*.js
src/locales/**/*.js
.vscode
+13 -18
View File
@@ -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
-97
View File
@@ -1,97 +0,0 @@
// https://umijs.org/config/
import { resolve } from 'path'
import { i18n } from './src/utils/config'
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',
},
],
],
// 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' },
},
},
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'],
extraBabelPlugins: [
[
'import',
{
libraryName: 'lodash',
libraryDirectory: '',
camel2DashComponentName: false,
},
'lodash',
],
],
}
+4 -4
View File
@@ -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),更好的问题更容易获得帮助。
+4 -4
View File
@@ -9,9 +9,9 @@
<div align="center">
A 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)
[![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)
@@ -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
+5
View File
@@ -0,0 +1,5 @@
const config = {
publicPath: 'https://cdn.antd-admin.zuiidea.com/',
}
export default config
+61
View File
@@ -0,0 +1,61 @@
/**
* see more, https://umijs.org/config
*/
import lessToJs from 'less-vars-to-js'
import fs from 'fs'
import routes from './routes'
import path from 'path'
import proxy from './proxy'
const theme = lessToJs(
fs.readFileSync(path.join(__dirname, '../src/themes/default.less'), 'utf8')
)
const config = {
hash: true,
ignoreMomentLocale: true,
targets: { ie: 11 },
theme,
proxy,
routes,
devtool: 'eval',
mock: {
exclude: ['utils/index'],
},
extraBabelPresets: ['@lingui/babel-preset-react'],
extraBabelPlugins: [
'macros',
[
'import',
{
libraryName: 'lodash',
libraryDirectory: '',
camel2DashComponentName: false,
},
'lodash',
],
[
'import',
{
libraryName: 'antd',
libraryDirectory: 'es',
style: 'css',
},
'antd',
],
[
'import',
{
libraryName: '@ant-design',
libraryDirectory: 'icons',
camel2DashComponentName: false,
},
'ant-design-icons',
],
],
chainWebpack: (memo) => {
memo.module.rule('po').test(/\.po$/).use('po').loader('@lingui/loader')
},
}
export default config
BIN
View File
Binary file not shown.
+7
View File
@@ -0,0 +1,7 @@
export default {
'/api/v1/weather': {
target: 'https://api.seniverse.com/',
changeOrigin: true,
pathRewrite: { '^/api/v1/weather': '/v3/weather' },
},
}
+13
View File
@@ -0,0 +1,13 @@
const routes = [
{
exact: false,
path: '/',
// component: '@/layouts/index', // comment due to double layout
routes: [
{ exact: true, path: '/login', component: '@/pages/login' },
{ exact: true, path: '/user', component: '@/pages/user' },
],
},
]
export default routes
-8
View File
@@ -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'))
}
+86
View File
@@ -0,0 +1,86 @@
# API configuration
## Why
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,
  })
}
```
## Configuration and use
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 {
  ...
  queryUser: '/user/:id',
  queryUserList: '/users',
  updateUser: 'Patch /user/:id',
  createUser: 'POST /user/:id',
  removeUser: 'DELETE /user/:id',
  removeUserList: 'POST /users/delete',
  ...
}
```
Used in other files
```javascript
import { queryUser } from 'api'
// in the general file
...
queryUser(option).then(data => console.log(data))
...
/ / Model file
...
yield call(queryUser, option)
...
```
## Method to realize
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 api from './api'
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]
  }
  return function(data) {
    return request({
      url,
      data,
      method,
    })
  }
}
const APIFunction = {}
for (const key in api) {
  APIFunction[key] = gen(api[key])
}
module.exports = APIFunction
```
+3 -3
View File
@@ -8,7 +8,7 @@
<div align="center">
A 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)
[![umi](https://img.shields.io/badge/umi-^2.2.1-orange.svg?style=flat-square)](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
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 194 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 118 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 199 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 124 KiB

+5
View File
@@ -2,6 +2,11 @@
- [Quick Start](getting-started.md)
- Customization
- [Configuration](configuration.md)
- [API Configuration](API-configuration.md)
- [I18n](i18n.md)
- [Layout](layout.md)
- [Request](request.md)
- Guide
- [Deploy](deploy.md)
- [Change Log](change-log.md)
- [FAQ](faq.md)
+1 -1
View File
@@ -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.
+10 -10
View File
@@ -12,7 +12,7 @@ You can do some custom configuration in `/src/utils/config.js`:
- Type: `String`
Configure the copyright notice to apply to the login page, at the bottom of the `Primay` layout.
Configure the copyright notice to apply to the login page, at the bottom of the `Primary` layout.
## logoPath
@@ -24,7 +24,7 @@ You can do some custom configuration in `/src/utils/config.js`:
- Type: `String`
Configure the prefix of the interface in the project. The interface related documents can be viewed [API configuration]()
Configure the prefix of the interface in the project. The interface related documents can be viewed [API configuration](API-configuration.md)
## fixedHeader
@@ -39,25 +39,25 @@ You can do some custom configuration in `/src/utils/config.js`:
Configuration? Which routes use which layout, unspecified route uses the default layout `Public`, the project currently has `Primary` and `Public` layouts,
     The default configuration is as follows:
```js
```javascript
layouts: [
{
name: 'primary',
include: [/.*/],
exlude: [/(\/(en|zh))*\/login/],
exclude: [/(\/(en|zh))*\/login/],
},
],
```
The object properties for each layout are as follows:
- `name` - The name of the layout;
- `name` - The name of the layout;
- `include` - Specifies a list of routing rules that use this layout, which can be a regular expression or a string;
- `exlude` - Specifies a list of routing rules that do not use this layout, which can be a regular expression or a string.
- `exclude` - Specifies a list of routing rules that do not use this layout, which can be a regular expression or a string.
> Note: `exlude` takes precedence over `include`, and the layout behind it has a higher priority than the previous layout. The development process may need to be combined with the layout in the `src/layouts` directory. For details, see [Using Layout]().
> Note: `exclude` takes precedence over `include`, and the layout previous it has a higher priority than the behind layout. The development process may need to be combined with the layout in the `src/layouts` directory. For details, see [Using Layout](./layout.md).
## i18n
@@ -65,7 +65,7 @@ You can do some custom configuration in `/src/utils/config.js`:
Configure internationalization, the default configuration is as follows:
```js
```javascript
i18n: {
languages: [
{
@@ -91,9 +91,9 @@ You can do some custom configuration in `/src/utils/config.js`:
- `key` - The `key` of the language is applied to the page url to distinguish the language, and also corresponds to the language package folder name in the `src/locales` directory;
- `title` - The name of the language, at the bottom of the login page, at the top of the `Primay` layout, the language switch is displayed;
- `title` - The name of the language, at the bottom of the login page, at the top of the `Primary` layout, the language switch is displayed;
- `flag` - The path of the flag icon of the language, the language switching display at the top of the `Primay` layout.
- `flag` - The path of the flag icon of the language, the language switching display at the top of the `Primary` layout.
### i18n.defaultLanguage
+2
View File
@@ -2,6 +2,8 @@
After the development is completed and verified in the development environment, it needs to be deployed to our users.
![i18n](./_media/term_build.svg)
## Build
First execute the following command,
+9
View File
@@ -0,0 +1,9 @@
# FAQ
Most asked
## create new page
1. just copy a page in /src/pages (route here auto generated by [umi](https://umijs.org/guide/router.html#basic-routing))
2. modify namespace/pathToRegexp in model.js
3. modify mock route.js to add a route
+75
View File
@@ -0,0 +1,75 @@
# globalization
## Add language
Take Japanese as an example.
![i18n](../_media/term_i18n.svg)
1. Add a language pack local file, `ja` is the Japanese language code, and a list of languages ​​that support translation [有道智云](http://ai.youdao.com/docs/doc-trans-api.s#p05), the `src/locales/ja/messages.json` file will be generated after running the following command.
```bash 
npm run add-locale ja
```
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
```
You will see the following information:
```bash
Catalog statistics:
┌─────────────┬─────────────┬─────────┐
│ Language │ Total count │ Missing │
├─────────────┼─────────────┼─────────┤
│ en (source) │ 52 │ - │
│ ja │ 52 │ 52 │
│ zh │ 52 │ 0 │
└─────────────┴─────────────┴─────────┘
```
3. At the same time, we have added the relevant configuration in `src/utils/config.js`.
```javascript
{
...
i18n: {
languages: [
...
{
key:'ja',
title: '日本語',
flag: '/japanese.svg',
},
],
},
}
```
> Routing related effects, after the configuration `npm run start` takes effect after restart.
4. Use the built-in commands for automatic translation. You will see the translated configuration in `src/locales/ja/messages.json`.
```bash
npm run trans:only
```
You will see the following information:
```bash
start: en -> ja
...
youdao: en -> ja: Unpublished -> 未発表
youdao: en -> ja: Update -> 更新
youdao: en -> ja: Update User -> ユーザーの更新
youdao: en -> ja: Username -> 名
...
All translations have been completed.
```
> `npm run trans` will execute `npm run extract` and `npm run trans:only` in order.
5. Finally, you can adjust the inaccurate fields in `src/locales/ja/messages.json`. Start the development mode `npm run start`, open [http://localhost:7000/ja/login](http://localhost:7000/ja/login) and you will see the Japanese version of the app.
+60
View File
@@ -0,0 +1,60 @@
# Layout
## Add a new 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
   layouts: [
           {
               name: 'primary',
               include: [/.*/],
               exclude: [/(\/(en|zh))*\/login/, /(\/(en|zh))*\/secondary\/(.*)/],
           },
           {
               name: 'secondary',
               include: [/(\/(en|zh))*\/secondary\/(.*)/],
           },
   ],
```
2. Add the `secondary` layout component to the `src/layouts/BaseLayout.js` file.
```javascript
   import SecondaryLayout from './SecondaryLayout'
   const LayoutMap = {
     primary: PrimaryLayout,
     public: PublicLayout,
     secondary: SecondaryLayout,
   }
```
3. Add the `SecondaryLayout.js` file to the `src/layouts/` directory.
```javascript
   import React from 'react'
   export default ({ children }) => {
     return (
       <div>
         <h1>Secondary</h1>
         {children}
       </div>
     )
   }
```
4. Add a `secondary/index.js` file to the `src/pages/` directory.
```javascript
   import React from 'react'
   export default ({ children }) => {
     Return <div>Secondary page Content</div>
   }
```
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.
-6
View File
@@ -1,6 +0,0 @@
{
"name": "antd-admin-devdoc",
"alias": ["devdoc-antd-admin.now.sh", "devdoc.antd-admin.zuiidea.com"],
"type": "static",
"public": true
}
-6
View File
@@ -1,6 +0,0 @@
{
"name": "antd-admin-doc",
"alias": ["doc-antd-admin.now.sh", "doc.antd-admin.zuiidea.com"],
"type": "static",
"public": true
}
+22
View File
@@ -0,0 +1,22 @@
# HTTP request
this project use axios for http service, file located in src/utils/request.js
## Custom Header
As for privilege access or modify cookie, you could add header param by yourself
```
axios.defaults.headers.common['Authorization'] = 'token'
```
Or
```
axios.interceptors.request.use(function (config) {
config.headers.token = window.localStorage.getItem('token');
return config;
}, function (error) {
return Promise.reject(error);
});
```
+86
View File
@@ -0,0 +1,86 @@
# 接口配置
## 为什么
在使用了`redux`或者`dva`项目中,我们经常会写类似下面的`service`层的函数,使代码结构更清晰,但是很容易看出,我们会写很多相似的代码,在`antd-admin@5.0`中,使用了更加简洁的配置方式实现了相同的功能。
```javascript
export async function login(data) {
return request({
url: '/api/v1/user/login',
method: 'post',
data,
})
}
```
## 配置和使用
在`src/services/api.js`文件中,你会看到如下配置对象,对象的键用于调用时的函数名称,对象的值为请求的`url`,默认请求方式为`GET`,如果是其他请求方式对象的值的格式则为`'method url'`。
```javascript
export default {
...
queryUser: '/user/:id',
queryUserList: '/users',
updateUser: 'Patch /user/:id',
createUser: 'POST /user/:id',
removeUser: 'DELETE /user/:id',
removeUserList: 'POST /users/delete',
...
}
```
在其他文件中使用
```javascript
import { queryUser } from 'api'
// 一般文件中
...
queryUser(option).then(data => console.log(data))
...
// model文件中
...
yield call(queryUser, option)
...
```
## 实现方式
参考`src/services/index.js`文件,对api配置进行遍历,每个属性都返回对应的封装后的request函数。
```javascript
import request from 'utils/request'
import { apiPrefix } from 'utils/config'
import api from './api'
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]
}
return function(data) {
return request({
url,
data,
method,
})
}
}
const APIFunction = {}
for (const key in api) {
APIFunction[key] = gen(api[key])
}
module.exports = APIFunction
```
+2 -2
View File
@@ -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
## 参与贡献
+4
View File
@@ -2,6 +2,10 @@
- [快速上手](zh-cn/getting-started.md)
- 定制化
- [配置项](zh-cn/configuration.md)
- [接口配置](zh-cn/API-configuration.md)
- [国际化](zh-cn/i18n.md)
- [布局](zh-cn/layout.md)
- [http 请求](zh-cn/request.md)
- 指南
- [部署](zh-cn/deploy.md)
- [更新日志](zh-cn/change-log.md)
+1 -1
View File
@@ -28,7 +28,7 @@
- 支持国际化,源码中抽离翻译字段,按需加载语言包,自动在线翻译。
- 支持按需引入 `ant-design-pro` 组件、`lodash` 函数。
- 支持按需引入 `lodash` 函数。
- 支持多布局,可根据规则规定哪些路由使用哪种布局。
+6 -6
View File
@@ -24,7 +24,7 @@
- 类型: `String`
配置项目中接口的前缀,接口相关文档可查看 [接口配置化]()
配置项目中接口的前缀,接口相关文档可查看 [接口配置](API-configuration.md)
## fixedHeader
@@ -39,12 +39,12 @@
配置哪些路由使用哪种布局,未指定路由使用默认布局 `Public`,项目中目前有 `Primary` 和 `Public` 两种布局,
默认配置如下:
```js
```javascript
layouts: [
{
name: 'primary',
include: [/.*/],
exlude: [/(\/(en|zh))*\/login/],
exclude: [/(\/(en|zh))*\/login/],
},
],
```
@@ -55,9 +55,9 @@
- `include` - 指定使用该布局的路由规则列表,规则可为正则表达式或者字符串;
- `exlude` - 指定不使用该布局的路由规则列表,规则可为正则表达式或者字符串。
- `exclude` - 指定不使用该布局的路由规则列表,规则可为正则表达式或者字符串。
> 注意:`exlude` 优先级高于 `include`,后面的布局优先级高于前面的布局。开发过程中可能需要结合`src/layouts`目录下的布局使用,具体方法可查看 [使用布局]()。
> 注意:`exclude` 优先级高于 `include`,前面的布局优先级高于后面的布局。开发过程中可能需要结合`src/layouts`目录下的布局使用,具体方法可查看 [使用布局](./layout.md)。
## i18n
@@ -65,7 +65,7 @@
配置国际化,默认配置如下:
```js
```javascript
i18n: {
languages: [
{
+3 -1
View File
@@ -2,6 +2,8 @@
完成开发并且在开发环境验证之后,就需要部署给我们的用户了。
![i18n](../_media/term_build.svg)
## 构建
先执行下面的命令,
@@ -34,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)。
## 本地验证
+7
View File
@@ -0,0 +1,7 @@
# 问题集锦
## 新建页面
1. 直接从/src/pages复制一个page (会自动创建路由[umi](https://umijs.org/zh/guide/router.html#%E7%BA%A6%E5%AE%9A%E5%BC%8F%E8%B7%AF%E7%94%B1))
2. 修改 namespace/pathToRegexp 在 model.js
3. 修改 mock中route.js增加一条route
+75
View File
@@ -0,0 +1,75 @@
# 国际化
## 新增应用语言
以新增日语为例。
![i18n](../_media/term_i18n.svg)
1. 添加语言包本地文件,`ja` 为日语的语言代码,支持翻译的语言列表参考 [有道智云](http://ai.youdao.com/docs/doc-trans-api.s#p05),运行下面命令后会生成 `src/locales/ja/messages.json` 文件。
```bash
npm run add-locale ja
```
2. 提取代码中需要翻译的字段,即 `<Trans>message</Trans>`、`` intl.formatMessage({ id: 'message `` 中 `message` 字段,运行下面命令后 `src/locales/ja/messages.json' }) 将会出现提取后的字段配置。
```bash
npm run extract
```
你将看到如下信息:
```bash
Catalog statistics:
┌─────────────┬─────────────┬─────────┐
│ Language │ Total count │ Missing │
├─────────────┼─────────────┼─────────┤
│ en (source) │ 52 │ - │
│ ja │ 52 │ 52 │
│ zh │ 52 │ 0 │
└─────────────┴─────────────┴─────────┘
```
3. 与此同时,我们在 `src/utils/config.js` 新增相关配置。
```javascript
{
...
i18n: {
languages: [
...
{
key:'ja',
title: '日本語',
flag: '/japanese.svg',
},
],
},
}
```
>  路由相关效果,配置后 `npm run start` 重启后生效。
4. 使用内置的命令进行自动翻译,在 `src/locales/ja/messages.json` 中将会看到翻译后的配置。
```bash
npm run trans:only
```
你将看到如下信息:
```bash
start: en -> ja
...
youdao: en -> ja: Unpublished -> 未発表
youdao: en -> ja: Update -> 更新
youdao: en -> ja: Update User -> ユーザーの更新
youdao: en -> ja: Username -> 名
...
All translations have been completed.
```
> `npm run trans` 将会依次执行 `npm run extract` 和 `npm run trans:only`
5. 最后,可以在 `src/locales/ja/messages.json` 中对翻译不准确的的字段进行调整。启动开发模式 `npm run start`,打开 [http://localhost:7000/ja/login](http://localhost:7000/ja/login),你将看到日语版本的应用。
+60
View File
@@ -0,0 +1,60 @@
# 布局
## 新增布局
以新增名为 `secondary` 的布局为例,使以 `secondary` 开头的路由都使用该布局。
1. 在 `src/utils/config.js` 新增相关配置,参数详细请查看 [layouts](/zh-cn/configuration?id=layouts)。
```javascript
layouts: [
{
name: 'primary',
include: [/.*/],
exclude: [/(\/(en|zh))*\/login/, /(\/(en|zh))*\/secondary\/(.*)/],
},
{
name: 'secondary',
include: [/(\/(en|zh))*\/secondary\/(.*)/],
},
],
```
2. 在`src/layouts/BaseLayout.js` 文件中新增 `secondary` 布局组件。
```javascript
import SecondaryLayout from './SecondaryLayout'
const LayoutMap = {
primary: PrimaryLayout,
public: PublicLayout,
secondary: SecondaryLayout,
}
```
3. 在`src/layouts/` 目录中新增 `SecondaryLayout.js` 文件。
```javascript
import React from 'react'
export default ({ children }) => {
return (
<div>
<h1>Secondary</h1>
{children}
</div>
)
}
```
4. 在`src/pages/` 目录中新增 `secondary/index.js` 文件。
```javascript
import React from 'react'
export default ({ children }) => {
return <div>Secondary page Content</div>
}
```
5. 最后,启动开发模式 `npm run start`,打开 [http://localhost:7000/secondary/](http://localhost:7000/secondary/),你将看到 `secondary` 布局的页面。
+24
View File
@@ -0,0 +1,24 @@
# HTTP请求
本项目使用了axios提供http请求服务,文件在src/utils/request.js
## 自定义Header
为了提供鉴权、修改cookie等服务,可以手动修改Header
```
axios.defaults.headers.common['Authorization'] = 'token'
```
或者
```
// 添加请求拦截器
axios.interceptors.request.use(function (config) {
// 在发送请求之前做些什么
config.headers.token = window.localStorage.getItem('token');
return config;
}, function (error) {
return Promise.reject(error);
});
```
+1 -1
View File
@@ -1,3 +1,3 @@
module.exports = {
testURL: 'http://localhost:8000',
testURL: 'http://localhost:8000'
}
+36
View File
@@ -0,0 +1,36 @@
{
"name": "Antd-Admin",
"start_url": ".",
"display": "standalone",
"background_color": "#fff",
"description": "A front-end solution for enterprise applications built upon Ant Design and UmiJS",
"icons": [{
"src": "logo/logo@96.png",
"sizes": "72x72"
},
{
"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"
}
]
}
-62
View File
@@ -1,62 +0,0 @@
/**
* Query objects that specify keys and values in an array where all values are objects.
* @param {array} array An array where all values are objects, like [{key:1},{key:2}].
* @param {string} key The key of the object that needs to be queried.
* @param {string} value The value of the object that needs to be queried.
* @return {object|undefined} Return frist object when query success.
*/
export function queryArray(array, key, value) {
if (!Array.isArray(array)) {
return
}
return array.filter(_ => _[key] === value)
}
export function randomNumber(min, max) {
return Math.floor(Math.random() * (max - min) + min)
}
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'
]
return avatarList[randomNumber(0, avatarList.length - 1)]
}
export const Constant = {
ApiPrefix: '/api/v1',
NotFound: {
message: 'Not Found',
documentation_url: '',
},
Color: {
green: '#64ea91',
blue: '#8fc9fb',
purple: '#d897eb',
red: '#f69899',
yellow: '#f8c82e',
peach: '#f797d6',
borderBase: '#e5e5e5',
borderSplit: '#f4f4f4',
grass: '#d6fbb5',
sky: '#c1e0fc',
},
}
export Mock from 'mockjs'
export qs from 'qs'
+4008
View File
File diff suppressed because it is too large Load Diff
+4 -3
View File
@@ -1,4 +1,5 @@
import { Mock, Constant } from './_utils'
import Mock from 'mockjs'
import { Constant } from './utils'
const { ApiPrefix, Color } = Constant
@@ -105,7 +106,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: [
{
@@ -135,7 +136,7 @@ const Dashboard = Mock.mock({
],
})
module.exports = {
export default {
[`GET ${ApiPrefix}/dashboard`](req, res) {
res.json(Dashboard)
},
+2
View File
@@ -0,0 +1,2 @@
declare module 'mockjs'
declare module 'qs'
-67
View File
@@ -1,67 +0,0 @@
import { Mock, Constant } from './_utils'
const { ApiPrefix } = Constant
let postId = 0
const database = Mock.mock({
'data|100': [
{
id() {
postId += 1
return postId + 10000
},
'status|1-2': 1,
title: '@title',
author: '@last',
categories: '@word',
tags: '@word',
'views|10-200': 1,
'comments|10-200': 1,
visibility: () => {
return Mock.mock(
'@pick(["Public",' + '"Password protected", ' + '"Private"])'
)
},
date: '@dateTime',
image() {
return Mock.Random.image(
'100x100',
Mock.Random.color(),
'#757575',
'png',
this.author.substr(0, 1)
)
},
},
],
}).data
module.exports = {
[`GET ${ApiPrefix}/posts`](req, res) {
const { query } = req
let { pageSize, page, ...other } = query
pageSize = pageSize || 10
page = page || 1
let newData = database
for (let key in other) {
if ({}.hasOwnProperty.call(other, key)) {
newData = newData.filter(item => {
if ({}.hasOwnProperty.call(item, key)) {
return (
String(item[key])
.trim()
.indexOf(decodeURI(other[key]).trim()) > -1
)
}
return true
})
}
}
res.status(200).json({
data: newData.slice((page - 1) * pageSize, page * pageSize),
total: newData.length,
})
},
}
+69 -14
View File
@@ -1,4 +1,4 @@
import { Constant } from './_utils'
import { Constant } from './utils'
const { ApiPrefix } = Constant
const database = [
@@ -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,13 +137,18 @@ const database = [
breadcrumbParentId: '5',
menuParentId: '5',
name: 'Rechartst',
zhName: 'Rechartst',
zh: {
name: 'Rechartst',
},
'pt-br': {
name: 'Rechartst',
},
icon: 'area-chart',
route: '/chart/Recharts',
},
]
module.exports = {
export default {
[`GET ${ApiPrefix}/routes`](req, res) {
res.status(200).json(database)
},
+48 -35
View File
@@ -1,8 +1,10 @@
import { Mock, Constant, qs, randomAvatar } from './_utils'
import Mock from 'mockjs'
import qs from 'qs'
import { Constant, randomAvatar, waitTime } from './utils'
const { ApiPrefix } = Constant
let usersListData = Mock.mock({
const usersListData = Mock.mock({
'data|80-100': [
{
id: '@id',
@@ -90,10 +92,28 @@ const NOTFOUND = {
documentation_url: 'http://localhost:8000/request',
}
module.exports = {
[`POST ${ApiPrefix}/user/login`](req, res) {
const authorized = (req, res) => {
const cookie = req.headers.cookie || ''
const cookies = qs.parse(cookie.replace(/\s/g, ''), { delimiter: ';' })
if (!cookies.token) {
res.status(401).send({ message: 'Not Login' })
return false
}
const token = JSON.parse(cookies.token)
if (cookies.token && token && token.deadline > new Date().getTime()) {
return token
}
res.status(401).send({ message: 'Not Login' })
return false
}
export default {
async [`POST ${ApiPrefix}/user/login`](req, res) {
await waitTime()
const { username, password } = req.body
const user = adminUsers.filter(item => item.username === username)
const user = adminUsers.filter((item) => item.username === username)
if (user.length > 0 && user[0].password === password) {
const now = new Date()
@@ -112,33 +132,27 @@ module.exports = {
}
},
[`GET ${ApiPrefix}/user/logout`](req, res) {
async [`GET ${ApiPrefix}/user/logout`](req, res) {
await waitTime()
res.clearCookie('token')
res.status(200).end()
},
[`GET ${ApiPrefix}/user`](req, res) {
const cookie = req.headers.cookie || ''
const cookies = qs.parse(cookie.replace(/\s/g, ''), { delimiter: ';' })
const response = {}
let user = {}
if (!cookies.token) {
res.status(200).send({ message: 'Not Login' })
async [`GET ${ApiPrefix}/user`](req, res) {
await waitTime()
const token = authorized(req, res)
if (!token) {
return
}
const token = JSON.parse(cookies.token)
if (token) {
response.success = token.deadline > new Date().getTime()
const userItem = adminUsers.find((_) => _.id === token.id)
if (userItem) {
const { password, ...rest } = userItem
res.json(rest)
} else {
res.status(401).send({ message: 'Not Login' })
}
if (response.success) {
const userItem = adminUsers.find(_ => _.id === token.id)
if (userItem) {
const { password, ...other } = userItem
user = other
}
}
response.user = user
res.json(response)
},
[`GET ${ApiPrefix}/users`](req, res) {
@@ -150,10 +164,10 @@ module.exports = {
let newData = database
for (let key in other) {
if ({}.hasOwnProperty.call(other, key)) {
newData = newData.filter(item => {
newData = newData.filter((item) => {
if ({}.hasOwnProperty.call(item, key)) {
if (key === 'address') {
return other[key].every(iitem => item[key].indexOf(iitem) > -1)
return other[key].every((iitem) => item[key].indexOf(iitem) > -1)
} else if (key === 'createTime') {
const start = new Date(other[key][0]).getTime()
const end = new Date(other[key][1]).getTime()
@@ -165,9 +179,8 @@ module.exports = {
return true
}
return (
String(item[key])
.trim()
.indexOf(decodeURI(other[key]).trim()) > -1
String(item[key]).trim().indexOf(decodeURI(other[key]).trim()) >
-1
)
}
return true
@@ -176,14 +189,14 @@ module.exports = {
}
res.status(200).json({
data: newData.slice((page - 1) * pageSize, page * pageSize),
list: newData.slice((page - 1) * pageSize, page * pageSize),
total: newData.length,
})
},
[`POST ${ApiPrefix}/users/delete`](req, res) {
const { ids=[] } = req.body
database = database.filter(item => !ids.some(_ => _ === item.id))
const { ids = [] } = req.body
database = database.filter((item) => !ids.some((_) => _ === item.id))
res.status(204).end()
},
@@ -220,7 +233,7 @@ module.exports = {
const { id } = req.params
const data = queryArray(database, id, 'id')
if (data) {
database = database.filter(item => item.id !== id)
database = database.filter((item) => item.id !== id)
res.status(204).end()
} else {
res.status(200).json(NOTFOUND)
@@ -232,7 +245,7 @@ module.exports = {
const editItem = req.body
let isExist = false
database = database.map(item => {
database = database.map((item) => {
if (item.id === id) {
isExist = true
return Object.assign({}, item, editItem)
+66
View File
@@ -0,0 +1,66 @@
/**
* Query objects that specify keys and values in an array where all values are objects.
* @param {array} array An array where all values are objects, like [{key:1},{key:2}].
* @param {string} key The key of the object that needs to be queried.
* @param {string} value The value of the object that needs to be queried.
* @return {object|undefined} Return frist object when query success.
*/
export function queryArray(array, key, value) {
if (!Array.isArray(array)) {
return
}
return array.filter((_) => _[key] === value)
}
export function randomNumber(min, max) {
return Math.floor(Math.random() * (max - min) + min)
}
export function randomAvatar() {
const avatarList = [
'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 `//image.zuiidea.com/${
avatarList[randomNumber(0, avatarList.length - 1)]
}?imageView2/1/w/200/h/200/format/webp/q/75|imageslim`
}
export const waitTime = (time: number = 300) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true)
}, time)
})
}
export const Constant = {
ApiPrefix: '/api/v1',
NotFound: {
message: 'Not Found',
documentation_url: '',
},
Color: {
green: '#64ea91',
blue: '#8fc9fb',
purple: '#d897eb',
red: '#f69899',
yellow: '#f8c82e',
peach: '#f797d6',
borderBase: '#e5e5e5',
borderSplit: '#f4f4f4',
grass: '#d6fbb5',
sky: '#c1e0fc',
},
}
+95 -84
View File
@@ -1,111 +1,122 @@
{
"name": "antd-admin",
"version": "5.0.0-beta",
"private": true,
"version": "6.0.0-a.1",
"license": "MIT",
"description": "An admin dashboard application demo built upon Ant Design and UmiJS",
"dependencies": {
"@lingui/react": "^2.7.0",
"ant-design-pro": "^2.1.0",
"antd": "^3.10.0",
"axios": "^0.18.0",
"babel-core": "7.0.0-bridge.0",
"classnames": "^2.2.6",
"d3-shape": "^1.2.2",
"draftjs-to-html": "^0.8.4",
"draftjs-to-markdown": "^0.5.1",
"@ant-design/icons": "^4.7.0",
"@ant-design/pro-layout": "^6.37.0",
"@lingui/core": "^3.13.3",
"@lingui/detect-locale": "^3.13.3",
"@lingui/react": "^3.13.3",
"antd": "^4.20.1",
"axios": "^0.27.2",
"classnames": "^2.3.1",
"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",
"enquire-js": "^0.2.1",
"highcharts-exporting": "^0.1.7",
"highcharts-more": "^0.1.7",
"echarts": "^5.3.2",
"echarts-for-react": "^3.0.2",
"echarts-gl": "^2.0.9",
"echarts-liquidfill": "^3.1.0",
"json-format": "^1.0.1",
"lodash": "^4.17.11",
"md5": "^2.2.1",
"lodash": "^4.17.21",
"make-plural": "^7.1.0",
"md5": "^2.3.0",
"nprogress": "^0.2.0",
"path-to-regexp": "^2.4.0",
"prop-types": "^15.6.2",
"qs": "^6.5.2",
"rc-tween-one": "^2.2.8",
"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.0",
"recharts": "^1.3.0",
"path-to-regexp": "^6.2.0",
"prop-types": "^15.8.1",
"qs": "^6.10.3",
"react": "^18.1.0",
"react-countup": "^6.2.0",
"react-dom": "^18.1.0",
"react-helmet": "^6.1.0",
"react-highcharts": "^16.1.0",
"react-perfect-scrollbar": "^1.5.8",
"react-router-dom": "^6.3.0",
"recharts": "^2.1.9",
"store": "^2.0.12"
},
"devDependencies": {
"@lingui/babel-preset-react": "^2.7.0",
"@lingui/cli": "^2.7.0",
"@lingui/loader": "^2.7.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.7.0",
"eslint-config-react-app": "^3.0.4",
"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.1",
"@babel/preset-react": "^7.16.7",
"@lingui/babel-preset-react": "^2.9.2",
"@lingui/cli": "^3.13.3",
"@lingui/loader": "^3.13.3",
"@lingui/macro": "^3.13.3",
"@typescript-eslint/eslint-plugin": "^5.21.0",
"@typescript-eslint/parser": "^5.21.0",
"babel-plugin-dev-expression": "^0.2.3",
"babel-plugin-import": "^1.13.5",
"babel-plugin-macros": "^3.1.0",
"babel-plugin-module-resolver": "^4.1.0",
"cross-env": "^7.0.3",
"eslint": "^8.14.0",
"eslint-config-prettier": "^8.5.0",
"eslint-config-react-app": "^7.0.1",
"eslint-plugin-babel": "^5.3.1",
"eslint-plugin-flowtype": "^8.0.3",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.5.0",
"husky": "^7.0.4",
"less-vars-to-js": "^1.3.0",
"lint-staged": "^7.3.0",
"mockjs": "^1.0.1-beta3",
"module": "^1.2.5",
"prettier": "^1.14.3",
"stylelint": "^9.6.0",
"stylelint-config-prettier": "^4.0.0",
"stylelint-config-standard": "^18.2.0",
"umi": "^2.2.1",
"umi-plugin-react": "^1.2.0"
"lint-staged": "^12.4.1",
"mockjs": "^1.1.0",
"prettier": "^2.6.2",
"stylelint": "^14.8.0",
"stylelint-config-prettier": "^9.0.3",
"stylelint-config-standard": "^25.0.0",
"typescript": "^4.6.4",
"umi": "4.0.0-canary.20220429.4"
},
"optionalDependencies": {
"puppeteer": "^1.9.0"
"engines": {
"node": ">= 10.0.0"
},
"lint-staged": {
"src/**/*.js": [
"eslint --ext .js --fix",
"npm run prettier",
"git add"
"*.{ts,tsx,js,jsx}": [
"npm run eslint",
"npm run prettier"
],
"**/*.less": [
"stylelint --syntax less",
"npm run prettier",
"git add"
"*.less": [
"npm run stylelint",
"npm run prettier"
]
},
"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"
],
"exclude": [
"**/node_modules/**"
]
}
],
"format": "minimal",
"extractBabelOptions": {
"presets": [
"umi/babel"
]
}
"runtimeConfigModule": [
"@/hooks/useIntlProvider",
"i18n"
]
},
"scripts": {
"analyze": "cross-env ANALYZE=1 umi build",
"build": "umi build",
"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)'",
"build": "cross-env UMI_ENV=prod umi build",
"test": "umi test",
"analyze": "cross-env ANALYZE=1 umi dev",
"eslint": "eslint --fix 'src/**/*.{ts,tsx,js.jsx}'",
"stylelint": "stylelint src/**/*.less --syntax less",
"prettier": "prettier --write 'src/**/*.{ts,tsx,js.jsx,less}'",
"precommit": "lint-staged",
"add-locale": "lingui add-locale",
"extract": "lingui extract",
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

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

After

Width:  |  Height:  |  Size: 973 B

View File
+15 -3
View File
@@ -56,9 +56,21 @@ const transform = async ({ from, to, locales, outputPath }) => {
let res = key
let way = 'youdao'
if (key.indexOf('/') !== 0) {
res = await youdao({
q: key,
})
const reg = '{([^{}]*)}'
const tasks = key
.match(new RegExp(`${reg}|((?<=(${reg}|^)).*?(?=(${reg}|$)))`, 'g'))
.map(item => {
if (new RegExp(reg).test(item)) {
return Promise.resolve(item)
}
return youdao({
q: item,
from,
to,
})
})
res = (await Promise.all(tasks)).join('')
} else {
res = `/${to + key}`
way = 'link'
-34
View File
@@ -1,34 +0,0 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Dropdown, Button, Icon, Menu } from 'antd'
const DropOption = ({
onMenuClick,
menuOptions = [],
buttonStyle,
dropdownProps,
}) => {
const menu = menuOptions.map(item => (
<Menu.Item key={item.key}>{item.name}</Menu.Item>
))
return (
<Dropdown
overlay={<Menu onClick={onMenuClick}>{menu}</Menu>}
{...dropdownProps}
>
<Button style={{ border: 'none', ...buttonStyle }}>
<Icon style={{ marginRight: 2 }} type="bars" />
<Icon type="down" />
</Button>
</Dropdown>
)
}
DropOption.propTypes = {
onMenuClick: PropTypes.func,
menuOptions: PropTypes.array.isRequired,
buttonStyle: PropTypes.object,
dropdownProps: PropTypes.object,
}
export default DropOption
-6
View File
@@ -1,6 +0,0 @@
{
"name": "DropOption",
"version": "0.0.0",
"private": true,
"main": "./DropOption.js"
}
-17
View File
@@ -1,17 +0,0 @@
import React from 'react'
import { Editor } from 'react-draft-wysiwyg'
import 'react-draft-wysiwyg/dist/react-draft-wysiwyg.css'
import styles from './Editor.less'
const DraftEditor = props => {
return (
<Editor
toolbarClassName={styles.toolbar}
wrapperClassName={styles.wrapper}
editorClassName={styles.editor}
{...props}
/>
)
}
export default DraftEditor
-106
View File
@@ -1,106 +0,0 @@
.wrapper {
height: 500px;
:global {
.rdw-dropdownoption-default {
padding: 6px;
}
.rdw-dropdown-optionwrapper {
box-sizing: content-box;
width: 100%;
border-radius: 0 0 2px 2px;
&:hover {
box-shadow: none;
}
}
.rdw-inline-wrapper {
flex-wrap: wrap;
margin-bottom: 0;
.rdw-option-wrapper {
margin-bottom: 6px;
}
}
.rdw-option-active {
box-shadow: 1px 1px 0 #e8e8e8 inset;
}
.rdw-colorpicker-option {
box-shadow: none;
}
.rdw-colorpicker-modal,
.rdw-embedded-modal,
.rdw-emoji-modal,
.rdw-image-modal,
.rdw-link-modal {
box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.05);
}
.rdw-colorpicker-modal,
.rdw-embedded-modal,
.rdw-link-modal {
height: auto;
}
.rdw-emoji-modal {
width: 214px;
}
.rdw-colorpicker-modal {
width: auto;
}
.rdw-embedded-modal-btn,
.rdw-image-modal-btn,
.rdw-link-modal-btn {
height: 32px;
margin-top: 12px;
}
.rdw-embedded-modal-input,
.rdw-embedded-modal-size-input,
.rdw-link-modal-input {
padding: 2px 6px;
height: 32px;
}
.rdw-dropdown-selectedtext {
color: #000;
}
.rdw-dropdown-wrapper,
.rdw-option-wrapper {
min-width: 36px;
transition: all 0.2s ease;
height: 30px;
&:active {
box-shadow: 1px 1px 0 #e8e8e8 inset;
}
&:hover {
box-shadow: 1px 1px 0 #e8e8e8;
}
}
.rdw-dropdown-wrapper {
min-width: 60px;
}
.rdw-editor-main {
box-sizing: border-box;
}
}
.editor {
border: 1px solid #f1f1f1;
padding: 5px;
border-radius: 2px;
height: auto;
min-height: 200px;
}
}
-6
View File
@@ -1,6 +0,0 @@
{
"name": "Editor",
"version": "0.0.0",
"private": true,
"main": "./Editor.js"
}
@@ -1,12 +1,14 @@
import React from 'react'
import PropTypes from 'prop-types'
import styles from './FilterItem.less'
import styles from './index.less'
const FilterItem = ({ label = '', children }) => {
interface FilterItemProps {
label: string
}
const FilterItem: React.FC<FilterItemProps> = ({ 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,17 +16,10 @@ const FilterItem = ({ label = '', children }) => {
</span>
))}
</div>
) : (
''
)}
<div className={styles.item}>{children}</div>
</div>
)
}
FilterItem.propTypes = {
label: PropTypes.string,
children: PropTypes.element.isRequired,
}
export default FilterItem
-6
View File
@@ -1,6 +0,0 @@
{
"name": "FilterItem",
"version": "0.0.0",
"private": true,
"main": "./FilterItem.js"
}
+29
View File
@@ -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: 16px;
}
&:hover {
color: @text-color;
}
}
}
.copyright {
color: @text-color-secondary;
font-size: @font-size-base;
}
}
+40
View File
@@ -0,0 +1,40 @@
import React from 'react'
import styles from './index.less'
interface LinkItem {
key: string
title: React.ReactNode
href?: string
blankTarget?: boolean
}
interface GlobalFooterProps {
links?: LinkItem[]
copyright?: React.ReactNode
}
const GlobalFooter: React.FC<GlobalFooterProps> = ({
links = [],
copyright,
}) => {
return (
<footer className={styles.globalFooter}>
<div className={styles.links}>
{links.map((link) => (
<a
key={link.key}
title={link.key}
target={link.blankTarget ? '_blank' : '_self'}
href={link.href}
rel="noreferrer"
>
{link.title}
</a>
))}
</div>
{copyright && <div className={styles.copyright}>{copyright}</div>}
</footer>
)
}
export default GlobalFooter
-66
View File
@@ -1,66 +0,0 @@
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 styles from './Bread.less'
@withI18n()
@withRouter
class Bread extends PureComponent {
generateBreadcrumbs = paths => {
return paths.map((item, key) => {
const content = (
<Fragment>
{item.icon ? (
<Icon type={item.icon} style={{ marginRight: 4 }} />
) : null}
{item.name}
</Fragment>
)
return (
<Breadcrumb.Item key={key}>
{paths.length - 1 !== key ? (
<Link to={item.route || '#'}>{content}</Link>
) : (
content
)}
</Breadcrumb.Item>
)
})
}
render() {
const { routeList, location, i18n } = this.props
// Find a route that matches the pathname.
const currentRoute = routeList.find(
_ => _.route && pathMatchRegexp(_.route, location.pathname)
)
// Find the breadcrumb navigation of the current route match and all its ancestors.
const paths = currentRoute
? queryAncestors(routeList, currentRoute, 'breadcrumbParentId').reverse()
: [
routeList[0],
{
id: 404,
name: i18n.t`Not Found`,
},
]
return (
<Breadcrumb className={styles.bread}>
{this.generateBreadcrumbs(paths)}
</Breadcrumb>
)
}
}
Bread.propTypes = {
routeList: PropTypes.array,
}
export default Bread
-16
View File
@@ -1,16 +0,0 @@
.bread {
margin-bottom: 24px;
:global {
.ant-breadcrumb {
display: flex;
align-items: center;
}
}
}
@media (max-width: 767px) {
.bread {
margin-bottom: 12px;
}
}
-174
View File
@@ -1,174 +0,0 @@
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 moment from 'moment'
import classnames from 'classnames'
import config from 'config'
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,
collapsed,
notifications,
onCollapseChange,
onAllNotificationsRead,
} = this.props
const rightContent = [
<Menu key="user" mode="horizontal" onClick={this.handleClickMenu}>
<SubMenu
title={
<Fragment>
<span style={{ color: '#999', marginRight: 4 }}>
<Trans>Hi,</Trans>
</span>
<span>{username}</span>
<Avatar style={{ marginLeft: 8 }} src={avatar} />
</Fragment>
}
>
<Menu.Item key="SignOut">
<Trans>Sign out</Trans>
</Menu.Item>
</SubMenu>
</Menu>,
]
if (config.i18n) {
const { languages } = config.i18n
const currentLanguage = languages.find(
item => item.key === i18n._language
)
rightContent.unshift(
<Menu
key="language"
selectedKeys={[currentLanguage.key]}
onClick={data => {
setLocale(data.key)
}}
mode="horizontal"
>
<SubMenu title={<Avatar size="small" src={currentLanguage.flag} />}>
{languages.map(item => (
<Menu.Item key={item.key}>
<Avatar
size="small"
style={{ marginRight: 8 }}
src={item.flag}
/>
{item.title}
</Menu.Item>
))}
</SubMenu>
</Menu>
)
}
rightContent.unshift(
<Popover
placement="bottomRight"
trigger="click"
key="notifications"
overlayClassName={styles.notificationPopover}
getPopupContainer={() => document.querySelector('#layoutHeader')}
content={
<div className={styles.notification}>
<List
itemLayout="horizontal"
dataSource={notifications}
locale={{
emptyText: <Trans>You have viewed all notifications.</Trans>,
}}
renderItem={item => (
<List.Item className={styles.notificationItem}>
<List.Item.Meta
title={
<Ellipsis tooltip lines={1}>
{item.title}
</Ellipsis>
}
description={moment(item.date).fromNow()}
/>
<Icon
style={{ fontSize: 10, color: '#ccc' }}
type="right"
theme="outlined"
/>
</List.Item>
)}
/>
{notifications.length ? (
<div
onClick={onAllNotificationsRead}
className={styles.clearButton}
>
<Trans>Clear notifications</Trans>
</div>
) : null}
</div>
}
>
<Badge
count={notifications.length}
dot
offset={[-10, 10]}
className={styles.iconButton}
>
<Icon className={styles.iconFont} type="bell" />
</Badge>
</Popover>
)
return (
<Layout.Header
className={classnames(styles.header, {
[styles.fixed]: fixed,
[styles.collapsed]: collapsed,
})}
id="layoutHeader"
>
<div
className={styles.button}
onClick={onCollapseChange.bind(this, !collapsed)}
>
<Icon
type={classnames({
'menu-unfold': collapsed,
'menu-fold': !collapsed,
})}
/>
</div>
<div className={styles.rightContainer}>{rightContent}</div>
</Layout.Header>
)
}
}
Header.propTypes = {
fixed: PropTypes.bool,
user: PropTypes.object,
menus: PropTypes.array,
collapsed: PropTypes.bool,
onSignOut: PropTypes.func,
notifications: PropTypes.array,
onCollapseChange: PropTypes.func,
onAllNotificationsRead: PropTypes.func,
}
export default Header
-154
View File
@@ -1,154 +0,0 @@
@import '~themes/vars.less';
.header {
padding: 0;
box-shadow: @shadow-2;
position: relative;
display: flex;
justify-content: space-between;
height: 72px;
z-index: 9;
align-items: center;
background-color: #fff;
&.fixed {
position: fixed;
top: 0;
right: 0;
width: ~'calc(100% - 256px)';
z-index: 9;
transition: width 0.2s;
&.collapsed {
width: ~'calc(100% - 80px)';
}
}
:global {
.ant-menu-submenu-title {
height: 72px;
}
.ant-menu-horizontal {
line-height: 72px;
& > .ant-menu-submenu:hover {
color: @primary-color;
background-color: @hover-color;
}
}
.ant-menu {
border-bottom: none;
height: 72px;
}
.ant-menu-horizontal > .ant-menu-submenu {
top: 0;
margin-top: 0;
}
.ant-menu-horizontal > .ant-menu-item,
.ant-menu-horizontal > .ant-menu-submenu {
border-bottom: none;
}
.ant-menu-horizontal > .ant-menu-item-active,
.ant-menu-horizontal > .ant-menu-item-open,
.ant-menu-horizontal > .ant-menu-item-selected,
.ant-menu-horizontal > .ant-menu-item:hover,
.ant-menu-horizontal > .ant-menu-submenu-active,
.ant-menu-horizontal > .ant-menu-submenu-open,
.ant-menu-horizontal > .ant-menu-submenu-selected,
.ant-menu-horizontal > .ant-menu-submenu:hover {
border-bottom: none;
}
}
.rightContainer {
display: flex;
align-items: center;
}
.button {
width: 72px;
height: 72px;
line-height: 72px;
text-align: center;
font-size: 18px;
cursor: pointer;
transition: @transition-ease-in;
&:hover {
color: @primary-color;
background-color: @hover-color;
}
}
}
.iconButton {
width: 48px;
height: 48px;
display: flex;
justify-content: center;
align-items: center;
border-radius: 24px;
cursor: pointer;
.background-hover();
&:hover {
.iconFont {
color: @primary-color;
}
}
& + .iconButton {
margin-left: 8px;
}
.iconFont {
color: #b2b0c7;
font-size: 24px;
}
}
.notification {
padding: 24px 0;
width: 320px;
.notificationItem {
transition: all 0.3s;
padding: 12px 24px;
cursor: pointer;
&:hover {
background-color: @hover-color;
}
}
.clearButton {
text-align: center;
height: 48px;
line-height: 48px;
cursor: pointer;
.background-hover();
}
}
.notificationPopover {
:global {
.ant-popover-inner-content {
padding: 0;
}
.ant-popover-arrow {
display: none;
}
.ant-list-item-content {
flex: 0;
margin-left: 16px;
}
}
}
@media (max-width: 767px) {
.header {
width: 100% !important;
}
}
-122
View File
@@ -1,122 +0,0 @@
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 store from 'store'
const { SubMenu } = Menu
@withRouter
class SiderMenu extends PureComponent {
state = {
openKeys: store.get('openKeys') || [],
}
onOpenChange = openKeys => {
const { menus } = this.props
const rootSubmenuKeys = menus.filter(_ => !_.menuParentId).map(_ => _.id)
const latestOpenKey = openKeys.find(
key => this.state.openKeys.indexOf(key) === -1
)
let newOpenKeys = openKeys
if (rootSubmenuKeys.indexOf(latestOpenKey) !== -1) {
newOpenKeys = latestOpenKey ? [latestOpenKey] : []
}
this.setState({
openKeys: newOpenKeys,
})
store.set('openKeys', newOpenKeys)
}
generateMenus = data => {
return data.map(item => {
if (item.children) {
return (
<SubMenu
key={item.id}
title={
<Fragment>
{item.icon && <Icon type={item.icon} />}
<span>{item.name}</span>
</Fragment>
}
>
{this.generateMenus(item.children)}
</SubMenu>
)
}
return (
<Menu.Item key={item.id}>
<Navlink to={addLangPrefix(item.route) || '#'}>
{item.icon && <Icon type={item.icon} />}
<span>{item.name}</span>
</Navlink>
</Menu.Item>
)
})
}
render() {
const {
collapsed,
theme,
menus,
location,
isMobile,
onCollapseChange,
} = this.props
// Generating tree-structured data for menu content.
const menuTree = arrayToTree(menus, 'id', 'menuParentId')
// Find a menu that matches the pathname.
const currentMenu = menus.find(
_ => _.route && pathMatchRegexp(_.route, location.pathname)
)
// Find the key that should be selected according to the current menu.
const selectedKeys = currentMenu
? queryAncestors(menus, currentMenu, 'menuParentId').map(_ => _.id)
: []
return (
<Menu
mode="inline"
theme={theme}
onOpenChange={this.onOpenChange}
openKeys={this.state.openKeys}
inlineCollapsed={collapsed}
selectedKeys={selectedKeys}
onClick={
isMobile
? () => {
onCollapseChange(true)
}
: undefined
}
>
{this.generateMenus(menuTree)}
</Menu>
)
}
}
SiderMenu.propTypes = {
menus: PropTypes.array,
theme: PropTypes.string,
isMobile: PropTypes.bool,
collapsed: PropTypes.bool,
onCollapseChange: PropTypes.func,
}
export default SiderMenu
-88
View File
@@ -1,88 +0,0 @@
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import { Icon, Switch, Layout } from 'antd'
import { withI18n, Trans } from '@lingui/react'
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,
collapsed,
onThemeChange,
onCollapseChange,
} = this.props
return (
<Layout.Sider
width={256}
theme={theme}
breakpoint="lg"
trigger={null}
collapsible
collapsed={collapsed}
onBreakpoint={isMobile ? null : onCollapseChange}
className={styles.sider}
>
<div className={styles.brand}>
<div className={styles.logo}>
<img alt="logo" src={config.logoPath} />
{collapsed ? null : <h1>{config.siteName}</h1>}
</div>
</div>
<div className={styles.menuContainer}>
<ScrollBar
option={{
// Disabled horizontal scrolling, https://github.com/utatti/perfect-scrollbar#options
suppressScrollX: true,
}}
>
<SiderMenu
menus={menus}
theme={theme}
isMobile={isMobile}
collapsed={collapsed}
onCollapseChange={onCollapseChange}
/>
</ScrollBar>
</div>
{collapsed ? null : (
<div className={styles.switchTheme}>
<span>
<Icon type="bulb" />
<Trans>Switch Theme</Trans>
</span>
<Switch
onChange={onThemeChange.bind(
this,
theme === 'dark' ? 'light' : 'dark'
)}
defaultChecked={theme === 'dark'}
checkedChildren={i18n.t`Dark`}
unCheckedChildren={i18n.t`Light`}
/>
</div>
)}
</Layout.Sider>
)
}
}
Sider.propTypes = {
menus: PropTypes.array,
theme: PropTypes.string,
isMobile: PropTypes.bool,
collapsed: PropTypes.bool,
onThemeChange: PropTypes.func,
onCollapseChange: PropTypes.func,
}
export default Sider
-110
View File
@@ -1,110 +0,0 @@
@import '~themes/vars.less';
.sider {
box-shadow: fade(@primary-color, 10%) 0 0 28px 0;
z-index: 10;
:global {
.ant-layout-sider-children {
display: flex;
flex-direction: column;
justify-content: space-between;
}
}
}
.brand {
z-index: 1;
height: 72px;
display: flex;
align-items: center;
justify-content: center;
padding: 0 24px;
box-shadow: 0 1px 9px -3px rgba(0, 0, 0, 0.2);
.logo {
display: flex;
align-items: center;
justify-content: center;
img {
width: 36px;
margin-right: 8px;
}
h1 {
vertical-align: text-bottom;
font-size: 16px;
text-transform: uppercase;
display: inline-block;
font-weight: 700;
color: @primary-color;
white-space: nowrap;
margin-bottom: 0;
.text-gradient();
:local {
animation: fadeRightIn 300ms @ease-in-out;
animation-fill-mode: both;
}
}
}
}
.menuContainer {
height: ~'calc(100vh - 120px)';
overflow-x: hidden;
flex: 1;
padding: 24px 0;
&::-webkit-scrollbar-thumb {
background-color: transparent;
}
&:hover {
&::-webkit-scrollbar-thumb {
background-color: rgba(0, 0, 0, 0.2);
}
}
:global {
.ant-menu-inline {
border-right: none;
}
}
}
.switchTheme {
width: 100%;
height: 48px;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 16px;
overflow: hidden;
transition: all 0.3s;
span {
white-space: nowrap;
overflow: hidden;
font-size: 12px;
}
:global {
.anticon {
min-width: 14px;
margin-right: 4px;
font-size: 14px;
}
}
}
@keyframes fadeLeftIn {
0% {
transform: translateX(5px);
opacity: 0;
}
100% {
transform: translateX(0);
opacity: 1;
}
}
-6
View File
@@ -1,6 +0,0 @@
import Header from './Header'
import Menu from './Menu'
import Bread from './Bread'
import Sider from './Sider'
export { Header, Menu, Bread, Sider }
@@ -1,67 +1,67 @@
.loader {
background-color: #fff;
width: 100%;
position: absolute;
top: 0;
bottom: 0;
left: 0;
z-index: 100000;
display: flex;
justify-content: center;
align-items: center;
opacity: 1;
text-align: center;
&.fullScreen {
position: fixed;
}
.warpper {
width: 100px;
height: 100px;
display: inline-flex;
flex-direction: column;
justify-content: space-around;
}
.inner {
width: 40px;
height: 40px;
margin: 0 auto;
text-indent: -12345px;
border-top: 1px solid rgba(0, 0, 0, 0.08);
border-right: 1px solid rgba(0, 0, 0, 0.08);
border-bottom: 1px solid rgba(0, 0, 0, 0.08);
border-left: 1px solid rgba(0, 0, 0, 0.7);
border-radius: 50%;
z-index: 100001;
:local {
animation: spinner 600ms infinite linear;
}
}
.text {
width: 100px;
height: 20px;
text-align: center;
font-size: 12px;
letter-spacing: 4px;
color: #000;
}
&.hidden {
z-index: -1;
opacity: 0;
transition: opacity 1s ease 0.5s, z-index 0.1s ease 1.5s;
}
}
@keyframes spinner {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.loader {
background-color: #fff;
width: 100%;
position: absolute;
top: 0;
bottom: 0;
left: 0;
z-index: 100000;
display: flex;
justify-content: center;
align-items: center;
opacity: 1;
text-align: center;
&.fullScreen {
position: fixed;
}
.warpper {
width: 100px;
height: 100px;
display: inline-flex;
flex-direction: column;
justify-content: space-around;
}
.inner {
width: 40px;
height: 40px;
margin: 0 auto;
text-indent: -12345px;
border-top: 1px solid rgba(0, 0, 0, 0.08);
border-right: 1px solid rgba(0, 0, 0, 0.08);
border-bottom: 1px solid rgba(0, 0, 0, 0.08);
border-left: 1px solid rgba(0, 0, 0, 0.7);
border-radius: 50%;
z-index: 100001;
:local {
animation: spinner 600ms infinite linear;
}
}
.text {
width: 100px;
height: 20px;
text-align: center;
font-size: 12px;
letter-spacing: 4px;
color: #000;
}
&.hidden {
z-index: -1;
opacity: 0;
transition: opacity 1s ease 0.5s, z-index 0.1s ease 1.5s;
}
}
@keyframes spinner {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@@ -1,9 +1,13 @@
import React from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
import styles from './Loader.less'
import styles from './index.less'
const Loader = ({ spinning = true, fullScreen }) => {
interface LoaderProps {
spinning?: boolean
fullScreen?: boolean
}
const Loader: React.FC<LoaderProps> = ({ spinning = false, fullScreen }) => {
return (
<div
className={classNames(styles.loader, {
@@ -19,9 +23,4 @@ const Loader = ({ spinning = true, fullScreen }) => {
)
}
Loader.propTypes = {
spinning: PropTypes.bool,
fullScreen: PropTypes.bool,
}
export default Loader
-6
View File
@@ -1,6 +0,0 @@
{
"name": "Loader",
"version": "0.0.0",
"private": true,
"main": "./Loader.js"
}
-33
View File
@@ -1,33 +0,0 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'
import Loader from '../Loader'
import styles from './Page.less'
export default class Page extends Component {
render() {
const { className, children, loading = false, inner = false } = this.props
const loadingStyle = {
height: 'calc(100vh - 184px)',
overflow: 'hidden',
}
return (
<div
className={classnames(className, {
[styles.contentInner]: inner,
})}
style={loading ? loadingStyle : null}
>
{loading ? <Loader spinning /> : ''}
{children}
</div>
)
}
}
Page.propTypes = {
className: PropTypes.string,
children: PropTypes.node,
loading: PropTypes.bool,
inner: PropTypes.bool,
}
@@ -1,4 +1,4 @@
@import '~themes/vars.less';
@import '~@/themes/vars.less';
.contentInner {
background: #fff;
+32
View File
@@ -0,0 +1,32 @@
import React from 'react'
import classnames from 'classnames'
import Loader from '../Loader'
import styles from './index.less'
interface IPageProps {
inner?: boolean
loading?: boolean
className?: string
}
const Page: React.FC = (props: IPageProps) => {
const { className, children, loading = false, inner = false } = props
const loadingStyle = {
height: 'calc(100vh - 184px)',
overflow: 'hidden',
}
return (
<div
className={classnames(className, {
[styles.contentInner]: inner,
})}
style={loading ? loadingStyle : null}
>
{loading ? <Loader spinning /> : ''}
{children}
</div>
)
}
export default Page
-6
View File
@@ -1,6 +0,0 @@
{
"name": "Page",
"version": "0.0.0",
"private": true,
"main": "./Page.js"
}
-9
View File
@@ -1,9 +0,0 @@
import Editor from './Editor'
import FilterItem from './FilterItem'
import DropOption from './DropOption'
import Loader from './Loader'
import ScrollBar from './ScrollBar'
import * as MyLayout from './Layout/index.js'
import Page from './Page'
export { MyLayout, Editor, FilterItem, DropOption, Loader, Page, ScrollBar }
+7
View File
@@ -0,0 +1,7 @@
import FilterItem from './FilterItem'
import Loader from './Loader'
import ScrollBar from './ScrollBar'
import GlobalFooter from './GlobalFooter'
import Page from './Page'
export { GlobalFooter, FilterItem, Loader, ScrollBar, Page }
+1
View File
@@ -0,0 +1 @@
export const LOCALE_LANGUAGE = 'LOCALE_LANGUAGE'
+33
View File
@@ -0,0 +1,33 @@
import { IConfig, ISupportedLocales } from '@/typings'
import { LOCALE_LANGUAGE } from '@/configs/constants'
import checkLanguage from '@/utils/checkLanguage'
import {
detect,
fromUrl,
fromStorage,
fromNavigator,
} from '@lingui/detect-locale'
const language = detect(
checkLanguage(fromUrl('lang')),
checkLanguage(fromStorage(LOCALE_LANGUAGE)),
checkLanguage(fromNavigator()),
'en'
)
export const config: IConfig = {
title: 'Antd Admin',
logo: 'logo.svg',
copyright: 'Ant Design Admin © 2021 zuiidea',
language: language as ISupportedLocales,
apiPrefix: '/api/v1',
/* Layout configuration, specify which layout to use for route. */
layouts: [
{
name: 'primary',
include: [/.*/],
exlude: [/\/login/],
},
],
}
+8
View File
@@ -0,0 +1,8 @@
import menus from './menus'
import menuIcon from './menus/icon'
export * from './default'
export * from './languages'
export * from './constants'
export { menus, menuIcon }
+32
View File
@@ -0,0 +1,32 @@
import { ILanguage, ILanguages, IAntdI18nMap } from '@/typings'
/**
* Countrys flags: https://www.flaticon.com/packs/countrys-flags
*/
export const language: ILanguage = {
en: {
flag: '/america.svg',
value: 'English',
},
zh: {
flag: '/china.svg',
value: '简体中文',
},
'pt-br': {
flag: '/portugal.svg',
value: 'Português',
},
}
export const languages: ILanguages[] = Object.entries(language).map(
([key, value]: any) => ({
key,
...value,
})
)
export const antdI18nMap: IAntdI18nMap = {
zh: 'zh_CN',
en: 'en_US',
'pt-br': 'pt_BR',
}
+34
View File
@@ -0,0 +1,34 @@
import {
PayCircleOutlined,
ShoppingCartOutlined,
MessageOutlined,
TeamOutlined,
UserOutlined,
DashboardOutlined,
ApiOutlined,
CameraOutlined,
EditOutlined,
CodeOutlined,
LineOutlined,
BarChartOutlined,
AreaChartOutlined,
} from '@ant-design/icons'
import { IMenuIcon } from '@/typings'
const menuIcon: IMenuIcon = {
'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 />,
}
export default menuIcon
+22
View File
@@ -0,0 +1,22 @@
import { t } from '@lingui/macro'
/*
* Note:
* Menu items with children need to set a key starting with "/"
* @see https://github.com/umijs/route-utils/blob/master/src/transformRoute/transformRoute.ts#L219
*/
const menus = [
{
path: '/',
name: t`Dashboard`,
icon: 'dashboard',
},
{
path: '/user',
name: t`User`,
icon: 'user',
},
]
export default menus
+8
View File
@@ -0,0 +1,8 @@
import { SettingDrawerProps } from '@ant-design/pro-layout'
const defaultSettings: SettingDrawerProps['settings'] = {
navTheme: 'light',
primaryColor: '#006EFF',
}
export default defaultSettings
+1 -1
View File
@@ -18,7 +18,7 @@ describe('Login', () => {
afterEach(() => page.close())
it('should login with failure', async () => {
await page.waitFor(selector => !!document.querySelector('#username'), {
await page.waitFor((selector) => !!document.querySelector('#username'), {
timeout: 3000,
})
await page.type('#username', 'wrong_user')
+16
View File
@@ -0,0 +1,16 @@
import { useNavigate, useLocation } from 'react-router-dom';
import { useLingui } from '@lingui/react';
import useConfig from './useConfig'
import useIntlProvider from './useIntlProvider'
import useLocalStorage from './useLocalStorage';
import useRequest from './useRequest';
export {
useConfig,
useNavigate,
useLocation,
useRequest,
useLocalStorage,
useIntlProvider,
useLingui,
}
+8
View File
@@ -0,0 +1,8 @@
import { useContext } from 'react'
import { ConfigContext } from '@/utils/context'
const useConfig = () => {
return useContext(ConfigContext)
}
export default useConfig
+47
View File
@@ -0,0 +1,47 @@
import { useEffect, useContext, useState } from 'react';
import { setupI18n } from '@lingui/core';
import { LOCALE_LANGUAGE } from '@/configs/constants';
import { ConfigContext } from '@/utils/context';
import { useLocalStorage } from '@/hooks';
import { antdI18nMap } from '@/configs';
import { SupportedLocales } from '@/typings';
import { ConfigProviderProps } from 'antd/lib/config-provider';
import { en, zh } from 'make-plural/plurals';
export const i18n = setupI18n({
localeData: {
en: { plurals: en },
zh: { plurals: zh },
},
});
const useIntlProvider = () => {
const { language: defaultLocale } = useContext(ConfigContext);
const [language, setLanguage] = useLocalStorage<SupportedLocales>(
LOCALE_LANGUAGE,
defaultLocale
);
const [locale, setLocale] = useState<ConfigProviderProps['locale']>();
useEffect(() => {
import(`@/locales/${language}/messages.json`).then(data => {
i18n.load(language, data.default);
i18n.activate(language);
});
const path = antdI18nMap[language];
import(`antd/lib/locale/${path}.js`).then(data => {
setLocale(data.default);
});
}, [language]);
return {
language,
setLanguage,
locale,
i18n,
};
};
export default useIntlProvider;

Some files were not shown because too many files have changed in this diff Show More