como-ts-utils.52443996.js 8.1 KB

1
  1. import{s as src}from"../szjcomo-utils/szjcomo-utils.8c09309c.js";import{c as commonjsGlobal}from"../como-admin-web/como-admin-web.4290f457.js";import{m as main}from"../como-validator/como-validator.c3b2e2bb.js";var dist={},comoUtils={};Object.defineProperty(comoUtils,"__esModule",{value:!0}),comoUtils.ComoTsUtils=void 0;const szjcomo=src;class _ComoTsUtils{constructor(){}static get Ins(){return _ComoTsUtils._instance||(_ComoTsUtils._instance=new _ComoTsUtils),_ComoTsUtils._instance}get szjComoUtils(){return szjcomo}AppResult(t,e,s=!0,r=0){return{data:e,message:t,code:r,error:s}}MtRand(t=0,e=1){return this.szjComoUtils.mt_rand(t,e)}StrMiddenHidden(t,e=0,s=0){let r=t.length-e-s,o="";for(let i=0;i<r;i++)o+="*";return t.substring(0,e)+o+t.substring(t.length-s)}Time(t=!1){return this.szjComoUtils.time(t)}StrToTime(t){return this.szjComoUtils.strToTime(t)}Date(t,e){return this.szjComoUtils.date(t,e)}MonthDay(t){return this.szjComoUtils.monthDay(t)}YearDay(t){return this.szjComoUtils.yearDay(t)}YearFirstDay(t){return this.szjComoUtils.yearFirstDay(t)}YearLastDay(t){return this.szjComoUtils.yearLastDay(t)}DateToYearDay(t){return this.szjComoUtils.dateToYearDay(t)}DateToYearWeek(t){return this.szjComoUtils.dateToYearWeek(t)}IsLeapYear(t){return this.szjComoUtils.isLeapYear(t)}MD5(t){return this.szjComoUtils.md5(t)}AesEncode(t,e="szjcomo"){return this.szjComoUtils.aes_encode(t,e)}AesDecode(t,e="szjcomo"){return this.szjComoUtils.aes_decode(t,e)}Sha1(t){return this.szjComoUtils.sha1(t)}Sha256(t){return this.szjComoUtils.sha256(t)}Base64Encode(t){return this.szjComoUtils.base64_encode(t)}Base64Decode(t){return this.szjComoUtils.base64_decode(t)}JsonEncode(t){return this.szjComoUtils.json_encode(t)}JsonDecode(t){return this.szjComoUtils.json_decode(t)}IsIdCardno(t){return this.szjComoUtils.isIdcardno(t)}IsIdentityNumber(t){return this.szjComoUtils.isIdentityNumber(t)}RepairIdentity(t){return this.szjComoUtils.repairIdentity(t)}GetZodiac(t){return this.szjComoUtils.getZodiac(t)}GetStarsign(t){return this.szjComoUtils.getStarsign(t)}GetAge(t,e=0,s=0,r=0){return this.szjComoUtils.getAge(t,e,s,r)}GetBorn(t){return this.szjComoUtils.getBorn(t)}GetGender(t){return this.szjComoUtils.getGender(t)}Trim(t,e=2){return this.szjComoUtils.trim(t,e)}StrLen(t){return this.szjComoUtils.strlen(t)}StrRand(t=4,e="default"){return this.szjComoUtils.str_rand(t,e)}MoneyFormat2(t){return this.szjComoUtils.money_format(t)}HtmlEscape(t){if(0==t.length)return"";return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\s/g,"&nbsp;").replace(/\'/g,"&#39;").replace(/\"/g,"&quot;")}HtmlUnEscape(t){if(0==t.length)return"";return t.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&nbsp;/g," ").replace(/&#39;/g,"'").replace(/&quot;/g,'"')}Empty(t){return this.szjComoUtils.empty(t)}IsNumber(t){return this.szjComoUtils.isNumber(t)}IsAlpha(t){return this.szjComoUtils.isAlpha(t)}IsChinese(t){return this.szjComoUtils.isChinese(t)}IsAlphaNumber(t){return this.szjComoUtils.isAlphaNumber(t)}IsPhone(t){return this.szjComoUtils.isPhone(t)}IsObject(t){return this.szjComoUtils.isObject(t)}IsTel(t){return this.szjComoUtils.isTel(t)}IsQQ(t){return this.szjComoUtils.isQQ(t)}IsEmail(t){return this.szjComoUtils.isEmail(t)}IsURL(t){return this.szjComoUtils.isURL(t)}IsArray(t){return this.szjComoUtils.isArray(t)}InArray(t,e){return this.szjComoUtils.inArray(t,e)}IsFunction(t){return this.szjComoUtils.isFunction(t)}ArrayAvg(t){return this.szjComoUtils.arrayAvg(t)}ArraySum(t){return this.szjComoUtils.arraySum(t)}ArrayMin(t){return this.szjComoUtils.arrayMin(t)}ArrayMax(t){return this.szjComoUtils.arrayMax(t)}ArrayRemove(t,e){return this.szjComoUtils.arrayRemove(t,e)}ArrayUnique(t){return this.szjComoUtils.arrayUnique(t)}ArraySort(t){return this.szjComoUtils.arraySort(t)}ArrayMerge(t,e){return this.szjComoUtils.arrayMerge(t,e)}ArrayPop(t){return this.szjComoUtils.arrayPop(t)}ArrayRand(t){return this.szjComoUtils.arrayRand(t)}ArrayRecursion(t,e=0,s="pid",r="id",o="children"){return this.szjComoUtils.arrayRecursion(t,e,s,r,o)}ArrayRecursiveBack(t,e="children"){return this.szjComoUtils.arrayRecursiveBack(t,e)}ComoEncode(t,e="0l23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"){let s,r,o,i,a=e.length,n=e.split(""),l="";for(let u=0;u<t.length;u++)s=t.charCodeAt(u),r=s%a,s=(s-r)/a,o=s%a,s=(s-o)/a,i=s%a,l+=n[i]+n[o]+n[r];return l}ComoDecode(str,secret="0l23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"){let l=secret.length,b,bl,b2,b3,d=0,s;s=new Array(Math.floor(str.length/3)),b=s.length;for(let t=0;t<b;t++)bl=secret.indexOf(str.charAt(d)),d++,b2=secret.indexOf(str.charAt(d)),d++,b3=secret.indexOf(str.charAt(d)),d++,s[t]=bl*l*l+b2*l+b3;return b=eval("String.fromCharCode("+s.join(",")+")"),b}}comoUtils.ComoTsUtils=_ComoTsUtils;var comoRule={},__awaiter=commonjsGlobal&&commonjsGlobal.__awaiter||function(t,e,s,r){return new(s||(s=Promise))((function(o,i){function a(t){try{l(r.next(t))}catch(e){i(e)}}function n(t){try{l(r.throw(t))}catch(e){i(e)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof s?e:new s((function(t){t(e)}))).then(a,n)}l((r=r.apply(t,e||[])).next())}))};Object.defineProperty(comoRule,"__esModule",{value:!0}),comoRule.ComoTsValidate=comoRule.ComoTsRuleUtil=void 0;const comoUtils_1=comoUtils,{comoRules:comoRules,validate:validate,ComoValidatorError:ComoValidatorError}=main;class ComoTsRuleUtil{constructor(){this.validatorRules=comoRules.getInstance()}Name(t){return this.validatorRules.name(t),this}Required(t){return this.validatorRules.required(t),this}NotEmpty(t){return this.validatorRules.notEmpty(t),this}Trim(){return this.validatorRules.trim(),this}IsJson(t){return this.validatorRules.isJson(t),this}DefaultValue(t){return this.validatorRules.default(t),this}ExtendRule(t){return this.validatorRules.extend(t),this}IsDate(t){return this.validatorRules.date(t),this}Number(t){return this.validatorRules.number(t),this}IsEmail(t){return this.validatorRules.email(t),this}MaxLength(t,e){return this.validatorRules.maxLength(t,e),this}MinLength(t,e){return this.validatorRules.minLength(t,e),this}MaxValue(t,e){return this.validatorRules.max(t,e),this}MinValue(t,e){return this.validatorRules.min(t,e),this}IsLetters(t){return this.validatorRules.letter(t),this}IsChinese(t){return this.validatorRules.chinese(t),this}IsLettersNumber(t){return this.validatorRules.letterNumber(t),this}IsChineseOrLetters(t){return this.validatorRules.extend(((e,s,r)=>{if(!(-1!=s.search(new RegExp("^[a-zA-Z一-龥]+$"))))throw new ComoValidatorError(null!=t?t:"只能是字母或中文或字母和中文的组合")})),this}IsLettersOrNumber(t){return this.validatorRules.extend(((e,s,r)=>{if(!/^[a-zA-Z0-9_]{1,}$/.test(s))throw new ComoValidatorError(null!=t?t:"字母或数字或下划线")})),this}IsPhone(t){return this.validatorRules.phone(t),this}IsObject(t){return this.validatorRules.object(t),this}IsArray(t){return this.validatorRules.isArray(t),this}IsQQ(t){return this.validatorRules.qq(t),this}IsURL(t){return this.validatorRules.url(t),this}InArray(t,e){return this.validatorRules.inArray(t,e),this}IsIp(t){return this.validatorRules.ip(t),this}Ref(t,e){return this.validatorRules.ref(t,e),this}IsIdCard(t){return this.validatorRules.idCard(t),this}IsIdentityNumber(t){return this.validatorRules.extend(((e,s,r)=>{try{comoUtils_1.ComoTsUtils.Ins.IsIdentityNumber(s.toString())}catch(o){throw t?new ComoValidatorError(t):o}})),this}HtmlEscape(t){return this.validatorRules.extend(((t,e,s)=>{let r=comoUtils_1.ComoTsUtils.Ins.HtmlEscape(e);s[t]=r})),this}Rules(){return this.validatorRules}static get Ins(){return new this}}comoRule.ComoTsRuleUtil=ComoTsRuleUtil;const ComoTsValidate=function(t,e){return __awaiter(this,void 0,void 0,(function*(){return yield validate(t,e)}))};comoRule.ComoTsValidate=ComoTsValidate,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ComoTsValidate=t.ComoTsRuleUtil=t.ComoTsUtils=void 0;const e=comoUtils;Object.defineProperty(t,"ComoTsUtils",{enumerable:!0,get:function(){return e.ComoTsUtils}});const s=comoRule;Object.defineProperty(t,"ComoTsRuleUtil",{enumerable:!0,get:function(){return s.ComoTsRuleUtil}}),Object.defineProperty(t,"ComoTsValidate",{enumerable:!0,get:function(){return s.ComoTsValidate}})}(dist);export{dist as d};