// 判断当前设备是否为手机
export const getCurrentDevice = () => {
  let userAgent = window.navigator.userAgent;
  if (userAgent) {
    if (
      /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
        userAgent
      )
    ) {
      // 是手机端
      return true;
    }
    return false;
  }
};

// 获取屏幕宽度
export const getDeviceWidth = () => {
  try {
    let width = document.documentElement.clientWidth;
    if (width) {
      return width;
    }
    return 0;
  } catch (e) {
    return 0;
  }
};
