/**
 * 根据电量获取电池对应的颜色和icon
 * @param soc - 电池电量百分比
 * @param lowConfig - 低电量配置
 * @param normalConfig - 正常电量配置
 * @param highConfig - 高电量配置
 */
interface generalConfigType {
  scope: [number, number]
  color: string
  icon: string
}
export function getBatteryColor({
  soc = 0,
  lowConfig = {
    scope: [0, 20],
    color: '#ee5d66',
    icon: 'dianliang',
  },
  normalConfig = {
    scope: [20, 80],
    color: '#f88b0d',
    icon: 'dianliang1',
  },
  highConfig = {
    scope: [80, 100],
    color: '#85c25a',
    icon: 'dianliang2',
  },
}: {
  soc?: number
  lowConfig?: generalConfigType
  normalConfig?: generalConfigType
  highConfig?: generalConfigType
}) {
  return soc >= highConfig.scope[0] && soc <= highConfig.scope[1]
    ? {
        soc,
        color: highConfig.color,
        icon: highConfig.icon,
      }
    : soc >= normalConfig.scope[0] && soc <= normalConfig.scope[1]
      ? {
          soc,
          color: normalConfig.color,
          icon: normalConfig.icon,
        }
      : soc >= lowConfig.scope[0] && soc <= lowConfig.scope[1]
        ? {
            soc,
            color: lowConfig.color,
            icon: lowConfig.icon,
          }
        : {
            soc,
            color: '#eeeeee',
            icon: lowConfig.icon,
          }
}
