export function getFileNameExt(fileName: string) {
  // @ts-ignore
  return fileName.split('.').pop().toLowerCase();
}

/**
 * 随机生成字符串
 */
export function getRandomString(len = 12, isSmall = false) {
  const _charStr = 'abacdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789';
  const _smallCharStr = 'abacdefghjklmnopqrstuvwxyz0123456789';
  const charStr = isSmall ? _smallCharStr : _charStr;
  const min = 0;
  const max = charStr.length - 1;
  let _str = '';
  //循环生成字符串
  for (let i = 0, index; i < len; i++) {
    index = (function (randomIndexFunc, i) {
      return randomIndexFunc(min, max, i, randomIndexFunc);
    })(function (min, max, i, _self) {
      const numStart = _charStr.length - 10;
      let indexTemp = Math.floor(Math.random() * (max - min + 1) + min);
      if (i == 0 && indexTemp >= numStart) {
        indexTemp = _self(min, max, i, _self);
      }
      return indexTemp;
    }, i);
    _str += _charStr[index];
  }
  return _str;
}
