import { useState } from "react";
export default function AppModel() {
  const [historyColor, setHistoryColor] = useState<string[]>([
    '#B0E38F',
    '#F19594',
    '#EC7270',
    '#996A99',
    '#4F374F',
    '#94E0E1',
    '#FBF1B8',
    '#E3F0E1',
    '#FDF8DC',
    '#569230',
  ]);

  /**
   * 新增颜色记录
   * 添加时，将移除最早的颜色
   * @param color 颜色
   */
  const addHistoryCoolor = (color: string) => {
    if( historyColor.includes(color)) return;
    setHistoryColor((state) => {
      const newState = [...state];
      newState.unshift(color);
      newState.pop();
      return newState;
    })
  }

  return {
    historyColor,
    addHistoryCoolor
  }
}