export function computedCuurentGrid() {
  const width = document.body.clientWidth;
  if (width >= 1600) {
    return "xxl";
  }
  if (width >= 1200 && width < 1600) {
    return "xl";
  }
  if (width >= 992 && width < 1200) {
    return "lg";
  }
  if (width >= 768 && width < 992) {
    return "md";
  }
  if (width >= 576 && width < 768) {
    return "sm";
  }
  if (width < 576) {
    return "xs";
  }
}


// 切割数组 1维变2维
export function arraySliceForX(arr, x = 3) {
  let newArr = [];
  for (let i = 0, l = arr.length; i < l; i++) {
    if (newArr.length === 0) {
      newArr.push([]);
    }
    if (newArr[newArr.length - 1].length > x - 1) {
      newArr.push([]);
    }
    newArr[newArr.length - 1].push(arr[i]);
  }
  return newArr;
}

// 切割数组 1维变2维，分组聚合展示
export function arraySliceForXG(arr, x = 3, isGroupTitle) {
  let newArr = [];
  for (let i = 0, l = arr.length; i < l; i++) {
    if (newArr.length === 0) {
      newArr.push([]);
    }
    if (isGroupTitle(arr[i])) {
      if (newArr[newArr.length - 1].length === 0) {
        newArr[newArr.length - 1].push(arr[i]);
      } else {
        newArr.push([arr[i]]);
      }
      newArr.push([]);
    } else {
      if (newArr[newArr.length - 1].length > x - 1) {
        newArr.push([]);
      }
      newArr[newArr.length - 1].push(arr[i]);
    }
  }
  return newArr;
}

export const simpleGrid = {
  xxl: 4,
  xl: 6,
  lg: 6,
  md: 7,
  sm: 24,
  xs: 24
};