@gindow/vue 1.0.3 → 1.0.5

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/README.md CHANGED
@@ -5,7 +5,7 @@ Vue3 通用基础包,为 `element-go`(桌面端)和 `vant-go`(移动端
5
5
  ## 特性
6
6
 
7
7
  - **工具函数**:`request`(HTTP 请求封装)、`resource`(RESTful 资源)、`DateTime`、`Formatter`、`Validate`、`Platform`、`download`、`get`
8
- - **Hooks**:`useBreak`(响应式断点)、`useNanoid`(ID 生成)、`useCaptcha`(验证码倒计时)、`useUpload`(图片上传处理)、`useChat`(AI 流式对话)
8
+ - **Hooks**:`useBreak`(响应式断点)、`useNanoid`(ID 生成)、`useCaptcha`(验证码倒计时)、`useUpload`(图片上传处理)
9
9
  - **类型定义**:`IModel`、`IAsset`、`IPagination`、`IResult`、`IMenu` 等通用接口
10
10
  - **国际化**:Vue3 provide/inject 模式的 i18n 系统,内置中英文
11
11
  - **基础样式**:TailwindCSS + 通用布局工具类
package/dist/style.css CHANGED
@@ -1,2 +1,2 @@
1
- [data-v-e336ca96] g,[data-v-e336ca96] path{stroke-width:var(--v519ff46c)}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.static{position:static}.shrink{flex-shrink:1}}@media screen and (width>=768px){.mob{display:none!important}}@media screen and (width<=768px){.web{display:none!important}}.bg-light{background-color:#ccc}.text-light{color:#ccc}.dark .bg-light{background-color:#333}.dark .text-light{color:#333}.flex-center{justify-content:center;align-items:center;display:flex!important}.flex-center-end{justify-content:end;align-items:center;display:flex!important}.flex-center-between{justify-content:space-between;align-items:center;display:flex!important}.flex-center-items{align-items:center;display:flex!important}
1
+ [data-v-e336ca96] g,[data-v-e336ca96] path{stroke-width:var(--v519ff46c)}@layer theme{:root,:host{--font-sans:ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--spacing:.25rem;--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.visible{visibility:visible}.static{position:static}.mt-1{margin-top:var(--spacing)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mt-3{margin-top:calc(var(--spacing) * 3)}.h-full{height:100%}.min-h-40{min-height:calc(var(--spacing) * 40)}.min-h-60{min-height:calc(var(--spacing) * 60)}.shrink{flex-shrink:1}.text-center{text-align:center}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}}@media screen and (width>=768px){.mob{display:none!important}}@media screen and (width<=768px){.web{display:none!important}}.bg-light{background-color:#ccc}.text-light{color:#ccc}.dark .bg-light{background-color:#333}.dark .text-light{color:#333}.flex-center{justify-content:center;align-items:center;display:flex!important}.flex-center-end{justify-content:end;align-items:center;display:flex!important}.flex-center-between{justify-content:space-between;align-items:center;display:flex!important}.flex-center-items{align-items:center;display:flex!important}
2
2
  /*$vite$:1*/
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=768,C=()=>{let e=(0,l.ref)(typeof window<`u`?window.matchMedia(`(min-width: ${S}px)`).matches:!0),t,n=t=>e.value=t.matches;(0,l.onMounted)(()=>{typeof window>`u`||(t=window.matchMedia(`(min-width: ${S}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}},w=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}},T=()=>({i:(e,t={})=>e?(0,l.h)(x,{icon:e,...t}):void 0}),E=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,D=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=E[n[e]&63];return t},O=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i-->0;)r+=e[Math.random()*e.length|0];return r},k=()=>({nanoid:D,numeric:(e=10)=>O(`1234567890`,e)()}),A=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)}},j=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)}},M=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),N=class e{static{this.dayjs=M.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)}},P=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}},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=N,exports.Formatter=A,exports.Platform=P,exports.Validate=j,exports.VueIcon=x,exports.default=I,exports.getLocale=b,exports.setLocale=y,exports.useBreak=C,exports.useCaptcha=w,exports.useIcon=T,exports.useLocale=v,exports.useNanoid=k;
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: () => {
@@ -125,7 +152,7 @@ declare const useBreak_2: () => {
125
152
  };
126
153
  export { useBreak_2 as useBreak }
127
154
 
128
- declare const useCaptcha_2: (api: (data: any) => Promise<void>) => {
155
+ declare const useCaptcha_2: (fetch: (data: any) => Promise<void>) => {
129
156
  waiting: globalThis.Ref<number, number>;
130
157
  send: (para?: {}) => Promise<unknown>;
131
158
  };
@@ -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,46 @@ var h = {
165
174
  "style"
166
175
  ]));
167
176
  }
168
- }), [["__scopeId", "data-v-e336ca96"]]), E = class {
177
+ }), [["__scopeId", "data-v-e336ca96"]]), F = 768, I = () => {
178
+ let t = d(typeof window < "u" ? window.matchMedia(`(min-width: ${F}px)`).matches : !0), n, r = (e) => t.value = e.matches;
179
+ s(() => {
180
+ typeof window > "u" || (n = window.matchMedia(`(min-width: ${F}px)`), t.value = n.matches, n.addEventListener("change", r));
181
+ }), o(() => n?.removeEventListener("change", r));
182
+ let i = e(() => t.value);
183
+ return {
184
+ isMobile: e(() => !t.value),
185
+ isDesktop: i
186
+ };
187
+ }, L = (e) => {
188
+ let t = d(0), n = d(!1), r = (t = {}) => new Promise((r, a) => {
189
+ n.value || (n.value = !0, e(t).then(() => {
190
+ i(), r(!0);
191
+ }).catch((e) => a(e)).finally(() => n.value = !1));
192
+ }), i = () => {
193
+ t.value = 60;
194
+ let e = setInterval(() => {
195
+ t.value--, t.value || clearTimeout(e);
196
+ }, 1e3);
197
+ };
198
+ return {
199
+ waiting: t,
200
+ send: r
201
+ };
202
+ }, R = () => ({ i: (e, t = {}) => e ? r(P, {
203
+ icon: e,
204
+ ...t
205
+ }) : void 0 }), z = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict", B = (e = 21) => {
206
+ let t = "", n = crypto.getRandomValues(new Uint8Array(e |= 0));
207
+ for (; e--;) t += z[n[e] & 63];
208
+ return t;
209
+ }, V = (e, t = 21) => (n = t) => {
210
+ let r = "", i = n | 0;
211
+ for (; i-- > 0;) r += e[Math.random() * e.length | 0];
212
+ return r;
213
+ }, H = () => ({
214
+ nanoid: B,
215
+ numeric: (e = 10) => V("1234567890", e)()
216
+ }), U = class {
169
217
  static {
170
218
  this.config = {};
171
219
  }
@@ -210,7 +258,7 @@ var h = {
210
258
  static {
211
259
  this.currency = (e = 0, t) => this.price(e, t);
212
260
  }
213
- }, D = class e {
261
+ }, W = class e {
214
262
  static {
215
263
  this.country = "";
216
264
  }
@@ -244,43 +292,368 @@ var h = {
244
292
  static {
245
293
  this.cname = (t) => e.cname_pattern.test(t);
246
294
  }
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;
249
- s(() => {
250
- typeof window > "u" || (n = window.matchMedia(`(min-width: ${O}px)`), t.value = n.matches, n.addEventListener("change", r));
251
- }), o(() => n?.removeEventListener("change", r));
252
- let i = e(() => t.value);
253
- return {
254
- isMobile: e(() => !t.value),
255
- isDesktop: i
256
- };
257
- }, A = (e) => {
258
- let t = d(0), n = d(!1), r = (t = {}) => new Promise((r, a) => {
259
- n.value || (n.value = !0, e(t).then(() => {
260
- i(), r(!0);
261
- }).catch((e) => a(e)).finally(() => n.value = !1));
262
- }), i = () => {
263
- t.value = 60;
264
- let e = setInterval(() => {
265
- t.value--, t.value || clearTimeout(e);
266
- }, 1e3);
267
- };
268
- return {
269
- waiting: t,
270
- send: r
271
- };
272
- }, j = () => ({ i: (e, t = {}) => e ? r(T, {
273
- icon: e,
274
- ...t
275
- }) : void 0 }), M = [T];
276
- M.forEach((e) => {
295
+ }, G = /* @__PURE__ */ C((/* @__PURE__ */ x(((e, t) => {
296
+ (function(n, r) {
297
+ 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();
298
+ })(e, (function() {
299
+ 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 = {
300
+ name: "en",
301
+ weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
302
+ months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
303
+ ordinal: function(e) {
304
+ var t = [
305
+ "th",
306
+ "st",
307
+ "nd",
308
+ "rd"
309
+ ], n = e % 100;
310
+ return "[" + e + (t[(n - 20) % 10] || t[n] || t[0]) + "]";
311
+ }
312
+ }, _ = function(e, t, n) {
313
+ var r = String(e);
314
+ return !r || r.length >= t ? e : "" + Array(t + 1 - r.length).join(n) + e;
315
+ }, v = {
316
+ s: _,
317
+ z: function(e) {
318
+ var t = -e.utcOffset(), n = Math.abs(t), r = Math.floor(n / 60), i = n % 60;
319
+ return (t <= 0 ? "+" : "-") + _(r, 2, "0") + ":" + _(i, 2, "0");
320
+ },
321
+ m: function e(t, n) {
322
+ if (t.date() < n.date()) return -e(n, t);
323
+ 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);
324
+ return +(-(r + (n - i) / (a ? i - o : o - i)) || 0);
325
+ },
326
+ a: function(e) {
327
+ return e < 0 ? Math.ceil(e) || 0 : Math.floor(e);
328
+ },
329
+ p: function(e) {
330
+ return {
331
+ M: l,
332
+ y: d,
333
+ w: c,
334
+ d: s,
335
+ D: f,
336
+ h: o,
337
+ m: a,
338
+ s: i,
339
+ ms: r,
340
+ Q: u
341
+ }[e] || String(e || "").toLowerCase().replace(/s$/, "");
342
+ },
343
+ u: function(e) {
344
+ return e === void 0;
345
+ }
346
+ }, y = "en", b = {};
347
+ b[y] = g;
348
+ var x = "$isDayjsObject", S = function(e) {
349
+ return e instanceof E || !(!e || !e[x]);
350
+ }, C = function e(t, n, r) {
351
+ var i;
352
+ if (!t) return y;
353
+ if (typeof t == "string") {
354
+ var a = t.toLowerCase();
355
+ b[a] && (i = a), n && (b[a] = n, i = a);
356
+ var o = t.split("-");
357
+ if (!i && o.length > 1) return e(o[0]);
358
+ } else {
359
+ var s = t.name;
360
+ b[s] = t, i = s;
361
+ }
362
+ return !r && i && (y = i), i || !r && y;
363
+ }, w = function(e, t) {
364
+ if (S(e)) return e.clone();
365
+ var n = typeof t == "object" ? t : {};
366
+ return n.date = e, n.args = arguments, new E(n);
367
+ }, T = v;
368
+ T.l = C, T.i = S, T.w = function(e, t) {
369
+ return w(e, {
370
+ locale: t.$L,
371
+ utc: t.$u,
372
+ x: t.$x,
373
+ $offset: t.$offset
374
+ });
375
+ };
376
+ var E = function() {
377
+ function g(e) {
378
+ this.$L = C(e.locale, null, !0), this.parse(e), this.$x = this.$x || e.x || {}, this[x] = !0;
379
+ }
380
+ var _ = g.prototype;
381
+ return _.parse = function(e) {
382
+ this.$d = function(e) {
383
+ var t = e.date, n = e.utc;
384
+ if (t === null) return /* @__PURE__ */ new Date(NaN);
385
+ if (T.u(t)) return /* @__PURE__ */ new Date();
386
+ if (t instanceof Date) return new Date(t);
387
+ if (typeof t == "string" && !/Z$/i.test(t)) {
388
+ var r = t.match(m);
389
+ if (r) {
390
+ var i = r[2] - 1 || 0, a = (r[7] || "0").substring(0, 3);
391
+ 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);
392
+ }
393
+ }
394
+ return new Date(t);
395
+ }(e), this.init();
396
+ }, _.init = function() {
397
+ var e = this.$d;
398
+ 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();
399
+ }, _.$utils = function() {
400
+ return T;
401
+ }, _.isValid = function() {
402
+ return this.$d.toString() !== p;
403
+ }, _.isSame = function(e, t) {
404
+ var n = w(e);
405
+ return this.startOf(t) <= n && n <= this.endOf(t);
406
+ }, _.isAfter = function(e, t) {
407
+ return w(e) < this.startOf(t);
408
+ }, _.isBefore = function(e, t) {
409
+ return this.endOf(t) < w(e);
410
+ }, _.$g = function(e, t, n) {
411
+ return T.u(e) ? this[t] : this.set(n, e);
412
+ }, _.unix = function() {
413
+ return Math.floor(this.valueOf() / 1e3);
414
+ }, _.valueOf = function() {
415
+ return this.$d.getTime();
416
+ }, _.startOf = function(e, t) {
417
+ var n = this, r = !!T.u(t) || t, u = T.p(e), p = function(e, t) {
418
+ var i = T.w(n.$u ? Date.UTC(n.$y, t, e) : new Date(n.$y, t, e), n);
419
+ return r ? i : i.endOf(s);
420
+ }, m = function(e, t) {
421
+ return T.w(n.toDate()[e].apply(n.toDate("s"), (r ? [
422
+ 0,
423
+ 0,
424
+ 0,
425
+ 0
426
+ ] : [
427
+ 23,
428
+ 59,
429
+ 59,
430
+ 999
431
+ ]).slice(t)), n);
432
+ }, h = this.$W, g = this.$M, _ = this.$D, v = "set" + (this.$u ? "UTC" : "");
433
+ switch (u) {
434
+ case d: return r ? p(1, 0) : p(31, 11);
435
+ case l: return r ? p(1, g) : p(0, g + 1);
436
+ case c:
437
+ var y = this.$locale().weekStart || 0, b = (h < y ? h + 7 : h) - y;
438
+ return p(r ? _ - b : _ + (6 - b), g);
439
+ case s:
440
+ case f: return m(v + "Hours", 0);
441
+ case o: return m(v + "Minutes", 1);
442
+ case a: return m(v + "Seconds", 2);
443
+ case i: return m(v + "Milliseconds", 3);
444
+ default: return this.clone();
445
+ }
446
+ }, _.endOf = function(e) {
447
+ return this.startOf(e, !1);
448
+ }, _.$set = function(e, t) {
449
+ 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;
450
+ if (c === l || c === d) {
451
+ var h = this.clone().set(f, 1);
452
+ h.$d[p](m), h.init(), this.$d = h.set(f, Math.min(this.$D, h.daysInMonth())).$d;
453
+ } else p && this.$d[p](m);
454
+ return this.init(), this;
455
+ }, _.set = function(e, t) {
456
+ return this.clone().$set(e, t);
457
+ }, _.get = function(e) {
458
+ return this[T.p(e)]();
459
+ }, _.add = function(r, u) {
460
+ var f, p = this;
461
+ r = Number(r);
462
+ var m = T.p(u), h = function(e) {
463
+ var t = w(p);
464
+ return T.w(t.date(t.date() + Math.round(e * r)), p);
465
+ };
466
+ if (m === l) return this.set(l, this.$M + r);
467
+ if (m === d) return this.set(d, this.$y + r);
468
+ if (m === s) return h(1);
469
+ if (m === c) return h(7);
470
+ var g = (f = {}, f[a] = t, f[o] = n, f[i] = e, f)[m] || 1, _ = this.$d.getTime() + r * g;
471
+ return T.w(_, this);
472
+ }, _.subtract = function(e, t) {
473
+ return this.add(-1 * e, t);
474
+ }, _.format = function(e) {
475
+ var t = this, n = this.$locale();
476
+ if (!this.isValid()) return n.invalidDate || p;
477
+ 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) {
478
+ return e && (e[n] || e(t, r)) || i[n].slice(0, a);
479
+ }, f = function(e) {
480
+ return T.s(a % 12 || 12, e, "0");
481
+ }, m = u || function(e, t, n) {
482
+ var r = e < 12 ? "AM" : "PM";
483
+ return n ? r.toLowerCase() : r;
484
+ };
485
+ return r.replace(h, (function(e, r) {
486
+ return r || function(e) {
487
+ switch (e) {
488
+ case "YY": return String(t.$y).slice(-2);
489
+ case "YYYY": return T.s(t.$y, 4, "0");
490
+ case "M": return s + 1;
491
+ case "MM": return T.s(s + 1, 2, "0");
492
+ case "MMM": return d(n.monthsShort, s, l, 3);
493
+ case "MMMM": return d(l, s);
494
+ case "D": return t.$D;
495
+ case "DD": return T.s(t.$D, 2, "0");
496
+ case "d": return String(t.$W);
497
+ case "dd": return d(n.weekdaysMin, t.$W, c, 2);
498
+ case "ddd": return d(n.weekdaysShort, t.$W, c, 3);
499
+ case "dddd": return c[t.$W];
500
+ case "H": return String(a);
501
+ case "HH": return T.s(a, 2, "0");
502
+ case "h": return f(1);
503
+ case "hh": return f(2);
504
+ case "a": return m(a, o, !0);
505
+ case "A": return m(a, o, !1);
506
+ case "m": return String(o);
507
+ case "mm": return T.s(o, 2, "0");
508
+ case "s": return String(t.$s);
509
+ case "ss": return T.s(t.$s, 2, "0");
510
+ case "SSS": return T.s(t.$ms, 3, "0");
511
+ case "Z": return i;
512
+ }
513
+ return null;
514
+ }(e) || i.replace(":", "");
515
+ }));
516
+ }, _.utcOffset = function() {
517
+ return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
518
+ }, _.diff = function(r, f, p) {
519
+ var m, h = this, g = T.p(f), _ = w(r), v = (_.utcOffset() - this.utcOffset()) * t, y = this - _, b = function() {
520
+ return T.m(h, _);
521
+ };
522
+ switch (g) {
523
+ case d:
524
+ m = b() / 12;
525
+ break;
526
+ case l:
527
+ m = b();
528
+ break;
529
+ case u:
530
+ m = b() / 3;
531
+ break;
532
+ case c:
533
+ m = (y - v) / 6048e5;
534
+ break;
535
+ case s:
536
+ m = (y - v) / 864e5;
537
+ break;
538
+ case o:
539
+ m = y / n;
540
+ break;
541
+ case a:
542
+ m = y / t;
543
+ break;
544
+ case i:
545
+ m = y / e;
546
+ break;
547
+ default: m = y;
548
+ }
549
+ return p ? m : T.a(m);
550
+ }, _.daysInMonth = function() {
551
+ return this.endOf(l).$D;
552
+ }, _.$locale = function() {
553
+ return b[this.$L];
554
+ }, _.locale = function(e, t) {
555
+ if (!e) return this.$L;
556
+ var n = this.clone(), r = C(e, t, !0);
557
+ return r && (n.$L = r), n;
558
+ }, _.clone = function() {
559
+ return T.w(this.$d, this);
560
+ }, _.toDate = function() {
561
+ return new Date(this.valueOf());
562
+ }, _.toJSON = function() {
563
+ return this.isValid() ? this.toISOString() : null;
564
+ }, _.toISOString = function() {
565
+ return this.$d.toISOString();
566
+ }, _.toString = function() {
567
+ return this.$d.toUTCString();
568
+ }, g;
569
+ }(), D = E.prototype;
570
+ return w.prototype = D, [
571
+ ["$ms", r],
572
+ ["$s", i],
573
+ ["$m", a],
574
+ ["$H", o],
575
+ ["$W", s],
576
+ ["$M", l],
577
+ ["$y", d],
578
+ ["$D", f]
579
+ ].forEach((function(e) {
580
+ D[e[1]] = function(t) {
581
+ return this.$g(t, e[0], e[1]);
582
+ };
583
+ })), w.extend = function(e, t) {
584
+ return e.$i ||= (e(t, E, w), !0), w;
585
+ }, w.locale = C, w.isDayjs = S, w.unix = function(e) {
586
+ return w(1e3 * e);
587
+ }, w.en = b[y], w.Ls = b, w.p = {}, w;
588
+ }));
589
+ })))(), 1), K = class e {
590
+ static {
591
+ this.dayjs = G.default;
592
+ }
593
+ static s(t, n = "/") {
594
+ return e.dayjs(t).format("YYYY/MM/DD HH:mm:ss".replace(/\//g, n));
595
+ }
596
+ static m(t, n = "/") {
597
+ return e.dayjs(t).format("YYYY/MM/DD HH:mm".replace(/\//g, n));
598
+ }
599
+ static h(t, n = "/") {
600
+ return e.dayjs(t).format("YYYY/MM/DD HH".replace(/\//g, n));
601
+ }
602
+ static d(t, n = "/") {
603
+ return e.dayjs(t).format("YYYY/MM/DD".replace(/\//g, n));
604
+ }
605
+ static M(t, n = "/") {
606
+ return e.dayjs(t).format("YYYY/MM".replace(/\//g, n));
607
+ }
608
+ static y(t) {
609
+ return e.dayjs(t).format("YYYY");
610
+ }
611
+ static date(t, n = "/") {
612
+ return e.dayjs(t).format("YYYY/MM/DD".replace(/\//g, n));
613
+ }
614
+ static time(t) {
615
+ return e.dayjs(t).format("HH:mm");
616
+ }
617
+ static format(t, n = "YYYY/MM/DD HH:mm:ss") {
618
+ return e.dayjs(t).format(n);
619
+ }
620
+ }, q = class e {
621
+ static get userAgent() {
622
+ return window.navigator.userAgent.toLowerCase();
623
+ }
624
+ static get isFlutter() {
625
+ return e.userAgent.match(/flutter/i) !== null;
626
+ }
627
+ static get isFlutterIOS() {
628
+ return e.isFlutter && e.isIOS;
629
+ }
630
+ static get isWeb() {
631
+ return window.matchMedia("(min-width: 992px)").matches;
632
+ }
633
+ static get isMobile() {
634
+ 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;
635
+ }
636
+ static get isIOS() {
637
+ return e.userAgent.match(/iphone|ipad|ipod|ios/i) !== null;
638
+ }
639
+ static get isWechat() {
640
+ return e.userAgent.match(/MicroMessenger/i) !== null;
641
+ }
642
+ static get isWxwork() {
643
+ return e.userAgent.match(/MicroMessenger/i) !== null && e.userAgent.match(/wxwork/i) !== null;
644
+ }
645
+ static get isMiniprogram() {
646
+ return e.userAgent.match(/MicroMessenger/i) !== null && e.userAgent.match(/miniprogram/i) !== null;
647
+ }
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 { K as DateTime, U as Formatter, q as Platform, W as Validate, P as VueIcon, Y as default, N as getLocale, M as setLocale, I as useBreak, L as useCaptcha, R as useIcon, j as useLocale, H 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.5",
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,51 @@
34
40
  },
35
41
  "peerDependencies": {
36
42
  "@iconify/vue": "^5.0.0",
43
+ "@visactor/vchart": "^2.0.0",
44
+ "@vueuse/core": "^12.0.0 || ^13.0.0 || ^14.0.0",
45
+ "dayjs": "^1.11.0",
46
+ "lodash": "^4.17.0",
47
+ "nanoid": "^5.0.0",
37
48
  "vue": "^3.5.0"
38
49
  },
39
50
  "peerDependenciesMeta": {
40
51
  "@iconify/vue": {
41
52
  "optional": true
53
+ },
54
+ "@visactor/vchart": {
55
+ "optional": true
56
+ },
57
+ "@vueuse/core": {
58
+ "optional": true
59
+ },
60
+ "dayjs": {
61
+ "optional": true
62
+ },
63
+ "lodash": {
64
+ "optional": true
65
+ },
66
+ "nanoid": {
67
+ "optional": true
42
68
  }
43
69
  },
44
70
  "devDependencies": {
45
71
  "@iconify/vue": "^5.0.1",
46
- "@tailwindcss/vite": "^4.3.0",
47
- "@types/node": "^22.19.20",
72
+ "@tailwindcss/vite": "^4.3.2",
73
+ "@types/lodash": "^4.17.24",
74
+ "@types/node": "^22.20.0",
75
+ "@visactor/vchart": "^2.1.2",
48
76
  "@vitejs/plugin-vue": "^6.0.7",
49
77
  "@vue/tsconfig": "^0.5.1",
50
- "tailwindcss": "^4.3.0",
78
+ "@vueuse/core": "^14.3.0",
79
+ "dayjs": "^1.11.21",
80
+ "lodash": "^4.18.1",
81
+ "nanoid": "^5.1.16",
82
+ "tailwindcss": "^4.3.2",
51
83
  "typescript": "^5.9.3",
52
84
  "unplugin-auto-import": "^21.0.0",
53
- "vite": "^8.0.16",
85
+ "vite": "^8.1.1",
54
86
  "vite-plugin-dts": "^4.5.4",
55
- "vue": "^3.5.35",
87
+ "vue": "^3.5.39",
56
88
  "vue-tsc": "^2.2.12"
57
89
  }
58
90
  }
Binary file
Binary file
@@ -0,0 +1,29 @@
1
+ import VChart, { type ISpec } from '@visactor/vchart'
2
+ import { computed, watch, onUnmounted } from 'vue'
3
+ import { useDark } from '@vueuse/core'
4
+
5
+ export { default as vBar } from './vBar.vue'
6
+ export { default as vFunnel } from './vFunnel.vue'
7
+ export { default as vLine } from './vLine.vue'
8
+ export { default as vNum } from './vNum.vue'
9
+ export { default as vPie } from './vPie.vue'
10
+
11
+ export const useChart = () => {
12
+
13
+ let chart: VChart
14
+
15
+ const isDark = useDark()
16
+ const theme = computed(() => isDark.value ? 'dark' : 'light')
17
+ const draw = (spec: ISpec, dom?: HTMLDivElement) => {
18
+ chart = new VChart(spec, { dom })
19
+ chart.setCurrentThemeSync(theme.value).renderAsync()
20
+ }
21
+
22
+ watch(() => isDark.value, () => chart.setCurrentThemeSync(theme.value).renderSync())
23
+
24
+ const update = (spec: ISpec) => chart.updateSpec(spec).then(() => chart.renderSync())
25
+
26
+ onUnmounted(() => chart && chart.release())
27
+
28
+ return { draw, update }
29
+ }
@@ -0,0 +1,51 @@
1
+ <template>
2
+ <div ref="chartRef" class="h-full min-h-60" />
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import type { PropType } from 'vue'
7
+ import type { IModel } from '../../types'
8
+ import { ref, computed, watch, onMounted } from 'vue'
9
+ import { useChart } from '.'
10
+
11
+ const { title, props, values } = defineProps({
12
+ title: { type: String, required: true },
13
+ props: { type: Object, default: () => ({}) },
14
+ values: { type: Array as PropType<IModel[]> },
15
+ })
16
+
17
+ const chartRef = ref<HTMLDivElement>()
18
+ const spec = computed(() => ({
19
+ type: 'bar',
20
+ xField: props.xField ?? 'month',
21
+ yField: props.yField ?? 'sales',
22
+ background: 'transparent',
23
+ data: [
24
+ {
25
+ values: values ?? [
26
+ { month: 'Monday', sales: 22 },
27
+ { month: 'Tuesday', sales: 13 },
28
+ { month: 'Wednesday', sales: 25 },
29
+ { month: 'Thursday', sales: 29 },
30
+ { month: 'Friday', sales: 38 }
31
+ ]
32
+ }
33
+ ],
34
+ axes: [
35
+ props.autoRotate ? {
36
+ orient: 'bottom',
37
+ sampling: false,
38
+ label: {
39
+ autoRotate: true
40
+ }
41
+ } : {}
42
+ ],
43
+ title: { text: title, textStyle: { fontSize: 14 } },
44
+ }))
45
+
46
+ const chart = useChart()
47
+
48
+ watch(() => values, () => chart.update(spec.value))
49
+
50
+ onMounted(() => chart.draw(spec.value, chartRef.value))
51
+ </script>
@@ -0,0 +1,36 @@
1
+ <template>
2
+ <div ref="chartRef" class="h-full min-h-60" />
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import type { PropType } from 'vue'
7
+ import type { IModel } from '../../types'
8
+ import { ref, onMounted } from 'vue'
9
+ import { useChart } from '.'
10
+
11
+ const { title, values } = defineProps({
12
+ title: { type: String, required: true },
13
+ props: { type: Object, default: () => ({}) },
14
+ values: { type: Array as PropType<IModel[]>, default: () => ([]) },
15
+ })
16
+
17
+ const chartRef = ref<HTMLDivElement>()
18
+ const spec = {
19
+ type: 'funnel',
20
+ categoryField: 'name',
21
+ valueField: 'value',
22
+ background: 'transparent',
23
+ isTransform: true,
24
+ isCone: false,
25
+ data: [{ values }],
26
+ title: { text: title },
27
+ transformLabel: { visible: true },
28
+ outerLabel: {
29
+ position: 'right',
30
+ visible: true,
31
+ },
32
+ legends: [{ visible: true }],
33
+ }
34
+
35
+ onMounted(() => useChart().draw(spec, chartRef.value))
36
+ </script>
@@ -0,0 +1,79 @@
1
+ <template>
2
+ <div ref="chartRef" class="h-full min-h-60" />
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import type { PropType } from 'vue'
7
+ import type { ISpec } from '@visactor/vchart'
8
+ import type { IModel } from '../../types'
9
+ import { ref, computed, watch, onMounted } from 'vue'
10
+ import { useChart } from '.'
11
+ import _ from 'lodash'
12
+
13
+ const { title, props, values, ...rest } = defineProps({
14
+ title: { type: String },
15
+ props: { type: Object, default: () => ({}) },
16
+ series: { type: Array as PropType<IModel[]> },
17
+ values: { type: Array as PropType<IModel[]> },
18
+ spec: { type: Object as PropType<ISpec> },
19
+ })
20
+
21
+ const chartRef = ref<HTMLDivElement>()
22
+ const chart = useChart()
23
+ const chartSpec = computed(() => _.merge({}, {
24
+ type: 'line',
25
+ xField: 'label',
26
+ yField: 'value',
27
+ seriesField: 'series',
28
+ background: 'transparent',
29
+ stack: true,
30
+ data: {
31
+ values: values ?? [
32
+ { label: 'Nail polish', series: 'Africa', value: 4229 },
33
+ { label: 'Nail polish', series: 'China', value: 3054 },
34
+ { label: 'Nail polish', series: 'USA', value: 12814 },
35
+ { label: 'Eyebrow pencil', series: 'Africa', value: 3932 },
36
+ { label: 'Eyebrow pencil', series: 'China', value: 5067 },
37
+ { label: 'Eyebrow pencil', series: 'USA', value: 13012 },
38
+ { label: 'Rouge', series: 'Africa', value: 5221 },
39
+ { label: 'Rouge', series: 'China', value: 7004 },
40
+ { label: 'Rouge', series: 'USA', value: 11624 },
41
+ { label: 'Lipstick', series: 'Africa', value: 9256 },
42
+ { label: 'Lipstick', series: 'China', value: 9054 },
43
+ { label: 'Lipstick', series: 'USA', value: 8814 },
44
+ { label: 'Eyeshadows', series: 'Africa', value: 3308 },
45
+ { label: 'Eyeshadows', series: 'China', value: 12043 },
46
+ { label: 'Eyeshadows', series: 'USA', value: 12998 },
47
+ { label: 'Eyeliner', series: 'Africa', value: 5432 },
48
+ { label: 'Eyeliner', series: 'China', value: 15067 },
49
+ { label: 'Eyeliner', series: 'USA', value: 12321 },
50
+ { label: 'Foundation', series: 'Africa', value: 13701 },
51
+ { label: 'Foundation', series: 'China', value: 10119 },
52
+ { label: 'Foundation', series: 'USA', value: 10342 },
53
+ { label: 'Lip gloss', series: 'Africa', value: 4008 },
54
+ { label: 'Lip gloss', series: 'China', value: 12043 },
55
+ { label: 'Lip gloss', series: 'USA', value: 22998 },
56
+ { label: 'Mascara', series: 'Africa', value: 18712 },
57
+ { label: 'Mascara', series: 'China', value: 10419 },
58
+ { label: 'Mascara', series: 'USA', value: 11261 }
59
+ ]
60
+ },
61
+ title: { text: title, textStyle: { fontSize: 14 } },
62
+ line: {
63
+ style: { lineWidth: 1 }
64
+ },
65
+ }, props))
66
+
67
+ const spec = computed(() => rest.spec || chartSpec.value)
68
+
69
+ let drawn = false
70
+
71
+ watch(spec, value => {
72
+ if (drawn) chart.update(value)
73
+ }, { deep: true })
74
+
75
+ onMounted(() => {
76
+ chart.draw(spec.value, chartRef.value)
77
+ drawn = true
78
+ })
79
+ </script>
@@ -0,0 +1,33 @@
1
+ <template>
2
+ <div class="v-num h-full min-h-40 flex-center text-center bg-color-overlay">
3
+ <div class="text-sm">
4
+ <div v-if="icon" class="flex-center">
5
+ <div class="icon" :style="{ backgroundColor: color }">
6
+ <vue-icon :icon />
7
+ </div>
8
+ </div>
9
+ <div class="mt-3 text-2xl">{{ (amount).toLocaleString() }}</div>
10
+ <div class="mt-1">{{ title }}</div>
11
+ <div v-if="growth !== null" class="mt-2" :class="raise ? 'text-green' : 'text-red'">{{ raise ? '+' : '' }}{{ growth }}</div>
12
+ </div>
13
+ </div>
14
+ </template>
15
+
16
+ <script setup lang="ts">
17
+ import VueIcon from '../VueIcon.vue';
18
+
19
+ const { growth } = defineProps({
20
+ icon: { type: String },
21
+ color: { type: String, default: '#093' },
22
+ title: { type: String, default: 'Total' },
23
+ amount: { type: Number, default: 0 },
24
+ growth: { type: [Number, String], default: null },
25
+ })
26
+
27
+ const value = computed(() => typeof growth === 'string' ? Number(growth.match(/-?\d+(\.\d+)?/g)?.[0] || 0) : growth as number)
28
+ const raise = computed(() => value.value > 0)
29
+ </script>
30
+
31
+ <style scoped>
32
+ .v-num .icon { display: inline-flex; color: #fff; padding: 8px; border-radius: 50%; }
33
+ </style>
@@ -0,0 +1,52 @@
1
+ <template>
2
+ <div ref="chartRef" class="h-full min-h-60" />
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import type { PropType } from 'vue'
7
+ import type { IModel } from '../../types'
8
+ import { ref, computed, watch, onMounted } from 'vue'
9
+ import { useChart } from '.'
10
+ import _ from 'lodash'
11
+
12
+ const { title, props, values } = defineProps({
13
+ title: { type: String, required: true },
14
+ props: { type: Object, default: () => ({}) },
15
+ values: { type: Array as PropType<IModel[]> },
16
+ })
17
+
18
+ const chartRef = ref<HTMLDivElement>()
19
+ const chart = useChart()
20
+ const spec = computed(() => _.merge({}, {
21
+ type: 'pie',
22
+ valueField: 'value',
23
+ categoryField: 'type',
24
+ background: 'transparent',
25
+ outerRadius: 1,
26
+ innerRadius: 0.4,
27
+ data: [
28
+ {
29
+ values: values ?? [
30
+ { type: 'oxygen', value: '46.60' },
31
+ { type: 'silicon', value: '27.72' },
32
+ { type: 'aluminum', value: '8.13' },
33
+ { type: 'iron', value: '5' },
34
+ { type: 'calcium', value: '3.63' },
35
+ ]
36
+ }
37
+ ],
38
+ title: { text: title, textStyle: { fontSize: 14 } },
39
+ label: { visible: true },
40
+ }, props))
41
+
42
+ let drawn = false
43
+
44
+ watch(spec, value => {
45
+ if (drawn) chart.update(value)
46
+ }, { deep: true })
47
+
48
+ onMounted(() => {
49
+ chart.draw(spec.value, chartRef.value)
50
+ drawn = true
51
+ })
52
+ </script>
@@ -1,6 +1,6 @@
1
1
  import { ref } from 'vue'
2
2
 
3
- export const useCaptcha = (api: (data: any) => Promise<void>) => {
3
+ export const useCaptcha = (fetch: (data: any) => Promise<void>) => {
4
4
 
5
5
  const waiting = ref(0)
6
6
  const loading = ref(false)
@@ -9,7 +9,7 @@ export const useCaptcha = (api: (data: any) => Promise<void>) => {
9
9
  return new Promise((resolve, reject) => {
10
10
  if (loading.value) return
11
11
  loading.value = true
12
- api(para).then(() => {
12
+ fetch(para).then(() => {
13
13
  timer()
14
14
  resolve(true)
15
15
  }).catch(err => reject(err))
@@ -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
@@ -22,11 +22,13 @@ const Vue: Plugin = {
22
22
  },
23
23
  }
24
24
 
25
- export * from './types'
26
- export * from './utils'
27
25
  export { useBreak } from './hooks/useBreak'
28
26
  export { useCaptcha } from './hooks/useCaptcha'
29
27
  export { useIcon } from './hooks/useIcon'
28
+ export { useNanoid } from './hooks/useNanoid'
29
+
30
+ export * from './types'
31
+ export * from './utils'
30
32
 
31
33
  export default Vue
32
34
 
@@ -56,7 +56,6 @@ declare global {
56
56
  const useAttrs: typeof import('vue').useAttrs
57
57
  const useBreak: typeof import('../hooks/useBreak').useBreak
58
58
  const useCaptcha: typeof import('../hooks/useCaptcha').useCaptcha
59
- const useChat: typeof import('../hooks/useChat').useChat
60
59
  const useCssModule: typeof import('vue').useCssModule
61
60
  const useCssVars: typeof import('vue').useCssVars
62
61
  const useIcon: typeof import('../hooks/useIcon').useIcon
@@ -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
+ }