front-standard-utils
Version:
3 lines (2 loc) • 3.85 kB
JavaScript
var t=function(t,e){var n;void 0===e&&(e=void 0);for(var r=(null!=(n=e)?n:window.location.search.substring(1)).split("&"),o=0;o<r.length;o++){var u=r[o].split("=");if(u[0]==t)return u[1]}return""};function e(t){for(var e=null!=t?t:window.location.search.substring(1),n=e.substr(e.indexOf("?")+1).split("&"),r={},o=0;o<n.length;o++){var u=n[o].split("=");r[u[0]]=u[1]}return r}var n=function(t,e){var n=new Date;n.setTime(n.getTime()+2592e6),document.cookie=t+"="+escape(e)+";expires="+n.toUTCString()+"; path=/"},r=function(t){var e,n=new RegExp("(^| )"+t+"=([^;]*)(;|$)");return(e=document.cookie.match(n))?unescape(e[2]):null},o=function(t){var e=new Date;e.setTime(e.getTime()-1e4),null!=r(t)&&(document.cookie=t+"=;expires="+e.toUTCString()+"; path=/")},u=function(t){var e;return void 0===t&&(t=""),(null!=(e=t)?e:"")+"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)}))},i=function(t,e){return null==t?void 0:t.filter((function(t,n,r){return r.findIndex((function(n){return t[e]==n[e]}))==n}))},a=function(t,e){if(t===e)return!0;if(t.length!=e.length)return!1;for(var n=0;n<t.length;++n)if(t[n]!==e[n])return!1;return!0},c=function(t){return/^(\+?0?86\-?)?1[3456789]\d{9}$/.test(t)},f=function(t){return/[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/i.test(t)},l=function(t){return/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(t)},s=function(t){return/^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/.test(t)},x=function(t){localStorage.removeItem(t)},d=function(t){return localStorage.getItem(t)},g=function(t,e){localStorage.setItem(t,e)},v=function(t){return!(!t||"object"!=typeof t||Array.isArray(t))&&!Object.keys(t).length};function p(t){switch(Object.prototype.toString.call(t).slice(8,-1)){case"Array":return t.map((function(t){return p(t)}));case"Object":return Object.keys(t).reduce((function(e,n){return e[n]=p(t[n]),e}),{});case"Date":return new t.constructor(Number(t));default:return t}}var m=function(t,e){var n;return void 0===e&&(e=200),function(){var r=this,o=arguments;n&&clearTimeout(n),n=setTimeout((function(){t.apply(r,o)}),e)}},w=function(t,e){void 0===e&&(e=200);var n=!0;return function(){if(n){var r=this,o=arguments;n=!1,setTimeout((function(){t.apply(r,o),n=!0}),e)}}};function h(t){return t.replace(/(?=\B(\d{3})+$)/g,",")}var b=function(t){var e=Number(t);return e>9?e:"0"+e},y=function(t,e,n){void 0===e&&(e="-"),void 0===n&&(n=":");var r=new Date(t),o=r.getFullYear(),u=r.getMonth()+1,i=r.getDate(),a=r.getHours(),c=r.getMinutes(),f=r.getSeconds();return o+e+b(u)+e+b(i)+" "+b(a)+n+b(c)+n+b(f)},D=function(t){var e=new Date(t).valueOf(),n=new Date(new Date((new Date).toLocaleDateString()).getTime()).valueOf(),r=((new Date).valueOf()-e)/1e3,o="";return r<=0||Math.floor(r/60)<=0?o="刚刚":r<3600?o=Math.floor(r/60)+"分钟前":r>=3600&&t-n>=0?o=Math.floor(r/3600)+"小时前":r/84600<=31&&(o=Math.ceil(r/86400)+"天前"),o},S=function(t){if(!t)return t;if("[object String]"!==Object.prototype.toString.call(t))return t;var e=!1,n=document.createElement("canvas");if(n.getContext&&n.getContext("2d"))try{0===n.toDataURL("image/webp").indexOf("data:image/webp")&&(e=!0)}catch(t){console.error(t)}return e&&(t+="?x-oss-process=image/format,webp"),t};export{a as arrayEqual,m as debounce,p as deepClone,o as delCookie,y as formatDate,b as formatNumber,r as getCookie,D as getFormatTime,d as getLocalStorage,u as getUUID,t as getUrlParam,e as getUrlParams,S as getWebpImg,l as isEmail,v as isEmptyObject,s as isIdCard,c as isPhoneNum,f as isUrl,i as removeDupArr,x as removeLocalStorage,n as setCookie,g as setLocalStorage,h as stringSepByThousands,w as throttle};
//# sourceMappingURL=front-standard-utils.esm.js.map