commit | author | age
|
9bcb19
|
1 |
import client from 'webpack-theme-color-replacer/client' |
I |
2 |
import generate from '@ant-design/colors/lib/generate' |
|
3 |
|
|
4 |
export default { |
|
5 |
getAntdSerials (color) { |
|
6 |
// 淡化(即less的tint) |
|
7 |
const lightens = new Array(9).fill().map((t, i) => { |
|
8 |
return client.varyColor.lighten(color, i / 10) |
|
9 |
}) |
|
10 |
// colorPalette变换得到颜色值 |
|
11 |
const colorPalettes = generate(color) |
|
12 |
const rgb = client.varyColor.toNum3(color.replace('#', '')).join(',') |
|
13 |
return lightens.concat(colorPalettes).concat(rgb) |
|
14 |
}, |
|
15 |
changeColor (newColor) { |
|
16 |
var options = { |
|
17 |
newColors: this.getAntdSerials(newColor), // new colors array, one-to-one corresponde with `matchColors` |
|
18 |
changeUrl (cssUrl) { |
|
19 |
return `/${cssUrl}` // while router is not `hash` mode, it needs absolute path |
|
20 |
} |
|
21 |
} |
|
22 |
return client.changer.changeColor(options, Promise) |
|
23 |
} |
|
24 |
} |