美文网首页
2019-08-10

2019-08-10

作者: gitblong | 来源:发表于2019-08-10 20:37 被阅读0次

    // eslint-disable-next-line eslint-comments/disable-enable-pair

    /* eslint-disable import/no-extraneous-dependencies */
    import client from 'webpack-theme-color-replacer/client';
    import generate from '@ant-design/colors/lib/generate';
    export default {
    getAntdSerials(color) {
    const lightCount = 9;
    const divide = 10; // 淡化(即less的tint)

    let lightens = new Array(lightCount).fill(0);
    lightens = lightens.map((_, i) => client.varyColor.lighten(color, i / divide));
    const colorPalettes = generate(color);
    return lightens.concat(colorPalettes);
    

    },

    changeColor(color) {
    if (!color) {
    return Promise.resolve();
    }

    const options = {
      // new colors array, one-to-one corresponde with `matchColors`
      newColors: this.getAntdSerials(color),
    
      changeUrl(cssUrl) {
        // while router is not `hash` mode, it needs absolute path
        return `/${cssUrl}`;
      },
    };
    return client.changer.changeColor(options, Promise);
    

    },
    };

    相关文章

      网友评论

          本文标题:2019-08-10

          本文链接:https://www.haomeiwen.com/subject/heldjctx.html