/**
 * 转换样式对象
 * @param style
 */
export function transformStyle(style: Record<string, any>) {
  const styleObj: Record<string, any> = {};
  for (const key in style) {
    if (typeof style[key] === "object") {
      switch (key) {
        // 背景色对象
        case "background":
          if (style[key].type === "none") styleObj[key] = "none";
          if (style[key].type === "color") styleObj[key] = style[key].color;
          if (style[key].type === "image") {
            styleObj[
              key + "-image"
            ] = `url(${style[key].image}) no-repeat center center`;
            styleObj[key + "-size"] = style[key].fillType;
          }
          break;
        // 边框对象
        case "borderRadius":
          if (style[key].type === "all")
            styleObj[key] = `${style[key].value}${style[key].unit}`;
          else
            styleObj[
              key
            ] = `${style[key].value.topLeft}${style[key].unit} ${style[key].value.topRight}${style[key].unit} ${style[key].value.bottomLeft}${style[key].unit} ${style[key].value.bottomRight}${style[key].unit}`;
          break;
      }
    } else if (typeof style[key] === "number") {
      styleObj[key] = style[key] + "px";
    } else if (typeof style[key] === "string") {
      styleObj[key] = style[key];
    }
  }
  
  return styleObj;
}
