const getQueryString = function (name) {
  // var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
  let r = window.location.search.substr(1).split("&");
  let urlObject = {};
  if (r.length > 0) {
    for (var i = 0, len = r.length; i < len; i++) {
      var urlItem = r[i];
      var item = urlItem.split("=");
      urlObject[item[0]] = item[1];
    }

    return urlObject[name];
  }
  return null;
};
const getTime = function (times) {
  var date = new Date(times);
  let Y = date.getFullYear() + "-";
  let M =
    (date.getMonth() + 1 < 10
      ? "0" + (date.getMonth() + 1)
      : date.getMonth() + 1) + "-";
  let D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
  let h =
    (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
  let m =
    (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) +
    ":";
  let s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
  return Y + M + D + h + m + s;
};
// 图片资源上传大小限制
const imgSourceSizeLimit = 2; // 2M
const imgSourceFomatLimit = ["jpg", "png", "jpeg", "gif", "webp"];

// 资源上传大小限制
const sourceSizeLimit = 10; // 5M
const sourceFomatLimit = ["audio", "video"];

export {
  getQueryString,
  getTime,
  imgSourceSizeLimit,
  imgSourceFomatLimit,
  sourceSizeLimit,
  sourceFomatLimit,
};
