style: eslint of naming-convention
This commit is contained in:
@@ -3,7 +3,7 @@ export class Color {
|
||||
fontColor: string;
|
||||
}
|
||||
|
||||
export const ColorList: Color[] = [
|
||||
export const COLOR_LIST: Color[] = [
|
||||
{bgColor: '#7bcfa6', fontColor: '#000000'}, // 石青
|
||||
{bgColor: '#bce672', fontColor: '#000000'}, // 松花色
|
||||
{bgColor: '#ff8936', fontColor: '#000000'}, // 橘黄
|
||||
@@ -13,16 +13,16 @@ export const ColorList: Color[] = [
|
||||
{bgColor: '#177cb0', fontColor: '#ffffff'}, // 靛青
|
||||
];
|
||||
|
||||
export const ColorListLength = ColorList.length;
|
||||
export const COLOR_LIST_LENGTH = COLOR_LIST.length;
|
||||
|
||||
/**
|
||||
* 获取一组随机颜色
|
||||
*
|
||||
* @param count 数量
|
||||
*/
|
||||
export function RandomColor(count: number = 1): Color[] {
|
||||
export function randomColor(count: number = 1): Color[] {
|
||||
const map = new Map<number, number>();
|
||||
ColorList.forEach((color, index) => map.set(index, 0));
|
||||
COLOR_LIST.forEach((color, index) => map.set(index, 0));
|
||||
const colorArray: Color[] = [];
|
||||
const oneRandomColor = () => {
|
||||
const minValue = Math.min.apply(null, Array.from(map.values()));
|
||||
@@ -30,7 +30,7 @@ export function RandomColor(count: number = 1): Color[] {
|
||||
const keyIndex = Math.floor(Math.random() * keys.length);
|
||||
const index = keys[keyIndex];
|
||||
map.set(index, minValue + 1);
|
||||
return ColorList[index];
|
||||
return COLOR_LIST[index];
|
||||
};
|
||||
for (let i = 0; i < count; i++) {
|
||||
colorArray.push(oneRandomColor());
|
||||
|
||||
Reference in New Issue
Block a user