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