import client from 'webpack-theme-color-replacer/client' import generate from '@ant-design/colors/lib/generate' import { SketonVue } from '../types/sketon.vue' export default { methods: { getAntdSerials(color: string) { // 淡化(即less的tint) const lightens = new Array(9).fill(null).map((t, i) => client.varyColor.lighten(color, i / 10)) const colorPalettes = generate(color) const rgb = client.varyColor.toNum3(color.replace('#', '')).join(',') return lightens.concat(colorPalettes).concat(rgb) }, // 运行时更改主题颜色 changeColor(this: SketonVue, newColor: string, theme: { [key: string]: any }) { var options = { newColors: this.getAntdSerials(newColor), // 新颜色数组,与" matchColors"一一对应 changeUrl(cssUrl: string) { return `/_nuxt/${cssUrl}` // while router is not `hash` mode, it needs absolute path }, appendToEl: 'head', //optional. The element selector for appending child with `