diff --git a/.gitignore b/.gitignore index 18b814abcf91eebf1cd3acb7b8e86c0de27baa67..7fd9f581cd9eb0afc2650747267d81bd20d1902d 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,5 @@ functions/* screenshot .firebase .eslintcache + +build diff --git a/CNAME b/CNAME new file mode 100644 index 0000000000000000000000000000000000000000..30c2d4d3624a8970342c7c6514217648aaed82d4 --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +preview.pro.ant.design \ No newline at end of file diff --git a/Dockerfile.hub b/Dockerfile.hub index 2e9c1ec9133f1762656e6bdc2672a1802bd24186..43d89815a58e41c45db2bacb2695798321f5f33c 100644 --- a/Dockerfile.hub +++ b/Dockerfile.hub @@ -1,10 +1,24 @@ -FROM nginx +FROM circleci/node:latest-browsers as builder WORKDIR /usr/src/app/ +USER root +COPY package.json ./ +RUN yarn + +COPY ./ ./ + +RUN npm run test:all + +RUN npm run build + + +FROM nginx + +WORKDIR /usr/share/nginx/html/ COPY ./docker/nginx.conf /etc/nginx/conf.d/default.conf -COPY ./dist /usr/share/nginx/html/ +COPY --from=builder /usr/src/app/dist /usr/share/nginx/html/ EXPOSE 80 diff --git a/README.md b/README.md index d87c1a57a7b8b0d90c36ef25b935b1236d5068a9..dd59126f045326230563700f152aca4e7bfc5bab 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,9 @@ English | [简体中文](./README.zh-CN.md) | [Русский](./README.ru-RU.md An out-of-box UI solution for enterprise applications as a React boilerplate. -[![Build With Umi](https://img.shields.io/badge/build%20with-umi-028fe4.svg?style=flat-square)](http://umijs.org/) [![Build Status](https://dev.azure.com/ant-design/ant-design-pro/_apis/build/status/ant-design.ant-design-pro?branchName=master)](https://dev.azure.com/ant-design/ant-design-pro/_build/latest?definitionId=1?branchName=master) [![Dependencies](https://img.shields.io/david/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro) [![DevDependencies](https://img.shields.io/david/dev/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro?type=dev) [![Gitter](https://img.shields.io/gitter/room/ant-design/pro-english.svg?style=flat-square&logoWidth=20&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgd2lkdGg9IjEyMzUiIGhlaWdodD0iNjUwIiB2aWV3Qm94PSIwIDAgNzQxMCAzOTAwIj4NCjxyZWN0IHdpZHRoPSI3NDEwIiBoZWlnaHQ9IjM5MDAiIGZpbGw9IiNiMjIyMzQiLz4NCjxwYXRoIGQ9Ik0wLDQ1MEg3NDEwbTAsNjAwSDBtMCw2MDBINzQxMG0wLDYwMEgwbTAsNjAwSDc0MTBtMCw2MDBIMCIgc3Ryb2tlPSIjZmZmIiBzdHJva2Utd2lkdGg9IjMwMCIvPg0KPHJlY3Qgd2lkdGg9IjI5NjQiIGhlaWdodD0iMjEwMCIgZmlsbD0iIzNjM2I2ZSIvPg0KPGcgZmlsbD0iI2ZmZiI%2BDQo8ZyBpZD0iczE4Ij4NCjxnIGlkPSJzOSI%2BDQo8ZyBpZD0iczUiPg0KPGcgaWQ9InM0Ij4NCjxwYXRoIGlkPSJzIiBkPSJNMjQ3LDkwIDMxNy41MzQyMzAsMzA3LjA4MjAzOSAxMzIuODczMjE4LDE3Mi45MTc5NjFIMzYxLjEyNjc4MkwxNzYuNDY1NzcwLDMwNy4wODIwMzl6Ii8%2BDQo8dXNlIHhsaW5rOmhyZWY9IiNzIiB5PSI0MjAiLz4NCjx1c2UgeGxpbms6aHJlZj0iI3MiIHk9Ijg0MCIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgeT0iMTI2MCIvPg0KPC9nPg0KPHVzZSB4bGluazpocmVmPSIjcyIgeT0iMTY4MCIvPg0KPC9nPg0KPHVzZSB4bGluazpocmVmPSIjczQiIHg9IjI0NyIgeT0iMjEwIi8%2BDQo8L2c%2BDQo8dXNlIHhsaW5rOmhyZWY9IiNzOSIgeD0iNDk0Ii8%2BDQo8L2c%2BDQo8dXNlIHhsaW5rOmhyZWY9IiNzMTgiIHg9Ijk4OCIvPg0KPHVzZSB4bGluazpocmVmPSIjczkiIHg9IjE5NzYiLz4NCjx1c2UgeGxpbms6aHJlZj0iI3M1IiB4PSIyNDcwIi8%2BDQo8L2c%2BDQo8L3N2Zz4%3D)](https://gitter.im/ant-design/pro-english?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Join the chat at https://gitter.im/ant-design/ant-design-pro](https://img.shields.io/gitter/room/ant-design/ant-design-pro.svg?style=flat-square&logoWidth=20&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgd2lkdGg9IjkwMCIgaGVpZ2h0PSI2MDAiIHZpZXdCb3g9IjAgMCAzMCAyMCI%2BDQo8ZGVmcz4NCjxwYXRoIGlkPSJzIiBkPSJNMCwtMSAwLjU4Nzc4NSwwLjgwOTAxNyAtMC45NTEwNTcsLTAuMzA5MDE3SDAuOTUxMDU3TC0wLjU4Nzc4NSwwLjgwOTAxN3oiIGZpbGw9IiNmZmRlMDAiLz4NCjwvZGVmcz4NCjxyZWN0IHdpZHRoPSIzMCIgaGVpZ2h0PSIyMCIgZmlsbD0iI2RlMjkxMCIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNSw1KSBzY2FsZSgzKSIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTAsMikgcm90YXRlKDIzLjAzNjI0MykiLz4NCjx1c2UgeGxpbms6aHJlZj0iI3MiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEyLDQpIHJvdGF0ZSg0NS44Njk4OTgpIi8%2BDQo8dXNlIHhsaW5rOmhyZWY9IiNzIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxMiw3KSByb3RhdGUoNjkuOTQ1Mzk2KSIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTAsOSkgcm90YXRlKDIwLjY1OTgwOCkiLz4NCjwvc3ZnPg%3D%3D)](https://gitter.im/ant-design/ant-design-pro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Netlify Status](https://api.netlify.com/api/v1/badges/ee4b4cc9-f8d7-4542-929f-a025c5927663/deploy-status)](https://app.netlify.com/sites/angry-lumiere-4b8ba4/deploys) ![](https://user-images.githubusercontent.com/8186664/44953195-581e3d80-aec4-11e8-8dcb-54b9db38ec11.png) +[![Build With Umi](https://img.shields.io/badge/build%20with-umi-028fe4.svg?style=flat-square)](http://umijs.org/) [![Build Status](https://dev.azure.com/ant-design/ant-design-pro/_apis/build/status/ant-design.ant-design-pro?branchName=master)](https://dev.azure.com/ant-design/ant-design-pro/_build/latest?definitionId=1?branchName=master) [![Dependencies](https://img.shields.io/david/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro) [![DevDependencies](https://img.shields.io/david/dev/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro?type=dev) [![Gitter](https://img.shields.io/gitter/room/ant-design/pro-english.svg?style=flat-square&logoWidth=20&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgd2lkdGg9IjEyMzUiIGhlaWdodD0iNjUwIiB2aWV3Qm94PSIwIDAgNzQxMCAzOTAwIj4NCjxyZWN0IHdpZHRoPSI3NDEwIiBoZWlnaHQ9IjM5MDAiIGZpbGw9IiNiMjIyMzQiLz4NCjxwYXRoIGQ9Ik0wLDQ1MEg3NDEwbTAsNjAwSDBtMCw2MDBINzQxMG0wLDYwMEgwbTAsNjAwSDc0MTBtMCw2MDBIMCIgc3Ryb2tlPSIjZmZmIiBzdHJva2Utd2lkdGg9IjMwMCIvPg0KPHJlY3Qgd2lkdGg9IjI5NjQiIGhlaWdodD0iMjEwMCIgZmlsbD0iIzNjM2I2ZSIvPg0KPGcgZmlsbD0iI2ZmZiI%2BDQo8ZyBpZD0iczE4Ij4NCjxnIGlkPSJzOSI%2BDQo8ZyBpZD0iczUiPg0KPGcgaWQ9InM0Ij4NCjxwYXRoIGlkPSJzIiBkPSJNMjQ3LDkwIDMxNy41MzQyMzAsMzA3LjA4MjAzOSAxMzIuODczMjE4LDE3Mi45MTc5NjFIMzYxLjEyNjc4MkwxNzYuNDY1NzcwLDMwNy4wODIwMzl6Ii8%2BDQo8dXNlIHhsaW5rOmhyZWY9IiNzIiB5PSI0MjAiLz4NCjx1c2UgeGxpbms6aHJlZj0iI3MiIHk9Ijg0MCIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgeT0iMTI2MCIvPg0KPC9nPg0KPHVzZSB4bGluazpocmVmPSIjcyIgeT0iMTY4MCIvPg0KPC9nPg0KPHVzZSB4bGluazpocmVmPSIjczQiIHg9IjI0NyIgeT0iMjEwIi8%2BDQo8L2c%2BDQo8dXNlIHhsaW5rOmhyZWY9IiNzOSIgeD0iNDk0Ii8%2BDQo8L2c%2BDQo8dXNlIHhsaW5rOmhyZWY9IiNzMTgiIHg9Ijk4OCIvPg0KPHVzZSB4bGluazpocmVmPSIjczkiIHg9IjE5NzYiLz4NCjx1c2UgeGxpbms6aHJlZj0iI3M1IiB4PSIyNDcwIi8%2BDQo8L2c%2BDQo8L3N2Zz4%3D)](https://gitter.im/ant-design/pro-english?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Join the chat at https://gitter.im/ant-design/ant-design-pro](https://img.shields.io/gitter/room/ant-design/ant-design-pro.svg?style=flat-square&logoWidth=20&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgd2lkdGg9IjkwMCIgaGVpZ2h0PSI2MDAiIHZpZXdCb3g9IjAgMCAzMCAyMCI%2BDQo8ZGVmcz4NCjxwYXRoIGlkPSJzIiBkPSJNMCwtMSAwLjU4Nzc4NSwwLjgwOTAxNyAtMC45NTEwNTcsLTAuMzA5MDE3SDAuOTUxMDU3TC0wLjU4Nzc4NSwwLjgwOTAxN3oiIGZpbGw9IiNmZmRlMDAiLz4NCjwvZGVmcz4NCjxyZWN0IHdpZHRoPSIzMCIgaGVpZ2h0PSIyMCIgZmlsbD0iI2RlMjkxMCIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNSw1KSBzY2FsZSgzKSIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTAsMikgcm90YXRlKDIzLjAzNjI0MykiLz4NCjx1c2UgeGxpbms6aHJlZj0iI3MiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEyLDQpIHJvdGF0ZSg0NS44Njk4OTgpIi8%2BDQo8dXNlIHhsaW5rOmhyZWY9IiNzIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxMiw3KSByb3RhdGUoNjkuOTQ1Mzk2KSIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTAsOSkgcm90YXRlKDIwLjY1OTgwOCkiLz4NCjwvc3ZnPg%3D%3D)](https://gitter.im/ant-design/ant-design-pro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Netlify Status](https://api.netlify.com/api/v1/badges/ee4b4cc9-f8d7-4542-929f-a025c5927663/deploy-status)](https://app.netlify.com/sites/angry-lumiere-4b8ba4/deploys) ![](https://badgen.net/badge/icon/Ant%20Design?icon=https://gw.alipayobjects.com/zos/antfincdn/Pp4WPgVDB3/KDpgvguMpGfqaHPjicRK.svg&label) + +![](https://user-images.githubusercontent.com/8186664/44953195-581e3d80-aec4-11e8-8dcb-54b9db38ec11.png) diff --git a/README.zh-CN.md b/README.zh-CN.md index f98da6682ad13436831e3a028b06ddd3247e885a..616b63a9d7cff385440744697ac68d3402a9e595 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -6,7 +6,9 @@ 开箱即用的中台前端/设计解决方案。 -[![Build With Umi](https://img.shields.io/badge/build%20with-umi-028fe4.svg?style=flat-square)](http://umijs.org/) [![Build Status](https://dev.azure.com/ant-design/ant-design-pro/_apis/build/status/ant-design.ant-design-pro?branchName=master)](https://dev.azure.com/ant-design/ant-design-pro/_build/latest?definitionId=1?branchName=master) [![Dependencies](https://img.shields.io/david/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro) [![DevDependencies](https://img.shields.io/david/dev/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro?type=dev) [![Join the chat at https://gitter.im/ant-design/ant-design-pro](https://img.shields.io/gitter/room/ant-design/ant-design-pro.svg?style=flat-square&logoWidth=20&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgd2lkdGg9IjkwMCIgaGVpZ2h0PSI2MDAiIHZpZXdCb3g9IjAgMCAzMCAyMCI%2BDQo8ZGVmcz4NCjxwYXRoIGlkPSJzIiBkPSJNMCwtMSAwLjU4Nzc4NSwwLjgwOTAxNyAtMC45NTEwNTcsLTAuMzA5MDE3SDAuOTUxMDU3TC0wLjU4Nzc4NSwwLjgwOTAxN3oiIGZpbGw9IiNmZmRlMDAiLz4NCjwvZGVmcz4NCjxyZWN0IHdpZHRoPSIzMCIgaGVpZ2h0PSIyMCIgZmlsbD0iI2RlMjkxMCIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNSw1KSBzY2FsZSgzKSIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTAsMikgcm90YXRlKDIzLjAzNjI0MykiLz4NCjx1c2UgeGxpbms6aHJlZj0iI3MiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEyLDQpIHJvdGF0ZSg0NS44Njk4OTgpIi8%2BDQo8dXNlIHhsaW5rOmhyZWY9IiNzIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxMiw3KSByb3RhdGUoNjkuOTQ1Mzk2KSIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTAsOSkgcm90YXRlKDIwLjY1OTgwOCkiLz4NCjwvc3ZnPg%3D%3D)](https://gitter.im/ant-design/ant-design-pro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Netlify Status](https://api.netlify.com/api/v1/badges/ee4b4cc9-f8d7-4542-929f-a025c5927663/deploy-status)](https://app.netlify.com/sites/angry-lumiere-4b8ba4/deploys) ![](https://user-images.githubusercontent.com/8186664/44953195-581e3d80-aec4-11e8-8dcb-54b9db38ec11.png) +[![Build With Umi](https://img.shields.io/badge/build%20with-umi-028fe4.svg?style=flat-square)](http://umijs.org/) [![Build Status](https://dev.azure.com/ant-design/ant-design-pro/_apis/build/status/ant-design.ant-design-pro?branchName=master)](https://dev.azure.com/ant-design/ant-design-pro/_build/latest?definitionId=1?branchName=master) [![Dependencies](https://img.shields.io/david/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro) [![DevDependencies](https://img.shields.io/david/dev/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro?type=dev) [![Join the chat at https://gitter.im/ant-design/ant-design-pro](https://img.shields.io/gitter/room/ant-design/ant-design-pro.svg?style=flat-square&logoWidth=20&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgd2lkdGg9IjkwMCIgaGVpZ2h0PSI2MDAiIHZpZXdCb3g9IjAgMCAzMCAyMCI%2BDQo8ZGVmcz4NCjxwYXRoIGlkPSJzIiBkPSJNMCwtMSAwLjU4Nzc4NSwwLjgwOTAxNyAtMC45NTEwNTcsLTAuMzA5MDE3SDAuOTUxMDU3TC0wLjU4Nzc4NSwwLjgwOTAxN3oiIGZpbGw9IiNmZmRlMDAiLz4NCjwvZGVmcz4NCjxyZWN0IHdpZHRoPSIzMCIgaGVpZ2h0PSIyMCIgZmlsbD0iI2RlMjkxMCIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoNSw1KSBzY2FsZSgzKSIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTAsMikgcm90YXRlKDIzLjAzNjI0MykiLz4NCjx1c2UgeGxpbms6aHJlZj0iI3MiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDEyLDQpIHJvdGF0ZSg0NS44Njk4OTgpIi8%2BDQo8dXNlIHhsaW5rOmhyZWY9IiNzIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxMiw3KSByb3RhdGUoNjkuOTQ1Mzk2KSIvPg0KPHVzZSB4bGluazpocmVmPSIjcyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMTAsOSkgcm90YXRlKDIwLjY1OTgwOCkiLz4NCjwvc3ZnPg%3D%3D)](https://gitter.im/ant-design/ant-design-pro?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Netlify Status](https://api.netlify.com/api/v1/badges/ee4b4cc9-f8d7-4542-929f-a025c5927663/deploy-status)](https://app.netlify.com/sites/angry-lumiere-4b8ba4/deploys) ![](https://badgen.net/badge/icon/Ant%20Design?icon=https://gw.alipayobjects.com/zos/antfincdn/Pp4WPgVDB3/KDpgvguMpGfqaHPjicRK.svg&label) + +![](https://user-images.githubusercontent.com/8186664/44953195-581e3d80-aec4-11e8-8dcb-54b9db38ec11.png) diff --git a/config/config.ts b/config/config.ts index 2e4b8e147835d1b151704beefde7e95c22053e72..696bc582c17d8e9ec566cb5bbf1722585d0e3c5f 100644 --- a/config/config.ts +++ b/config/config.ts @@ -65,6 +65,12 @@ if (isAntDesignProPreview) { code: 'UA-72788897-6', }, ]); + plugins.push([ + 'umi-plugin-pro', + { + serverUrl: 'https://ant-design-pro.netlify.com', + }, + ]); } export default { diff --git a/config/plugin.config.ts b/config/plugin.config.ts index 4b4ed895083dc62bf1449c8f4899bb6a213577ea..4ba5a55e9b3b6fc9237ba371ca864ee35bf5373d 100644 --- a/config/plugin.config.ts +++ b/config/plugin.config.ts @@ -25,24 +25,14 @@ function getModulePackageName(module: { context: string }) { } export default (config: any) => { - // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。 + // preview.pro.ant.design only do not use in your production; if ( process.env.ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site' || process.env.NODE_ENV !== 'production' ) { - // 将所有 less 合并为一个供 themePlugin使用 - // const outFile = path.join(__dirname, '../.temp/ant-design-pro.less'); - // const stylesDir = path.join(__dirname, '../src/'); - - // config.plugin('merge-less').use(MergeLessPlugin, [ - // { - // stylesDir, - // outFile, - // }, - // ]); config.plugin('webpack-theme-color-replacer').use(ThemeColorReplacer, [ { - fileName: 'css/theme-colors.css', + fileName: 'css/theme-colors-[contenthash:8].css', matchColors: getAntdSerials('#1890ff'), // 主色系列 // 改变样式选择器,解决样式覆盖问题 changeSelector(selector: string): string { @@ -57,23 +47,15 @@ export default (config: any) => { return selector; } }, + // isJsUgly: true, }, ]); - // config.plugin('ant-design-theme').use(AntDesignThemePlugin, [ - // { - // antDir: path.join(__dirname, '../node_modules/antd'), - // stylesDir, - // varFile: path.join(__dirname, '../node_modules/antd/es/style/themes/default.less'), - // mainLessFile: outFile, // themeVariables: ['@primary-color'], - // indexFileName: 'index.html', - // generateOne: true, - // lessUrl: 'https://gw.alipayobjects.com/os/lib/less.js/3.8.1/less.min.js', - // }, - // ]); } + // optimize chunks config.optimization - .runtimeChunk(false) // share the same chunks across different modules + // share the same chunks across different modules + .runtimeChunk(false) .splitChunks({ chunks: 'async', name: 'vendors', diff --git a/lambda/api.js b/lambda/api.js index e0c147a6a3baa8ee307b69df1a4a2d11ba1072c5..105f0b04009dbda90109cd8b2cdea82c0870e2e1 100644 --- a/lambda/api.js +++ b/lambda/api.js @@ -6,6 +6,21 @@ const matchMock = require('./mock/matchMock'); const app = express(); +app.all('*', (req, res, next) => { + res.header('Access-Control-Allow-Origin', '*'); + res.header( + 'Access-Control-Allow-Headers', + 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild', + ); + res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS'); + + if (req.method == 'OPTIONS') { + res.send(200); + } else { + next(); + } +}); + app.use(matchMock); exports.handler = serverLess(app); diff --git a/package.json b/package.json index bc89256e96852fa616e51515d061fb6c74dfec40..d63cda7150c675d8febc51b34d17dcd4de046321 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "analyze": "cross-env ANALYZE=1 umi build", "build": "umi build", + "deploy": "cross-env ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION=site npm run site && npm run gh-pages", "docker-hub:build": "docker build -f Dockerfile.hub -t ant-design-pro ./", "docker-prod:build": "docker-compose -f ./docker/docker-compose.yml build", "docker-prod:dev": "docker-compose -f ./docker/docker-compose.yml up", @@ -13,10 +14,11 @@ "docker:dev": "docker-compose -f ./docker/docker-compose.dev.yml up", "docker:push": "npm run docker-hub:build && npm run docker:tag && docker push antdesign/ant-design-pro", "docker:tag": "docker tag ant-design-pro antdesign/ant-design-pro", - "fetch:blocks": "node ./scripts/fetch-blocks.js", + "fetch:blocks": "fetch-blocks", "format-imports": "import-sort --write '**/*.{js,jsx,ts,tsx}'", "functions:build": "netlify-lambda build ./lambda", "functions:run": "cross-env NODE_ENV=dev netlify-lambda serve ./lambda", + "gh-pages": "cp CNAME ./dist/ && gh-pages -d dist", "lint": "npm run lint:js && npm run lint:style && npm run lint:prettier", "lint-staged": "lint-staged", "lint-staged:js": "eslint --ext .js,.jsx,.ts,.tsx ", @@ -25,7 +27,7 @@ "lint:prettier": "check-prettier lint", "lint:style": "stylelint --fix \"src/**/*.less\" --syntax less", "prettier": "prettier -c --write **/*", - "site": "npm run fetch:blocks && npm run functions:build && umi build", + "site": "npm run fetch:blocks && npm run build && npm run functions:build", "start": "umi dev", "start:no-mock": "cross-env MOCK=none umi dev", "test": "umi test", @@ -114,6 +116,7 @@ "enzyme": "^3.9.0", "eslint": "^5.16.0", "express": "^4.17.1", + "fetch-blocks": "^1.0.0", "gh-pages": "^2.0.1", "husky": "^2.3.0", "import-sort-cli": "^6.0.0", @@ -129,7 +132,10 @@ "serverless-http": "^2.0.2", "slash2": "^2.0.0", "stylelint": "^10.1.0", - "webpack-theme-color-replacer": "^1.1.5", + "umi-plugin-ga": "^1.1.3", + "umi-plugin-pro": "^1.0.2", + "umi-types": "^0.3.8", + "webpack-theme-color-replacer": "^1.2.15", "mockjs": "^1.0.1-beta3", "eslint-import-resolver-alias": "^1.1.2" }, diff --git a/scripts/fetch-blocks.js b/scripts/fetch-blocks.js deleted file mode 100644 index 996ef78f8f28630d3e61daafbbd5cff3e7916ee5..0000000000000000000000000000000000000000 --- a/scripts/fetch-blocks.js +++ /dev/null @@ -1,130 +0,0 @@ -const path = require('path'); -const fs = require('fs'); -const fetch = require('node-fetch'); -const exec = require('child_process').exec; -const getNewRouteCode = require('./repalceRouter'); -const router = require('./router.config'); -const chalk = require('chalk'); -const insertCode = require('./insertCode'); - -const fetchGithubFiles = async () => { - const ignoreFile = ['_scripts']; - const data = await fetch(`https://api.github.com/repos/ant-design/pro-blocks/git/trees/master`); - if (data.status !== 200) { - return; - } - const { tree } = await data.json(); - const files = tree.filter(file => file.type === 'tree' && !ignoreFile.includes(file.path)); - return Promise.resolve(files); -}; - -const relativePath = path.join(__dirname, '../config/config.ts'); - -const findAllInstallRouter = router => { - let routers = []; - router.forEach(item => { - if (item.component && item.path) { - if (item.path !== '/user' || item.path !== '/') { - routers.push({ - ...item, - routes: !!item.routes, - }); - } - } - if (item.routes) { - routers = routers.concat(findAllInstallRouter(item.routes)); - } - }); - return routers; -}; - -const filterParentRouter = (router, layout) => { - return [...router] - .map(item => { - if (!item.path && item.component === '404') { - return item; - } - if (item.routes && (!router.component || layout)) { - return { ...item, routes: filterParentRouter(item.routes, false) }; - } - if (item.redirect) { - return item; - } - return null; - }) - .filter(item => item); -}; -const firstUpperCase = pathString => { - return pathString - .replace('.', '') - .split(/\/|\-/) - .map(s => s.toLowerCase().replace(/( |^)[a-z]/g, L => L.toUpperCase())) - .filter(s => s) - .join(''); -}; - -const execCmd = shell => { - return new Promise((resolve, reject) => { - exec(shell, { encoding: 'utf8' }, (error, statusbar) => { - if (error) { - console.log(error); - return reject(error); - } - console.log(statusbar); - resolve(); - }); - }); -}; - -// replace router config -const parentRouter = filterParentRouter(router, true); -const { routesPath, code } = getNewRouteCode(relativePath, parentRouter); -// write ParentRouter -fs.writeFileSync(routesPath, code); - -const installBlock = async () => { - let gitFiles = await fetchGithubFiles(); - const installRouters = findAllInstallRouter(router); - const installBlockIteration = async i => { - const item = installRouters[i]; - - if (!item || !item.path) { - return Promise.resolve(); - } - const gitPath = firstUpperCase(item.path); - // 如果这个区块在 git 上存在 - if (gitFiles.find(file => file.path === gitPath)) { - console.log('install ' + chalk.green(item.name) + ' to: ' + chalk.yellow(item.path)); - gitFiles = gitFiles.filter(file => file.path !== gitPath); - const skipModifyRouter = item.routes ? '--skip-modify-routes' : ''; - const cmd = `umi block add https://github.com/ant-design/pro-blocks/tree/master/${gitPath} --path=${item.path} ${skipModifyRouter}`; - try { - await execCmd(cmd); - console.log(`install ${chalk.hex('#1890ff')(item.name)} success`); - } catch (error) { - console.error(error); - } - } - return installBlockIteration(i + 1); - }; - // 安装路由中设置的区块 - await installBlockIteration(0); - - const installGitFile = async i => { - const item = gitFiles[i]; - if (!item || !item.path) { - return Promise.resolve(); - } - console.log('install ' + chalk.green(item.path)); - const cmd = `umi block add https://github.com/ant-design/pro-blocks/tree/master/${item.path}`; - await execCmd(cmd); - return installBlockIteration(1); - }; - - // 安装 router 中没有的剩余区块. - installGitFile(0); -}; -installBlock().then(() => { - // 插入 pro 需要的演示代码 - insertCode(); -}); diff --git a/scripts/insertCode.js b/scripts/insertCode.js deleted file mode 100644 index 298df951d3d2f6d271157bcb8b86500c145cbc5a..0000000000000000000000000000000000000000 --- a/scripts/insertCode.js +++ /dev/null @@ -1,161 +0,0 @@ -const parser = require('@babel/parser'); -const traverse = require('@babel/traverse'); -const generate = require('@babel/generator'); -const t = require('@babel/types'); -const fs = require('fs'); -const path = require('path'); -const prettier = require('prettier'); -const chalk = require('chalk'); - -const parseCode = code => { - return parser.parse(code, { - sourceType: 'module', - plugins: ['typescript', 'jsx'], - }).program.body[0]; -}; - -/** - * 生成代码 - * @param {*} ast - */ -function generateCode(ast) { - const newCode = generate.default(ast, {}).code; - return prettier.format(newCode, { - // format same as ant-design-pro - singleQuote: true, - trailingComma: 'es5', - printWidth: 100, - parser: 'typescript', - }); -} - -const SettingCodeString = ` - - dispatch({ - type: 'settings/changeSetting', - payload: config, - }) - } - /> -`; - -const mapAst = (configPath, callBack) => { - const ast = parser.parse(fs.readFileSync(configPath, 'utf-8'), { - sourceType: 'module', - plugins: ['typescript', 'jsx'], - }); - // 查询当前配置文件是否导出 routes 属性 - traverse.default(ast, { - Program({ node }) { - const { body } = node; - callBack(body); - }, - }); - return generateCode(ast); -}; - -const insertBasicLayout = configPath => { - return mapAst(configPath, body => { - const index = body.findIndex(item => { - return item.type !== 'ImportDeclaration'; - }); - - body.forEach(item => { - // 从包中导出 SettingDrawer - if (item.type === 'ImportDeclaration') { - if (item.source.value === '@ant-design/pro-layout') { - item.specifiers.push(parseCode(`SettingDrawer`).expression); - } - } - if (item.type === 'VariableDeclaration') { - const { - id, - init: { body }, - } = item.declarations[0]; - // 给 BasicLayout 中插入 button 和 设置抽屉 - if (id.name === `BasicLayout`) { - body.body.forEach(node => { - if (node.type === 'ReturnStatement') { - const JSXFragment = parseCode(`<>`).expression; - JSXFragment.children.push({ ...node.argument }); - JSXFragment.children.push(parseCode(SettingCodeString).expression); - node.argument = JSXFragment; - } - }); - } - } - }); - }); -}; - -const insertBlankLayout = configPath => { - return mapAst(configPath, body => { - const index = body.findIndex(item => { - return item.type !== 'ImportDeclaration'; - }); - // 从组件中导入 CopyBlock - body.splice( - index, - 0, - parseCode(`import CopyBlock from '@/components/CopyBlock'; - `), - ); - body.forEach(item => { - if (item.type === 'VariableDeclaration') { - const { id, init } = item.declarations[0]; - // 给 BasicLayout 中插入 button 和 设置抽屉 - if (id.name === `Layout`) { - const JSXFragment = parseCode(`<>`).expression; - JSXFragment.children.push({ ...init.body }); - JSXFragment.children.push(parseCode(` `).expression); - init.body = JSXFragment; - } - } - }); - }); -}; - -const insertRightContent = configPath => { - return mapAst(configPath, body => { - const index = body.findIndex(item => { - return item.type !== 'ImportDeclaration'; - }); - // 从组件中导入 CopyBlock - body.splice(index, 0, parseCode(`import NoticeIconView from './NoticeIconView';`)); - - body.forEach(item => { - if (item.type === 'VariableDeclaration') { - const classBody = item.declarations[0].init.body; - classBody.body.forEach(node => { - if (node.type === 'ReturnStatement') { - const index = node.argument.children.findIndex(item => { - if (item.type === 'JSXElement') { - if (item.openingElement.name.name === 'Avatar') { - return true; - } - } - }); - node.argument.children.splice(index, 1, parseCode(``).expression); - node.argument.children.splice(index, 0, parseCode(``).expression); - } - }); - } - }); - }); -}; - -module.exports = () => { - const basicLayoutPath = path.join(__dirname, '../src/layouts/BasicLayout.tsx'); - fs.writeFileSync(basicLayoutPath, insertBasicLayout(basicLayoutPath)); - console.log(`insert ${chalk.hex('#1890ff')('BasicLayout')} success`); - - const rightContentPath = path.join(__dirname, '../src/components/GlobalHeader/RightContent.tsx'); - fs.writeFileSync(rightContentPath, insertRightContent(rightContentPath)); - console.log(`insert ${chalk.hex('#1890ff')('RightContent')} success`); - - const blankLayoutPath = path.join(__dirname, '../src/layouts/BlankLayout.tsx'); - fs.writeFileSync(blankLayoutPath, insertBlankLayout(blankLayoutPath)); - console.log(`insert ${chalk.hex('#1890ff')('blankLayoutPath')} success`); -}; diff --git a/scripts/repalceRouter.js b/scripts/repalceRouter.js deleted file mode 100644 index 4bb3c4f45ca91eb1b8b8b7d645221f99c89052b7..0000000000000000000000000000000000000000 --- a/scripts/repalceRouter.js +++ /dev/null @@ -1,77 +0,0 @@ -const parser = require('@babel/parser'); -const traverse = require('@babel/traverse'); -const generate = require('@babel/generator'); -const t = require('@babel/types'); -const fs = require('fs'); -const prettier = require('prettier'); - -const getNewRouteCode = (configPath, newRoute) => { - const ast = parser.parse(fs.readFileSync(configPath, 'utf-8'), { - sourceType: 'module', - plugins: ['typescript'], - }); - let routesNode = null; - const importModules = []; - // 查询当前配置文件是否导出 routes 属性 - traverse.default(ast, { - Program({ node }) { - // find import - const { body } = node; - body.forEach(item => { - if (t.isImportDeclaration(item)) { - const { specifiers } = item; - const defaultEpecifier = specifiers.find(s => { - return t.isImportDefaultSpecifier(s) && t.isIdentifier(s.local); - }); - if (defaultEpecifier && t.isStringLiteral(item.source)) { - importModules.push({ - identifierName: defaultEpecifier.local.name, - modulePath: item.source.value, - }); - } - } - }); - }, - ObjectExpression({ node, parent }) { - // find routes on object, like { routes: [] } - if (t.isArrayExpression(parent)) { - // children routes - return; - } - const { properties } = node; - properties.forEach(p => { - const { key, value } = p; - if (t.isObjectProperty(p) && t.isIdentifier(key) && key.name === 'routes') { - if (value) { - // find json file program expression - (p.value = parser.parse(JSON.stringify(newRoute)).program.body[0].expression), - (routesNode = value); - } - } - }); - }, - }); - if (routesNode) { - const code = generateCode(ast); - return { code, routesPath: configPath }; - } else { - throw new Error('route array config not found.'); - } -}; - -/** - * 生成代码 - * @param {*} ast - */ -function generateCode(ast) { - const newCode = generate.default(ast, {}).code; - return prettier.format(newCode, { - // format same as ant-design-pro - singleQuote: true, - trailingComma: 'es5', - printWidth: 100, - parser: 'typescript', - }); -} - -module.exports = getNewRouteCode; diff --git a/scripts/router.config.js b/scripts/router.config.js deleted file mode 100644 index 38a90a1b9dc84db35bc6d30eb58bd7fad296304e..0000000000000000000000000000000000000000 --- a/scripts/router.config.js +++ /dev/null @@ -1,236 +0,0 @@ -module.exports = [ - { - path: '/', - component: '../layouts/BlankLayout', - routes: [ - // user - { - path: '/user', - component: '../layouts/UserLayout', - routes: [ - { path: '/user/login', name: 'login', component: './User/Login' }, - { path: '/user/register', name: 'register', component: './User/Register' }, - { - path: '/user/register-result', - name: 'register.result', - component: './User/RegisterResult', - }, - { path: '/user', redirect: '/user/login' }, - { - component: '404', - }, - ], - }, - // app - { - path: '/', - component: '../layouts/BasicLayout', - Routes: ['src/pages/Authorized'], - authority: ['admin', 'user'], - routes: [ - // dashboard - { - path: '/dashboard', - name: 'dashboard', - icon: 'dashboard', - routes: [ - { - path: '/dashboard/analysis', - name: 'analysis', - component: './Dashboard/Analysis', - }, - { - path: '/dashboard/monitor', - name: 'monitor', - component: './Dashboard/Monitor', - }, - { - path: '/dashboard/workplace', - name: 'workplace', - component: './Dashboard/Workplace', - }, - ], - }, - // forms - { - path: '/form', - icon: 'form', - name: 'form', - routes: [ - { - path: '/form/basic-form', - name: 'basicform', - component: './Form/BasicForm', - }, - { - path: '/form/step-form', - name: 'stepform', - component: './Form/StepForm', - }, - { - path: '/form/advanced-form', - name: 'advancedform', - authority: ['admin'], - component: './Form/AdvancedForm', - }, - ], - }, - // list - { - path: '/list', - icon: 'table', - name: 'list', - routes: [ - { - path: '/list/table-list', - name: 'searchtable', - component: './list/Tablelist', - }, - { - path: '/list/basic-list', - name: 'basiclist', - component: './list/Basiclist', - }, - { - path: '/list/card-list', - name: 'cardlist', - component: './list/Cardlist', - }, - { - path: '/list/search', - name: 'search-list', - component: './list/search', - routes: [ - { - path: '/list/search/articles', - name: 'articles', - component: './list/Articles', - }, - { - path: '/list/search/projects', - name: 'projects', - component: './list/Projects', - }, - { - path: '/list/search/applications', - name: 'applications', - component: './list/Applications', - }, - { - path: '/list/search', - redirect: '/list/search/articles', - }, - ], - }, - ], - }, - { - path: '/profile', - name: 'profile', - icon: 'profile', - routes: [ - // profile - { - path: '/profile/basic', - name: 'basic', - component: './Profile/BasicProfile', - }, - { - path: '/profile/basic/:id', - hideInMenu: true, - component: './Profile/BasicProfile', - }, - { - path: '/profile/advanced', - name: 'advanced', - authority: ['admin'], - component: './Profile/AdvancedProfile', - }, - ], - }, - { - name: 'result', - icon: 'check-circle-o', - path: '/result', - routes: [ - // result - { - path: '/result/success', - name: 'success', - component: './Result/Success', - }, - { path: '/result/fail', name: 'fail', component: './Result/Error' }, - ], - }, - { - name: 'exception', - icon: 'warning', - path: '/exception', - routes: [ - // exception - { - path: '/exception/403', - name: 'not-permission', - component: './Exception/403', - }, - { - path: '/exception/404', - name: 'not-find', - component: './Exception/404', - }, - { - path: '/exception/500', - name: 'server-error', - component: './Exception/500', - }, - ], - }, - { - name: 'account', - icon: 'user', - path: '/account', - routes: [ - { - path: '/account/center', - name: 'center', - component: './Account/Center/Center', - }, - { - path: '/account/settings', - name: 'settings', - component: './Account/Settings/Info', - }, - ], - }, - // editor - { - name: 'editor', - icon: 'highlight', - path: '/editor', - routes: [ - { - path: '/editor/flow', - name: 'flow', - component: './Editor/GGEditor/Flow', - }, - { - path: '/editor/mind', - name: 'mind', - component: './Editor/GGEditor/Mind', - }, - { - path: '/editor/koni', - name: 'koni', - component: './Editor/GGEditor/Koni', - }, - ], - }, - { path: '/', redirect: '/dashboard/analysis', authority: ['admin', 'user'] }, - { - component: '404', - }, - ], - }, - ], - }, -]; diff --git a/src/components/CopyBlock/index.tsx b/src/components/CopyBlock/index.tsx index fb9d8ac09a40007aaab24e13a29fc1dbc13658ef..810e9c1d0733095f9741094afa79b3916122dc5a 100644 --- a/src/components/CopyBlock/index.tsx +++ b/src/components/CopyBlock/index.tsx @@ -1,7 +1,7 @@ import { Icon, Popover, Typography } from 'antd'; +import React, { useRef } from 'react'; import { FormattedMessage } from 'umi-plugin-react/locale'; -import React, { useRef } from 'react'; import { connect } from 'dva'; import { isAntDesignPro } from '@/utils/utils'; import styles from './index.less'; diff --git a/src/components/GlobalHeader/AvatarDropdown.tsx b/src/components/GlobalHeader/AvatarDropdown.tsx index 2d105d51eb91427deb423e0925e1e51e3bfe50dc..d23380434a8d2f300a38d6ebf8974ec2df063626 100644 --- a/src/components/GlobalHeader/AvatarDropdown.tsx +++ b/src/components/GlobalHeader/AvatarDropdown.tsx @@ -1,5 +1,6 @@ import { Avatar, Icon, Menu, Spin } from 'antd'; import { ConnectProps, ConnectState } from '@/models/connect'; + import { ClickParam } from 'antd/es/menu'; import { CurrentUser } from '@/models/user'; import { FormattedMessage } from 'umi-plugin-react/locale'; diff --git a/src/components/HeaderSearch/index.tsx b/src/components/HeaderSearch/index.tsx index a6e8698e9259502dce39e7643c549fd92cf09575..85258d47096be9e6e42bce19ae0f29714b6d8a9e 100644 --- a/src/components/HeaderSearch/index.tsx +++ b/src/components/HeaderSearch/index.tsx @@ -1,7 +1,7 @@ import { AutoComplete, Icon, Input } from 'antd'; +import { AutoCompleteProps, DataSourceItemType } from 'antd/es/auto-complete'; import React, { Component } from 'react'; -import { DataSourceItemType, AutoCompleteProps } from 'antd/es/auto-complete'; import classNames from 'classnames'; import debounce from 'lodash/debounce'; import styles from './index.less'; diff --git a/src/components/SelectLang/index.tsx b/src/components/SelectLang/index.tsx index b7abd6378233e09bed868c707884b252036b0745..f8fd0512cdbf093fec734e7cec786ed049d36678 100644 --- a/src/components/SelectLang/index.tsx +++ b/src/components/SelectLang/index.tsx @@ -1,5 +1,6 @@ import { Icon, Menu } from 'antd'; import { formatMessage, getLocale, setLocale } from 'umi-plugin-react/locale'; + import { ClickParam } from 'antd/es/menu'; import React from 'react'; import classNames from 'classnames'; diff --git a/src/components/SettingDrawer/themeColorClient.ts b/src/components/SettingDrawer/themeColorClient.ts index 8aa3b360ba12857f0506be35793ae9bde4cb07b5..d663e3bf8ac46a9d97e2cca912750dab5aed2453 100644 --- a/src/components/SettingDrawer/themeColorClient.ts +++ b/src/components/SettingDrawer/themeColorClient.ts @@ -4,26 +4,27 @@ import client from 'webpack-theme-color-replacer/client'; import generate from '@ant-design/colors/lib/generate'; export default { - lastColor: '#1890ff', - primaryColor: '#1890ff', - getAntdSerials(color: string) { + getAntdSerials(color: string): string[] { + const lightCount = 9; + const divide = 10; // 淡化(即less的tint) - const lightens = new Array(9).fill(0).map((_, i) => client.varyColor.lighten(color, i / 10)); + let lightens = new Array(lightCount).fill(0); + lightens = lightens.map((_, i) => client.varyColor.lighten(color, i / divide)); const colorPalettes = generate(color); return lightens.concat(colorPalettes); }, - changeColor(newColor: string) { - const lastColor = this.lastColor || this.primaryColor; + changeColor(color?: string): Promise { + if (!color) { + return Promise.resolve(); + } const options = { - // hash模式下用相对路径 - cssUrl: '/css/theme-colors.css', - // current colors array. The same as `matchColors` - oldColors: this.getAntdSerials(lastColor), - // new colors array, one-to-one corresponde with `oldColors` - newColors: this.getAntdSerials(newColor || this.primaryColor), + // new colors array, one-to-one corresponde with `matchColors` + newColors: this.getAntdSerials(color), + changeUrl(cssUrl: string): string { + // while router is not `hash` mode, it needs absolute path + return `/${cssUrl}`; + }, }; - const promise = client.changer.changeColor(options, Promise); - this.lastColor = lastColor; - return promise; + return client.changer.changeColor(options, Promise); }, }; diff --git a/src/layouts/BasicLayout.tsx b/src/layouts/BasicLayout.tsx index 49786f4686bb4da71db430ecea79351dc3a0c36c..87587feddce05d160dc8eec0b6db873e413ed8b0 100644 --- a/src/layouts/BasicLayout.tsx +++ b/src/layouts/BasicLayout.tsx @@ -19,7 +19,7 @@ import { formatMessage } from 'umi-plugin-react/locale'; import { isAntDesignPro } from '@/utils/utils'; import logo from '../assets/logo.svg'; -export interface BasicLayoutProps extends ProLayoutProps, ConnectProps { +export interface BasicLayoutProps extends ProLayoutProps, Omit { breadcrumbNameMap: { [path: string]: MenuDataItem; }; diff --git a/src/layouts/UserLayout.tsx b/src/layouts/UserLayout.tsx index f774a337a9609afe98ba01df28f33f55d3e2644e..34565a739488c2310cf1a8fe1ae41e811554c831 100644 --- a/src/layouts/UserLayout.tsx +++ b/src/layouts/UserLayout.tsx @@ -1,5 +1,6 @@ import { ConnectProps, ConnectState } from '@/models/connect'; import { DefaultFooter, MenuDataItem, getMenuData, getPageTitle } from '@ant-design/pro-layout'; + import DocumentTitle from 'react-document-title'; import Link from 'umi/link'; import React from 'react'; @@ -27,7 +28,7 @@ const UserLayout: React.SFC = props => { pathname: '', }, } = props; - const { breadcrumb } = getMenuData(routes, props); + const { breadcrumb } = getMenuData(routes); return ( - extends Partial> { +export interface ConnectProps extends Partial> { dispatch?: Dispatch; } diff --git a/src/models/login.ts b/src/models/login.ts index 4e250a79cbb09187244f5d2a31045fd3a90bcb6f..3dd5a82456e1264acc3c11724ba1012c325f0c94 100644 --- a/src/models/login.ts +++ b/src/models/login.ts @@ -4,7 +4,9 @@ import { parse, stringify } from 'qs'; import { EffectsCommandMap } from 'dva'; import { routerRedux } from 'dva/router'; -export function getPageQuery(): string { +export function getPageQuery(): { + [key: string]: string; +} { return parse(window.location.href.split('?')[1]); } diff --git a/src/models/setting.ts b/src/models/setting.ts index 15beb48e1c3b5a06b548cb7c32811a949920111c..2e52eb54f11cbee5efde3a6ecafae3532b78c570 100644 --- a/src/models/setting.ts +++ b/src/models/setting.ts @@ -15,9 +15,11 @@ export interface SettingModelType { } const updateTheme = (newPrimaryColor?: string) => { - const timeOut = 0; - const hideMessage = message.loading('正在切换主题!', timeOut); - themeColorClient.changeColor(newPrimaryColor).finally(() => hideMessage()); + if (newPrimaryColor) { + const timeOut = 0; + const hideMessage = message.loading('正在切换主题!', timeOut); + themeColorClient.changeColor(newPrimaryColor).finally(() => hideMessage()); + } }; /* diff --git a/src/pages/404.tsx b/src/pages/404.tsx index 80fe09c9427ee294a7c8385cf8b1083b0dac3e4d..47d6df7008c309f839cc14706fdd75c7ec3ca9fc 100644 --- a/src/pages/404.tsx +++ b/src/pages/404.tsx @@ -1,5 +1,5 @@ -import React from 'react'; import { Button } from 'antd'; +import React from 'react'; import router from 'umi/router'; // 这里应该使用 antd 的 404 result 组件, diff --git a/src/pages/Authorized.tsx b/src/pages/Authorized.tsx index 8de52d42ccea89b2d0b9809e8e519d9c57b140ce..1bfd82670bf4c1a9fcdfb249b3b9654b479c057f 100644 --- a/src/pages/Authorized.tsx +++ b/src/pages/Authorized.tsx @@ -1,4 +1,5 @@ import { ConnectProps, ConnectState, Route, UserModelState } from '@/models/connect'; + import Authorized from '@/utils/Authorized'; import React from 'react'; import Redirect from 'umi/redirect';