From 5e99cb1f95d1ec3190f436e2633baf007fcf22ee Mon Sep 17 00:00:00 2001 From: hz Date: Sat, 25 May 2019 22:20:47 +0800 Subject: [PATCH 01/18] =?UTF-8?q?=E9=AB=98=E6=80=A7=E8=83=BD=E6=96=B9?= =?UTF-8?q?=E6=A1=88=E5=AE=9E=E7=8E=B0ant-design=E5=9C=A8=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=97=B6=E5=8A=A8=E6=80=81=E6=94=B9=E5=8F=98=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E8=89=B2=EF=BC=88=E5=88=A9=E7=94=A8webpack-theme-colo?= =?UTF-8?q?r-replacer=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/plugin.config.js | 41 +++++++++++++------ package.json | 3 +- .../SettingDrawer/themeColorClient.js | 27 ++++++++++++ src/models/setting.js | 8 ++++ 4 files changed, 65 insertions(+), 14 deletions(-) create mode 100644 src/components/SettingDrawer/themeColorClient.js diff --git a/config/plugin.config.js b/config/plugin.config.js index 59ce550f..e57be8f8 100644 --- a/config/plugin.config.js +++ b/config/plugin.config.js @@ -1,7 +1,8 @@ // Change theme plugin import MergeLessPlugin from 'antd-pro-merge-less'; -import AntDesignThemePlugin from 'antd-theme-webpack-plugin'; +// import AntDesignThemePlugin from 'antd-theme-webpack-plugin'; +const ThemeColorReplacer = require('webpack-theme-color-replacer'); import path from 'path'; function getModulePackageName(module) { @@ -39,18 +40,21 @@ export default config => { outFile, }, ]); - - config.plugin('ant-design-theme').use(AntDesignThemePlugin, [ - { - antDir: path.join(__dirname, '../node_modules/antd'), - stylesDir, - varFile: path.join(__dirname, '../node_modules/antd/lib/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', - }, - ]); + config.plugin('webpack-theme-color-replacer').use(ThemeColorReplacer, [{ + fileName: 'css/theme-colors.css', + matchColors: getAntdSerials('#1890ff'), // 主色系列 + }]); + // config.plugin('ant-design-theme').use(AntDesignThemePlugin, [ + // { + // antDir: path.join(__dirname, '../node_modules/antd'), + // stylesDir, + // varFile: path.join(__dirname, '../node_modules/antd/lib/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 @@ -81,3 +85,14 @@ export default config => { }, }); }; + +function getAntdSerials(color) { + const lightens = new Array(9).fill().map((t, i) => { + return ThemeColorReplacer.varyColor.lighten(color, i / 10); + }); + // 此处为了简化,采用了darken。实际按color.less需求可以引入tinycolor, colorPalette变换得到颜色值 + const darkens = new Array(6).fill().map((t, i) => { + return ThemeColorReplacer.varyColor.darken(color, i / 10); + }); + return lightens.concat(darkens); +} diff --git a/package.json b/package.json index 0704f91a..f45c87f7 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,8 @@ "resize-observer-polyfill": "^1.5.1", "umi": "^2.4.4", "umi-plugin-react": "^1.7.2", - "umi-request": "^1.0.5" + "umi-request": "^1.0.5", + "webpack-theme-color-replacer": "^1.1.3" }, "devDependencies": { "@types/history": "^4.7.2", diff --git a/src/components/SettingDrawer/themeColorClient.js b/src/components/SettingDrawer/themeColorClient.js new file mode 100644 index 00000000..9157c107 --- /dev/null +++ b/src/components/SettingDrawer/themeColorClient.js @@ -0,0 +1,27 @@ +const client = require('webpack-theme-color-replacer/client') + +export default { + primaryColor: '#1890ff', + getAntdSerials (color) { + // 淡化(即less的tint) + const lightens = new Array(9).fill().map((t, i) => { + return client.varyColor.lighten(color, i / 10) + }) + // 此处为了简化,采用了darken。实际按color.less需求可以引入tinycolor, colorPalette变换得到颜色值 + const darkens = new Array(6).fill().map((t, i) => { + return client.varyColor.darken(color, i / 10) + }) + return lightens.concat(darkens) + }, + changeColor (newColor) { + const lastColor = this.lastColor || this.primaryColor + const options = { + cssUrl: '/css/theme-colors.css', // hash模式下用相对路径 + oldColors: this.getAntdSerials(lastColor), // current colors array. The same as `matchColors` + newColors: this.getAntdSerials(newColor || this.primaryColor) // new colors array, one-to-one corresponde with `oldColors` + } + const promise = client.changer.changeColor(options) + this.lastColor = lastColor + return promise + } +} diff --git a/src/models/setting.js b/src/models/setting.js index 3956ed3d..0ab74d90 100644 --- a/src/models/setting.js +++ b/src/models/setting.js @@ -1,6 +1,13 @@ import { message } from 'antd'; import defaultSettings from '../defaultSettings'; +import themeColorClient from '../components/SettingDrawer/themeColorClient' +const updateTheme = newPrimaryColor => { + const hideMessage = message.loading('正在切换主题!', 0) + themeColorClient.changeColor(newPrimaryColor) + .finally(() => hideMessage()) +} +/* let lessNodesAppended; const updateTheme = primaryColor => { // Don't compile less in production! @@ -59,6 +66,7 @@ const updateTheme = primaryColor => { buildIt(); } }; +*/ const updateColorWeak = colorWeak => { document.body.className = colorWeak ? 'colorWeak' : ''; From 25c42c38527aa31b1596cde3aa59a7c4a4a05b39 Mon Sep 17 00:00:00 2001 From: hz Date: Sun, 26 May 2019 12:31:29 +0800 Subject: [PATCH 02/18] =?UTF-8?q?=E4=BD=BF=E7=94=A8@ant-design/colors?= =?UTF-8?q?=E7=94=9F=E6=88=90=E4=B8=BB=E9=A2=98=E8=89=B2=E7=B3=BB=EF=BC=9B?= =?UTF-8?q?=E5=85=BC=E5=AE=B9IE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/plugin.config.js | 16 +++------------- package.json | 8 ++++---- .../SettingDrawer/themeColorClient.js | 17 ++++++----------- 3 files changed, 13 insertions(+), 28 deletions(-) diff --git a/config/plugin.config.js b/config/plugin.config.js index e57be8f8..4582fe2f 100644 --- a/config/plugin.config.js +++ b/config/plugin.config.js @@ -2,8 +2,9 @@ import MergeLessPlugin from 'antd-pro-merge-less'; // import AntDesignThemePlugin from 'antd-theme-webpack-plugin'; -const ThemeColorReplacer = require('webpack-theme-color-replacer'); +import ThemeColorReplacer from 'webpack-theme-color-replacer'; import path from 'path'; +import generate from '@ant-design/colors/lib/generate'; function getModulePackageName(module) { if (!module.context) return null; @@ -42,7 +43,7 @@ export default config => { ]); config.plugin('webpack-theme-color-replacer').use(ThemeColorReplacer, [{ fileName: 'css/theme-colors.css', - matchColors: getAntdSerials('#1890ff'), // 主色系列 + matchColors: generate('#1890ff'), // 主色系列 }]); // config.plugin('ant-design-theme').use(AntDesignThemePlugin, [ // { @@ -85,14 +86,3 @@ export default config => { }, }); }; - -function getAntdSerials(color) { - const lightens = new Array(9).fill().map((t, i) => { - return ThemeColorReplacer.varyColor.lighten(color, i / 10); - }); - // 此处为了简化,采用了darken。实际按color.less需求可以引入tinycolor, colorPalette变换得到颜色值 - const darkens = new Array(6).fill().map((t, i) => { - return ThemeColorReplacer.varyColor.darken(color, i / 10); - }); - return lightens.concat(darkens); -} diff --git a/package.json b/package.json index f45c87f7..5684d8d7 100644 --- a/package.json +++ b/package.json @@ -82,15 +82,14 @@ "resize-observer-polyfill": "^1.5.1", "umi": "^2.4.4", "umi-plugin-react": "^1.7.2", - "umi-request": "^1.0.5", - "webpack-theme-color-replacer": "^1.1.3" + "umi-request": "^1.0.5" }, "devDependencies": { "@types/history": "^4.7.2", "@types/react": "^16.8.1", "@types/react-dom": "^16.0.11", "antd-pro-merge-less": "^1.0.0", - "antd-theme-webpack-plugin": "^1.2.0", + "@ant-design/colors": "^3.1.0", "babel-eslint": "^10.0.1", "chalk": "^2.4.2", "check-prettier": "^1.0.1", @@ -127,7 +126,8 @@ "tslint": "^5.12.1", "tslint-config-prettier": "^1.17.0", "tslint-react": "^3.6.0", - "umi-plugin-ga": "^1.1.3" + "umi-plugin-ga": "^1.1.3", + "webpack-theme-color-replacer": "^1.1.4" }, "optionalDependencies": { "puppeteer": "^1.12.1" diff --git a/src/components/SettingDrawer/themeColorClient.js b/src/components/SettingDrawer/themeColorClient.js index 9157c107..9918122c 100644 --- a/src/components/SettingDrawer/themeColorClient.js +++ b/src/components/SettingDrawer/themeColorClient.js @@ -1,17 +1,11 @@ -const client = require('webpack-theme-color-replacer/client') +/* eslint-disable import/no-extraneous-dependencies */ +import generate from '@ant-design/colors/lib/generate'; +import client from 'webpack-theme-color-replacer/client' export default { primaryColor: '#1890ff', getAntdSerials (color) { - // 淡化(即less的tint) - const lightens = new Array(9).fill().map((t, i) => { - return client.varyColor.lighten(color, i / 10) - }) - // 此处为了简化,采用了darken。实际按color.less需求可以引入tinycolor, colorPalette变换得到颜色值 - const darkens = new Array(6).fill().map((t, i) => { - return client.varyColor.darken(color, i / 10) - }) - return lightens.concat(darkens) + return generate(color) }, changeColor (newColor) { const lastColor = this.lastColor || this.primaryColor @@ -20,8 +14,9 @@ export default { oldColors: this.getAntdSerials(lastColor), // current colors array. The same as `matchColors` newColors: this.getAntdSerials(newColor || this.primaryColor) // new colors array, one-to-one corresponde with `oldColors` } - const promise = client.changer.changeColor(options) + const promise = client.changer.changeColor(options, Promise); this.lastColor = lastColor return promise } } + From c83a1d899a94c7dc4a3e8171c02e1c4f7ff5e01d Mon Sep 17 00:00:00 2001 From: hz Date: Sun, 26 May 2019 14:59:33 +0800 Subject: [PATCH 03/18] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E9=97=AE=E9=A2=98=EF=BC=9B=20npm=20run=20pre?= =?UTF-8?q?ttier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/plugin.config.js | 19 +++++++++++---- .../SettingDrawer/themeColorClient.js | 23 +++++++++---------- src/models/setting.js | 9 ++++---- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/config/plugin.config.js b/config/plugin.config.js index 4582fe2f..b8056c92 100644 --- a/config/plugin.config.js +++ b/config/plugin.config.js @@ -41,10 +41,21 @@ export default config => { outFile, }, ]); - config.plugin('webpack-theme-color-replacer').use(ThemeColorReplacer, [{ - fileName: 'css/theme-colors.css', - matchColors: generate('#1890ff'), // 主色系列 - }]); + config.plugin('webpack-theme-color-replacer').use(ThemeColorReplacer, [ + { + fileName: 'css/theme-colors.css', + matchColors: generate('#1890ff'), // 主色系列 + // 改变样式选择器,解决样式覆盖问题 + changeSelector(selector) { + switch (selector) { + case '.ant-calendar-today .ant-calendar-date': + return ':not(.ant-calendar-selected-day)' + selector; + default: + return selector; + } + }, + }, + ]); // config.plugin('ant-design-theme').use(AntDesignThemePlugin, [ // { // antDir: path.join(__dirname, '../node_modules/antd'), diff --git a/src/components/SettingDrawer/themeColorClient.js b/src/components/SettingDrawer/themeColorClient.js index 9918122c..9eeee6d7 100644 --- a/src/components/SettingDrawer/themeColorClient.js +++ b/src/components/SettingDrawer/themeColorClient.js @@ -1,22 +1,21 @@ /* eslint-disable import/no-extraneous-dependencies */ import generate from '@ant-design/colors/lib/generate'; -import client from 'webpack-theme-color-replacer/client' +import client from 'webpack-theme-color-replacer/client'; export default { primaryColor: '#1890ff', - getAntdSerials (color) { - return generate(color) + getAntdSerials(color) { + return generate(color); }, - changeColor (newColor) { - const lastColor = this.lastColor || this.primaryColor + changeColor(newColor) { + const lastColor = this.lastColor || this.primaryColor; const options = { cssUrl: '/css/theme-colors.css', // hash模式下用相对路径 oldColors: this.getAntdSerials(lastColor), // current colors array. The same as `matchColors` - newColors: this.getAntdSerials(newColor || this.primaryColor) // new colors array, one-to-one corresponde with `oldColors` - } + newColors: this.getAntdSerials(newColor || this.primaryColor), // new colors array, one-to-one corresponde with `oldColors` + }; const promise = client.changer.changeColor(options, Promise); - this.lastColor = lastColor - return promise - } -} - + this.lastColor = lastColor; + return promise; + }, +}; diff --git a/src/models/setting.js b/src/models/setting.js index 0ab74d90..bb4df715 100644 --- a/src/models/setting.js +++ b/src/models/setting.js @@ -1,12 +1,11 @@ import { message } from 'antd'; import defaultSettings from '../defaultSettings'; -import themeColorClient from '../components/SettingDrawer/themeColorClient' +import themeColorClient from '../components/SettingDrawer/themeColorClient'; const updateTheme = newPrimaryColor => { - const hideMessage = message.loading('正在切换主题!', 0) - themeColorClient.changeColor(newPrimaryColor) - .finally(() => hideMessage()) -} + const hideMessage = message.loading('正在切换主题!', 0); + themeColorClient.changeColor(newPrimaryColor).finally(() => hideMessage()); +}; /* let lessNodesAppended; const updateTheme = primaryColor => { From 867301ac9fcfe6cbff3d15fa49794b79d84ae25a Mon Sep 17 00:00:00 2001 From: hz Date: Sun, 26 May 2019 19:15:14 +0800 Subject: [PATCH 04/18] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E9=97=AE=E9=A2=98=EF=BC=9B=E8=A7=A3=E5=86=B3?= =?UTF-8?q?@keyframe=E5=86=85=E9=A2=9C=E8=89=B2=E6=9B=BF=E6=8D=A2=E6=97=A0?= =?UTF-8?q?=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/plugin.config.js | 30 ++++++++++++++----- package.json | 2 +- .../SettingDrawer/themeColorClient.js | 7 ++++- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/config/plugin.config.js b/config/plugin.config.js index b8056c92..77a23dd5 100644 --- a/config/plugin.config.js +++ b/config/plugin.config.js @@ -44,15 +44,22 @@ export default config => { config.plugin('webpack-theme-color-replacer').use(ThemeColorReplacer, [ { fileName: 'css/theme-colors.css', - matchColors: generate('#1890ff'), // 主色系列 + matchColors: getAntdSerials('#1890ff'), // 主色系列 // 改变样式选择器,解决样式覆盖问题 changeSelector(selector) { - switch (selector) { - case '.ant-calendar-today .ant-calendar-date': - return ':not(.ant-calendar-selected-day)' + selector; - default: - return selector; - } + var fix = { + '.ant-calendar-today .ant-calendar-date': + ':not(.ant-calendar-selected-date)' + selector, + '.ant-btn:focus,.ant-btn:hover': selector + .split(',') + .map(s => s + ':not(.ant-btn-primary)') + .join(','), + '.ant-btn.active,.ant-btn:active': selector + .split(',') + .map(s => s + ':not(.ant-btn-primary)') + .join(','), + }; + return fix[selector] || selector; }, }, ]); @@ -97,3 +104,12 @@ export default config => { }, }); }; + +function getAntdSerials(color) { + const colorPalettes = generate(color); + // 淡化(即less的tint) + const lightens = new Array(9).fill().map((t, i) => { + return ThemeColorReplacer.varyColor.lighten(color, i / 10); + }); + return colorPalettes.concat(lightens); +} diff --git a/package.json b/package.json index 5684d8d7..c50ec8b6 100644 --- a/package.json +++ b/package.json @@ -127,7 +127,7 @@ "tslint-config-prettier": "^1.17.0", "tslint-react": "^3.6.0", "umi-plugin-ga": "^1.1.3", - "webpack-theme-color-replacer": "^1.1.4" + "webpack-theme-color-replacer": "^1.1.5" }, "optionalDependencies": { "puppeteer": "^1.12.1" diff --git a/src/components/SettingDrawer/themeColorClient.js b/src/components/SettingDrawer/themeColorClient.js index 9eeee6d7..a0e476de 100644 --- a/src/components/SettingDrawer/themeColorClient.js +++ b/src/components/SettingDrawer/themeColorClient.js @@ -5,7 +5,12 @@ import client from 'webpack-theme-color-replacer/client'; export default { primaryColor: '#1890ff', getAntdSerials(color) { - return generate(color); + // 淡化(即less的tint) + const lightens = new Array(9).fill().map((t, i) => { + return client.varyColor.lighten(color, i / 10); + }); + const colorPalettes = generate(color); + return lightens.concat(colorPalettes); }, changeColor(newColor) { const lastColor = this.lastColor || this.primaryColor; From 2755b5144125f55da6957bff2283a0745dd64131 Mon Sep 17 00:00:00 2001 From: hz Date: Sun, 26 May 2019 20:36:59 +0800 Subject: [PATCH 05/18] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/plugin.config.js | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/config/plugin.config.js b/config/plugin.config.js index 77a23dd5..3801df6d 100644 --- a/config/plugin.config.js +++ b/config/plugin.config.js @@ -47,19 +47,16 @@ export default config => { matchColors: getAntdSerials('#1890ff'), // 主色系列 // 改变样式选择器,解决样式覆盖问题 changeSelector(selector) { - var fix = { - '.ant-calendar-today .ant-calendar-date': - ':not(.ant-calendar-selected-date)' + selector, - '.ant-btn:focus,.ant-btn:hover': selector - .split(',') - .map(s => s + ':not(.ant-btn-primary)') - .join(','), - '.ant-btn.active,.ant-btn:active': selector - .split(',') - .map(s => s + ':not(.ant-btn-primary)') - .join(','), - }; - return fix[selector] || selector; + switch (selector) { + case '.ant-calendar-today .ant-calendar-date': + return ':not(.ant-calendar-selected-date)' + selector; + case '.ant-btn:focus,.ant-btn:hover': + return '.ant-btn:focus:not(.ant-btn-primary),.ant-btn:hover:not(.ant-btn-primary)'; + case '.ant-btn.active,.ant-btn:active': + return '.ant-btn.active:not(.ant-btn-primary),.ant-btn:active:not(.ant-btn-primary)'; + default: + return selector; + } }, }, ]); @@ -106,10 +103,10 @@ export default config => { }; function getAntdSerials(color) { - const colorPalettes = generate(color); // 淡化(即less的tint) const lightens = new Array(9).fill().map((t, i) => { return ThemeColorReplacer.varyColor.lighten(color, i / 10); }); - return colorPalettes.concat(lightens); + const colorPalettes = generate(color); + return lightens.concat(colorPalettes); } From fcf8c8b1464422aa728d0cf11e6639df0058df29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Fri, 31 May 2019 22:32:31 +0800 Subject: [PATCH 06/18] script: add two variable --- package.json | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 96c560d1..a07f2c09 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,6 @@ "fetch:blocks": "node ./scripts/fetch-blocks.js", "functions:build": "netlify-lambda build ./lambda", "functions:run": "cross-env NODE_ENV=dev netlify-lambda serve ./lambda", - "generateMock": "node ./scripts/generateMock", "lint": "npm run lint:js && npm run lint:ts && npm run lint:style && npm run lint:prettier", "lint-staged": "lint-staged", "lint-staged:js": "eslint --ext .js", @@ -148,6 +147,17 @@ "scripts/**/*.js" ], "create-umi": { + "ignoreScript": [ + "docker*", + "functions*", + "site", + "generateMock" + ], + "ignoreDependencies": [ + "netlify*", + "serverless", + "express" + ], "copy": [ [ "create-umi/README.md", @@ -175,4 +185,4 @@ "create-umi" ] } -} +} \ No newline at end of file From 600332e68355a1330fc358e3ae856047e77701d4 Mon Sep 17 00:00:00 2001 From: huangzheng Date: Sun, 2 Jun 2019 18:41:59 +0800 Subject: [PATCH 07/18] lint --- config/plugin.config.ts | 10 ++++++---- src/models/setting.ts | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/config/plugin.config.ts b/config/plugin.config.ts index e142565d..1bef947e 100644 --- a/config/plugin.config.ts +++ b/config/plugin.config.ts @@ -46,7 +46,7 @@ export default (config: any) => { fileName: 'css/theme-colors.css', matchColors: getAntdSerials('#1890ff'), // 主色系列 // 改变样式选择器,解决样式覆盖问题 - changeSelector(selector) { + changeSelector(selector: string) { switch (selector) { case '.ant-calendar-today .ant-calendar-date': return ':not(.ant-calendar-selected-date)' + selector; @@ -103,10 +103,12 @@ export default (config: any) => { }); }; -function getAntdSerials(color) { +const getAntdSerials = (color: string) => { + const lightNum = 9; + const devide10 = 10; // 淡化(即less的tint) - const lightens = new Array(9).fill().map((t, i) => { - return ThemeColorReplacer.varyColor.lighten(color, i / 10); + const lightens = new Array(lightNum).fill().map((t, i) => { + return ThemeColorReplacer.varyColor.lighten(color, i / devide10); }); const colorPalettes = generate(color); return lightens.concat(colorPalettes); diff --git a/src/models/setting.ts b/src/models/setting.ts index 2b8e4a1d..2ba1469e 100644 --- a/src/models/setting.ts +++ b/src/models/setting.ts @@ -12,9 +12,11 @@ export interface SettingModelType { }; } -const updateTheme = (newPrimaryColor:string) => { - const hideMessage = message.loading('正在切换主题!', 0); - themeColorClient.changeColor(newPrimaryColor).finally(() => hideMessage()); +const updateTheme = (newPrimaryColor?: string) => { + const timeOut = 0; + const hideMessage = message.loading('正在切换主题!', timeOut); + themeColorClient.changeColor(newPrimaryColor) + .finally(() => hideMessage()); }; /* From a1fba3624d98eec63d643d516d6a0cc4fcc45387 Mon Sep 17 00:00:00 2001 From: huangzheng Date: Sun, 2 Jun 2019 18:44:01 +0800 Subject: [PATCH 08/18] remove MergeLessPlugin --- config/plugin.config.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/config/plugin.config.ts b/config/plugin.config.ts index 1bef947e..deebcbe5 100644 --- a/config/plugin.config.ts +++ b/config/plugin.config.ts @@ -1,6 +1,6 @@ // Change theme plugin -import MergeLessPlugin from 'antd-pro-merge-less'; +// import MergeLessPlugin from 'antd-pro-merge-less'; // import AntDesignThemePlugin from 'antd-theme-webpack-plugin'; import ThemeColorReplacer from 'webpack-theme-color-replacer'; import path from 'path'; @@ -32,15 +32,15 @@ export default (config: any) => { process.env.NODE_ENV !== 'production' ) { // 将所有 less 合并为一个供 themePlugin使用 - const outFile = path.join(__dirname, '../.temp/ant-design-pro.less'); - const stylesDir = path.join(__dirname, '../src/'); + // 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('merge-less').use(MergeLessPlugin, [ + // { + // stylesDir, + // outFile, + // }, + // ]); config.plugin('webpack-theme-color-replacer').use(ThemeColorReplacer, [ { fileName: 'css/theme-colors.css', From 5c558eb8af47dbdee684fc530af7b48c6447cbe7 Mon Sep 17 00:00:00 2001 From: huangzheng Date: Sun, 2 Jun 2019 18:49:12 +0800 Subject: [PATCH 09/18] tslint --- config/plugin.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/plugin.config.ts b/config/plugin.config.ts index deebcbe5..806c344d 100644 --- a/config/plugin.config.ts +++ b/config/plugin.config.ts @@ -46,7 +46,7 @@ export default (config: any) => { fileName: 'css/theme-colors.css', matchColors: getAntdSerials('#1890ff'), // 主色系列 // 改变样式选择器,解决样式覆盖问题 - changeSelector(selector: string) { + changeSelector(selector: string): string { switch (selector) { case '.ant-calendar-today .ant-calendar-date': return ':not(.ant-calendar-selected-date)' + selector; From c744d2ae2b3d9c9bd687dca4efa4b67396939158 Mon Sep 17 00:00:00 2001 From: hz Date: Mon, 3 Jun 2019 00:41:56 +0800 Subject: [PATCH 10/18] lint --- src/models/setting.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/models/setting.ts b/src/models/setting.ts index 2ba1469e..d0d76da7 100644 --- a/src/models/setting.ts +++ b/src/models/setting.ts @@ -15,8 +15,7 @@ export interface SettingModelType { const updateTheme = (newPrimaryColor?: string) => { const timeOut = 0; const hideMessage = message.loading('正在切换主题!', timeOut); - themeColorClient.changeColor(newPrimaryColor) - .finally(() => hideMessage()); + themeColorClient.changeColor(newPrimaryColor).finally(() => hideMessage()); }; /* From 34c74a057fe6e3f1f7c6be405f0167c1e1a3aed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Mon, 3 Jun 2019 16:01:06 +0800 Subject: [PATCH 11/18] add netlify -logo --- README.fr-FR.md | 7 +++++++ README.ja-JP.md | 6 ++++++ README.md | 6 ++++++ README.ru-RU.md | 6 ++++++ README.tr-TR.md | 6 ++++++ README.zh-CN.md | 6 ++++++ 6 files changed, 37 insertions(+) diff --git a/README.fr-FR.md b/README.fr-FR.md index 6ebb306b..a228c54e 100644 --- a/README.fr-FR.md +++ b/README.fr-FR.md @@ -128,3 +128,10 @@ Toute forme de contribution est la bienvenue, voici quelques exemples de façons - Utiliser Ant Design Pro dans votre travail quotidien. - Soumettre des [issues](http://github.com/ant-design/ant-design-pro/issues) pour reporter les bugs ou poser des questions. - Proposer des [pull requests](http://github.com/ant-design/ant-design-pro/pulls) pour améliorer notre code. + + + \ No newline at end of file diff --git a/README.ja-JP.md b/README.ja-JP.md index b1217775..e02077d7 100644 --- a/README.ja-JP.md +++ b/README.ja-JP.md @@ -130,3 +130,9 @@ Gitpod(GitHub 用の無料オンライン開発環境)でプロジェクト - 更新すること。 改善を、[pull requests](http://github.com/ant-design/ant-design-pro/pulls) で送ってください。 [![DevDependencies](https://img.shields.io/david/dev/ant-design/ant-design-pro.svg)](https://david-dm.org/ant-design/ant-design-pro?type=dev) + + \ No newline at end of file diff --git a/README.md b/README.md index 233095a4..65625f8d 100644 --- a/README.md +++ b/README.md @@ -130,3 +130,9 @@ Any type of contribution is welcome, here are some examples of how you may contr - Use Ant Design Pro in your daily work. - Submit [issues](http://github.com/ant-design/ant-design-pro/issues) to report bugs or ask questions. - Propose [pull requests](http://github.com/ant-design/ant-design-pro/pulls) to improve our code. + + \ No newline at end of file diff --git a/README.ru-RU.md b/README.ru-RU.md index 804c9828..3c084cb5 100644 --- a/README.ru-RU.md +++ b/README.ru-RU.md @@ -94,3 +94,9 @@ $ npm start # visit http://localhost:8000 - Использовать Ant Design Pro в ежедневной работе. - Создавать [задачи](http://github.com/ant-design/ant-design-pro/issues) заводить баги или отвечать на вопросы. - Делать [pull-реквесты](http://github.com/ant-design/ant-design-pro/pulls) для совершенствования нашего кода. + + diff --git a/README.tr-TR.md b/README.tr-TR.md index 82921ab7..ec2b6632 100644 --- a/README.tr-TR.md +++ b/README.tr-TR.md @@ -122,3 +122,9 @@ Her türlü desteğinize açığız, bu projeye nasıl katkıda bulunabileceğin - Günlük işinizde Ant Design Pro kullanın. - Hataları bildirmek veya soru sormak için [issues](http://github.com/ant-design/ant-design-pro/issues) gönderin. - kodumuzu geliştirmek için [pull requests](http://github.com/ant-design/ant-design-pro/pulls) gönderin. + + diff --git a/README.zh-CN.md b/README.zh-CN.md index 9e020581..d66d7d03 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -120,3 +120,9 @@ $ npm run docker-prod:build - 在你的公司或个人项目中使用 Ant Design Pro。 - 通过 [Issue](http://github.com/ant-design/ant-design-pro/issues) 报告 bug 或进行咨询。 - 提交 [Pull Request](http://github.com/ant-design/ant-design-pro/pulls) 改进 Pro 的代码。 + + From 6eb7139a526146eb11b2e2fac7d7e50429ffc922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Mon, 3 Jun 2019 18:16:14 +0800 Subject: [PATCH 12/18] add netlify logo in footer --- src/layouts/BasicLayout.tsx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/layouts/BasicLayout.tsx b/src/layouts/BasicLayout.tsx index 03d86f36..71ba6d49 100644 --- a/src/layouts/BasicLayout.tsx +++ b/src/layouts/BasicLayout.tsx @@ -11,6 +11,7 @@ import React, { useState } from 'react'; import logo from '../assets/logo.svg'; import Authorized from '@/utils/Authorized'; import { formatMessage } from 'umi-plugin-react/locale'; +import { isAntDesignProOrDev } from '@/utils/utils'; import { BasicLayout as ProLayoutComponents, BasicLayoutProps as ProLayoutComponentsProps, @@ -40,6 +41,30 @@ const menuDataRender = (menuList: MenuDataItem[]): MenuDataItem[] => { }); }; +const footerRender: BasicLayoutProps['footerRender'] = (_, defaultDom) => { + if (!isAntDesignProOrDev()) { + return defaultDom; + } + return ( + <> + {defaultDom} +
+ + netlify logo + +
+ + ); +}; + const BasicLayout: React.FC = props => { const { dispatch, children, settings } = props; /** @@ -86,6 +111,7 @@ const BasicLayout: React.FC = props => { ...routers, ]; }} + footerRender={footerRender} menuDataRender={menuDataRender} formatMessage={formatMessage} rightContentRender={rightProps => } From 8d9dee9762fbb0261a6126449871951bb5720e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Mon, 3 Jun 2019 18:35:04 +0800 Subject: [PATCH 13/18] add style --- src/layouts/BasicLayout.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/layouts/BasicLayout.tsx b/src/layouts/BasicLayout.tsx index 71ba6d49..177cd776 100644 --- a/src/layouts/BasicLayout.tsx +++ b/src/layouts/BasicLayout.tsx @@ -54,9 +54,10 @@ const footerRender: BasicLayoutProps['footerRender'] = (_, defaultDom) => { padding: '0px 20px 20px', }} > - + netlify logo From 56fff6aa8037bba73cd60cc7355ee44d92bd373b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Mon, 3 Jun 2019 18:41:38 +0800 Subject: [PATCH 14/18] edit style --- src/layouts/BasicLayout.tsx | 6 +++--- src/utils/utils.ts | 12 ++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/layouts/BasicLayout.tsx b/src/layouts/BasicLayout.tsx index 177cd776..deb54079 100644 --- a/src/layouts/BasicLayout.tsx +++ b/src/layouts/BasicLayout.tsx @@ -11,7 +11,7 @@ import React, { useState } from 'react'; import logo from '../assets/logo.svg'; import Authorized from '@/utils/Authorized'; import { formatMessage } from 'umi-plugin-react/locale'; -import { isAntDesignProOrDev } from '@/utils/utils'; +import { isAntDesignPro } from '@/utils/utils'; import { BasicLayout as ProLayoutComponents, BasicLayoutProps as ProLayoutComponentsProps, @@ -42,7 +42,7 @@ const menuDataRender = (menuList: MenuDataItem[]): MenuDataItem[] => { }; const footerRender: BasicLayoutProps['footerRender'] = (_, defaultDom) => { - if (!isAntDesignProOrDev()) { + if (!isAntDesignPro()) { return defaultDom; } return ( @@ -51,7 +51,7 @@ const footerRender: BasicLayoutProps['footerRender'] = (_, defaultDom) => {
diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 480064c3..183dda9e 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -5,14 +5,18 @@ export function isUrl(path: string) { return reg.test(path); } -// 给官方演示站点用,用于关闭真实开发环境不需要使用的特性 -export function isAntDesignProOrDev() { - const { NODE_ENV } = process.env; +export function isAntDesignPro() { if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') { return true; } + return window.location.hostname === 'preview.pro.ant.design'; +} + +// 给官方演示站点用,用于关闭真实开发环境不需要使用的特性 +export function isAntDesignProOrDev() { + const { NODE_ENV } = process.env; if (NODE_ENV === 'development') { return true; } - return window.location.hostname === 'preview.pro.ant.design'; + return isAntDesignPro(); } From dc5053053f0f116db3526aafa82437a8276c9e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Tue, 4 Jun 2019 10:09:50 +0800 Subject: [PATCH 15/18] add return type --- src/utils/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 183dda9e..beddb201 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -5,7 +5,7 @@ export function isUrl(path: string) { return reg.test(path); } -export function isAntDesignPro() { +export function isAntDesignPro(): boolean { if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') { return true; } @@ -13,7 +13,7 @@ export function isAntDesignPro() { } // 给官方演示站点用,用于关闭真实开发环境不需要使用的特性 -export function isAntDesignProOrDev() { +export function isAntDesignProOrDev(): boolean { const { NODE_ENV } = process.env; if (NODE_ENV === 'development') { return true; From 07adcdc558b919da63704cb89ddb40921fad6803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Tue, 4 Jun 2019 10:15:47 +0800 Subject: [PATCH 16/18] fix cr warning --- src/layouts/BasicLayout.tsx | 4 ++-- src/utils/utils.ts | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/layouts/BasicLayout.tsx b/src/layouts/BasicLayout.tsx index deb54079..c6cc156c 100644 --- a/src/layouts/BasicLayout.tsx +++ b/src/layouts/BasicLayout.tsx @@ -50,14 +50,14 @@ const footerRender: BasicLayoutProps['footerRender'] = (_, defaultDom) => { {defaultDom}
netlify logo diff --git a/src/utils/utils.ts b/src/utils/utils.ts index beddb201..e7c70ce3 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -1,22 +1,24 @@ /* eslint no-useless-escape:0 import/prefer-default-export:0 */ const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/; -export function isUrl(path: string) { +const isUrl = (path: string): boolean => { return reg.test(path); -} +}; -export function isAntDesignPro(): boolean { +const isAntDesignPro = (): boolean => { if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') { return true; } return window.location.hostname === 'preview.pro.ant.design'; -} +}; // 给官方演示站点用,用于关闭真实开发环境不需要使用的特性 -export function isAntDesignProOrDev(): boolean { +const isAntDesignProOrDev = (): boolean => { const { NODE_ENV } = process.env; if (NODE_ENV === 'development') { return true; } return isAntDesignPro(); -} +}; + +export { isAntDesignProOrDev, isAntDesignPro, isUrl }; From 1e202534b504752ba7f4a7ff5da946f51368bfae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Mon, 3 Jun 2019 16:27:34 +0800 Subject: [PATCH 17/18] add scripts in create umi --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index a07f2c09..fa4ac82d 100644 --- a/package.json +++ b/package.json @@ -179,7 +179,6 @@ "LICENSE", "netlify.toml", "README.*.md", - "scripts", "azure-pipelines.yml", "docker", "create-umi" From a775889edc9777308d26a12e44367c36c6697258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Mon, 3 Jun 2019 16:28:09 +0800 Subject: [PATCH 18/18] remove copy files --- create-umi/README.md | 56 ----------------- create-umi/package.json | 131 ---------------------------------------- package.json | 10 --- 3 files changed, 197 deletions(-) delete mode 100644 create-umi/README.md delete mode 100644 create-umi/package.json diff --git a/create-umi/README.md b/create-umi/README.md deleted file mode 100644 index 14c3286a..00000000 --- a/create-umi/README.md +++ /dev/null @@ -1,56 +0,0 @@ -# Ant Design Pro - -This project is initialized with [Ant Design Pro](https://pro.ant.design). Follow is the quick guide for how to use. - -## Environment Prepare - -Install `node_modules`: -```bash -npm install -``` - -or - -```bash -yarn -``` - -## Provided Scripts - -Ant Design Pro provides some useful script to help you quick start and build with web project, code style check and test. - -Scripts provided in `package.json`. It's safe to modify or add additional script: - -### Start project - -```bash -npm start -``` - -### Build project - -```bash -npm run build -``` - -### Check code style - -```bash -npm run lint -``` - -You can also use script to auto fix some lint error: - -```bash -npm run lint:fix -``` - -### Test code - -```bash -npm test -``` - -## More - -You can view full document on our [official website](https://pro.ant.design). And welcome any feedback in our [github](https://github.com/ant-design/ant-design-pro). \ No newline at end of file diff --git a/create-umi/package.json b/create-umi/package.json deleted file mode 100644 index 95879f14..00000000 --- a/create-umi/package.json +++ /dev/null @@ -1,131 +0,0 @@ -{ - "name": "ant-design-pro", - "version": "4.0.0", - "private": true, - "description": "An out-of-box UI solution for enterprise applications", - "scripts": { - "analyze": "cross-env ANALYZE=1 umi build", - "build": "umi build", - "lint": "npm run lint:js && npm run lint:ts && npm run lint:style && npm run lint:prettier", - "lint-staged": "lint-staged", - "lint-staged:js": "eslint --ext .js", - "lint-staged:ts": "tslint", - "lint:fix": "eslint --fix --ext .js src tests && npm run lint:style && npm run tslint:fix", - "lint:js": "eslint --ext .js src tests", - "lint:prettier": "check-prettier lint", - "lint:style": "stylelint --fix \"src/**/*.less\" --syntax less", - "lint:ts": "tslint -p . -c tslint.yml", - "prettier": " check-prettier write", - "start": "umi dev", - "start:no-mock": "cross-env MOCK=none umi dev", - "test": "umi test", - "test:all": "node ./tests/run-tests.js", - "test:component": "umi test ./src/components", - "tslint:fix": "tslint --fix \"src/**/*.ts*\"", - "fetch:blocks": "node ./scripts/fetch-blocks.js" - }, - "husky": { - "hooks": { - "pre-commit": "npm run lint-staged" - } - }, - "lint-staged": { - "**/*.less": "stylelint --syntax less", - "**/*.{js,jsx}": "npm run lint-staged:js", - "**/*.{js,ts,tsx,md,json,jsx,less}": [ "npm run prettier", "git add" ], - "**/*.{ts,tsx}": "npm run lint-staged:ts" - }, - "browserslist": [ "> 1%", "last 2 versions", "not ie <= 10" ], - "dependencies": { - "@ant-design/pro-layout": "^4.4.2", - "@antv/data-set": "^0.10.2", - "antd": "^3.19.1", - "bizcharts": "^3.5.3-beta.0", - "bizcharts-plugin-slider": "^2.1.1-beta.1", - "classnames": "^2.2.6", - "dva": "^2.4.1", - "lodash": "^4.17.11", - "lodash-decorators": "^6.0.1", - "memoize-one": "^5.0.4", - "moment": "^2.24.0", - "numeral": "^2.0.6", - "omit.js": "^1.0.2", - "path-to-regexp": "^3.0.0", - "qs": "^6.7.0", - "rc-animate": "^2.8.3", - "react": "^16.8.6", - "react-container-query": "^0.11.0", - "react-copy-to-clipboard": "^5.0.1", - "react-document-title": "^2.0.3", - "react-dom": "^16.8.6", - "react-fittext": "^1.0.0", - "react-media": "^1.9.2", - "react-media-hook2": "^1.0.5" - }, - "devDependencies": { - "@types/classnames": "^2.2.7", - "@types/history": "^4.7.2", - "@types/lodash": "^4.14.133", - "@types/react": "^16.8.19", - "@types/react-document-title": "^2.0.3", - "@types/react-dom": "^16.8.4", - "antd-pro-merge-less": "^1.0.0", - "antd-theme-webpack-plugin": "^1.2.0", - "babel-eslint": "^10.0.1", - "chalk": "^2.4.2", - "check-prettier": "^1.0.3", - "cross-env": "^5.2.0", - "cross-port-killer": "^1.1.1", - "enzyme": "^3.9.0", - "eslint": "^5.16.0", - "eslint-config-airbnb": "^17.1.0", - "eslint-config-prettier": "^4.3.0", - "eslint-plugin-babel": "^5.3.0", - "eslint-plugin-compat": "^3.1.1", - "eslint-plugin-import": "^2.17.3", - "eslint-plugin-jsx-a11y": "^6.2.1", - "eslint-plugin-markdown": "^1.0.0", - "eslint-plugin-react": "^7.13.0", - "express": "^4.17.1", - "gh-pages": "^2.0.1", - "husky": "^2.3.0", - "jest-puppeteer": "^4.2.0", - "jsdom-global": "^3.0.2", - "less": "^3.9.0", - "lint-staged": "^8.1.7", - "merge-umi-mock-data": "^2.0.6", - "mockjs": "^1.0.1-beta3", - "prettier": "^1.17.1", - "serverless-http": "^2.0.2", - "slash2": "^2.0.0", - "stylelint": "^10.0.1", - "stylelint-config-css-modules": "^1.4.0", - "stylelint-config-prettier": "^5.2.0", - "stylelint-config-rational-order": "^0.1.2", - "stylelint-config-standard": "^18.3.0", - "stylelint-declaration-block-no-ignored-properties": "^2.1.0", - "stylelint-order": "^3.0.0", - "tslint": "^5.17.0", - "tslint-config-prettier": "^1.18.0", - "tslint-eslint-rules": "^5.4.0", - "tslint-react": "^4.0.0", - "umi": "^2.7.0-beta.2", - "umi-plugin-ga": "^1.1.3", - "umi-plugin-pro-block": "^1.3.2", - "umi-plugin-react": "^1.8.0-beta.1", - "umi-request": "^1.0.7" - }, - "optionalDependencies": { - "puppeteer": "^1.17.0" - }, - "engines": { - "node": ">=10.0.0" - }, - "checkFiles": [ - "src/**/*.js*", - "src/**/*.ts*", - "src/**/*.less", - "config/**/*.js*", - "scripts/**/*.js" - ] -} diff --git a/package.json b/package.json index fa4ac82d..627dd722 100644 --- a/package.json +++ b/package.json @@ -158,16 +158,6 @@ "serverless", "express" ], - "copy": [ - [ - "create-umi/README.md", - "README.md" - ], - [ - "create-umi/package.json", - "package.json" - ] - ], "ignore": [ ".dockerignore", ".git",