@gindow/vue 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vue.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require("vue"),t=require("@iconify/vue");var n={cancel:`取消`,confirm:`确认`,empty:{noData:`暂无数据`},dialog:{tip:`操作提示`,confirm:`操作确认`}},r={cancel:`Cancel`,confirm:`Confirm`,empty:{noData:`No data`},dialog:{tip:`Tip`,confirm:`Confirm`}},i=()=>{let e=[`en`,`zh-CN`],t=localStorage.getItem(`locale`),n=navigator.language;return t&&e.includes(t)?t:n&&e.includes(n)?n:n&&e.includes(n.split(`-`)[0])?n.split(`-`)[0]:e[0]??`zh-CN`},a=Symbol(`vue-locale`),o=(0,e.ref)(i()),s=(0,e.reactive)({en:r,"zh-CN":n}),c=t=>{if(t?.locale&&(o.value=t.locale),t?.messages)for(let[e,n]of Object.entries(t.messages))s[e]=n;return(0,e.provide)(a,{locale:o,messages:s}),{locale:o,messages:s}},l=()=>{let t=(0,e.inject)(a,void 0),n=t?.locale??o,r=t?.messages??s;return{locale:n,t:(e,t)=>{let i=r[n.value],a=e.replace(/\[(\d+)]/g,`.$1`).split(`.`),o=i;for(let t of a)if(o=o?.[t],o===void 0)return e;let s=o??e;return t&&typeof s==`string`&&(s=s.replace(/\{(\w+)\}/g,(e,n)=>t[n]===void 0?`{${n}}`:String(t[n]))),s}}},u=e=>o.value=e,d=()=>o.value,f=((e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n})((0,e.defineComponent)({__name:`VueIcon`,props:{vendor:{type:String,default:`icon-park-outline`},icon:{type:String,default:``},type:{type:String,default:``},size:{type:Number,default:16},strokeWidth:{type:Number,default:3},color:{type:String}},setup(n){(0,e.useCssVars)(e=>({v519ff46c:l.value}));let r=n,i={folder:`folder-close`,png:`pic-one`,jpeg:`pic-one`,jpg:`pic-one`,gif:`pic-one`,webp:`pic-one`,bmp:`pic-one`,svg:`pic-one`,mp4:`video`,avi:`video`,mov:`video`,wmv:`video`,flv:`video`,mkv:`video`,webm:`video`,mp3:`music-one`,wav:`music-one`,wma:`music-one`,aac:`music-one`,ogg:`music-one`,flac:`music-one`,pdf:`file-pdf`,doc:`file-word`,docx:`file-word`,xls:`file-excel`,xlsx:`file-excel`,csv:`file-excel`,ppt:`file-ppt`,pptx:`file-ppt`,txt:`file-txt`,md:`file-txt-one`,json:`code`,xml:`code`,html:`code`,css:`code`,js:`code`,ts:`code`,jsx:`code`,tsx:`code`,py:`code`,php:`code`,cpp:`code`,c:`code`,java:`code`,go:`code`,rs:`code`,zip:`zip`,rar:`zip`,"7z":`zip`,tar:`zip`,gz:`zip`,bz2:`zip`},a={image:`pic-one`,video:`video`,audio:`music-one`,text:`file-txt`,application:`file-text`,font:`file-text`,pdf:`file-pdf`,doc:`file-word`,sheet:`file-excel`,ppt:`file-ppt`,md:`file-txt-one`,canvas:`book-open`,album:`pic-one`,yearbook:`book-open`},o=(0,e.computed)(()=>{if(r.icon)return r.icon;if(!r.type)return``;if(r.type===`folder`)return`folder-close`;let[e,t]=r.type.toLowerCase().split(`/`);return t&&i[t]?i[t]:e&&a[e]?a[e]:e&&i[e]?i[e]:`file-text`}),s=(0,e.computed)(()=>{let e=o.value;return e?e.includes(`:`)?e:`${r.vendor}:${e}`:``}),c=(0,e.computed)(()=>r.color?{color:r.color}:void 0),l=(0,e.computed)(()=>r.strokeWidth);return(r,i)=>((0,e.openBlock)(),(0,e.createBlock)((0,e.unref)(t.Icon),{icon:s.value,width:n.size,height:n.size,style:(0,e.normalizeStyle)(c.value),"aria-hidden":null},null,8,[`icon`,`width`,`height`,`style`]))}}),[[`__scopeId`,`data-v-e336ca96`]]),p=class{static{this.config={}}static{this.set=e=>this.config=e}static{this.id=(e=``)=>e.slice(-12).toUpperCase()}static{this.date=(e=``)=>e.substring(0,10)+` `+e.substring(11,19)}static{this.idcard=(e=``)=>e?e.substring(0,6)+`****`+e.substring(14):``}static{this.phone=(e=``,t=!1)=>t||!e?e:e.substring(0,3)+`****`+e.substring(e.length-4)}static{this.email=(e=``)=>{let[t,n]=e.split(`@`);return!t||!n?e:`${t.length>2?t[0]+`****`+t[t.length-1]:t}@${n}`}}static{this.bankcard=(e=``)=>e.substring(0,4)+`****`+e.substring(e.length-4)}static{this.url=(e=``)=>e.replace(/:\/\//g,`:##`).replace(/\/+/g,`/`).replace(/:##/g,`://`)}static{this.price=(e=0,t)=>{let{locale:n,decimals:r,currency:i}=this.config,a=typeof e==`string`?parseFloat(e):e;return new Intl.NumberFormat(n,{style:`currency`,currency:t??i??`CNY`,minimumFractionDigits:r??2,maximumFractionDigits:r??2}).format(a/100)}}static{this.currency=(e=0,t)=>this.price(e,t)}},m=class e{static{this.country=``}static{this.set=e=>this.country=e}static get phone_pattern(){return this.country.toUpperCase()===`CN`?/([1][3,4,5,6,7,8,9][0-9]{9})$/:/^(?:\+?[1-9]\d{7,14}|\d{6,11})$/}static{this.email_pattern=/^([a-zA-Z0-9_\.-]+)@([\da-zA-Z\.-]+)\.([a-zA-Z\.]{2,6})$/}static{this.idcard_pattern=/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/}static{this.cname_pattern=/^(?:[\u4e00-\u9fa5·]{2,16})$/}static{this.password_pattern=/^(?![A-Za-z]+$)(?![0-9]+$)(?![^A-Za-z0-9]+$).{8,20}$/}static{this.phone=t=>e.phone_pattern.test(t)}static{this.email=t=>e.email_pattern.test(t)}static{this.idcard=t=>e.idcard_pattern.test(t)}static{this.cname=t=>e.cname_pattern.test(t)}},h=768,g=()=>{let t=(0,e.ref)(typeof window<`u`?window.matchMedia(`(min-width: ${h}px)`).matches:!0),n,r=e=>t.value=e.matches;(0,e.onMounted)(()=>{typeof window>`u`||(n=window.matchMedia(`(min-width: ${h}px)`),t.value=n.matches,n.addEventListener(`change`,r))}),(0,e.onBeforeUnmount)(()=>n?.removeEventListener(`change`,r));let i=(0,e.computed)(()=>t.value);return{isMobile:(0,e.computed)(()=>!t.value),isDesktop:i}},_=t=>{let n=(0,e.ref)(0),r=(0,e.ref)(!1),i=(e={})=>new Promise((n,i)=>{r.value||(r.value=!0,t(e).then(()=>{a(),n(!0)}).catch(e=>i(e)).finally(()=>r.value=!1))}),a=()=>{n.value=60;let e=setInterval(()=>{n.value--,n.value||clearTimeout(e)},1e3)};return{waiting:n,send:i}},v=()=>({i:(t,n={})=>t?(0,e.h)(f,{icon:t,...n}):void 0}),y=[f];y.forEach(e=>{e.install=t=>{let n=e.name??e.__name;n&&t.component(n,e)}});var b={install(e,t){c(t),y.forEach(t=>e.use(t))}};exports.Formatter=p,exports.Validate=m,exports.VueIcon=f,exports.default=b,exports.getLocale=d,exports.setLocale=u,exports.useBreak=g,exports.useCaptcha=_,exports.useIcon=v,exports.useLocale=l;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require("vue"),u=require("@iconify/vue");var d={cancel:`取消`,confirm:`确认`,empty:{noData:`暂无数据`},dialog:{tip:`操作提示`,confirm:`操作确认`}},f={cancel:`Cancel`,confirm:`Confirm`,empty:{noData:`No data`},dialog:{tip:`Tip`,confirm:`Confirm`}},p=()=>{let e=[`en`,`zh-CN`],t=localStorage.getItem(`locale`),n=navigator.language;return t&&e.includes(t)?t:n&&e.includes(n)?n:n&&e.includes(n.split(`-`)[0])?n.split(`-`)[0]:e[0]??`zh-CN`},m=Symbol(`vue-locale`),h=(0,l.ref)(p()),g=(0,l.reactive)({en:f,"zh-CN":d}),_=e=>{if(e?.locale&&(h.value=e.locale),e?.messages)for(let[t,n]of Object.entries(e.messages))g[t]=n;return(0,l.provide)(m,{locale:h,messages:g}),{locale:h,messages:g}},v=()=>{let e=(0,l.inject)(m,void 0),t=e?.locale??h,n=e?.messages??g;return{locale:t,t:(e,r)=>{let i=n[t.value],a=e.replace(/\[(\d+)]/g,`.$1`).split(`.`),o=i;for(let t of a)if(o=o?.[t],o===void 0)return e;let s=o??e;return r&&typeof s==`string`&&(s=s.replace(/\{(\w+)\}/g,(e,t)=>r[t]===void 0?`{${t}}`:String(r[t]))),s}}},y=e=>h.value=e,b=()=>h.value,x=((e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n})((0,l.defineComponent)({__name:`VueIcon`,props:{vendor:{type:String,default:`icon-park-outline`},icon:{type:String,default:``},type:{type:String,default:``},size:{type:Number,default:16},strokeWidth:{type:Number,default:3},color:{type:String}},setup(e){(0,l.useCssVars)(e=>({v519ff46c:s.value}));let t=e,n={folder:`folder-close`,png:`pic-one`,jpeg:`pic-one`,jpg:`pic-one`,gif:`pic-one`,webp:`pic-one`,bmp:`pic-one`,svg:`pic-one`,mp4:`video`,avi:`video`,mov:`video`,wmv:`video`,flv:`video`,mkv:`video`,webm:`video`,mp3:`music-one`,wav:`music-one`,wma:`music-one`,aac:`music-one`,ogg:`music-one`,flac:`music-one`,pdf:`file-pdf`,doc:`file-word`,docx:`file-word`,xls:`file-excel`,xlsx:`file-excel`,csv:`file-excel`,ppt:`file-ppt`,pptx:`file-ppt`,txt:`file-txt`,md:`file-txt-one`,json:`code`,xml:`code`,html:`code`,css:`code`,js:`code`,ts:`code`,jsx:`code`,tsx:`code`,py:`code`,php:`code`,cpp:`code`,c:`code`,java:`code`,go:`code`,rs:`code`,zip:`zip`,rar:`zip`,"7z":`zip`,tar:`zip`,gz:`zip`,bz2:`zip`},r={image:`pic-one`,video:`video`,audio:`music-one`,text:`file-txt`,application:`file-text`,font:`file-text`,pdf:`file-pdf`,doc:`file-word`,sheet:`file-excel`,ppt:`file-ppt`,md:`file-txt-one`,canvas:`book-open`,album:`pic-one`,yearbook:`book-open`},i=(0,l.computed)(()=>{if(t.icon)return t.icon;if(!t.type)return``;if(t.type===`folder`)return`folder-close`;let[e,i]=t.type.toLowerCase().split(`/`);return i&&n[i]?n[i]:e&&r[e]?r[e]:e&&n[e]?n[e]:`file-text`}),a=(0,l.computed)(()=>{let e=i.value;return e?e.includes(`:`)?e:`${t.vendor}:${e}`:``}),o=(0,l.computed)(()=>t.color?{color:t.color}:void 0),s=(0,l.computed)(()=>t.strokeWidth);return(t,n)=>((0,l.openBlock)(),(0,l.createBlock)((0,l.unref)(u.Icon),{icon:a.value,width:e.size,height:e.size,style:(0,l.normalizeStyle)(o.value),"aria-hidden":null},null,8,[`icon`,`width`,`height`,`style`]))}}),[[`__scopeId`,`data-v-e336ca96`]]),S=class{static{this.config={}}static{this.set=e=>this.config=e}static{this.id=(e=``)=>e.slice(-12).toUpperCase()}static{this.date=(e=``)=>e.substring(0,10)+` `+e.substring(11,19)}static{this.idcard=(e=``)=>e?e.substring(0,6)+`****`+e.substring(14):``}static{this.phone=(e=``,t=!1)=>t||!e?e:e.substring(0,3)+`****`+e.substring(e.length-4)}static{this.email=(e=``)=>{let[t,n]=e.split(`@`);return!t||!n?e:`${t.length>2?t[0]+`****`+t[t.length-1]:t}@${n}`}}static{this.bankcard=(e=``)=>e.substring(0,4)+`****`+e.substring(e.length-4)}static{this.url=(e=``)=>e.replace(/:\/\//g,`:##`).replace(/\/+/g,`/`).replace(/:##/g,`://`)}static{this.price=(e=0,t)=>{let{locale:n,decimals:r,currency:i}=this.config,a=typeof e==`string`?parseFloat(e):e;return new Intl.NumberFormat(n,{style:`currency`,currency:t??i??`CNY`,minimumFractionDigits:r??2,maximumFractionDigits:r??2}).format(a/100)}}static{this.currency=(e=0,t)=>this.price(e,t)}},C=class e{static{this.country=``}static{this.set=e=>this.country=e}static get phone_pattern(){return this.country.toUpperCase()===`CN`?/([1][3,4,5,6,7,8,9][0-9]{9})$/:/^(?:\+?[1-9]\d{7,14}|\d{6,11})$/}static{this.email_pattern=/^([a-zA-Z0-9_\.-]+)@([\da-zA-Z\.-]+)\.([a-zA-Z\.]{2,6})$/}static{this.idcard_pattern=/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/}static{this.cname_pattern=/^(?:[\u4e00-\u9fa5·]{2,16})$/}static{this.password_pattern=/^(?![A-Za-z]+$)(?![0-9]+$)(?![^A-Za-z0-9]+$).{8,20}$/}static{this.phone=t=>e.phone_pattern.test(t)}static{this.email=t=>e.email_pattern.test(t)}static{this.idcard=t=>e.idcard_pattern.test(t)}static{this.cname=t=>e.cname_pattern.test(t)}},w=c(o(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?t.exports=r():typeof define==`function`&&define.amd?define(r):(n=typeof globalThis<`u`?globalThis:n||self).dayjs=r()})(e,(function(){"use strict";var e=1e3,t=6e4,n=36e5,r=`millisecond`,i=`second`,a=`minute`,o=`hour`,s=`day`,c=`week`,l=`month`,u=`quarter`,d=`year`,f=`date`,p=`Invalid Date`,m=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,h=/\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:`en`,weekdays:`Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday`.split(`_`),months:`January_February_March_April_May_June_July_August_September_October_November_December`.split(`_`),ordinal:function(e){var t=[`th`,`st`,`nd`,`rd`],n=e%100;return`[`+e+(t[(n-20)%10]||t[n]||t[0])+`]`}},_=function(e,t,n){var r=String(e);return!r||r.length>=t?e:``+Array(t+1-r.length).join(n)+e},v={s:_,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?`+`:`-`)+_(r,2,`0`)+`:`+_(i,2,`0`)},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,l),a=n-i<0,o=t.clone().add(r+(a?-1:1),l);return+(-(r+(n-i)/(a?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:l,y:d,w:c,d:s,D:f,h:o,m:a,s:i,ms:r,Q:u}[e]||String(e||``).toLowerCase().replace(/s$/,``)},u:function(e){return e===void 0}},y=`en`,b={};b[y]=g;var x=`$isDayjsObject`,S=function(e){return e instanceof E||!(!e||!e[x])},C=function e(t,n,r){var i;if(!t)return y;if(typeof t==`string`){var a=t.toLowerCase();b[a]&&(i=a),n&&(b[a]=n,i=a);var o=t.split(`-`);if(!i&&o.length>1)return e(o[0])}else{var s=t.name;b[s]=t,i=s}return!r&&i&&(y=i),i||!r&&y},w=function(e,t){if(S(e))return e.clone();var n=typeof t==`object`?t:{};return n.date=e,n.args=arguments,new E(n)},T=v;T.l=C,T.i=S,T.w=function(e,t){return w(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var E=function(){function g(e){this.$L=C(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[x]=!0}var _=g.prototype;return _.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(t===null)return new Date(NaN);if(T.u(t))return new Date;if(t instanceof Date)return new Date(t);if(typeof t==`string`&&!/Z$/i.test(t)){var r=t.match(m);if(r){var i=r[2]-1||0,a=(r[7]||`0`).substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)}}return new Date(t)}(e),this.init()},_.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},_.$utils=function(){return T},_.isValid=function(){return this.$d.toString()!==p},_.isSame=function(e,t){var n=w(e);return this.startOf(t)<=n&&n<=this.endOf(t)},_.isAfter=function(e,t){return w(e)<this.startOf(t)},_.isBefore=function(e,t){return this.endOf(t)<w(e)},_.$g=function(e,t,n){return T.u(e)?this[t]:this.set(n,e)},_.unix=function(){return Math.floor(this.valueOf()/1e3)},_.valueOf=function(){return this.$d.getTime()},_.startOf=function(e,t){var n=this,r=!!T.u(t)||t,u=T.p(e),p=function(e,t){var i=T.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?i:i.endOf(s)},m=function(e,t){return T.w(n.toDate()[e].apply(n.toDate(`s`),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},h=this.$W,g=this.$M,_=this.$D,v=`set`+(this.$u?`UTC`:``);switch(u){case d:return r?p(1,0):p(31,11);case l:return r?p(1,g):p(0,g+1);case c:var y=this.$locale().weekStart||0,b=(h<y?h+7:h)-y;return p(r?_-b:_+(6-b),g);case s:case f:return m(v+`Hours`,0);case o:return m(v+`Minutes`,1);case a:return m(v+`Seconds`,2);case i:return m(v+`Milliseconds`,3);default:return this.clone()}},_.endOf=function(e){return this.startOf(e,!1)},_.$set=function(e,t){var n,c=T.p(e),u=`set`+(this.$u?`UTC`:``),p=(n={},n[s]=u+`Date`,n[f]=u+`Date`,n[l]=u+`Month`,n[d]=u+`FullYear`,n[o]=u+`Hours`,n[a]=u+`Minutes`,n[i]=u+`Seconds`,n[r]=u+`Milliseconds`,n)[c],m=c===s?this.$D+(t-this.$W):t;if(c===l||c===d){var h=this.clone().set(f,1);h.$d[p](m),h.init(),this.$d=h.set(f,Math.min(this.$D,h.daysInMonth())).$d}else p&&this.$d[p](m);return this.init(),this},_.set=function(e,t){return this.clone().$set(e,t)},_.get=function(e){return this[T.p(e)]()},_.add=function(r,u){var f,p=this;r=Number(r);var m=T.p(u),h=function(e){var t=w(p);return T.w(t.date(t.date()+Math.round(e*r)),p)};if(m===l)return this.set(l,this.$M+r);if(m===d)return this.set(d,this.$y+r);if(m===s)return h(1);if(m===c)return h(7);var g=(f={},f[a]=t,f[o]=n,f[i]=e,f)[m]||1,_=this.$d.getTime()+r*g;return T.w(_,this)},_.subtract=function(e,t){return this.add(-1*e,t)},_.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||p;var r=e||`YYYY-MM-DDTHH:mm:ssZ`,i=T.z(this),a=this.$H,o=this.$m,s=this.$M,c=n.weekdays,l=n.months,u=n.meridiem,d=function(e,n,i,a){return e&&(e[n]||e(t,r))||i[n].slice(0,a)},f=function(e){return T.s(a%12||12,e,`0`)},m=u||function(e,t,n){var r=e<12?`AM`:`PM`;return n?r.toLowerCase():r};return r.replace(h,(function(e,r){return r||function(e){switch(e){case`YY`:return String(t.$y).slice(-2);case`YYYY`:return T.s(t.$y,4,`0`);case`M`:return s+1;case`MM`:return T.s(s+1,2,`0`);case`MMM`:return d(n.monthsShort,s,l,3);case`MMMM`:return d(l,s);case`D`:return t.$D;case`DD`:return T.s(t.$D,2,`0`);case`d`:return String(t.$W);case`dd`:return d(n.weekdaysMin,t.$W,c,2);case`ddd`:return d(n.weekdaysShort,t.$W,c,3);case`dddd`:return c[t.$W];case`H`:return String(a);case`HH`:return T.s(a,2,`0`);case`h`:return f(1);case`hh`:return f(2);case`a`:return m(a,o,!0);case`A`:return m(a,o,!1);case`m`:return String(o);case`mm`:return T.s(o,2,`0`);case`s`:return String(t.$s);case`ss`:return T.s(t.$s,2,`0`);case`SSS`:return T.s(t.$ms,3,`0`);case`Z`:return i}return null}(e)||i.replace(`:`,``)}))},_.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},_.diff=function(r,f,p){var m,h=this,g=T.p(f),_=w(r),v=(_.utcOffset()-this.utcOffset())*t,y=this-_,b=function(){return T.m(h,_)};switch(g){case d:m=b()/12;break;case l:m=b();break;case u:m=b()/3;break;case c:m=(y-v)/6048e5;break;case s:m=(y-v)/864e5;break;case o:m=y/n;break;case a:m=y/t;break;case i:m=y/e;break;default:m=y}return p?m:T.a(m)},_.daysInMonth=function(){return this.endOf(l).$D},_.$locale=function(){return b[this.$L]},_.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=C(e,t,!0);return r&&(n.$L=r),n},_.clone=function(){return T.w(this.$d,this)},_.toDate=function(){return new Date(this.valueOf())},_.toJSON=function(){return this.isValid()?this.toISOString():null},_.toISOString=function(){return this.$d.toISOString()},_.toString=function(){return this.$d.toUTCString()},g}(),D=E.prototype;return w.prototype=D,[[`$ms`,r],[`$s`,i],[`$m`,a],[`$H`,o],[`$W`,s],[`$M`,l],[`$y`,d],[`$D`,f]].forEach((function(e){D[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),w.extend=function(e,t){return e.$i||=(e(t,E,w),!0),w},w.locale=C,w.isDayjs=S,w.unix=function(e){return w(1e3*e)},w.en=b[y],w.Ls=b,w.p={},w}))}))(),1),T=class e{static{this.dayjs=w.default}static s(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD HH:mm:ss`.replace(/\//g,n))}static m(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD HH:mm`.replace(/\//g,n))}static h(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD HH`.replace(/\//g,n))}static d(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD`.replace(/\//g,n))}static M(t,n=`/`){return e.dayjs(t).format(`YYYY/MM`.replace(/\//g,n))}static y(t){return e.dayjs(t).format(`YYYY`)}static date(t,n=`/`){return e.dayjs(t).format(`YYYY/MM/DD`.replace(/\//g,n))}static time(t){return e.dayjs(t).format(`HH:mm`)}static format(t,n=`YYYY/MM/DD HH:mm:ss`){return e.dayjs(t).format(n)}},E=class e{static get userAgent(){return window.navigator.userAgent.toLowerCase()}static get isFlutter(){return e.userAgent.match(/flutter/i)!==null}static get isFlutterIOS(){return e.isFlutter&&e.isIOS}static get isWeb(){return window.matchMedia(`(min-width: 992px)`).matches}static get isMobile(){return e.userAgent.match(/(phone|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)!==null}static get isIOS(){return e.userAgent.match(/iphone|ipad|ipod|ios/i)!==null}static get isWechat(){return e.userAgent.match(/MicroMessenger/i)!==null}static get isWxwork(){return e.userAgent.match(/MicroMessenger/i)!==null&&e.userAgent.match(/wxwork/i)!==null}static get isMiniprogram(){return e.userAgent.match(/MicroMessenger/i)!==null&&e.userAgent.match(/miniprogram/i)!==null}},D=768,O=()=>{let e=(0,l.ref)(typeof window<`u`?window.matchMedia(`(min-width: ${D}px)`).matches:!0),t,n=t=>e.value=t.matches;(0,l.onMounted)(()=>{typeof window>`u`||(t=window.matchMedia(`(min-width: ${D}px)`),e.value=t.matches,t.addEventListener(`change`,n))}),(0,l.onBeforeUnmount)(()=>t?.removeEventListener(`change`,n));let r=(0,l.computed)(()=>e.value);return{isMobile:(0,l.computed)(()=>!e.value),isDesktop:r}},k=e=>{let t=(0,l.ref)(0),n=(0,l.ref)(!1),r=(t={})=>new Promise((r,a)=>{n.value||(n.value=!0,e(t).then(()=>{i(),r(!0)}).catch(e=>a(e)).finally(()=>n.value=!1))}),i=()=>{t.value=60;let e=setInterval(()=>{t.value--,t.value||clearTimeout(e)},1e3)};return{waiting:t,send:r}},A=()=>({i:(e,t={})=>e?(0,l.h)(x,{icon:e,...t}):void 0}),j=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,M=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=j[n[e]&63];return t},N=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i-->0;)r+=e[Math.random()*e.length|0];return r},P=()=>({nanoid:M,numeric:(e=10)=>N(`1234567890`,e)()}),F=[x];F.forEach(e=>{e.install=t=>{let n=e.name??e.__name;n&&t.component(n,e)}});var I={install(e,t){_(t),F.forEach(t=>e.use(t))}};exports.DateTime=T,exports.Formatter=S,exports.Platform=E,exports.Validate=C,exports.VueIcon=x,exports.default=I,exports.getLocale=b,exports.setLocale=y,exports.useBreak=O,exports.useCaptcha=k,exports.useIcon=A,exports.useLocale=v,exports.useNanoid=P;
package/dist/vue.d.ts CHANGED
@@ -1,11 +1,26 @@
1
1
  import { ComponentOptionsMixin } from 'vue';
2
2
  import { ComponentProvideOptions } from 'vue';
3
+ import { default as default_2 } from 'dayjs';
3
4
  import { DefineComponent } from 'vue';
5
+ import { nanoid } from 'nanoid';
4
6
  import { Plugin as Plugin_2 } from 'vue';
5
7
  import { PublicProps } from 'vue';
6
8
  import { RendererElement } from 'vue';
7
9
  import { RendererNode } from 'vue';
8
10
 
11
+ export declare class DateTime {
12
+ static dayjs: typeof default_2;
13
+ static s(date?: default_2.ConfigType, symbol?: string): string;
14
+ static m(date?: default_2.ConfigType, symbol?: string): string;
15
+ static h(date?: default_2.ConfigType, symbol?: string): string;
16
+ static d(date?: default_2.ConfigType, symbol?: string): string;
17
+ static M(date?: default_2.ConfigType, symbol?: string): string;
18
+ static y(date?: default_2.ConfigType): string;
19
+ static date(date?: default_2.ConfigType, symbol?: string): string;
20
+ static time(date?: default_2.ConfigType): string;
21
+ static format(date?: default_2.ConfigType, format?: string): string;
22
+ }
23
+
9
24
  export declare class Formatter {
10
25
  static config: {
11
26
  locale?: string;
@@ -117,6 +132,18 @@ export declare interface IUploadUserFile {
117
132
  mimeType?: string;
118
133
  }
119
134
 
135
+ export declare class Platform {
136
+ static get userAgent(): string;
137
+ static get isFlutter(): boolean;
138
+ static get isFlutterIOS(): boolean;
139
+ static get isWeb(): boolean;
140
+ static get isMobile(): boolean;
141
+ static get isIOS(): boolean;
142
+ static get isWechat(): boolean;
143
+ static get isWxwork(): boolean;
144
+ static get isMiniprogram(): boolean;
145
+ }
146
+
120
147
  export declare const setLocale: (lang: string) => string;
121
148
 
122
149
  declare const useBreak_2: () => {
@@ -143,6 +170,12 @@ export declare const useLocale: () => {
143
170
  t: (path: string, params?: Record<string, string | number>) => string;
144
171
  };
145
172
 
173
+ declare const useNanoid_2: () => {
174
+ nanoid: typeof nanoid;
175
+ numeric: (length?: number) => string;
176
+ };
177
+ export { useNanoid_2 as useNanoid }
178
+
146
179
  export declare class Validate {
147
180
  static country: string;
148
181
  static set: (country: string) => string;
package/dist/vue.mjs CHANGED
@@ -1,7 +1,16 @@
1
1
  import { computed as e, createBlock as t, defineComponent as n, h as r, inject as i, normalizeStyle as a, onBeforeUnmount as o, onMounted as s, openBlock as c, provide as l, reactive as u, ref as d, unref as f, useCssVars as p } from "vue";
2
2
  import { Icon as m } from "@iconify/vue";
3
- //#region src/locale/zh-CN.ts
4
- var h = {
3
+ //#region \0rolldown/runtime.js
4
+ var h = Object.create, g = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, v = Object.getOwnPropertyNames, y = Object.getPrototypeOf, b = Object.prototype.hasOwnProperty, x = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), S = (e, t, n, r) => {
5
+ if (t && typeof t == "object" || typeof t == "function") for (var i = v(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !b.call(e, s) && s !== n && g(e, s, {
6
+ get: ((e) => t[e]).bind(null, s),
7
+ enumerable: !(r = _(t, s)) || r.enumerable
8
+ });
9
+ return e;
10
+ }, C = (e, t, n) => (n = e == null ? {} : h(y(e)), S(t || !e || !e.__esModule ? g(n, "default", {
11
+ value: e,
12
+ enumerable: !0
13
+ }) : n, e)), w = {
5
14
  cancel: "取消",
6
15
  confirm: "确认",
7
16
  empty: { noData: "暂无数据" },
@@ -9,7 +18,7 @@ var h = {
9
18
  tip: "操作提示",
10
19
  confirm: "操作确认"
11
20
  }
12
- }, g = {
21
+ }, T = {
13
22
  cancel: "Cancel",
14
23
  confirm: "Confirm",
15
24
  empty: { noData: "No data" },
@@ -17,23 +26,23 @@ var h = {
17
26
  tip: "Tip",
18
27
  confirm: "Confirm"
19
28
  }
20
- }, _ = () => {
29
+ }, E = () => {
21
30
  let e = ["en", "zh-CN"], t = localStorage.getItem("locale"), n = navigator.language;
22
31
  return t && e.includes(t) ? t : n && e.includes(n) ? n : n && e.includes(n.split("-")[0]) ? n.split("-")[0] : e[0] ?? "zh-CN";
23
- }, v = Symbol("vue-locale"), y = d(_()), b = u({
24
- en: g,
25
- "zh-CN": h
26
- }), x = (e) => {
27
- if (e?.locale && (y.value = e.locale), e?.messages) for (let [t, n] of Object.entries(e.messages)) b[t] = n;
28
- return l(v, {
29
- locale: y,
30
- messages: b
32
+ }, D = Symbol("vue-locale"), O = d(E()), k = u({
33
+ en: T,
34
+ "zh-CN": w
35
+ }), A = (e) => {
36
+ if (e?.locale && (O.value = e.locale), e?.messages) for (let [t, n] of Object.entries(e.messages)) k[t] = n;
37
+ return l(D, {
38
+ locale: O,
39
+ messages: k
31
40
  }), {
32
- locale: y,
33
- messages: b
41
+ locale: O,
42
+ messages: k
34
43
  };
35
- }, S = () => {
36
- let e = i(v, void 0), t = e?.locale ?? y, n = e?.messages ?? b;
44
+ }, j = () => {
45
+ let e = i(D, void 0), t = e?.locale ?? O, n = e?.messages ?? k;
37
46
  return {
38
47
  locale: t,
39
48
  t: (e, r) => {
@@ -43,7 +52,7 @@ var h = {
43
52
  return r && typeof s == "string" && (s = s.replace(/\{(\w+)\}/g, (e, t) => r[t] === void 0 ? `{${t}}` : String(r[t]))), s;
44
53
  }
45
54
  };
46
- }, C = (e) => y.value = e, w = () => y.value, T = /* @__PURE__ */ ((e, t) => {
55
+ }, M = (e) => O.value = e, N = () => O.value, P = /*#__PURE__*/ ((e, t) => {
47
56
  let n = e.__vccOpts || e;
48
57
  for (let [e, r] of t) n[e] = r;
49
58
  return n;
@@ -165,7 +174,7 @@ var h = {
165
174
  "style"
166
175
  ]));
167
176
  }
168
- }), [["__scopeId", "data-v-e336ca96"]]), E = class {
177
+ }), [["__scopeId", "data-v-e336ca96"]]), F = class {
169
178
  static {
170
179
  this.config = {};
171
180
  }
@@ -210,7 +219,7 @@ var h = {
210
219
  static {
211
220
  this.currency = (e = 0, t) => this.price(e, t);
212
221
  }
213
- }, D = class e {
222
+ }, I = class e {
214
223
  static {
215
224
  this.country = "";
216
225
  }
@@ -244,17 +253,370 @@ var h = {
244
253
  static {
245
254
  this.cname = (t) => e.cname_pattern.test(t);
246
255
  }
247
- }, O = 768, k = () => {
248
- let t = d(typeof window < "u" ? window.matchMedia(`(min-width: ${O}px)`).matches : !0), n, r = (e) => t.value = e.matches;
256
+ }, L = /* @__PURE__ */ C((/* @__PURE__ */ x(((e, t) => {
257
+ (function(n, r) {
258
+ typeof e == "object" && t !== void 0 ? t.exports = r() : typeof define == "function" && define.amd ? define(r) : (n = typeof globalThis < "u" ? globalThis : n || self).dayjs = r();
259
+ })(e, (function() {
260
+ var e = 1e3, t = 6e4, n = 36e5, r = "millisecond", i = "second", a = "minute", o = "hour", s = "day", c = "week", l = "month", u = "quarter", d = "year", f = "date", p = "Invalid Date", m = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, h = /\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, g = {
261
+ name: "en",
262
+ weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
263
+ months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
264
+ ordinal: function(e) {
265
+ var t = [
266
+ "th",
267
+ "st",
268
+ "nd",
269
+ "rd"
270
+ ], n = e % 100;
271
+ return "[" + e + (t[(n - 20) % 10] || t[n] || t[0]) + "]";
272
+ }
273
+ }, _ = function(e, t, n) {
274
+ var r = String(e);
275
+ return !r || r.length >= t ? e : "" + Array(t + 1 - r.length).join(n) + e;
276
+ }, v = {
277
+ s: _,
278
+ z: function(e) {
279
+ var t = -e.utcOffset(), n = Math.abs(t), r = Math.floor(n / 60), i = n % 60;
280
+ return (t <= 0 ? "+" : "-") + _(r, 2, "0") + ":" + _(i, 2, "0");
281
+ },
282
+ m: function e(t, n) {
283
+ if (t.date() < n.date()) return -e(n, t);
284
+ var r = 12 * (n.year() - t.year()) + (n.month() - t.month()), i = t.clone().add(r, l), a = n - i < 0, o = t.clone().add(r + (a ? -1 : 1), l);
285
+ return +(-(r + (n - i) / (a ? i - o : o - i)) || 0);
286
+ },
287
+ a: function(e) {
288
+ return e < 0 ? Math.ceil(e) || 0 : Math.floor(e);
289
+ },
290
+ p: function(e) {
291
+ return {
292
+ M: l,
293
+ y: d,
294
+ w: c,
295
+ d: s,
296
+ D: f,
297
+ h: o,
298
+ m: a,
299
+ s: i,
300
+ ms: r,
301
+ Q: u
302
+ }[e] || String(e || "").toLowerCase().replace(/s$/, "");
303
+ },
304
+ u: function(e) {
305
+ return e === void 0;
306
+ }
307
+ }, y = "en", b = {};
308
+ b[y] = g;
309
+ var x = "$isDayjsObject", S = function(e) {
310
+ return e instanceof E || !(!e || !e[x]);
311
+ }, C = function e(t, n, r) {
312
+ var i;
313
+ if (!t) return y;
314
+ if (typeof t == "string") {
315
+ var a = t.toLowerCase();
316
+ b[a] && (i = a), n && (b[a] = n, i = a);
317
+ var o = t.split("-");
318
+ if (!i && o.length > 1) return e(o[0]);
319
+ } else {
320
+ var s = t.name;
321
+ b[s] = t, i = s;
322
+ }
323
+ return !r && i && (y = i), i || !r && y;
324
+ }, w = function(e, t) {
325
+ if (S(e)) return e.clone();
326
+ var n = typeof t == "object" ? t : {};
327
+ return n.date = e, n.args = arguments, new E(n);
328
+ }, T = v;
329
+ T.l = C, T.i = S, T.w = function(e, t) {
330
+ return w(e, {
331
+ locale: t.$L,
332
+ utc: t.$u,
333
+ x: t.$x,
334
+ $offset: t.$offset
335
+ });
336
+ };
337
+ var E = function() {
338
+ function g(e) {
339
+ this.$L = C(e.locale, null, !0), this.parse(e), this.$x = this.$x || e.x || {}, this[x] = !0;
340
+ }
341
+ var _ = g.prototype;
342
+ return _.parse = function(e) {
343
+ this.$d = function(e) {
344
+ var t = e.date, n = e.utc;
345
+ if (t === null) return /* @__PURE__ */ new Date(NaN);
346
+ if (T.u(t)) return /* @__PURE__ */ new Date();
347
+ if (t instanceof Date) return new Date(t);
348
+ if (typeof t == "string" && !/Z$/i.test(t)) {
349
+ var r = t.match(m);
350
+ if (r) {
351
+ var i = r[2] - 1 || 0, a = (r[7] || "0").substring(0, 3);
352
+ return n ? new Date(Date.UTC(r[1], i, r[3] || 1, r[4] || 0, r[5] || 0, r[6] || 0, a)) : new Date(r[1], i, r[3] || 1, r[4] || 0, r[5] || 0, r[6] || 0, a);
353
+ }
354
+ }
355
+ return new Date(t);
356
+ }(e), this.init();
357
+ }, _.init = function() {
358
+ var e = this.$d;
359
+ this.$y = e.getFullYear(), this.$M = e.getMonth(), this.$D = e.getDate(), this.$W = e.getDay(), this.$H = e.getHours(), this.$m = e.getMinutes(), this.$s = e.getSeconds(), this.$ms = e.getMilliseconds();
360
+ }, _.$utils = function() {
361
+ return T;
362
+ }, _.isValid = function() {
363
+ return this.$d.toString() !== p;
364
+ }, _.isSame = function(e, t) {
365
+ var n = w(e);
366
+ return this.startOf(t) <= n && n <= this.endOf(t);
367
+ }, _.isAfter = function(e, t) {
368
+ return w(e) < this.startOf(t);
369
+ }, _.isBefore = function(e, t) {
370
+ return this.endOf(t) < w(e);
371
+ }, _.$g = function(e, t, n) {
372
+ return T.u(e) ? this[t] : this.set(n, e);
373
+ }, _.unix = function() {
374
+ return Math.floor(this.valueOf() / 1e3);
375
+ }, _.valueOf = function() {
376
+ return this.$d.getTime();
377
+ }, _.startOf = function(e, t) {
378
+ var n = this, r = !!T.u(t) || t, u = T.p(e), p = function(e, t) {
379
+ var i = T.w(n.$u ? Date.UTC(n.$y, t, e) : new Date(n.$y, t, e), n);
380
+ return r ? i : i.endOf(s);
381
+ }, m = function(e, t) {
382
+ return T.w(n.toDate()[e].apply(n.toDate("s"), (r ? [
383
+ 0,
384
+ 0,
385
+ 0,
386
+ 0
387
+ ] : [
388
+ 23,
389
+ 59,
390
+ 59,
391
+ 999
392
+ ]).slice(t)), n);
393
+ }, h = this.$W, g = this.$M, _ = this.$D, v = "set" + (this.$u ? "UTC" : "");
394
+ switch (u) {
395
+ case d: return r ? p(1, 0) : p(31, 11);
396
+ case l: return r ? p(1, g) : p(0, g + 1);
397
+ case c:
398
+ var y = this.$locale().weekStart || 0, b = (h < y ? h + 7 : h) - y;
399
+ return p(r ? _ - b : _ + (6 - b), g);
400
+ case s:
401
+ case f: return m(v + "Hours", 0);
402
+ case o: return m(v + "Minutes", 1);
403
+ case a: return m(v + "Seconds", 2);
404
+ case i: return m(v + "Milliseconds", 3);
405
+ default: return this.clone();
406
+ }
407
+ }, _.endOf = function(e) {
408
+ return this.startOf(e, !1);
409
+ }, _.$set = function(e, t) {
410
+ var n, c = T.p(e), u = "set" + (this.$u ? "UTC" : ""), p = (n = {}, n[s] = u + "Date", n[f] = u + "Date", n[l] = u + "Month", n[d] = u + "FullYear", n[o] = u + "Hours", n[a] = u + "Minutes", n[i] = u + "Seconds", n[r] = u + "Milliseconds", n)[c], m = c === s ? this.$D + (t - this.$W) : t;
411
+ if (c === l || c === d) {
412
+ var h = this.clone().set(f, 1);
413
+ h.$d[p](m), h.init(), this.$d = h.set(f, Math.min(this.$D, h.daysInMonth())).$d;
414
+ } else p && this.$d[p](m);
415
+ return this.init(), this;
416
+ }, _.set = function(e, t) {
417
+ return this.clone().$set(e, t);
418
+ }, _.get = function(e) {
419
+ return this[T.p(e)]();
420
+ }, _.add = function(r, u) {
421
+ var f, p = this;
422
+ r = Number(r);
423
+ var m = T.p(u), h = function(e) {
424
+ var t = w(p);
425
+ return T.w(t.date(t.date() + Math.round(e * r)), p);
426
+ };
427
+ if (m === l) return this.set(l, this.$M + r);
428
+ if (m === d) return this.set(d, this.$y + r);
429
+ if (m === s) return h(1);
430
+ if (m === c) return h(7);
431
+ var g = (f = {}, f[a] = t, f[o] = n, f[i] = e, f)[m] || 1, _ = this.$d.getTime() + r * g;
432
+ return T.w(_, this);
433
+ }, _.subtract = function(e, t) {
434
+ return this.add(-1 * e, t);
435
+ }, _.format = function(e) {
436
+ var t = this, n = this.$locale();
437
+ if (!this.isValid()) return n.invalidDate || p;
438
+ var r = e || "YYYY-MM-DDTHH:mm:ssZ", i = T.z(this), a = this.$H, o = this.$m, s = this.$M, c = n.weekdays, l = n.months, u = n.meridiem, d = function(e, n, i, a) {
439
+ return e && (e[n] || e(t, r)) || i[n].slice(0, a);
440
+ }, f = function(e) {
441
+ return T.s(a % 12 || 12, e, "0");
442
+ }, m = u || function(e, t, n) {
443
+ var r = e < 12 ? "AM" : "PM";
444
+ return n ? r.toLowerCase() : r;
445
+ };
446
+ return r.replace(h, (function(e, r) {
447
+ return r || function(e) {
448
+ switch (e) {
449
+ case "YY": return String(t.$y).slice(-2);
450
+ case "YYYY": return T.s(t.$y, 4, "0");
451
+ case "M": return s + 1;
452
+ case "MM": return T.s(s + 1, 2, "0");
453
+ case "MMM": return d(n.monthsShort, s, l, 3);
454
+ case "MMMM": return d(l, s);
455
+ case "D": return t.$D;
456
+ case "DD": return T.s(t.$D, 2, "0");
457
+ case "d": return String(t.$W);
458
+ case "dd": return d(n.weekdaysMin, t.$W, c, 2);
459
+ case "ddd": return d(n.weekdaysShort, t.$W, c, 3);
460
+ case "dddd": return c[t.$W];
461
+ case "H": return String(a);
462
+ case "HH": return T.s(a, 2, "0");
463
+ case "h": return f(1);
464
+ case "hh": return f(2);
465
+ case "a": return m(a, o, !0);
466
+ case "A": return m(a, o, !1);
467
+ case "m": return String(o);
468
+ case "mm": return T.s(o, 2, "0");
469
+ case "s": return String(t.$s);
470
+ case "ss": return T.s(t.$s, 2, "0");
471
+ case "SSS": return T.s(t.$ms, 3, "0");
472
+ case "Z": return i;
473
+ }
474
+ return null;
475
+ }(e) || i.replace(":", "");
476
+ }));
477
+ }, _.utcOffset = function() {
478
+ return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
479
+ }, _.diff = function(r, f, p) {
480
+ var m, h = this, g = T.p(f), _ = w(r), v = (_.utcOffset() - this.utcOffset()) * t, y = this - _, b = function() {
481
+ return T.m(h, _);
482
+ };
483
+ switch (g) {
484
+ case d:
485
+ m = b() / 12;
486
+ break;
487
+ case l:
488
+ m = b();
489
+ break;
490
+ case u:
491
+ m = b() / 3;
492
+ break;
493
+ case c:
494
+ m = (y - v) / 6048e5;
495
+ break;
496
+ case s:
497
+ m = (y - v) / 864e5;
498
+ break;
499
+ case o:
500
+ m = y / n;
501
+ break;
502
+ case a:
503
+ m = y / t;
504
+ break;
505
+ case i:
506
+ m = y / e;
507
+ break;
508
+ default: m = y;
509
+ }
510
+ return p ? m : T.a(m);
511
+ }, _.daysInMonth = function() {
512
+ return this.endOf(l).$D;
513
+ }, _.$locale = function() {
514
+ return b[this.$L];
515
+ }, _.locale = function(e, t) {
516
+ if (!e) return this.$L;
517
+ var n = this.clone(), r = C(e, t, !0);
518
+ return r && (n.$L = r), n;
519
+ }, _.clone = function() {
520
+ return T.w(this.$d, this);
521
+ }, _.toDate = function() {
522
+ return new Date(this.valueOf());
523
+ }, _.toJSON = function() {
524
+ return this.isValid() ? this.toISOString() : null;
525
+ }, _.toISOString = function() {
526
+ return this.$d.toISOString();
527
+ }, _.toString = function() {
528
+ return this.$d.toUTCString();
529
+ }, g;
530
+ }(), D = E.prototype;
531
+ return w.prototype = D, [
532
+ ["$ms", r],
533
+ ["$s", i],
534
+ ["$m", a],
535
+ ["$H", o],
536
+ ["$W", s],
537
+ ["$M", l],
538
+ ["$y", d],
539
+ ["$D", f]
540
+ ].forEach((function(e) {
541
+ D[e[1]] = function(t) {
542
+ return this.$g(t, e[0], e[1]);
543
+ };
544
+ })), w.extend = function(e, t) {
545
+ return e.$i ||= (e(t, E, w), !0), w;
546
+ }, w.locale = C, w.isDayjs = S, w.unix = function(e) {
547
+ return w(1e3 * e);
548
+ }, w.en = b[y], w.Ls = b, w.p = {}, w;
549
+ }));
550
+ })))(), 1), R = class e {
551
+ static {
552
+ this.dayjs = L.default;
553
+ }
554
+ static s(t, n = "/") {
555
+ return e.dayjs(t).format("YYYY/MM/DD HH:mm:ss".replace(/\//g, n));
556
+ }
557
+ static m(t, n = "/") {
558
+ return e.dayjs(t).format("YYYY/MM/DD HH:mm".replace(/\//g, n));
559
+ }
560
+ static h(t, n = "/") {
561
+ return e.dayjs(t).format("YYYY/MM/DD HH".replace(/\//g, n));
562
+ }
563
+ static d(t, n = "/") {
564
+ return e.dayjs(t).format("YYYY/MM/DD".replace(/\//g, n));
565
+ }
566
+ static M(t, n = "/") {
567
+ return e.dayjs(t).format("YYYY/MM".replace(/\//g, n));
568
+ }
569
+ static y(t) {
570
+ return e.dayjs(t).format("YYYY");
571
+ }
572
+ static date(t, n = "/") {
573
+ return e.dayjs(t).format("YYYY/MM/DD".replace(/\//g, n));
574
+ }
575
+ static time(t) {
576
+ return e.dayjs(t).format("HH:mm");
577
+ }
578
+ static format(t, n = "YYYY/MM/DD HH:mm:ss") {
579
+ return e.dayjs(t).format(n);
580
+ }
581
+ }, z = class e {
582
+ static get userAgent() {
583
+ return window.navigator.userAgent.toLowerCase();
584
+ }
585
+ static get isFlutter() {
586
+ return e.userAgent.match(/flutter/i) !== null;
587
+ }
588
+ static get isFlutterIOS() {
589
+ return e.isFlutter && e.isIOS;
590
+ }
591
+ static get isWeb() {
592
+ return window.matchMedia("(min-width: 992px)").matches;
593
+ }
594
+ static get isMobile() {
595
+ return e.userAgent.match(/(phone|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i) !== null;
596
+ }
597
+ static get isIOS() {
598
+ return e.userAgent.match(/iphone|ipad|ipod|ios/i) !== null;
599
+ }
600
+ static get isWechat() {
601
+ return e.userAgent.match(/MicroMessenger/i) !== null;
602
+ }
603
+ static get isWxwork() {
604
+ return e.userAgent.match(/MicroMessenger/i) !== null && e.userAgent.match(/wxwork/i) !== null;
605
+ }
606
+ static get isMiniprogram() {
607
+ return e.userAgent.match(/MicroMessenger/i) !== null && e.userAgent.match(/miniprogram/i) !== null;
608
+ }
609
+ }, B = 768, V = () => {
610
+ let t = d(typeof window < "u" ? window.matchMedia(`(min-width: ${B}px)`).matches : !0), n, r = (e) => t.value = e.matches;
249
611
  s(() => {
250
- typeof window > "u" || (n = window.matchMedia(`(min-width: ${O}px)`), t.value = n.matches, n.addEventListener("change", r));
612
+ typeof window > "u" || (n = window.matchMedia(`(min-width: ${B}px)`), t.value = n.matches, n.addEventListener("change", r));
251
613
  }), o(() => n?.removeEventListener("change", r));
252
614
  let i = e(() => t.value);
253
615
  return {
254
616
  isMobile: e(() => !t.value),
255
617
  isDesktop: i
256
618
  };
257
- }, A = (e) => {
619
+ }, H = (e) => {
258
620
  let t = d(0), n = d(!1), r = (t = {}) => new Promise((r, a) => {
259
621
  n.value || (n.value = !0, e(t).then(() => {
260
622
  i(), r(!0);
@@ -269,18 +631,29 @@ var h = {
269
631
  waiting: t,
270
632
  send: r
271
633
  };
272
- }, j = () => ({ i: (e, t = {}) => e ? r(T, {
634
+ }, U = () => ({ i: (e, t = {}) => e ? r(P, {
273
635
  icon: e,
274
636
  ...t
275
- }) : void 0 }), M = [T];
276
- M.forEach((e) => {
637
+ }) : void 0 }), W = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", G = (e = 21) => {
638
+ let t = "", n = crypto.getRandomValues(new Uint8Array(e |= 0));
639
+ for (; e--;) t += W[n[e] & 63];
640
+ return t;
641
+ }, K = (e, t = 21) => (n = t) => {
642
+ let r = "", i = n | 0;
643
+ for (; i-- > 0;) r += e[Math.random() * e.length | 0];
644
+ return r;
645
+ }, q = () => ({
646
+ nanoid: G,
647
+ numeric: (e = 10) => K("1234567890", e)()
648
+ }), J = [P];
649
+ J.forEach((e) => {
277
650
  e.install = (t) => {
278
651
  let n = e.name ?? e.__name;
279
652
  n && t.component(n, e);
280
653
  };
281
654
  });
282
- var N = { install(e, t) {
283
- x(t), M.forEach((t) => e.use(t));
655
+ var Y = { install(e, t) {
656
+ A(t), J.forEach((t) => e.use(t));
284
657
  } };
285
658
  //#endregion
286
- export { E as Formatter, D as Validate, T as VueIcon, N as default, w as getLocale, C as setLocale, k as useBreak, A as useCaptcha, j as useIcon, S as useLocale };
659
+ export { R as DateTime, F as Formatter, z as Platform, I as Validate, P as VueIcon, Y as default, N as getLocale, M as setLocale, V as useBreak, H as useCaptcha, U as useIcon, j as useLocale, q as useNanoid };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gindow/vue",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Vue3 通用基础包,包含工具函数、Hooks、类型定义、国际化、基础样式",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -8,16 +8,22 @@
8
8
  "types": "./dist/vue.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
+ "@source": "./src/index.ts",
11
12
  "types": "./dist/vue.d.ts",
12
13
  "import": "./dist/vue.mjs",
13
14
  "require": "./dist/vue.cjs"
14
15
  },
15
16
  "./resolver": {
17
+ "@source": "./src/resolver.ts",
16
18
  "types": "./dist/resolver.d.ts",
17
19
  "import": "./dist/resolver.mjs",
18
20
  "require": "./dist/resolver.cjs"
19
21
  },
20
- "./style.css": "./dist/style.css",
22
+ "./style.css": {
23
+ "@source": "./src/style.css",
24
+ "import": "./dist/style.css",
25
+ "require": "./dist/style.css"
26
+ },
21
27
  "./src/*": "./src/*",
22
28
  "./package.json": "./package.json"
23
29
  },
@@ -34,25 +40,35 @@
34
40
  },
35
41
  "peerDependencies": {
36
42
  "@iconify/vue": "^5.0.0",
43
+ "dayjs": "^1.11.0",
44
+ "nanoid": "^5.0.0",
37
45
  "vue": "^3.5.0"
38
46
  },
39
47
  "peerDependenciesMeta": {
40
48
  "@iconify/vue": {
41
49
  "optional": true
50
+ },
51
+ "dayjs": {
52
+ "optional": true
53
+ },
54
+ "nanoid": {
55
+ "optional": true
42
56
  }
43
57
  },
44
58
  "devDependencies": {
45
59
  "@iconify/vue": "^5.0.1",
46
- "@tailwindcss/vite": "^4.3.0",
47
- "@types/node": "^22.19.20",
60
+ "@tailwindcss/vite": "^4.3.1",
61
+ "@types/node": "^22.20.0",
48
62
  "@vitejs/plugin-vue": "^6.0.7",
49
63
  "@vue/tsconfig": "^0.5.1",
50
- "tailwindcss": "^4.3.0",
64
+ "dayjs": "^1.11.21",
65
+ "nanoid": "^5.1.16",
66
+ "tailwindcss": "^4.3.1",
51
67
  "typescript": "^5.9.3",
52
68
  "unplugin-auto-import": "^21.0.0",
53
- "vite": "^8.0.16",
69
+ "vite": "^8.1.0",
54
70
  "vite-plugin-dts": "^4.5.4",
55
- "vue": "^3.5.35",
71
+ "vue": "^3.5.39",
56
72
  "vue-tsc": "^2.2.12"
57
73
  }
58
74
  }
@@ -0,0 +1,9 @@
1
+ import { nanoid } from 'nanoid'
2
+ import { customAlphabet } from 'nanoid/non-secure'
3
+
4
+ export const useNanoid = () => {
5
+
6
+ const numeric = (length = 10) => customAlphabet('1234567890', length)()
7
+
8
+ return { nanoid, numeric }
9
+ }
package/src/index.ts CHANGED
@@ -27,6 +27,7 @@ export * from './utils'
27
27
  export { useBreak } from './hooks/useBreak'
28
28
  export { useCaptcha } from './hooks/useCaptcha'
29
29
  export { useIcon } from './hooks/useIcon'
30
+ export { useNanoid } from './hooks/useNanoid'
30
31
 
31
32
  export default Vue
32
33
 
@@ -0,0 +1,42 @@
1
+ import dayjs from 'dayjs'
2
+
3
+ export class DateTime {
4
+
5
+ static dayjs = dayjs
6
+
7
+ static s(date?: dayjs.ConfigType, symbol = '/') {
8
+ return DateTime.dayjs(date).format('YYYY/MM/DD HH:mm:ss'.replace(/\//g, symbol))
9
+ }
10
+
11
+ static m(date?: dayjs.ConfigType, symbol = '/') {
12
+ return DateTime.dayjs(date).format('YYYY/MM/DD HH:mm'.replace(/\//g, symbol))
13
+ }
14
+
15
+ static h(date?: dayjs.ConfigType, symbol = '/') {
16
+ return DateTime.dayjs(date).format('YYYY/MM/DD HH'.replace(/\//g, symbol))
17
+ }
18
+
19
+ static d(date?: dayjs.ConfigType, symbol = '/') {
20
+ return DateTime.dayjs(date).format('YYYY/MM/DD'.replace(/\//g, symbol))
21
+ }
22
+
23
+ static M(date?: dayjs.ConfigType, symbol = '/') {
24
+ return DateTime.dayjs(date).format('YYYY/MM'.replace(/\//g, symbol))
25
+ }
26
+
27
+ static y(date?: dayjs.ConfigType) {
28
+ return DateTime.dayjs(date).format('YYYY')
29
+ }
30
+
31
+ static date(date?: dayjs.ConfigType, symbol = '/') {
32
+ return DateTime.dayjs(date).format('YYYY/MM/DD'.replace(/\//g, symbol))
33
+ }
34
+
35
+ static time(date?: dayjs.ConfigType) {
36
+ return DateTime.dayjs(date).format('HH:mm')
37
+ }
38
+
39
+ static format(date?: dayjs.ConfigType, format = 'YYYY/MM/DD HH:mm:ss') {
40
+ return DateTime.dayjs(date).format(format)
41
+ }
42
+ }
@@ -1,2 +1,4 @@
1
1
  export { Formatter } from './formatter'
2
2
  export { Validate } from './validate'
3
+ export { DateTime } from './datetime'
4
+ export { Platform } from './platform'
@@ -0,0 +1,38 @@
1
+ export class Platform {
2
+
3
+ static get userAgent() {
4
+ return window.navigator.userAgent.toLowerCase()
5
+ }
6
+
7
+ static get isFlutter() {
8
+ return Platform.userAgent.match(/flutter/i) !== null
9
+ }
10
+
11
+ static get isFlutterIOS() {
12
+ return Platform.isFlutter && Platform.isIOS
13
+ }
14
+
15
+ static get isWeb() {
16
+ return window.matchMedia('(min-width: 992px)').matches
17
+ }
18
+
19
+ static get isMobile() {
20
+ return Platform.userAgent.match(/(phone|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i) !== null
21
+ }
22
+
23
+ static get isIOS() {
24
+ return Platform.userAgent.match(/iphone|ipad|ipod|ios/i) !== null
25
+ }
26
+
27
+ static get isWechat() {
28
+ return Platform.userAgent.match(/MicroMessenger/i) !== null
29
+ }
30
+
31
+ static get isWxwork() {
32
+ return Platform.userAgent.match(/MicroMessenger/i) !== null && Platform.userAgent.match(/wxwork/i) !== null
33
+ }
34
+
35
+ static get isMiniprogram() {
36
+ return Platform.userAgent.match(/MicroMessenger/i) !== null && Platform.userAgent.match(/miniprogram/i) !== null
37
+ }
38
+ }