//获取url后面拼接的参数 export const getQueryString = (name) => { let urlStr = window.location.href.split('?')[1] const urlSearchParams = new URLSearchParams(urlStr) const result = Object.fromEntries(urlSearchParams.entries()) return name ? result[name] : result } //是否iOS设备 export const isIOS = () => userAgent.indexOf('iPhone') > -1 || userAgent.indexOf('iPad') > -1; //是否Android设备 export const isAndroid = () => userAgent.indexOf('Android') > -1; export const deepClone = (source) => { if (!source && typeof source !== "object") { return source; } const targetObj = source.constructor === Array ? [] : {}; Object.keys(source).forEach((keys) => { if (source[keys] && typeof source[keys] === "object") { (targetObj)[keys] = deepClone(source[keys]); } else { (targetObj)[keys] = source[keys]; } }); return targetObj; } /** * @description 生成唯一 uuid * @returns {String} */ export function generateUUID() { let uuid = ""; for (let i = 0; i < 32; i++) { let random = (Math.random() * 16) | 0; if (i === 8 || i === 12 || i === 16 || i === 20) uuid += "-"; uuid += (i === 12 ? 4 : i === 16 ? (random & 3) | 8 : random).toString(16); } return uuid; }