const generateData = (x = 3, y = 2, z = 1, gData = []) => {
  //x: 每一级下的节点总数。y: 每一级节点里有y个节点、存在子节点。z：树的level层级（0代表一级）
  const _loop = (_level?: any, _preKey?: any, _tns?: any) => {
    const preKey = _preKey || "0";
    const tns = _tns || gData;

    const children = [];
    for (let i = 0; i < x; i++) {
      const key = `${preKey}-${i}`;
      tns.push({ title: `${key}`, key: `${key}-key` });
      if (i < y) {
        children.push(key);
      }
    }
    if (_level < 0) {
      return tns;
    }

    const __level = _level - 1;
    children.forEach((key, index) => {
      tns[index].children = [];
      return _loop(__level, key, tns[index].children);
    });
    return null;
  };
  _loop(z);
  return gData;
};

const gData = generateData();

export { gData };
