// eslint-disable-next-line no-useless-escapeconst xiaobangguihuaRegx = /xiaobangguihua\/[\d\.]+/i;/*** 比较版本号,大于等于返回 true,只支持*.*.*的格式,例如4.3.0* @param {string} v1 版本1* @param {string} v2 版本2*/const compareVersion = (v1 = '', v2 = '') => { const preVersion1 = parseFloat(v1); const preVersion2 = parseFloat(v2); const nextVersion1 = v1.replace(`${preVersion1}.`, ''); const nextVersion2 = v2.replace(`${preVersion2}.`, ''); if (preVersion1 > preVersion2) { return true; } if (preVersion1 < preVersion2) { return false; } return nextVersion1 >= nextVersion2;};// 根据正则获取版本号const getVersion = regx => { const query = String(window.navigator.userAgent) .toLowerCase() .match(regx); if (!query) { return [0, 0, 0]; } const version = query[0].match(/\d+/g) || {}; if (typeof version[0] === 'undefined' || typeof version[1] === 'undefined' || typeof version[2] === 'undefined') { return [0, 0, 0]; } return [parseInt(version[0], 10), parseInt(version[1], 10), parseInt(version[2], 10)];};/*** 判断当前版本是否大于传入版本** @param {string} v1 传入版本* @return {boolean} true当前版本大于传入版本 false当前版本小于传入版本*/export const gtVersion = v2 => { const v1 = getVersion(xiaobangguihuaRegx).join('.'); return compareVersion(v1, v2);};