Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ant-design-pro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
ant-design-pro
Commits
25c42c38
Commit
25c42c38
authored
May 26, 2019
by
hz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
使用@ant-design/colors生成主题色系;兼容IE
parent
5e99cb1f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
28 deletions
+13
-28
config/plugin.config.js
config/plugin.config.js
+3
-13
package.json
package.json
+4
-4
src/components/SettingDrawer/themeColorClient.js
src/components/SettingDrawer/themeColorClient.js
+6
-11
No files found.
config/plugin.config.js
View file @
25c42c38
...
@@ -2,8 +2,9 @@
...
@@ -2,8 +2,9 @@
import
MergeLessPlugin
from
'
antd-pro-merge-less
'
;
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
ThemeColorReplacer
from
'
webpack-theme-color-replacer
'
;
import
path
from
'
path
'
;
import
path
from
'
path
'
;
import
generate
from
'
@ant-design/colors/lib/generate
'
;
function
getModulePackageName
(
module
)
{
function
getModulePackageName
(
module
)
{
if
(
!
module
.
context
)
return
null
;
if
(
!
module
.
context
)
return
null
;
...
@@ -42,7 +43,7 @@ export default config => {
...
@@ -42,7 +43,7 @@ export default config => {
]);
]);
config
.
plugin
(
'
webpack-theme-color-replacer
'
).
use
(
ThemeColorReplacer
,
[{
config
.
plugin
(
'
webpack-theme-color-replacer
'
).
use
(
ThemeColorReplacer
,
[{
fileName
:
'
css/theme-colors.css
'
,
fileName
:
'
css/theme-colors.css
'
,
matchColors
:
ge
tAntdSerials
(
'
#1890ff
'
),
// 主色系列
matchColors
:
ge
nerate
(
'
#1890ff
'
),
// 主色系列
}]);
}]);
// config.plugin('ant-design-theme').use(AntDesignThemePlugin, [
// config.plugin('ant-design-theme').use(AntDesignThemePlugin, [
// {
// {
...
@@ -85,14 +86,3 @@ export default config => {
...
@@ -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
);
}
package.json
View file @
25c42c38
...
@@ -82,15 +82,14 @@
...
@@ -82,15 +82,14 @@
"
resize-observer-polyfill
"
:
"
^1.5.1
"
,
"
resize-observer-polyfill
"
:
"
^1.5.1
"
,
"
umi
"
:
"
^2.4.4
"
,
"
umi
"
:
"
^2.4.4
"
,
"
umi-plugin-react
"
:
"
^1.7.2
"
,
"
umi-plugin-react
"
:
"
^1.7.2
"
,
"
umi-request
"
:
"
^1.0.5
"
,
"
umi-request
"
:
"
^1.0.5
"
"
webpack-theme-color-replacer
"
:
"
^1.1.3
"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"
@types/history
"
:
"
^4.7.2
"
,
"
@types/history
"
:
"
^4.7.2
"
,
"
@types/react
"
:
"
^16.8.1
"
,
"
@types/react
"
:
"
^16.8.1
"
,
"
@types/react-dom
"
:
"
^16.0.11
"
,
"
@types/react-dom
"
:
"
^16.0.11
"
,
"
antd-pro-merge-less
"
:
"
^1.0.0
"
,
"
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
"
,
"
babel-eslint
"
:
"
^10.0.1
"
,
"
chalk
"
:
"
^2.4.2
"
,
"
chalk
"
:
"
^2.4.2
"
,
"
check-prettier
"
:
"
^1.0.1
"
,
"
check-prettier
"
:
"
^1.0.1
"
,
...
@@ -127,7 +126,8 @@
...
@@ -127,7 +126,8 @@
"
tslint
"
:
"
^5.12.1
"
,
"
tslint
"
:
"
^5.12.1
"
,
"
tslint-config-prettier
"
:
"
^1.17.0
"
,
"
tslint-config-prettier
"
:
"
^1.17.0
"
,
"
tslint-react
"
:
"
^3.6.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"
:
{
"optionalDependencies"
:
{
"puppeteer"
:
"^1.12.1"
"puppeteer"
:
"^1.12.1"
...
...
src/components/SettingDrawer/themeColorClient.js
View file @
25c42c38
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
{
export
default
{
primaryColor
:
'
#1890ff
'
,
primaryColor
:
'
#1890ff
'
,
getAntdSerials
(
color
)
{
getAntdSerials
(
color
)
{
// 淡化(即less的tint)
return
generate
(
color
)
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
)
{
changeColor
(
newColor
)
{
const
lastColor
=
this
.
lastColor
||
this
.
primaryColor
const
lastColor
=
this
.
lastColor
||
this
.
primaryColor
...
@@ -20,8 +14,9 @@ export default {
...
@@ -20,8 +14,9 @@ export default {
oldColors
:
this
.
getAntdSerials
(
lastColor
),
// current colors array. The same as `matchColors`
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
)
const
promise
=
client
.
changer
.
changeColor
(
options
,
Promise
);
this
.
lastColor
=
lastColor
this
.
lastColor
=
lastColor
return
promise
return
promise
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment