import { colorList } from './config'; // 生成随机的16进制颜色 export const getRandomColor = function () { let str = '#'; const arr = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', ]; for (let i = 0; i < 6; i++) { const num = parseInt(String(Math.random() * 16)); str += arr[num]; } return str; }; // 获取随机预设颜色 export const getRandomPresetColor = function () { const index = parseInt(String(Math.random() * colorList.length)); return colorList[index]; };